【发布时间】:2021-04-19 16:40:38
【问题描述】:
Unhandled exception in 0x7B372F75 (ig9icd32.dll) in forespend.exe: 0xC0000005: access violation writing to location 0x07E00000. 我试图运行glClear(GL_COLOR_BUFFER_BIT);,但它返回了这个错误,我的程序一直在运行和工作,但似乎由于这个错误它无法正常工作。
glClear 正在使用其中的其他标签,例如“GL_DEPTH_BUFFER_BIT”等。
在调试中没有问题出现,错误只是出现在代码中间,如下所示:
如果存在GL_COLOR_BUFFER_BIT 的替代品,我想知道。
代码:
#include<GL/glfw3.h>
#include<map>
#include<iostream>
#include<stdio.h>
#include<chrono>
#include<stdlib.h>
#define WIDTH 320
#define HEIGHT 200
struct key {
};
GLFWwindow* window;
GLFWmonitor* monitor;
bool running = 1, windowed;
std::map<int, key> keyMap;
void update(){}
void input(){}
void draw(){
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
}
int main() {
glfwWindowHint(GLFW_SAMPLES, 1);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
if (!glfwInit()) fprintf(stderr, "opengl error\n");
window = glfwCreateWindow(WIDTH, HEIGHT, "end", NULL, NULL);
if (window == NULL) {std::cout << "window error\n" << std::endl; glfwTerminate();}
glfwMakeContextCurrent(window);
monitor = glfwGetPrimaryMonitor();
while (running)
{
update();
input();
draw();
}
glfwDestroyWindow(window);
glfwTerminate();
}
【问题讨论】:
-
使用
glGetError检查 OpenGL 状态中的错误。顺便说一句,你说你以前问过类似的问题。我没看到。 -
glfwGetError()在glfwMakeContextCurrent()之后返回什么? -
我问过它,但它被阻止说我需要添加调试详细信息,没有要添加的,所以我写了我没有任何内容,并且由于它没有被取消阻止,所以我删除了。我在
glClear(GL_COLOR_BUFFER_BIT)之后尝试了glGetError,当我用std::cout打印错误时返回了0。但我也尝试了 genpfault 所说的,它返回了The GLFW library is not initialized,如果我可以毫无问题地对其进行编码,我不确定为什么会发生这种情况,只是运行显示这些问题。我该怎么办? -
什么操作系统?您是否安装了 OpenGL 兼容的 gfx 驱动程序? (注意 Windows MS Windows 更新通常会强制使用错误的 OpenGL 来自 MS 的错误 gfx 驱动程序来推广 DirectX ...如果您需要手动下载和安装供应商驱动程序)...好的,您的图像建议 Win10,所以我肯定会检查gfx 驱动程序
-
我如何安装opengl?我按照 opengl 的说明去英特尔下载中心下载英特尔 uhd 620 图形更新,但是当我运行安装程序时,它说这不适用于我的系统。还有其他安装方法吗?我的笔记本是 NP350XAA-KFWBR,cpu 是 i5-8250u...谢谢你告诉我关于 windows 更新的事情,我不知道