🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Tutorial: Lesson 1 Screen flicker

Started by
2 comments, last by Thomas Dalsgaard 17 years, 11 months ago
Hey all. I have until resently been developing console applications in c++ with OpenGL. Now I need to take it one step further and base my program on windows. Using the excellent lesson 1 from I have made my application run from windows based input rather than "glut". I have one problem though. The raw (none of my code) lesson 1 enables fullscreen mode and window mode. When in fullscreen mode and I 'alt'-'tab' to another window it appears as if the screen refresh rate has gone from 85Hz to somewhere around 60Hz (this is what I call flickering). The application 'lesson 1' test whether the window is minimized, and calls this state inactive. This is inside the message loop: case WM_ACTIVATE: // Watch For Window Activate Message { if (!HIWORD(wParam)) // Check Minimization State { active=TRUE; // Program Is Active } else { active=FALSE; // Program Is No Longer Active } return 0; // Return To The Message Loop } I have tried to change the test so it corresponds to whether the window is actually active: case WM_ACTIVATE: // Watch For Window Activate Message { active = LOWORD(wParam); //Check whether application is active } and the test seems to work! The problem has not been solved though, and the screen still flickes when 'alt'-'tab' out of the application. This is offcouse only a problem on CRT-monitors, but I would really like to know how to solve it anyway ;) regards Thomas Dalsgaard
Advertisement
I'm guessing your problem is related to the full screen switching done.

If you post the whole code, we can help you a little more.

If I remember correctly, the way nehe switched to fullscreen ignores the current refreshment rate of your monitor.

<ed. spell-check>

[Edited by - StarikKalachnikov on August 4, 2006 6:53:05 AM]
Next time I give my advice, I'll buy some bubblegum so I won't your kick ass!
I guess your problem is related to the ChangeDisplaySettings() function, that is used to switch the screen resolution.

By default, if you don't specify any refresh rate in the corresponding field of DEVMODE structure, ChangeDisplaySettings() will take the first compatible resolution it finds, in this case having a 60Hz refresh rate.

Try to put 85 in the DEVMODE.dmDisplayFrequency and add the DM_DISPLAYFREQUENCY in the flags you give to ChangeDisplaySettings(), assuming 85Hz is compatible with your display.

As you see, Microsoft didn't put a lot of effort to support OpenGL fullscreen applications... It would be so nice to have some kind of exclusive fullscreen mode like we have with DirectX.
Thanks to you both for replying so fast ;) I have tried rikibee's solution, and it works perfectly!!

The reason I had not included the code was because it was the source code of lesson 1 from NeHe that produced the flickering. I see now that the link to the tutorial I tried to include in the text is missing. I think I need to read up on the section 'how to make effects' more thouroughly.

Thanks again
Thomas Dalsgaard

This topic is closed to new replies.

Advertisement