PDA

View Full Version : Scaling & offsetting textures



devdept
01-19-2010, 03:20 AM
Hi All,

Scaling and offsetting textures is very easy like below:


glTexCoord2d(offsetX + scaleX * U, offsetY + scaleY * V);
Is there a way to specify a scale and offset somewhere else and leave the glTexCoord2d() call like below:


glTexCoord2d(U, V);
so we don't need to recompile the object every time the user changes the texture scale?

Thanks,

Alberto

ZbuffeR
01-19-2010, 03:32 AM
You can do that on the texture matrix.

devdept
01-19-2010, 03:44 AM
Texture matrix, I've never heard about it. Where can I learn more?

Thanks,

Alberto

ZbuffeR
01-19-2010, 04:03 AM
http://glprogramming.com/red/chapter09.html#name17

devdept
01-19-2010, 05:19 AM
Ah, do you mean?


glMatrixMode(GL_TEXTURE); /* enter texture matrix mode */
glScaled(...);
glRotated(...);


Thanks,

Alberto

ZbuffeR
01-19-2010, 05:34 AM
yes.