如何在openGL中使用纹理压缩?

时间:2022-01-01 05:14:52

I'm making an image viewer using openGL and I've run into a situation where I need to load very large (>50MB) images to be viewed. I'm loading the images as textures and displaying them to a GL_QUAD which has been working great for smaller images, but on the large images the loading fails and I get a blank rectangle. So far I've implemented a very ugly hack that uses another program to convert the images to smaller, lower resolution versions which can be loaded, but I'm looking for a more elegant solution. I've found that openGL has a texture compression feature but I can't get it to work. When I call

我正在使用openGL创建一个图像查看器,我遇到了需要加载非常大(> 50MB)图像才能查看的情况。我正在将图像作为纹理加载并将它们显示到GL_QUAD,这对于较小的图像效果很好,但在大图像上加载失败并得到一个空白矩形。到目前为止,我已经实现了一个非常丑陋的黑客,它使用另一个程序将图像转换为可以加载的更小,更低分辨率的版本,但我正在寻找更优雅的解决方案。我发现openGL有一个纹理压缩功能,但我无法让它工作。我打电话的时候

glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ARB, t.width(), t.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, t.bits());

I get the compiler error "GL_COMPRESSED_RGBA_ARB undeclared". What am I doing wrong? Is there a library I'm missing? And more generally, is this a viable solution to my problem?

我得到编译器错误“GL_COMPRESSED_RGBA_ARB unclared”。我究竟做错了什么?我有遗失的图书馆吗?更一般地说,这是我的问题的可行解决方案吗?

I'm using Qt Creator on a Windows Vista machine, with a NVIDIA Quadro FX 1700 graphics card.

我在Windows Vista机器上使用Qt Creator,配有NVIDIA Quadro FX 1700显卡。

2 个解决方案

#1


On my own GFX card the maximum resolution for an opengl texture is 8192x8192, if your image is bigger then 50MB, it is propably a very very high resolution... Check http://www.opengl.org/resources/faq/technical/texture.htm , it describes how you can find the maximum texture size.

在我自己的GFX卡上,opengl纹理的最大分辨率是8192x8192,如果你的图像大于50MB,它的分辨率非常高......请查看http://www.opengl.org/resources/faq/technical /texture.htm,它描述了如何找到最大纹理大小。

#2


First, I'd have to ask what resolution are these large images? Secondly, to use a define such as GL_COMPRESSED_RGBA_ARB, you would need to download and use something like GLEW which is more modernized in the GL api than the standard MS-Dev install.

首先,我不得不问这些大图像的分辨率是多少?其次,要使用诸如GL_COMPRESSED_RGBA_ARB之类的定义,您需要下载和使用GLEW之类的东西,它在GL api中比标准的MS-Dev安装更现代化。

#1


On my own GFX card the maximum resolution for an opengl texture is 8192x8192, if your image is bigger then 50MB, it is propably a very very high resolution... Check http://www.opengl.org/resources/faq/technical/texture.htm , it describes how you can find the maximum texture size.

在我自己的GFX卡上,opengl纹理的最大分辨率是8192x8192,如果你的图像大于50MB,它的分辨率非常高......请查看http://www.opengl.org/resources/faq/technical /texture.htm,它描述了如何找到最大纹理大小。

#2


First, I'd have to ask what resolution are these large images? Secondly, to use a define such as GL_COMPRESSED_RGBA_ARB, you would need to download and use something like GLEW which is more modernized in the GL api than the standard MS-Dev install.

首先,我不得不问这些大图像的分辨率是多少?其次,要使用诸如GL_COMPRESSED_RGBA_ARB之类的定义,您需要下载和使用GLEW之类的东西,它在GL api中比标准的MS-Dev安装更现代化。