Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: How to run Several versions of OpenGL

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Newbie Newbie
    Join Date
    Apr 2014

    How to run Several versions of OpenGL

    Hello, I'm new to game developing in C++ and I would really like to know how to run two different versions of OpenGL, In this case I want to use OpenGL 2.1 while my PC has OpenGL 4.4.
    I have already googled the internet and there's no info that I could find.

    The compiler I'm using is MS Visual Studio 2013.

    If there's any info that is missing please tell me.

  2. #2
    Member Regular Contributor
    Join Date
    Dec 2009
    Generally you cannot request an OpenGL context of a specific version. The GLW API, which is the link between OpenGL and the Windows system allows the application to specify an OpenGL version, but it will return a context of any version that is upwards compatible with the requested version.

    So if you request an OpenGL 2.1 on your PC you'll probably create an OpenGL 4.4 context using the compatibility profile, because that is upwards compatible to OpenGL 2.1.

    On the one hand this means that you can run any OpenGL 2.1 program on your OpenGL 4.4 system, but on the other hand it will happily allow you to use compute shaders or tesselation, which aren't supported in a "pure" OpenGL 2.1 context.

    So you can develop for OpenGL 2.1 on a OpenGL 4.4 system, but to guarantee that the application works on any 2.1 system, you have to test on old drivers or check otherwise that you don't use any of the newer features.

  3. #3
    Member Regular Contributor
    Join Date
    Apr 2004
    You can request specific GL version with wglCreateContextAttribsARB by specifying attributes like WGL_CONTEXT_MAJOR_VERSION_ARB and WGL_CONTEXT_MINOR_VERSION_ARB.
    The tricky part is to get to this function.
    1) You first need to use the ordinary wglCreateContext to get "some" context and make it current because wglGetProcAddress requires you to have current context.
    2) Then use wglGetProcAddress to get wglCreateContextAttribsARB.
    3) make the fisrst context non-current and destroy it.
    4) use wglCreateContextAttribsARB to create a new context with the desired properties (GL version or others) and make it current.

    I know, its quite a mess. At least you can use single window for all this (the one in which you will actually draw).

    Ah, yes, the context returned by wglCreateContextAttribsARB may not actually be exactly of the version you requested. The function spec only says the new context will be "compatible" to the requested, for some quite complicated definition of "compatible".
    Read the specification in

Posting Permissions

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