views:

401

answers:

3

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?

+3  A: 

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);
Ashwin
+3  A: 

@Ash: I like this series of GL questions and answers... hope you post a lot more...

@Whoever is downmodding these: stop it! this is just what stackoverflow is for!

Mark Harrison
A: 

@Mark Harrison: A long time back I had noted down the very basic problems that most developers/students face when they write and compile their first OpenGL/graphics programs. I'm trying to move those notes over to StackOverflow since it seems like the best place where I can share them and also get updated/better solutions to those.

PS: I'm thrilled to find a Pixar/graphics person out here. Right now it seems to be filled to the brim with web/.Net folks :-)

Ashwin