'glCreateShader' was not declared in this scope?

后端 未结 3 2049
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 07:30

Why am I getting these errors?

error: \'GL_VERTEX_SHADER\' was not declared in this scope
error: \'glCreateShader\' was not declared in thi

相关标签:
3条回答
  • 2021-01-18 08:00

    What does glGetString(GL_VERSION) return?

    CreateShader is not in GLUT but OpenGL 2.0. If your "includes to glut" are not including gl.h for some reason or your GL version is less than 2.0, the headers will not declare it.

    I'd also check your gl.h to see if CreateShader is actually declared there.

    Edit: This OpenGL header version thing seems to be a general problem in Windows. Most people suggest using GLEW or another extension loader library to get around it.

    0 讨论(0)
  • 2021-01-18 08:07

    libepoxy is like an extended gl.h;

    #include <GL/gl.h can be replaced with #include <epoxy/gl.h>, and -lGL with -lepoxy. If you are on Windows/Mac you will have to build the source, so it might not be worth it if you already have a loader that you prefer, but I have found it works pretty well as a drop in replacement for GL/gl.h for GL3.3+, that got rid of the errors.

    0 讨论(0)
  • 2021-01-18 08:08

    You need to either use an OpenGL loading library to load OpenGL functions, or manually load the functions yourself. You can't just use gl.h and expect to get everything.

    0 讨论(0)
提交回复
热议问题