Menu
GLUT Tutorials

GLUT

Fullscreen



Tutorials > GLUT > Fullscreen

View Full Source

Introduction

Fullscreen In previous tutorials, we have used a small window. Your specific application may require you to display your application in fullscreen. This is usually seen in games.

Do not worry too much about the code within the display function. This code is explained within the OpenGL tutorials.

Contents of main.cpp :


Our first step is to create a boolean variable specifying whether or not we are in fullscreen mode.

bool fullscreen = false;

In all of the tutorials, we will switch to fullscreen by pressing the F1 key.

void specialKeyboard(int key, int x, int y)
{
	if (key == GLUT_KEY_F1)
	{

The fullscreen variable is toggled.

		fullscreen = !fullscreen;

Switching to fullscreen is as simple as a single call to glutFullScreen. This function does not accept any parameters.

		if (fullscreen)
			glutFullScreen();

The application will switch back to windowed mode if an attempt is made to either resize or reposition the window. This is done with a call to glutReshapeWindow or glutPositionWindow. These functions both accept two integers indicating the size and position of the window.

The code below uses the same values as in our main function, thereby reverting back to the original window.

		else
		{
			glutReshapeWindow(500, 500);
			glutPositionWindow(50, 50);
		}
	}
}

As can be seen, it is extremely simple to switch between fullscreen and windowed mode.

Please let me know of any comments you may have : Contact Me

Source Files : Visual Studio Dev-C++ Unix / Linux

< Tutorial 04 - Rendering And Animation  

Back to Top


All Rights Reserved, © Zeus Communication, Multimedia & Development 2004-2005

Read the Disclaimer

Links