PDA

View Full Version : Sub Images



Spahrep
06-29-2001, 06:15 AM
If i load a 512x512 texture that is made up
of smaller 64x64 textures,
and i want to bind a smaller part of the
texture how do I do that?

Im aware that i could do somethning like,

x1 = (z%4)*(double(64)/double(512));
x2 = x1+.125;
y1 = 1 - (z/4)*(double(64)/double(512));
y2 = y1 - .125;

glBindTexture(GL_TEXTURE_2D, TMap[0]);

glBegin(GL_QUADS);
glTexCoord2f(x1, y1);
glVertex3f(-UNIT*XR, UNIT, 0.0f);
glTexCoord2f(x2, y1);
glVertex3f( UNIT*XR, UNIT, 0.0f);
glTexCoord2f(x2, y2);
glVertex3f( UNIT*XR,-UNIT, 0.0f);
glTexCoord2f(x1, y2);
glVertex3f(-UNIT*XR,-UNIT, 0.0f);
glEnd();

But thatwont work if i want them to bind and
repeat and I am having other
problems with this method.

A friend said that you could use a method to
actualy create and bind smaller
images from the larger one.

Anyone have any idea how to do this and some
psuedo code?

DFrey
06-29-2001, 07:53 AM
I know of no way to do that. There may be some obscure extension available in some far removed OpenGL implementation that would let you do that however. But for the sake of compatibility, I'd just use seperate textures. The overhead of using seperate smaller textures versus one large texture is not that significant.