Is a fake context needed to create modern OpenGL context?

Viewed 198

According to this page (and several others) you need to create a dummy window, then a dummy legacy context, then use wglCreateContextAttribsARB to create a modern context.

However I tried using the old way with wglCreateContext and loading functions manually:

glCreateShader = wglGetProcAddress("glCreateShader");
glShaderSource = wglGetProcAddress("glShaderSource");
glCompileShader = wglGetProcAddress("glCompileShader");
...etc for all other functions that I need

Then I checked the context version:

int minor;
int major;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
printf("%d.%d\n", major, minor);

And I got "4.6". Why isn't the version something like 2.0 and why is the fake context thing needed?

1 Answers

If you are willing to limit your application to never using WGL extensions (ie: you can't do things like control vsync, use more advanced pixel formats, create robust or debug OpenGL contexts, or any number of other tools) and always using a compatibility context, then yes, you can get away with not using the more modern context creation APIs. But there's no reason to impose such limits on your program.

Related