Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Necessary to destroy original window of dummy ctxt

  1. #1
    Junior Member Regular Contributor
    Join Date
    Sep 2003
    Location
    Ireland
    Posts
    136

    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?

  2. #2
    Junior Member Regular Contributor
    Join Date
    Sep 2003
    Location
    Ireland
    Posts
    136

    Re: Necessary to destroy original window of dummy ctxt

    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?

  3. #3
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    393

    Re: Necessary to destroy original window of dummy ctxt

    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.

  4. #4
    Advanced Member Frequent Contributor Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    952

    Re: Necessary to destroy original window of dummy ctxt

    Quote Originally Posted by Wiki
    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.
    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!

    Quote Originally Posted by charliejay
    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?
    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.

  5. #5
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,792

    Re: Necessary to destroy original window of dummy ctxt

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

  6. #6
    Junior Member Regular Contributor
    Join Date
    Sep 2003
    Location
    Ireland
    Posts
    136

    Re: Necessary to destroy original window of dummy ctxt

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •