Search code examples
c++openglheaderidentifier

glActiveTexutre and GL_TEXTURE0 not working, both undeclared identifiers


So I recently picked up C++ again, only to have it throw all kinds of errors at me upon build. I included gl.h, glu.h, and the associated libraries, but Visual Studio tells me that glActiveTexture and GL_TEXTURE0 are not identifiers. Is something wrong with my gl headers? Any help would be great.

void setupCubeMap(GLuint& texture)
{
    glActiveTexture(GL_TEXTURE0);
    glEnable(GL_TEXTURE_CUBE_MAP);
    glGenTextures(1, &texture);
}

Solution

  • These functions and enums are not part of the GL1.1 that is part of the the Windows API. You could either use a current version ofglext.h and manually load the function pointers via wglGetProcAddress(), or use some helper library like GLEW, which handle all this cross-platform and without much hassle.