I was wondering if it was possible somehow to apply a scale to a texture to make it possible to use direct texel coordinates instead of normalized coordinates?
For example, if you wanted the 64 X 64 rectangle at 0,0 in a 256X256 texture you could just use coordinates 0,0 ; 64,0 ; 64,64 ; 0,64 instead of 0f,0f ; 0.25f, 0f ; 0.25f, 0.25f ; 0f, 0,25f.
I know I can just divide by dimensions, but it would make life a lot easier right
And anyway OpenGL must translate normalized coordinates to actual texel coordinates anyway internally at some point right?
You can transform the texture-matrix just like the modelview/projection-matrix
glMatrixMode(GL_TEXTURE)
Is this texture matrix global, or is there a texture matrix for each texture?
It’s global. And becareful with push and pop - the texture matrix stack is much smaller, and typically only 2 deep.
Interesting…
How it is used??
I have a Texture Image that is 64x128px and I want to texture a quad from (0,0) to (45,70)
I need to scale the texureCoords with the textureMatrix??
Rafael.-
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GL11.glScalef(someValueX, somevalueY, someValueZ);
DrawSomeStuff();
GL11.glPopMatrix();
Thats if you can next Transforms in Textures, if you have no such methodology in your engine/game, then you can do it in a simpler fashion:
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glLoadIdentity();
GL11.glScalef(someValueX, somevalueY, someValueZ);
DrawSomeStuff();
DP 