PDA

View Full Version : Listener for when opengl context is visible.



Mctittles
10-07-2011, 03:28 PM
Hello all. I'm trying to have a quick menu animation the first time my game is booted up, however I'm running into some timing problems.
What I am doing (in windows) is creating a window with CreateWindowEx and when WM_CREATE is called I do the SetPixelFormat and other opengl setup. There is a thread created that handles all animation calculations, while the existing thread contains my drawing loop.

The problem I'm running into is that by the time the actual window is visible the intro animation has already completed. What seems to be happening is both the thread for animating and the opengl draw loop are running while windows before anything is visible to the user. I tried holding off on looping or running the second thread until WM_CREATE is called, but that seems to be called way before the window can be seen.

So my question is. Does anyone know of some type of listener or a variable that can be checked to see if the opengl screen is actually showing to the user, so I can wait until there to do my animation?

Simon Arbon
10-07-2011, 04:59 PM
Windows will send you the WM_PAINT message when the window is visible on the screen.
Just start your animation thread when you get this message.

Mctittles
10-07-2011, 07:45 PM
Thanks that worked!

Funny thing is I run this on an older Windows XP machine and it boots up instantly and runs smooth, however in a much more powerful Vista machine there is jerky lag when the animation starts. I think it has something to do with Vista disabling Aero as there is also a flicker when changing to fullscreen which seems to coincide with the lag I am seeing. I can add a Sleep to wait for it that is probably only going to be timed right for the machine I'm on.
Don't think there is a fix for this problem, just an annoyance of Vista + Aero I guess.