Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(OpenGL) wglCreateContext() context's version

I want to know which version wglCreateContext() will return to me. Does it always return the highest version available? Do you have some official documentation links about that?

like image 758
panicq Avatar asked Oct 25 '25 22:10

panicq


2 Answers

You need to use wglCreatContextAttribsARB (...) from the extension: WGL_ARB_create_context.

Something to the effect:

    // Request an OpenGL 3.3 context
    const GLuint attribs [] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
                                WGL_CONTEXT_MINOR_VERSION_ARB, 3,
                                0 };

    HGLRC hRC = wglCreateContextAttribsARB (hDC, 0, attribs);

Ironically, this means creating an OpenGL context, loading that extension, destroying the original context and creating a new one by calling wglCreateContextAttribsARB (...). See the extension spec. I listed for more details.


When this extension is supported, calling

    wglCreateContext (hdc)

Is equivalent to calling

    wglCreateContextAttribsARB (hdc, 0, NULL)
like image 144
Andon M. Coleman Avatar answered Oct 27 '25 17:10

Andon M. Coleman


Nope, it's not defined. You need to ask for a particular version if you want any guarantees.

You can typically expect a Compatibility profile, though, because of the need for the legacy support.

like image 24
Bartek Banachewicz Avatar answered Oct 27 '25 16:10

Bartek Banachewicz