Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using OpenGL textures larger than window/display size

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?

like image 502
Ashwin Nanjappa Avatar asked Aug 18 '08 08:08

Ashwin Nanjappa


1 Answers

There's a simple solution.

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

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:

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);
like image 169
Ashwin Nanjappa Avatar answered Oct 25 '22 18:10

Ashwin Nanjappa