//------------------------------------------------------------------------------
// Active le GameMode
//------------------------------------------------------------------------------

void    Enable_GameMode()
 {
    if (g_gamemode)
     {
        glutGameModeString("640x480:32");           // Sélectionne le mode 800x600 en 32 bits
        if (glutGameModeGet(GLUT_GAME_MODE_POSSIBLE))                                         
         {
            glutEnterGameMode();                    // Active le Fullscreen
            glutSetCursor(GLUT_CURSOR_NONE);
         }
        else g_gamemode = false;                    // Ne peut pas entrer en Fullscreen, bascule en fenêtre
     }
    if (!g_gamemode)
     {
        int answer = MessageBox(NULL,                       // Affiche une boîte de dialogue
        "Impossible de passer en FullScreen 640*480 32 bits",// Message
        "Erreur",                               // Titre de la fenêtre
        MB_ICONERROR | MB_OK);                // Icône et boutons
        exit(0);
     }
 }

//------------------------------------------------------------------------------
// Initialise l'affichage
//------------------------------------------------------------------------------

void    InitGL()
 {
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);           // Arrière Plan Noir
    glClearDepth(1.0f);                             // Configuration de la profondeur du buffer

    glDepthFunc(GL_LEQUAL);                         // Le type de profondeur à tester
    glEnable(GL_DEPTH_TEST);                        // Active le test de profondeur, peut-être pour corriger des imperfections

    glBlendFunc(GL_SRC_ALPHA, GL_ONE);              // Notre fonction de blending (lorsqu'il sera activé par la touche B)
    glDisable(GL_BLEND);                            // Désactive le blending (effet de mélange de couleur, activé avec la touche B)

    glAlphaFunc(GL_GREATER,0.2f);                   // Permet de choisir présicemment un alpha sur les TGA
    glEnable(GL_ALPHA_TEST);                        // Active l'alpha

    // glEnable(GL_CULL_FACE);                      // Retire les faces cachées
    glShadeModel(GL_SMOOTH);                        // Smooth Shading Activé, il doit lisser les formes (?)

    glEnable(GL_TEXTURE_2D);                        // Textures 2D activées
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtered (ca lisser les textures mais moins ien que le TriLinear Filtering)
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtered
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);

    glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);     // Setup The Ambient Light
    glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);     // Setup The Diffuse Light
    glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);   // Position The Light
    glEnable(GL_LIGHT1);                                // Enable Light One

    glHint(GL_FOG_HINT,GL_NICEST);
    glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
    glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);
    glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);

    g_quadratic=gluNewQuadric();                    // Create A Pointer To The Quadric Object (Return 0 If No Memory) (NEW)
	gluQuadricNormals(g_quadratic, GLU_SMOOTH);     // Create Smooth Normals (NEW)
	gluQuadricTexture(g_quadratic, GL_TRUE);        // Create Texture Coords (NEW)
 }

//------------------------------------------------------------------------------
// Fonction de redimensionnement et d'initialisation de la fenêtre
//------------------------------------------------------------------------------

void    Reshape(int w,int h)
 {
    width=(int)w/2;
    height=(int)h/2;

    glViewport(0,0,w,h);                                // Définit la zone de rendu
    glMatrixMode(GL_PROJECTION);                        // Sélectionne la matrice de projection
    glLoadIdentity();                                   // Initialise la matrice de projection
    gluPerspective(45.0f,(float)(w)/(float)(h),1,100);        // Définit la projection

    SetCursorPos(width,height);                         // On place le curseur au centre
    mouse_up=height;                                    // On définit l'angle haut-bas
    mouse_rl=width;                                     // On définit l'angle gauche-droite
 }

//------------------------------------------------------------------------------
// Fin Du Fichier
//------------------------------------------------------------------------------