在学习OpenGL时,我在寻找可以评估各种图像类型的图像阅读器,如".png", ".bmp", ".tga", ".dds", ...
。我的计划是提取PARAMS像height
,width
,type
图像文件,并与下面样的功能设置:OpenGL通用图像阅读器和GLFW(glfwReadImage,glfwLoadTexture2D)支持各种图像格式
glTexImage2D(GL_TEXTURE_2D, 0, <color format>, <width>, <height>,
0, <color orientation>, <data type>, <actual data>);
我通过CImg library和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
像PARAMS任何库,并允许我们单独设置它通过glTexImage2D
。
GLFW呢,这个问题中提到的函数有用吗? – iammilind
你是正确的,glfwReadImage()只加载TGA文件。再一次,只支持一种图像格式不是世界末日;离线图像格式转换工具是一毛钱一打。但是如果你只支持一种格式,我仍然推荐使用TGA的DDS。 – postgoodism