使用大于窗口/显示大小的OpenGL纹理

时间:2020-12-11 15:36:54

I'm having problems using textures that are larger than the OpenGL window or the display size as non-display render targets.
What's the solution for this problem?

我在使用大于OpenGL窗口的纹理或显示尺寸作为非显示渲染目标时遇到问题。这个问题的解决方案是什么?

1 个解决方案

#1


4  

There's a simple solution.

有一个简单的解决方案。

Assuming your (non-display) textures are 1024x1024 and you are restricted to a 256x256 window/display.

假设您的(非显示)纹理是1024x1024并且您被限制为256x256窗口/显示。

unsigned int WIN_WIDTH = 256;
unsigned int WIN_HEIGHT = WIN_WIDTH;
unsigned int TEX_WIDTH = 1024;
unsigned int TEX_HEIGHT = TEX_WIDTH;

Use the window size to create your OpenGL window:

使用窗口大小创建OpenGL窗口:

glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);

But, use the texture size for everything else:

但是,将纹理大小用于其他一切:

glViewport(0, 0, TEX_WIDTH, TEX_HEIGHT);
gluOrtho2D(0.0, TEX_WIDTH, 0.0, TEX_HEIGHT);
glTexCoord2i(TEX_WIDTH, TEX_HEIGHT);

#1


4  

There's a simple solution.

有一个简单的解决方案。

Assuming your (non-display) textures are 1024x1024 and you are restricted to a 256x256 window/display.

假设您的(非显示)纹理是1024x1024并且您被限制为256x256窗口/显示。

unsigned int WIN_WIDTH = 256;
unsigned int WIN_HEIGHT = WIN_WIDTH;
unsigned int TEX_WIDTH = 1024;
unsigned int TEX_HEIGHT = TEX_WIDTH;

Use the window size to create your OpenGL window:

使用窗口大小创建OpenGL窗口:

glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);

But, use the texture size for everything else:

但是,将纹理大小用于其他一切:

glViewport(0, 0, TEX_WIDTH, TEX_HEIGHT);
gluOrtho2D(0.0, TEX_WIDTH, 0.0, TEX_HEIGHT);
glTexCoord2i(TEX_WIDTH, TEX_HEIGHT);