【发布时间】:2019-05-19 07:21:54
【问题描述】:
我正在使用这个 SOIL 函数在 OpenGL 中加载纹理文件。但是我想访问:
- 加载图像的高度和宽度。
- 图像的 Bpp(每字节像素值)(8、24 等)。
- 数据指针。
给定的函数不返回任何这些特征。我想要一些关于如何使用这个或任何其他类似的 SOIL 函数找到这些的帮助。这是我使用的功能。
GLuint loadSOIL(const char* imagePath) {
cout << "Reading image: " << imagePath << endl;
GLuint texture = 0;
//Load Image File Directly into an OpenGL Texture
texture = SOIL_load_OGL_texture
(
imagePath,
SOIL_LOAD_RGB,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_TEXTURE_REPEATS
);
// error check
if (texture == 0) {
cout << "SOIL loading error: " << SOIL_last_result() << endl;
}
return texture;
}
【问题讨论】:
-
请注意,最好使用
!texture而不是texture == 0(与texture == false相同)