You Like My Tutorials? Click The Banner To Keep 'Em Coming!

glGameDeveloper(): The Game Developer's Source for OpenGL Coding
Main Menu
Latest News
Archived News
Tutorials
Links
E-Mail Me

Other
Message Board
My Guestbook

Tutorials -- Texture Mapping
 


Texture Mapping Polygons Page 4 of 5
< Previous Jump to Page: 1 | 2 | 3 | 4 | 5 Next >

A Texturing Secret

Here'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.

Texture Mapping Polygons Page 4 of 5
< Previous Jump to Page: 1 | 2 | 3 | 4 | 5 Next >

This site best viewed with MS Internet Explorer 5.0 at 16-bit color and at least 800x600.

All Contents of this site are Copyright 1999, 2000 Joe Zimmerman. No part of this site (code, HTML, etc.) may be reproduced without my permission.

Click Here!