rotating texture maps?

Started by
5 comments, last by wamingo 21 years, 2 months ago
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
Advertisement
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
doh... I''m gonna go bang my head on something hard now...
it works great.
Thank you very much!
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 - |
Not sure about the performance hit, but the flexibility is incredibly increased by the texture matrix.
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 - |
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.

This topic is closed to new replies.

Advertisement