**关闭。**此题需要debugging details。目前不接受答复。
编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将帮助其他人回答这个问题。
7天前关闭
Improve this question
每当我尝试调整窗口大小时,都会遇到这个问题:Exception thrown at 0x0000000000000000 in fps-opengl.exe: 0xC0000005: Access violation executing location 0x0000000000000000.
这是我目前为止的代码:
#include "engine.h"
#include "Source.h"
//void framebuffer_size_callback(GLFWwindow* window, int width, int height);
int main() {
//engine engine();
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(800, 600, "wonder window", NULL, NULL);
if (window == nullptr) {
std::cout << "error init window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
while (!glfwWindowShouldClose(window)) {
// implement calculation of elapsed time here pass to onuserinput
//engine.onuserinput();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
engine.h是空的,除了glfw includes和glad。Visual studio在glviewport行后发现错误。
1条答案
按热度按时间qco9c6ql1#
在调用任何其他OpenGL方法之前,需要初始化glad库。glad github repo上的说明建议在打开窗口并绑定上下文后必须调用以下代码: