Jump to content
  • Advertisement
Sign in to follow this  
umas

Texture Positioning

This topic is 2441 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

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!