LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

Rep: Reputation: 32
OpenGL texture matrix rotation


Ok, I have the code:

Code:
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glRotate(X, 1,0,0);
glRotate(Y, 0,1,0); 
glMatrixMode(GL_MODELVIEW);
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
The_Nerd
Member
 
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
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
<edit>
I REALLY need to start refreshing before i post
</edit>

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

glPushAttrib(GL_TRANSFORM_BIT);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(0.5, 0.5, 0);
glRotatef(angle, 0, 0, 1);
glTranslatef(-0.5, -0.5, 0);
glPopAttrib();

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
The_Nerd
Member
 
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.
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 05:24 AM.

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