Some questions about OpenGL/Win32

Started by
4 comments, last by shane1985 18 years, 11 months ago
I'm currently trying to create a popup dialog box with a picture control inside, where I will then render textured quads. The issue I'm running into is this: I don't know the hwnd of the control until the user opens the dialog box, so I can't initialize the OpenGL rendering context until this point. This means I have to load textures into the rendering context at the point too. If I only had to do it once, that would be fine, but it seems that when I close the dialog box, it destroys the rendering context. This requires me to recreate it, along with reloading all my textures every time the user opens the dialog box. Is there any easier way to do this? Thanks -Shane
Advertisement
i and a couple have been dealing with this problem.
here is the link to the thread:
http://www.gamedev.net/community/forums/topic.asp?topic_id=319124

here is the link to codeproject that has a sample program:
http://www.codeproject.com/opengl/openglstruct.asp
I did look at that thread - it seemed like you were just trying to render onto a dialog box that would be displayed for the entirety of the program's run time. I'm trying to figure out the best way to render onto a temporary popup dialog box.

Anyone have any ideas?

Thanks
-Shane
Could you use the CreateDialog function? That would allow you to create your dialog box once when your program starts, do all your initialization in WM_INITDIALOG once, then hold on to the dialog box for the duration of the program. When you want the user to see your dialog box, call ShowWindow with the HWND you get back from CreateDialog, and when the user clicks the close button or Alt-F4, catch the WM_CLOSE message in the dialog's WndProc, and call HideWindow. At the end of your program, simply call DestroyWindow.
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Quote:Original post by shane1985
Is there any easier way to do this?

wglShareLists() allows you to make display lists and textures available to a number of rendering contexts. You could probably create 'base' context when your program starts, then whenever a dialog box is created let the dialog's context 'tap' into the 'base' list with wglShare... The shared textures/display lists are supposed to exist until all contexts using them are destroyed so this'd possibly save you reloading them every time.
Hey tolaris, thanks a lot!
That's what I was looking for.
Thanks to insanity's idea as well - that might come in useful in one of my other projects.

This topic is closed to new replies.

Advertisement