Permalink
Browse files

Cleaned up fullscreen init

  • Loading branch information...
1 parent 25c7742 commit 627a54cec3ede557e78bdc4483f48cdd061e6e8a @stegu stegu committed Mar 27, 2011
Showing with 16 additions and 10 deletions.
  1. +16 −10 benchmark/common/noisebench.c
@@ -352,19 +352,24 @@ int main(int argc, char *argv[]) {
double performance = 0.0;
int ndims = 2; // Currently running version of noise: 2D, 3D or 4D
FILE *logfile;
+ GLFWvidmode vidmode;
GLboolean running = GL_TRUE; // Main loop exits when this is set to GL_FALSE
// Initialise GLFW
glfwInit();
- // Open the OpenGL window
-#ifdef __APPLE__
- // MacOS X clips oversized fullscreen windows, it doesn't resize them
- if( !glfwOpenWindow(1280, 800, 8,8,8,8, 32,0, GLFW_FULLSCREEN) )
-#else
- if( !glfwOpenWindow(4096, 4096, 8,8,8,8, 32,0, GLFW_FULLSCREEN) )
-#endif
+ // Open a temporary OpenGL window just to determine the desktop size
+ if( !glfwOpenWindow(256, 256, 8,8,8,8, 32,0, GLFW_WINDOW) )
+ {
+ glfwTerminate(); // glfwOpenWindow failed, quit the program.
+ return 1;
+ }
+ glfwGetDesktopMode(&vidmode);
+ glfwCloseWindow();
+
+ // Open a fullscreen window using the current desktop resolution
+ if( !glfwOpenWindow(vidmode.Width, vidmode.Height, 8,8,8,8, 32,0, GLFW_FULLSCREEN) )
{
glfwTerminate(); // glfwOpenWindow failed, quit the program.
return 1;
@@ -377,9 +382,10 @@ int main(int argc, char *argv[]) {
logfile = fopen(LOGFILENAME, "w");
- fprintf(logfile, "GL vendor: %s\n", glGetString(GL_VENDOR));
- fprintf(logfile, "GL renderer: %s\n", glGetString(GL_RENDERER));
- fprintf(logfile, "GL version: %s\n", glGetString(GL_VERSION));
+ fprintf(logfile, "GL vendor: %s\n", glGetString(GL_VENDOR));
+ fprintf(logfile, "GL renderer: %s\n", glGetString(GL_RENDERER));
+ fprintf(logfile, "GL version: %s\n", glGetString(GL_VERSION));
+ fprintf(logfile, "Desktop size: %d x %d pixels\n", vidmode.Width, vidmode.Height);
// Create the shader object from two external GLSL source files
createShader(&programObject, VERTEXSHADERFILE2D, FRAGMENTSHADERFILE2D);

0 comments on commit 627a54c

Please sign in to comment.