c++ - glfwSwapBuffers(窗口); 失败并抛出异常
问题描述
我在这里从官方 GLFW 文档中复制了一些代码:https ://www.glfw.org/documentation.html但它一直在它所说的地方引发异常glfwSwapBuffers();
。
在 Main.exe 中的 0x0000000000000000 处引发异常:0xC0000005:访问冲突执行位置 0x0000000000000000
#include<iostream>
#include<glad/glad.h>
#include<GLFW/glfw3.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
glfwInit();
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (window == NULL)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
解决方案
推荐阅读
- ios - 访问从协议继承的属性的实例变量
- assembly - mips 程序集将返回值保存到特定地址
- c - 通过文本文件数据从堆栈中添加和删除
- android - .NET Core API 向连接的应用程序发送广播?
- c# - ViewModel 通知绑定的 ComboBox List 已更改
- excel - 用VBA打开文件夹,路径中有括号
- angular - 从 Angular 服务和组件中的可观察对象返回和接收转换数据的正确方法是什么?
- graph - 如何使用散景更新networkx图的数据源?
- angular - 在 Firestore 中的 Mat 幻灯片切换真/假更新
- c++ - 我有这个程序的问题。有人看到我做错了吗?对此相当陌生