Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Problem with wglgetprocaddress()

  1. #1
    Newbie Newbie
    Join Date
    Nov 2012
    Posts
    1

    Problem with wglgetprocaddress()

    Hi,

    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?

    I'm a little confused.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Dec 2009
    Posts
    198
    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.


  3. #3
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,069
    Quote Originally Posted by mbentrup View Post
    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.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    661
    The GL 1.1 functions are being exported by opengl32.dll. You may call GetProcAddress() instead to resolve those symbols, if you really need to.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Dec 2009
    Posts
    198
    Quote Originally Posted by Aleksandar View Post
    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.

  6. #6
    Intern Contributor
    Join Date
    Sep 2004
    Posts
    77
    Quote Originally Posted by mbentrup View Post
    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.

Posting Permissions

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