c++copenglwgl

wglGetProcAddress returning NULL


I am using wlgGetProcAddress to get functions using a context created with wglCreateContext. I have set the context with wglMakeCurrent. I get a valid function pointer for glGetStringi, but I get NULL for glGetString. I thought that glGetString and glGetStringi were introduced in the same version of OpenGL (1.0). Any ideas why I am getting this NULL?

const GLubyte* (*glGetString)(GLenum);
const GLubyte* (*glGetStringi)(GLenum, GLuint);
glGetString = reinterpret_cast<decltype(glGetString)>(wglGetProcAddress("glGetString"));
glGetStringi = reinterpret_cast<decltype(glGetStringi)>(wglGetProcAddress("glGetStringi"));

In case it matters, I have a Radeon HD 7950 with driver version 13.251.0.0.


Solution

  • glGetStringi was introduced much later than 1.0 - I believe it is 3.3. To make things worse, on core 3.3+ profile you can't use glGetString(GL_EXTENSIONS), but required to use glGetStringi, which is unavailable for lower profile versions.

    MSDN documentation says wglGetProcAddress only returns addresses for extension functions. And 'extension' in their terms is everything that is not in GL 1.1.

    Please read https://www.opengl.org/discussion_boards/showthread.php/168281-Can-t-get-wglGetProcAddress-to-work-in-opengl-3-1