So I'm working on this OpenGL 3D Graph program, and like, I ran into some trouble, since I wanted it to support fullscreen, so I made the following;

int main(int argc, char *argv[])
    {
    ...  // Some stuff
    glutSpecialFunc(SpecKey);
    ... // More stuff
    }

Which is calling the following function;

GLvoid ResetWindowSize(GLvoid)  // Reset WindowSize
    {
    glutReshapeWindow(WindowWidth, WindowHeight);
    glutPositionWindow(0,0);
    }

GLvoid SpecKey(GLint key, GLint x, GLint y)
	{
	if (key == GLUT_KEY_F1)     // Toggle FullScreen
            {
	    fullscreen = !fullscreen; // Toggle FullScreenBool
	    if (fullscreen)
	    	{
		glutFullScreen();     // Enable Fullscreen
            	}
	    else
            	{
            	ResetWindowSize();    // Make Window, and resize
            	}
            }
	}

WindowWidth and WindowHeight are both global variables, which are updated everytime I'm resizing the window.

fullscreen is a global bool.

The problem is, that going to fullscreen is working fine, however returning to windowed mode, is giving me some problem since it returns with a window resolution equal to my desktop resolution, and not the resolution which is givin' in the variables WindowWidth and WindowHeight.

Anyone able to figure out the problem?

EDIT; I'm able to get it into a fixed resolution using fixes values instead of the variables like this;

GLvoid ResetWindowSize(GLvoid)  // Reset WindowSize
    {
    glutReshapeWindow(800, 600);
    glutPositionWindow(0,0);
    }

However to make this work I'm forced to call the "ResetWindowSize" function twice?

Anyone?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.