我试图通过OpenGL API
为application
课程编译此程序:
#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);
它表示startup()
函数中的这行代码存在问题:
void startup()
{
render_program = compile_shaders();
glCreateVertexArrays(1, &vertex_array_object); // <--
glBindVertexArray(vertex_array_object);
}
我尝试过使用glGenVertexArrays
,但仍然无法成功编译。
答案 0 :(得分:0)
glCreateVertexArrays
是OpenGL 4.5的一个功能。如果是NULL
,那很可能意味着程序中当前的OpenGL上下文不支持它。
你确定: