OpenGL 中的图像加载用于 GIS 应用程序

发布于 2024-09-14 18:01:59 字数 380 浏览 1 评论 0原文

我目前正在开发一个内部 GIS 应用程序。背景图像通过将图像分解为我认为所谓的纹素和 mipmap 来加载到 OpenGL 中,之后构建显示列表以将每个纹素纹理映射到矩形上。这听起来很标准,但问题是,目前对于没有整齐地划分为 2^n 像素 x 2^m 像素纹素的图像,剩余部分将被丢弃。即使我要捕获剩余部分并以某种方式处理它们,我也无法想象答案是不断测试纹素细分,最终导致在整齐的边界上完全捕获图像?或者是吗?

在某些情况下,我加载的图像是 geotiff,我需要将每个像素都包含在我的背景中。我听说 glDrawPixels 很慢。我知道我可以自己测试一下,但我有一种感觉,这个领域的人正在使用 opengl 中的纹理,而不是跟踪像素转储。

我是 OpenGL 新手,我相信该应用程序将自身限制为 1.1 调用。

I am currently working on an in house GIS app. Background images are loaded in OpenGL by breaking the image down into what I guess are termed texels and mipmapped, after which a display list is built to texture map each texel onto rectangles. This sounds pretty standard, but the issue is that currently for images that do not divide neatly into 2^n pixel x 2^m pixel texels, the remainders are thrown away. Even if I were to capture the remainders and handle them in some way, I can't imagine that the answer is to continually test for texel subdivisions that eventually result in total capture of the image on neat boundaries? Or is it?

In some cases the images that I'm loading are geotiffs, and I need every single pixel to be included on my background. I've heard that glDrawPixels is slow. I know I could test this for myself, but I have a feeling that people in this space are using textures in opengl, not keeping track of pixel dumps.

I'm new to OpenGL, and I believe that the app is limiting itself to 1.1 calls.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑,眼淚并存 2024-09-21 18:01:59

在 OpenGL 1.1 中处理两个图像的非幂的标准方法是将图像存储在尺寸为最接近的较大二次幂的纹理中,然后修改纹理坐标,一些伪代码:

float sMax = image.width / texture.width;
float tMax = image.height / texture.height;

glBegin(GL_QUADS);
glVertex2f(0, 0);
glTexCoord2f(sMax, 0);
glVertex2f(1, 0);
glTexCoord2f(sMax, tMax);
glVertex2f(1, 1);
glTexCoord2f(0, 0);
glVertex2f(0, tMax);
glTexCoord2f(0, 1);
glEnd();

使用更高版本的 OpenGL 或者如果您'使用扩展时,您可以使用矩形纹理:

http://www.opengl.org /registry/specs/ARB/texture_rectangle.txt

The standard way of handling non power of two images in OpenGL 1.1 is to store the image in a texture with dimension of the nearest larger power of two and then modifying the texture coordinates, some pseudocode:

float sMax = image.width / texture.width;
float tMax = image.height / texture.height;

glBegin(GL_QUADS);
glVertex2f(0, 0);
glTexCoord2f(sMax, 0);
glVertex2f(1, 0);
glTexCoord2f(sMax, tMax);
glVertex2f(1, 1);
glTexCoord2f(0, 0);
glVertex2f(0, tMax);
glTexCoord2f(0, 1);
glEnd();

With a higher version of OpenGL or if you're using extension you can use rectangular textures:

http://www.opengl.org/registry/specs/ARB/texture_rectangle.txt

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文