Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ OpenGL通用图像阅读器和GLFW(glfwReadImage,glfwLoadTexture2D)支持各种图像格式_C++_C_Image_Opengl_Glfw - Fatal编程技术网

C++ OpenGL通用图像阅读器和GLFW(glfwReadImage,glfwLoadTexture2D)支持各种图像格式

C++ OpenGL通用图像阅读器和GLFW(glfwReadImage,glfwLoadTexture2D)支持各种图像格式,c++,c,image,opengl,glfw,C++,C,Image,Opengl,Glfw,在学习OpenGL的同时,我正在寻找一个图像阅读器,它可以评估各种图像类型,如“.png”、“.bmp”、“.tga”、“.dds”、…。我的计划是提取图像文件的高度,宽度,类型等参数,并将其设置为以下类型的函数: glTexImage2D(GL_TEXTURE_2D, 0, <color format>, <width>, <height>, 0, <color orientation>, <data type>, <a

在学习OpenGL的同时,我正在寻找一个图像阅读器,它可以评估各种图像类型,如
“.png”、“.bmp”、“.tga”、“.dds”、…
。我的计划是提取图像文件的
高度
宽度
类型
等参数,并将其设置为以下类型的函数:

glTexImage2D(GL_TEXTURE_2D, 0, <color format>, <width>, <height>,
    0, <color orientation>, <data type>, <actual data>);
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
进行设置。

您应该看看–它可能正是您想要的。

对广泛的图像格式有相当不错的支持,但已不在积极开发之中,;作者太忙了


也是一个不错的选择;这只是DDS,但这并不像人们想象的那么大问题。加载JPGs/PNGs/etc.对于原型开发(以及最终用户的轻松定制)非常方便,但DDS文件通常是更好的长期选择,因为它们本身支持游戏和交互应用程序中常用的几种功能(BCn、立方体环境贴图、体积纹理等)

GLFW怎么样?问题中提到的函数有用吗?@iammilind:GLFW只有TGA图像文件的代码。所以它不是很通用。GLFW呢,问题中提到的函数有用吗?glfwReadImage()只加载TGA文件是正确的。同样,只支持一种图像格式并不是世界末日;脱机图像格式转换工具非常多。但如果你只打算支持一种格式,我还是推荐DDS而不是TGA。