glCreateProgram 访问冲突执行位置 0x00000000
glCreateProgram Access violation executing location 0x00000000
我已经初始化了 GLFW,我可以调用其他 gl 函数。可以使用 OpenGL 管道绘制人脸。但是,它在执行 glCreateProgram()
.
时给了我这个错误
错误:
Exception thrown at 0x00000000 in Voxel.exe: 0xC0000005: Access
violation executing location 0x00000000.
简化代码:
void error_callback(int error, const char* description)
{
cerr << description << endl;
}
[...]
if (!glfwInit())
{
cout << "Failed to create GLFW3 / OpenGL context";
system("PAUSE");
exit(EXIT_FAILURE);
}
else
cout << "GLFW3 initialized!" << endl;
glfwSetErrorCallback(error_callback);
glFrontFace(GL_CW);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
width = 600;
height = 600;
this->window = glfwCreateWindow(width, height, "voxel", NULL, NULL);
glfwSetWindowSize(this->window, width, height);
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
if (!this->window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(this->window);
glfwSwapInterval(0);
cout << "OpenGL version: " << glGetString(GL_VERSION) << endl;
GLuint program = glCreateProgram();
[...]
我不明白为什么会这样。
GLFW 不会为您加载扩展和现代功能。因此 glCreateProgram 未初始化。
您需要一个实际的扩展加载器。您还必须检查 glCreateProgram 等。您的目标系统实际上支持。
我已经初始化了 GLFW,我可以调用其他 gl 函数。可以使用 OpenGL 管道绘制人脸。但是,它在执行 glCreateProgram()
.
错误:
Exception thrown at 0x00000000 in Voxel.exe: 0xC0000005: Access violation executing location 0x00000000.
简化代码:
void error_callback(int error, const char* description)
{
cerr << description << endl;
}
[...]
if (!glfwInit())
{
cout << "Failed to create GLFW3 / OpenGL context";
system("PAUSE");
exit(EXIT_FAILURE);
}
else
cout << "GLFW3 initialized!" << endl;
glfwSetErrorCallback(error_callback);
glFrontFace(GL_CW);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
width = 600;
height = 600;
this->window = glfwCreateWindow(width, height, "voxel", NULL, NULL);
glfwSetWindowSize(this->window, width, height);
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
if (!this->window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(this->window);
glfwSwapInterval(0);
cout << "OpenGL version: " << glGetString(GL_VERSION) << endl;
GLuint program = glCreateProgram();
[...]
我不明白为什么会这样。
GLFW 不会为您加载扩展和现代功能。因此 glCreateProgram 未初始化。
您需要一个实际的扩展加载器。您还必须检查 glCreateProgram 等。您的目标系统实际上支持。