View Full Version : GLFW window opening extremely slow?

WIld Sage
09-27-2011, 02:08 AM
Okay, so I'm trying to start a project using GLFW. But every time I open a window, it at first appears to have frozen (white window, "waiting" cursor, wont accept any input whatsoever), but after about 30-60 seconds it creates the window that it's supposed to. I've tried this with 3 or 4 different programs and the result is always the same. Am I setting up my project wrong or something?

I'm using Visual Studio 2010 Ultimate. Here's my source code:


#include "GL/glew.h"
#include "GL/wglew.h"
#include "GL/glfw.h"

#include <stdio.h>

#pragma comment (lib, "glfw.lib")
#pragma comment (lib, "opengl32.lib")
#pragma comment (lib, "glu32.lib")

int main(int argc, char** args)
bool running = true;
glfwOpenWindow(640, 480, 8, 8, 8, 8, 24, 0, GLFW_WINDOW);
glClearColor(0.5, 0.5, 1.0, 1.0);
while (running)
// Begin Main Loop //


running = !glfwGetKey(GLFW_KEY_ESC) &amp;&amp; glfwGetWindowParam(GLFW_OPENED);

return 0;
It's not the cleanest code, but like I said I've tried a few different simple programs and the result is the same - a 30 second - minute long delay until the window opens.

Stuart McDonald
09-28-2011, 04:50 AM
I'm using GLFW on Windows 7 with ATI card compiling with minGW and I've not seen this, but I did have a problem with fullscreen taking over a minute to start up. A couple of driver updates later and the problem disappeared. Does fullscreen take the same time?

So all I can suggest is check you've got the latest drivers. Only other thing that stands out is glewInit. I've not used that so don't know if it could be an issue.

You could also try using freeGlut to see what it does.

WIld Sage
09-28-2011, 06:15 PM
I've tried commenting out all glew-related code, but nothing changes. I don't want to use glut because it doesn't support the features I want - GLFW does everything I need it to (except disabling the windows DWM, but that's only one thing, and I can code that in myself).

I'm using an NVidia card on windows 7, and I have the latest driver version (280.26). Fullscreen gives the same delay.

Alfonse Reinheart
09-28-2011, 06:32 PM
Do you know what the exact function is that's getting the slowdown? Can you step through your main function and see which function is taking a long time?

Also, is this a release build?

WIld Sage
09-28-2011, 07:10 PM
The function that's taking forever is glwOpenWindow(). I tried release, debug, and even a build I compiled myself, same result.

09-29-2011, 01:36 AM
And when you break the debug build in the middle the 60 seconds, can you see where inside glwOpenWindow() you fall into ?

BTW, can you describe your hardware setup, os version, driver version ?

Stuart McDonald
09-29-2011, 02:04 AM
I don't want to use glut because it doesn't support the features I wantThe point was to see if this is something specific to GLFW.

You could build a debug version with a static GLFW and step through it's code to see exactly what's going on. Also, you could use gDEBugger (now free) and break on every openGL call to see which one is taking the time (http://www.gremedy.com/).

WIld Sage
09-29-2011, 07:37 PM
Okay, I tried opening a glut window with similar problems. Rather than displaying a frozen window, however, glut simply takes it's minute before it opens any window.

Alfonse Reinheart
09-29-2011, 11:00 PM
So, did you debug into the library? Where was it stalled?

WIld Sage
09-29-2011, 11:22 PM
Couldn't figure out how ._.

09-30-2011, 04:41 AM
Isn't it Visual studio that actually spends the time? Have you tried simply to run the generated executable outside of VS?
I'm pretty sure your issue has nothing to do with GLUT or GLFW.

09-30-2011, 07:28 AM
If this is only stalling while running under visual studio, inspect the internal Visual studio output window (not the console window etc) and see if it is stalling on loading a dll.

eg. "Loaded 'C:\Windows\SysWOW64\ntdll.dll'"

If that is the case, google for the message - I recall at my previous company similar symptoms when somehow the nt dll symbols were installed and they took 1min+ to load every time they went to debug.

WIld Sage
09-30-2011, 02:47 PM
It stalls when I run the application outside of visual studio, both release and debug builds.

WIld Sage
10-01-2011, 01:52 PM
Okay found it! I tried opening a window in pure Win32, to the same delay. After putting a bunch of break points in, I pinpointed the problem at ChoosePixelFormat()

0, 0, 0, 0, 0, 0,
0, 0,
0, 0, 0, 0, 0,
0, 0, 0 };

int PixFormat = ChoosePixelFormat(gHdc, &amp;pfd);

Any idea why that's taking so long?


I tried skipping ChoosePixelFormat entirely by just specifying "7" (which is what ChoosePixelFormat returns for me), but I'm getting the same delay! The delay moved to SetPixelFormat, which was previously instant! What the heck is going on?

I paused it in the middle of the delay, and the name of the item on the call stack it's on is "ntdll.dll!776200ed()". I opened the dissasembly and it says "776200ED add esp,4 " is where it's at.

Does anyone know about this? I'm stumped...

WIld Sage
10-02-2011, 12:55 AM
The problem is solved. For some reason, when your executable is named "game.exe", ChoosePixelFormat() looks for another exe, over and over and over again. Yeah. Don't try to figure out the logic behind that one.

10-02-2011, 01:35 AM
Those executables sound like some relics from Red Alert 2 :

Are you using Nvidia hardware ? Maybe it is time their driver would enhance whatever strange optimization/workaround they put in place for that game ...