views:

759

answers:

1

I have a pic.bmp that I'm attempting to tile onto a 3 x 2 rectangular flat surface for a demo I'm making.

I'm attempting to keep the aspect ratio of the bmp in tact but I still want to tile it across that surface. Right now I have the surfaces vertices as (0,0,0), (3,0,0), (0,2,0) and (3,2,0).

How can I apply this bmp to the flat surface and tile it? What is the best way to do this in GLUT & OpenGL?

+3  A: 

See this NeHe lesson for a sample. To do tiling just write something like this:

glBegin(GL_QUADS);
     // your surface
     glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f,  0.0f,  0.0f); 
     glTexCoord2f(3.0f, 0.0f); glVertex3f( 3.0f,  0.0f,  0.0f); 
     glTexCoord2f(3.0f, 2.0f); glVertex3f( 3.0f,  2.0f,  0.0f); 
     glTexCoord2f(0.0f, 2.0f); glVertex3f( 0.0f,  2.0f,  0.0f); 
glEnd();

This will set texture coordinates to tile any texture 3x2 times on this surface.

dragonfly