【发布时间】:2019-10-05 15:04:50
【问题描述】:
我正在尝试加载 .jpg 图像作为背景,我使用 stbi_load 加载了它,但是当我尝试绘制纹理时出现以下错误: 在 0x69ABF340 (nvoglv32.dll) 处引发异常 0xC0000005:访问冲突读取位置 0x0C933000。发生了
我在加载图像时尝试更改通道,可能图像不是rgb而是rgba,没有成功。
int width = 1280;
int height = 720;
int channels = 3;
GLuint t;
stbi_set_flip_vertically_on_load(true);
unsigned char *image = stbi_load("bg.jpg",
&width,
&height,
&channels,
STBI_rgb);
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &t);
glBindTexture(GL_TEXTURE_2D, t);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
glBindTexture(GL_TEXTURE_2D, 0);
窗口应该包含指定的纹理,而不是我得到一个带有异常的白色窗口。
【问题讨论】: