#### Archived

This topic is now archived and is closed to further replies.

# rotating texture maps?

This topic is 5778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi all! Could you help a newbee (me) rotate texture maps please? I''ve searched the net up and down and found some, but none of it seems to work for me (doing it wrong probably)... Even messed with trigonometry but it seems I must have slept during my once long-ago math classes I''ve managed to load up the uv coordinates from the ASE format like this (simplified and snipped down a single point in a triangle): glTexCoord2d( uvmap[0].u , uvmap[0].v ); glVertex3f ( ver[0].x , ver[0].y , ver[0].z ); what I want is to rotate the UVmap, lets just say 45 degrees... I need to use glMatrixMode(GL_TEXTURE); is that right ? but how? something like this:?? glMatrixMode(GL_TEXTURE); glRotatef( 45, 0 , 0 , 1 ) glTexCoord2d( uvmap[0].u , uvmap[0].v ); glMatrixMode(GL_MODELVIEW); glVertex3f ( ver[0].x , ver[0].y , ver[0].z ); of course this isn''t it or I wouldn''t be asking... please assist

##### Share on other sites
That should work.

// setup model transform
glMatrixMode(GL_MODELVIEW);

// setup texture transform
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity(); // might not need this if your sure it is already identity
glRotatef(45.0,0,0,1); // rotate around z axis (ie x(u),y(v) are affected)

glBegin(GL_WHATEVER);
glTexCoord2f(u1,v1);
glVertex3f(x,y,z);

...

glEnd();

glPopMatrix(); // restore texture matrix

##### Share on other sites
doh... I''m gonna go bang my head on something hard now...
it works great.
Thank you very much!

##### Share on other sites
just know that using a texture matrix can more than half your fillrate and/or vertex throughput (depending on the video card). So don''t use it just because you can.

| - Project-X - my mega project.. big things comming soon - | - adDeath - an ad blocker I made - | - email me - |

##### Share on other sites
Not sure about the performance hit, but the flexibility is incredibly increased by the texture matrix.

##### Share on other sites
I''ve seen graphs showing vertex througput on quadros before, the hit was around 50% when using texture matrices. but of course quadros arn''t exactly cutting edge. And if your not transform limited anyway, well, it don''t matter too much now does ett?

| - Project-X - my mega project.. big things comming soon - | - adDeath - an ad blocker I made - | - email me - |

##### Share on other sites
I''ve seen that graph too, and it''s not representative of the total time, just of the GPU part. I''ve seen the same graph (for GeForce) where the CPU part was taken in account, and texgen was faster because with texgen the CPU has nothing to do.

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 14
• 14
• ### Forum Statistics

• Total Topics
633388
• Total Posts
3011620
• ### Who's Online (See full list)

There are no registered users currently online

×