Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-03-2004, 10:16 AM   #1
Registered: Aug 2002
Distribution: Debian
Posts: 540

Rep: Reputation: 32
OpenGL texture matrix rotation

Ok, I have the code:

glRotate(X, 1,0,0);
glRotate(Y, 0,1,0); 
My problem is that my texture doesn't rotate the way I want it too. This is because texture coords are in the range (0-1), and since glRotatef rotates around 0, then I get my texture rotated off one corner of my polygon. How do I fix this?
Old 09-03-2004, 10:53 AM   #2
Registered: Aug 2002
Distribution: Debian
Posts: 540

Original Poster
Rep: Reputation: 32
Thumbs up

Never mind. I figured it out.

Just have to do a glTranslatef(0.5, 0.5, 0.5); before and a glTranslatef(-0.5, -0.5, -0.5); after.
Old 09-03-2004, 11:07 AM   #3
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
I REALLY need to start refreshing before i post

hopefully we're talking about 2d textures cos i dont know anything 3d textures. so we have our texture coordinates (a, b, c, d) i assume that your not trying freaky perspectuve effects so d=1 and c is irrelevant.

i am quite confused as to what effect your trying to achieve by rotating about the x and y axes, surely if you want to spin the texture you want to rotate it about the Z axis??

anyway, if you want to spin the texture about its center then first we have to move to the the center of the texture, then rotate, then move back, just like we would normally

glTranslatef(0.5, 0.5, 0);
glRotatef(angle, 0, 0, 1);
glTranslatef(-0.5, -0.5, 0);

make sure all required coordinates lie in the texture or you might include garbage data

Last edited by kev82; 09-03-2004 at 11:08 AM.
Old 09-03-2004, 02:11 PM   #4
Registered: Aug 2002
Distribution: Debian
Posts: 540

Original Poster
Rep: Reputation: 32
Thanks. Sorry I made you reply when I didn't need you too.

Appreciate it though.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Counter-strike source : Texture problems svu Linux - Games 4 10-27-2005 12:34 PM
Flickering Texture tariqzi Linux - Hardware 0 10-24-2005 03:28 AM
How to render a window to a GL texture SilverEagle Programming 1 03-20-2005 10:03 AM
DDS texture Loading BenRichards Programming 0 11-04-2004 02:37 PM
Texture matrix transforms on on multi texture? The_Nerd Programming 2 08-31-2004 10:36 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration