View the Most Wanted LQ Wiki articles.
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org OpenGL texture matrix rotation
 User Name Remember Me? 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

 09-03-2004, 11:16 AM #1 The_Nerd Member   Registered: Aug 2002 Distribution: Debian Posts: 540 Rep: 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?
 09-03-2004, 11:53 AM #2 The_Nerd Member   Registered: Aug 2002 Distribution: Debian Posts: 540 Original Poster Rep: 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.
 09-03-2004, 12:07 PM #3 kev82 Senior Member   Registered: Apr 2003 Location: Lancaster, England Distribution: Debian Etch, OS X 10.4 Posts: 1,263 Rep: 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 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 12:08 PM.
 09-03-2004, 03:11 PM #4 The_Nerd Member   Registered: Aug 2002 Distribution: Debian Posts: 540 Original Poster Rep: 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 Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post svu Linux - Games 4 10-27-2005 01:34 PM tariqzi Linux - Hardware 0 10-24-2005 04:28 AM SilverEagle Programming 1 03-20-2005 11:03 AM BenRichards Programming 0 11-04-2004 03:37 PM The_Nerd Programming 2 08-31-2004 11:36 PM

All times are GMT -5. The time now is 12:52 AM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -
 Advertisement
 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.
 Syndicate Latest Threads   LQ News Twitter: @linuxquestions identi.ca: @linuxquestions Facebook: linuxquestions Google+: linuxquestions