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?
You are only allowed to call SetPixelFormat once for a window ( see SetPixelFormat function (wingdi.h) - Win32 apps | Microsoft Learn ). 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).
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.