| |||||||||||
|
Main Menu Other |
Tutorials -- Texture Mapping | ||||||||||
|
A Texturing SecretHere's a cool trick. Set all the texcoords like this and watch how the texture animates across the polygon. int r = rotate; glBegin(GL_POLYGON); glTexCoord3f( r/100, r/100, 0); glVertex3f(-5, 5, 0); glTexCoord3f( r/100+1, r/100, 0); glVertex3f( 5, 5, 0); glTexCoord3f( r/100+1, r/100+1, 0); glVertex3f( 5, -5, 0); glTexCoord3f( r/100, r/100+1, 0); glVertex3f(-5, -5, 0); glEnd(); This of course only works if you have a "rotate" variable, like we declared in the Drawing Triangles tutorial. Note how the coords are set up similarly to the previous code. All the coords are the same, except we added r/100 to each coordinate. The ones that were 0 are r/100, and the ones that were 1 are r/100+1. That way it still maps the coords to the right corners.
|
|||||||||||