C++ 使用GLCreateVertexArray时出现OpenGL异常

C++ 使用GLCreateVertexArray时出现OpenGL异常,c++,opengl,exception,C++,Opengl,Exception,我试图通过openglapi为这个应用程序类编译这个程序: #include "sb7.h" using namespace sb7; class my_application : public application { public: void startup() { render_program = compile_shaders(); glCreateVertexArrays(1, &vertex_array_object);

我试图通过
openglapi
为这个
应用程序
类编译这个程序:

#include "sb7.h"

using namespace sb7;
class my_application : public application
{
public:

    void startup()
    {
        render_program = compile_shaders();
        glCreateVertexArrays(1, &vertex_array_object);    // <--
        glBindVertexArray(vertex_array_object);
    } 
    void shutdown()
    {
        glDeleteProgram(render_program);
        glDeleteVertexArrays(1, &vertex_array_object);
        glDeleteProgram(render_program);
    }

    void render(double currentTime)
    {
        const GLfloat color[] = {  0.0f, 2.0f, 0.0f, 1.0f };
        glClearBufferfv(GL_COLOR, 0, color);

        glUseProgram(render_program);

        glDrawArrays(GL_TRIANGLES, 0, 3);   
    }
private:
    GLuint render_program;
    GLuint vertex_array_object;
};

DECLARE_MAIN(my_application);  

我尝试过使用
glgenvertexarray
,但仍然没有成功编译。

glcreatevertexarray
是OpenGL 4.5中的一个函数。如果它
NULL
,则很可能意味着程序中的当前OpenGL上下文不支持它

你确定:

  • 您有一个支持OpenGL 4.5的图形卡
  • 您有支持OpenGL 4.5的图形卡驱动程序吗
  • 您正在使用的框架初始化OpenGL 4.5上下文

谢谢!实际上,Glgenvertexarray起了作用。此外,GLSL程序应使用400版进行编译。
void startup()
{
    render_program = compile_shaders();
    glCreateVertexArrays(1, &vertex_array_object);    // <--
    glBindVertexArray(vertex_array_object);
}