Advertisement

lesson35 + texture=how?

Started by November 24, 2001 09:18 AM
6 comments, last by Prod 23 years, 3 months ago
ive been using nehe''s lesson 35 for my landscape generation, but i cant seem to get it to run with textures, ive loaded a bmp, and put in the glTexCoord''s but i still just have an empty landscape! any advice? where exactly should i put the glTexCoord''s?
anyone?
Advertisement
Are you entering the proper glTexCoord2f() for every vertex?
i do believe so, here is the code:

for ( X = 0; X < MAP_SIZE; X += STEP_SIZE )
for ( Y = 0; Y < MAP_SIZE; Y += STEP_SIZE )
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[0]);
// Get The (X, Y, Z) Value For The Bottom Left Vertex
x = X;
y = Height(pHeightMap, X, Y );
z = Y;


glTexCoord2f(0, 0);
glVertex3i(x, y, z);// Send This Vertex To OpenGL To Be Rendered (Integer Points Are Faster)



// Get The (X, Y, Z) Value For The Top Left Vertex
x = X;
y = Height(pHeightMap, X, Y + STEP_SIZE );
z = Y + STEP_SIZE ;


glTexCoord2f(1, 0);
glVertex3i(x, y, z);// Send This Vertex To OpenGL To Be Rendered

// Get The (X, Y, Z) Value For The Top Right Vertex
x = X + STEP_SIZE;
y = Height(pHeightMap, X + STEP_SIZE, Y + STEP_SIZE );
z = Y + STEP_SIZE ;


glTexCoord2f(1, 1);
glVertex3i(x, y, z); // Send This Vertex To OpenGL To Be Rendered


// Get The (X, Y, Z) Value For The Bottom Right Vertex
x = X + STEP_SIZE;
y = Height(pHeightMap, X + STEP_SIZE, Y );
z = Y;


glTexCoord2f(0, 1);
glVertex3i(x, y, z); // Send This Vertex To OpenGL To Be Rendered

glDisable(GL_TEXTURE_2D);
}


Edited by - prod on November 24, 2001 10:48:50 PM
To use texturing, the glEnable(GL_TEXTURE_2D) and glBindTexture(GL_TEXTURE_2D, texture[0]) functions must be called before glBegin is called or else they will not take affect. A texture can only be changed before the drawing of polygons is done.
oh hahaha, dumb mistake on my half!

thanks!
Advertisement
i have a feeling its my video card now. All i get is white terrain even though i switched everything. I remember a friend of mine having the same problem with my machine on his program, the land did not texture on the 3dfx Voodoo cards. I will ask him now
Try making the texture 128x128. 3dfx cards don''t like bigger textures( >= 256x256 ).

Zack

A moment enjoyed is not wasted.
-Gamers.com
A moment enjoyed is not wasted. -Gamers.com

This topic is closed to new replies.

Advertisement