Opengl tryb gamemode

witam, mam problem z poprawną implementacją trybu gamemode i późniejszą implementacją wyjścia z tego trybu, prosiłbym o pomoc :slight_smile: o to kod:

#include 


/*

 * program wyswietla szescian z zachowaniem proporcji

 * obsluga klawiatury i zmiana trybu na fullscreen i window mode

 */



const int width = 640;

const int height = 480;

const float a = 1.0;

float fovy = 45.0, aspect = 1.0, near_ = 0.1, far_ = 10.0;//parametry dla gluPerspective(); 

bool fullscreen = false;

bool gamemode = false;


void uklad(){

    glBegin(GL_LINES);

        glColor3f(0.0, 1.0, 0.0); //zielona oś X

        glVertex3f(-8.0, 0.0, 0.0);

        glVertex3f( 8.0, 0.0, 0.0); 


        glColor3f(0.0, 0.0, 1.0); // niebieska oś Y

        glVertex3f(0.0, -8.0, 0.0);

        glVertex3f(0.0, 8.0, 0.0);


        glColor3f(1.0, 0.0, 0.0); // czerwona oś Z

        glVertex3f(0.0, 0.0, -8.0);

        glVertex3f(0.0, 0.0, 8.0);

    glEnd();

}



void sciana(){

    glBegin(GL_QUADS);

        glVertex3f(-a / 2, 0.0, a / 2);

        glVertex3f(-a / 2, 0.0, -a / 2);

        glVertex3f( a / 2, 0.0, -a / 2);

        glVertex3f( a / 2, 0.0, a / 2);

    glEnd();

}


void szescian(){

    //dolna sciana

    glPushMatrix();

        glTranslatef(0.0, -a /2, 0.0);

        glColor3f(0.0, 0.0, 1.0);

        sciana();

    glPopMatrix();


    //gorna sciana

    glPushMatrix();

        glTranslatef(0.0, a /2, 0.0);

        glColor3f(0.0, 1.0, 1.0);

        sciana();

    glPopMatrix();


    //lewa sciana

    glPushMatrix();

        glRotatef(90.0, 0.0, 0.0, 1.0);

        glTranslatef(0.0, a /2, 0.0);

        glColor3f(0.0, 1.0, 0.0);

        sciana();

    glPopMatrix();


    //prawa sciana

    glPushMatrix();

        glRotatef(90.0, 0.0, 0.0, 1.0);

        glTranslatef(0.0, -a /2, 0.0);

        glColor3f(1.0, 1.0, 0.0);

        sciana();

    glPopMatrix();


    //tylna sciana

    glPushMatrix();

        glRotatef(90.0, -1.0, 0.0, 0.0);

        glTranslatef(0.0, a /2, 0.0);

        glColor3f(1.0, 0.0, 0.0);

        sciana();

    glPopMatrix();


    //przednia sciana

    glPushMatrix();

        glRotatef(90.0, -1.0, 0.0, 0.0);

        glTranslatef(0.0, -a /2, 0.0);

        glColor3f(0.4, 1.0, 0.0);

        sciana();

    glPopMatrix();

}


void display() 

{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//"czyszczenie" tła okan i bufora głębokosci

    glLoadIdentity();

    gluLookAt(2.0,2.0,2.0, 0.0,0.0,0.0, 0.0,1.0,0.0);//obserwator 

        uklad();

        szescian();

    glFlush();

} 


void odrysuj(int width, int height){

    float h = float(height), w = float(width);

    glViewport(0, 0, width, height);

    glMatrixMode(GL_PROJECTION);

    glLoadIdentity();

    gluPerspective(fovy, w/h, near_, far_);

    glMatrixMode(GL_MODELVIEW);

    glLoadIdentity();

}


void init(){

    glClearColor(0.0,0.0,0.0,1.0);

    glEnable(GL_DEPTH_TEST);//włącznie algorytmu zasłaniania

}


void keyboard(int key, int x, int y){

    switch(key){

        case GLUT_KEY_F1:

            fullscreen = !fullscreen;

            if(fullscreen == true){

                glutFullScreen();

            } else {

                glutLeaveFullScreen();

            }

            break;

        case GLUT_KEY_F2:

            gamemode = !gamemode;

            if(gamemode == true){

                glutGameModeString("1366x768");

                glutGameModeGet(GLUT_GAME_MODE_POSSIBLE);

                glutEnterGameMode();

            } else {

                glutLeaveGameMode();

                glutInitWindowSize(width, height);

                glutCreateWindow("Scena testowa");

            }

            break;

    }

}


int main(int argc, char** argv)

{

    glutInit(&argc, argv);  

    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);

    glutInitWindowSize(width, height);

    glutInitWindowPosition(100,100);

    glutCreateWindow("Scena testowa");

        init();

    glutDisplayFunc(display);

    glutReshapeFunc(odrysuj);

    glutSpecialFunc(keyboard);

    glutMainLoop();

    return 0;

}