Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on an OpenGL project, coming from D3D. They're organised in very different ways, so it's tricky going :)

Is there any way for a Windows application to request a specific OpenGL context version, e.g. 2.1 or 3.x?

Also, I believe I need to use wglext.h from the OpenGL registry as the GL.h that ships with Windows is an earlier version, 1.1 or 1.4 - can anyone confirm?

share|improve this question
The OpenGL Wiki's "Getting Started" page is a good place to... get started. – Nicol Bolas Jun 11 '12 at 15:32

At first, you must know that you can run a given version of OpenGL in two different profiles: Compatibility profile is supposed to be compatible with the previous versions, and Core profile which doesn't support previous versions but might be faster/smaller. There is also a forward compatibility mode, best for you is to check on OpenGL website for more details about them.

Assuming you're using wgl to create an OpenGL context and glew, here is a code snippet that gives you access to advanced options such as version and profile:

// Usual initialization
if(!wglMakeCurrent(Context->hDC, Context->hRC))
    return 0;                               


GLint attribs[] =
    // Here we ask for OpenGL 2.1
    // Uncomment this for forward compatibility mode
    // Uncomment this for Compatibility profile
    // We are using Core profile here

HGLRC CompHRC = wglCreateContextAttribsARB(Context->hDC, 0, attribs);
if (CompHRC && wglMakeCurrent(Context->hDC, CompHRC))
    Context->hRC = CompHRC;

Don't forget to include wglew.h to get access to wglCreateContextAttribsARB. If you're not using glew (or something equivalent), I think you should do, especially if you're working under Windows and want to avoid a lot of pain.

share|improve this answer

I use GL Load

then it is a simply a matter of including the version of the header you want.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.