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.
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.
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.
- You first need to use the ordinary wglCreateContext to get “some” context and make it current because wglGetProcAddress requires you to have current context.
- Then use wglGetProcAddress to get wglCreateContextAttribsARB.
- make the fisrst context non-current and destroy it.
- 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 http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.