Rotate a texture

Started by
5 comments, last by Krohm 17 years, 4 months ago
Hello, could anyone plz tell me how can I rotate a texture? I mean that I can rotate the texture once and then draw that rotated texture, so that I won't have to do the rotation each time I want to use that texture. Regards.
Advertisement
Quote:Original post by jeff_rowa
Hello,
could anyone plz tell me how can I rotate a texture? I mean that I can rotate the texture once and then draw that rotated texture, so that I won't have to do the rotation each time I want to use that texture.
Why do you need to rotate the texture?

Keep in mind that you have the OpenGL texture matrix available, which is a much more straightforward means of accomplishing texture transformations than manipulating the texture image manually.

Also, such manipulations aren't particularly trivial. If you rotate the texture image, what are the dimensions of the new, rotated image? What do you do with the 'extra' texels that are introduced around the edges?

In any case, I'm guessing that whatever problem you're trying to solve, there's a better solution than rotating the texture image itself.

Perhaps you could provide some more info about the context.
really inefficient: render rotated texture using rotated texcoords, readback and use as texture.

like suggested above: try to avoid such operations
hi guyz, tnx for the reply, well I capture current scene and use it as a texture, but the scene is mirrored so I want to mirror the current texture so I could get the correct image of the scene, so the only solution I can think of is to rotate it 180 degree, but as you said it should be a better way of doing it.
Well, you can flip it by switching to GL_TEXTURE matrix mode and scaling it or rotating.

You could also render a second pass with the scale negated, if your using it for a mirror or something, since it would be from another perspective anyway.


tnx smitty1276, I negated the value of s and it's mirrored :)
Quote:Original post by Eitsch
really inefficient: render rotated texture using rotated texcoords, readback and use as texture.

Really inefficient with regard to what? I guess you're speaking about texture resampling on CPU.
This doesn't seem to be a performance path either if the operation happens often (such as a special effect in a few games).

Previously "Krohm"

This topic is closed to new replies.

Advertisement