GLuint TexAPMenu = 0;

void LoadMenu()
{
    TexAPMenu = loadTexture("./Images/ArrierePlanMenu.png");
}

void BoucleRenderMenu()
{
    while (continuer && nbRender == RENDER_MENU_PRINCIPAL)
    {
        while(SDL_PollEvent(&event))
        {
            switch(event.type)
            {
                case SDL_QUIT:
                    continuer = false;
                    break;

                case SDL_KEYDOWN:
                    if(event.key.keysym.sym == SDLK_ESCAPE) continuer = false;

                    if(event.key.keysym.sym == SDLK_f)
                    {
                        IsFullScreen = !IsFullScreen;
                        SDL_FreeSurface(Screen);
                        if(IsFullScreen) 
                                         Screen = SDL_SetVideoMode(0, 0, 32, SDL_OPENGL | SDL_FULLSCREEN);
                        else 
                                         Screen = SDL_SetVideoMode(0, 0, 32, SDL_OPENGL | SDL_RESIZABLE);
                        SDL_Delay(50);
                        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
                        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 6);
                        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
                        glViewport(0, 0, (GLsizei) Screen->w, (GLsizei) Screen->h);
                        glMatrixMode(GL_PROJECTION);
                        glLoadIdentity();
                        gluOrtho2D(0, LARGEUR_ECRAN, 0, HAUTEUR_ECRAN);
                        glMatrixMode(GL_MODELVIEW);
                        glLoadIdentity();
                        LoadMenu();
                        texte.LoadFont();
                    }
                    break;

                case SDL_VIDEORESIZE:
                    HauteurEcran = event.resize.h;
                    LargeurEcran = event.resize.w;
		    Screen = SDL_SetVideoMode(0, 0, 32, SDL_OPENGL | SDL_RESIZABLE);
                    glViewport(0, 0, (GLsizei) event.resize.w, (GLsizei) event.resize.h);
                    glMatrixMode(GL_PROJECTION);
                    glLoadIdentity();
                    gluOrtho2D(0, LARGEUR_ECRAN, 0, HAUTEUR_ECRAN);
                    glMatrixMode(GL_MODELVIEW);
                    glLoadIdentity();
                    break;

            }
        }

        glClear(GL_COLOR_BUFFER_BIT);
        glLoadIdentity();

        //glEnable(GL_TEXTURE_2D);
        //glBindTexture(GL_TEXTURE_2D, TexAPMenu);

        glBegin(GL_QUADS);
            glColor3ub(255, 0, 255);

            glTexCoord2f (0.0, 0.0);
            glVertex2f(0, 0);

            glTexCoord2f (0.0, 1.0);
            glVertex2f(0, HAUTEUR_ECRAN );

            glTexCoord2f (1.0, 1.0);
            glVertex2f(LARGEUR_ECRAN, HAUTEUR_ECRAN);

            glTexCoord2f (1.0, 0.0);
            glVertex2f(LARGEUR_ECRAN, 0);
        glEnd();

        //glDisable(GL_TEXTURE_2D);

        DessineFPS();

        glFlush();
        SDL_GL_SwapBuffers();
        
        SDL_Delay(50);


    }
}
