Necessary to destroy original window of dummy ctxt

Just out of curiousity…

So I’m reading this discussion scrap opengl32.dll where Alfonse Reinheart links (on page 2) to Creating an OpenGL Context

where it says

Fortunately, this context does not need to be our final context. All we need to do is create a dummy context to get function pointers, then use those functions directly. Unfortunately, Windows does not allow recreation of a rendering context within a single window. You must destroy the window entirely and recreate it after we are finished with the dummy context.

I’m pretty sure my code for getting a 4.1 context does so (successfully) by creating the dummy context AND the final 4.1 context on the same window, seeming to contradict what is said in the quoted paragraph.

Could someone clarify for me whether the statement is correct, and if so, under what circumstances, please?

Further reading on the wiki (http://www.opengl.org/wiki/Platform_specifics:_Windows) gives this

How many times can I call SetPixelFormat?

For each window, once. According to MSDN, it would lead to significant complications if they allowed for more flexibility.

Never call GetDC(NULL) and then call SetPixelFormat. This gives the DC for the entire desktop. Instead, create a fullscreen window.

…so perhaps that’s the limitation?

You are only allowed to call SetPixelFormat once for a window ( see http://msdn.microsoft.com/en-us/library/dd369049(v=vs.85).aspx ). Perhaps in your app, both methods selected the same pixel format so you got away with it, but it isn’t safe to do this ever.

You can re-create a rendering context in the same window, or have multiple rendering context per window, or 1 context per multiple windows (as long as they are all using same pixel format) as long as you only set the pixel format once.

What does it mean “recreate context”? But I fill this is a complete NONSENSE!

That’s why I don’t like Wikis. Furthermore, I have found some nonsense in Wikipedia considering 3D rendering pipeline.

Please, don’t believe everything you read on Wikis!

Of course it works! You don’t need to change pixel format if you want to create 3.0+ rendering context. But it is true that you shouldn’t set pixel format more than once.

When do we need to use dummy window for setting pixel format?

  • When we need a multi-sample pixel format, for example.

Why? Because we need to set pixel format in order to activate GL context, BUT after that we traverse supported formats and choose a multi-sample one. Since this is a different format, we have to set it in another window (not the window used for the dummy context).

I hope it is clear now. :wink:

I have since added clarification to the Wiki that it’s about the window’s pixel format, not the context creation itself.

Thanks to everyone for the replies and the change to the wiki, pretty sure I only call SetPixelFormat once (I set up the dummy context with the same PFD that I want for the GL4.1 context), which puts me on the path in Dan’s second paragraph.

Edit:
…and I don’t use multisample.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.