Advertisement Jump to content
Sign in to follow this  

OpenGL OpenGL + Window controls

This topic is 4766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I am trying to make a simple application using OpenGL and WinAPI. I've got a dialog form where the scene - together with some windows controls (edit box, button and a check box) - is displayed. Everything seems fine but after my dialog loses focus (i.e, it hides under other window), the windows controls are not redrawed when the dialog gets its focus back again. You can take a look and see what I mean : I guess that the problem should be solved somewhere around WM_PAINT message. For the time being, here is what I do after getting WM_PAINT message :
case WM_PAINT:
   Render();   // just render GL scene (that's where SwapBuffers() is called)
   return TRUE; 
I'd be thankful if you could help me with this one! :)

Share this post

Link to post
Share on other sites
Im not an expert in using win32 forms. But I think u need to call this:

case WM_PAINT: // paint
BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);

Hope that works for u!

Share this post

Link to post
Share on other sites
Thanks, Cacks! Actually it solves the problem I mentioned. Unfortunately, now it seems that I get WM_PAINT message _only_ when my dialog gets focus. This means that Render() function isn't continuously called each frame. Do you know what can I do about this? Maybe I should put Render() into a timer?

Plus, how can I correctly initialize PAINTSTRUCT ps ?

Great thanks!

Share this post

Link to post
Share on other sites
As I say, im not an expert, but I think that the WM_PAINT message is only meant to be sent on special occassions such as minimising & maximising & uncovering of the window, so put ur renderer in a timer within the main procedure.

typedef struct tagPAINTSTRUCT {
HDC hdc;
BOOL fErase;
RECT rcPaint;
BOOL fRestore;
BOOL fIncUpdate;
BYTE rgbReserved[16];

Declared in Winuser.h

Which I think its included in windows.h

Got this from MSDN.

I presume it is initialised when creating a form, but Im not sure.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!