在学习 OpenGL 时,我正在寻找可以评估各种图像类型的图像阅读器,例如".png", ".bmp", ".tga", ".dds", .... 我的计划是提取图像文件的参数,如height, width,type并使用以下函数进行设置:
glTexImage2D(GL_TEXTURE_2D, 0, <color format>, <width>, <height>,
0, <color orientation>, <data type>, <actual data>);
我浏览了CImg 库和stb_image.c。但是,我不知道如何获取 ,widhth等height参数type。
这似乎是<GL/glfw.h>一个很好的框架。我的印象是它只是".tga"使用以下函数加载格式:
int glfwLoadTexture2D(const char *name, int flags);
它支持所有格式吗?
另外,我在它附近看到了以下功能。如果有人可以简要介绍一下,那将是一个奖励。
int glfwReadImage(const char *name, GLFWimage *img, int flags);
void glfwFreeImage(GLFWimage *img);
在哪里:
typedef struct {
int Width, Height;
int Format;
int BytesPerPixel;
unsigned char *Data;
} GLFWimage;
如果 GLFW 不支持所有格式,那么是否有任何库可以获取上述GLFWimage参数,并允许我们glTexImage2D单独设置它。