Jump to content
  • Advertisement
Sign in to follow this  
krez

OpenGL rendering OGL in a win32 control

This topic is 4909 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

i want to render some openGL stuff in a control (a static control, if it matters) on a window, in straight win32 (no MFC, .net, or anything else). needless to say, i can't get it to work. if i use a normal message pump, and update the static control with OGL when the form is painted (i.e. in the WM_PAINT handler), it never updates or anything. if i use the "game loop" type loop (with peekmessage, etc) the opengl control updates but the rest of the window never does, it just gets stuck with whatever was on the screen when the window first appeared. any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
I've got this working before, but don't have access to my source code at the moment and it was a while ago. So, based on that my suggestion would be, in the first version with the message pump are you calling SwapBuffers( hDC ) after your opengl code?

Share this post


Link to post
Share on other sites
Go to where you create your control in the resource viewer (if using MSVC) and turn 'Owner Draw' (or Parent Draw or something) off. If your static control doesn't have one of those, try a button control :)

Share this post


Link to post
Share on other sites
Quote:
Original post by paulc
in the first version with the message pump are you calling SwapBuffers( hDC ) after your opengl code?

yes i am.
Quote:
Original post by FReY
Go to where you create your control in the resource viewer (if using MSVC) and turn 'Owner Draw' (or Parent Draw or something) off. If your static control doesn't have one of those, try a button control :)

i am not using any sort of resource viewer, i am just typing my code in:

// in WM_CREATE message:
g_PBHWND = CreateWindowEx(WS_EX_CLIENTEDGE, "STATIC", "", WS_CHILD | WS_VISIBLE,
0, 0, 100, 100, hWnd, (HMENU)NULL, GetModuleHandle(NULL), NULL);


i read that you must give the child window (control) a CS_OWNDC flag when the class is registered, so i think i'm going to try and create my own window class to use instead of the static control... but if anyone has any other information please post it, since i don't have such a great feeling about this :)

Share this post


Link to post
Share on other sites
make sure get hDC from static control hWnd (hDC = ::GetDC(statichWnd)
wglMakeCurrent()
set viewport to static client rect.

Or make your own OpenGL window control.

Oh, if you want to get WM_PAINT from static control you have to subclass it and do your own painting.

Share this post


Link to post
Share on other sites
Wouldnt it be easier to just register a new window class and then init that to work with GL?

Surley you dont need the extended features of a Static, (basically because it has very few extra features above that of a normal window)

Share this post


Link to post
Share on other sites
Quote:
Original post by ZedFx
Wouldnt it be easier to just register a new window class and then init that to work with GL?

Surley you dont need the extended features of a Static, (basically because it has very few extra features above that of a normal window)



Yes certainly but it is not rocket science to do it on static control.

I forgot, the easy way is to do SS_OWNERDRAW. Your window proc will get a WM_DRAWITEM. When you get that check if it is the static control, and then you can paint on it. This means simply doing your OpenGL->drawScene() functions. The HDC and HWND will be in the WM_DRAWITEM message you just wglMakeCurrent(hDC,hRC) and away you go no need to subclass it.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!