Sign in to follow this  

Rotate a texture

This topic is 4016 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.


Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

This topic is 4016 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this