Sign in to follow this  
umas

Texture Positioning

Recommended Posts

umas    100
Hey guys,

I want to position a texture. The problem is, that I don't know how to move it diagonal.
First, I tried to translate the texture to the origin, rotate it and translate it back...didn't work.
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
glTranslatef(0.5,0,0.5);
glRotatef(angle,0,1,0);
glTranslatef(-0.5,0,-0.5);

It goes a little bit in the wrong direction (more to the x-axis).
Then I tried just to translate...
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
glTranslatef(tex_x,0,tex_z);

didn't work...I don't know why, but the tex_z variable didn't have any effect - and only the x-translation is not enough.
does anybody have an idea? perhaps, I just did'nt understand the principle of these translations :(

thanks a lot for your help :)

Share this post


Link to post
Share on other sites
the_visualist    188
If you want to move it to the right, use glTranslatef with x, 0, 0.
If you want to move it up, use glTranslatef with 0, y, 0.
If you want to do both (which means diagonal), use glTranslatef with x, y, 0.
Do this without any glRotate calls.

If you still want to rotate it for some reason, then you can easily use glRotatef after it was translated.

Share this post


Link to post
Share on other sites

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