i have a little issue with wglGetProcAddress(“glGetString”). After i created a valid current OpenGL Context the function call give me a null pointer. Why? If I do the same with wglGetProcAddress(“glCreateProgram”) i get a correct function pointer. Why it doesn’t work with glGetString?
wglGetProcAddress() only returns the addresses of OpenGL extension functions, where Microsofts definition of “extension” means anything that does not exist in OpenGL 1.1.
Generally, directly accessing wgl is full of pitfalls, so it is highly recommended to use an OpenGL wrapper, which hides all the uglyness. Microsoft has shown no intention to make low-level OpenGL programming less painful during the last decade, so I expect that the current situation will not improve until the Graphics Card Vendors take up the initiative and define a better OpenGL ABI for Windows.
[QUOTE=mbentrup;1244882]Generally, directly accessing wgl is full of pitfalls, so it is highly recommended to use an OpenGL wrapper, which hides all the uglyness.
May I ask why do you think it is “ugly” to use extensions without wrappers? What are the pitfalls? On the contrary, I think it is much better experience than using wrappers. It takes some time when new extensions are introduced, but it is worth of the effort.
The problem is that the original poster isn’t using any extensions, he just wants to use a core OpenGL 2.0 function. Still he must use the extension API, because the opengl32.dll is still on the level of OpenGL 1.1. If the wgl would allow to query all OpenGL functions, you could just blindly always use qglGetProcAddress, but as it is, you can only query functions which were not part of OpenGL 1.1.
So e.g. if I want to program for OpenGL 3.2 using pure wgl without wrappers, I need to check both the OpenGL 3.2 and OpenGL 1.1 specs to find how I can call a function. I consider that ugly, but I assume that it’s a matter of taste.
Or much easier, you can use the gl.h (and maybe glext.h) from Microsoft to compile. Every function not found in the header files needs a (wgl)GetProcAddress() call. And GL_* symbols not found, have to be defined, too.