PDA

View Full Version : translating texels in a texture



fiche
09-30-2010, 01:03 AM
I have a function which is passed an x,y coordinate. This function calls glTexSubImage2D and updates the texture at texel x,y. I'd like to apply an offset to the coordinates. Is there a way to translate texel coordinates or do I have to handle this outside of opengl? At first I thought I could use
glMatrixMode(GL_TEXTURE)
glTranslatef()

but I got the impression it isn't used for translating the parameters of glTexSubImage2D

Alfonse Reinheart
09-30-2010, 02:46 AM
but I got the impression it isn't used for translating the parameters of glTexSubImage2D

You're right; it doesn't. Texture matrices transform texture coordinates only.

Really, can't you just pass the offset directly to the function? Or, if code cleanliness is not important, can't you store the offset in a global variable or something?

fiche
09-30-2010, 10:39 AM
A texel translation would have been the cleanest solution. Overall, I have several functions like this, and I would have preferred that the code calling the functions and the functions themselves did not have to account for the offset.