【发布时间】:2020-03-14 11:23:08
【问题描述】:
这是我的代码:
int h, w, c;
unsigned char* img = stbi_load("bricks.jpg", &w, &h, &c, 0);
if (img == NULL) {
printf("Error in loading the image\n");
}
printf("Image loaded with width of %d, height of %d, and %d channels", w, h, c);
GLuint txtr = 0;
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &txtr);
glBindTexture(GL_TEXTURE_2D, txtr);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, img);
由于某种原因,当我取消评论 glTexImage2D 时,我的窗口不再打开。 w 和 h 均由 stbi_load 计算,它是 stb_image.h 库的一部分。我的错在哪里?
【问题讨论】:
标签: c++ visual-studio opengl glut