implementing vertex arrays...

Started by
1 comment, last by James Trotter 21 years, 1 month ago
I''m rendering a landscape, using a heightmap, and putting it into a display list. But now I want to use vertex arrays. I have made many attempts to implement it, but I haven''t managed yet! So, please, if anyone has some good piece of code that they have used, or still do use in some terrain rendering engine, could you just post some code that shows how you were doing it? I''m currently rendering with triangle strips, like this: glBegin(GL_TRIANGLE_STRIP); for (X = 0; X <= mapsize; X += trisize) { // Go through all of the rows of the height map if(switchsides) { // Check if we need to render the opposite way for this column // Render a column of the terrain, for this current X. // We start at mapsize and render down to 0. for (Y = mapsize; Y >= 0; Y -= trisize) { x = X; // Get the (X, Y, Z) value for the bottom left vertex FloatToInt(&y, parent->map[mapID]->Height(X, Y)); z = Y; Normal.x = parent->map[mapID]->normalMap[x][z][0]; Normal.y = parent->map[mapID]->normalMap[x][z][1]; Normal.z = parent->map[mapID]->normalMap[x][z][2]; color = parent->map[mapID]->LightMapData[x][z]; glNormal3f(Normal.x, Normal.y, Normal.z); glColor3f(color, color, color); SetTextureCoord((float)x, (float)z); // Set the current texture coordinate and render the vertex glVertex3i(x, y, z); x = X + trisize; // Get the (X, Y, Z) value for the bottom right vertex FloatToInt(&y, parent->map[mapID]->Height(X + trisize, Y)); z = Y; Normal.x = parent->map[mapID]->normalMap[x][z][0]; Normal.y = parent->map[mapID]->normalMap[x][z][1]; Normal.z = parent->map[mapID]->normalMap[x][z][2]; color = parent->map[mapID]->LightMapData[x][z]; glNormal3f(Normal.x, Normal.y, Normal.z); glColor3f(color, color, color); SetTextureCoord((float)x, (float)z); // Set the current texture coordinate and render the vertex glVertex3i(x, y, z); } } else { // Render a column of the terrain, for this current X. // We start at 0 and render down up to mapsize. for ( Y = 0; Y <= mapsize; Y += trisize) { x = X + trisize; // Get the (X, Y, Z) value for the bottom right vertex FloatToInt(&y, parent->map[mapID]->Height(X + trisize, Y)); z = Y; if (x > mapsize) { color = parent->map[mapID]->LightMapData[0][z]; Normal.x = parent->map[mapID]->normalMap[0][z][0]; Normal.y = parent->map[mapID]->normalMap[0][z][1]; Normal.z = parent->map[mapID]->normalMap[0][z][2]; } else { color = parent->map[mapID]->LightMapData[x][z]; Normal.x = parent->map[mapID]->normalMap[x][z][0]; Normal.y = parent->map[mapID]->normalMap[x][z][1]; Normal.z = parent->map[mapID]->normalMap[x][z][2]; } glNormal3f(Normal.x, Normal.y, Normal.z); glColor3f(color, color, color); SetTextureCoord((float)x, (float)z); // Set the current texture coordinate and render the vertex glVertex3i(x, y, z); x = X; // Get the (X, Y, Z) value for the bottom left vertex FloatToInt(&y, parent->map[mapID]->Height(X, Y)); z = Y; Normal.x = parent->map[mapID]->normalMap[x][z][0]; Normal.y = parent->map[mapID]->normalMap[x][z][1]; Normal.z = parent->map[mapID]->normalMap[x][z][2]; color = parent->map[mapID]->LightMapData[x][z]; glNormal3f(Normal.x, Normal.y, Normal.z); glColor3f(color, color, color); SetTextureCoord((float)x, (float)z); // Set the current texture coordinate and render the vertex glVertex3i(x, y, z); } } switchsides = !switchsides; // Switch the direction the column renders to allow the fluid tri strips } glEnd(); I greatly appreciate your help!
Advertisement
For some reason your name sounds familiar...

Join the World Wide Revolution:
quote:Original post by neurokaotix
For some reason your name sounds familiar...

Join the World Wide Revolution:


Maybe, from where do you think you''ve heard it? I can''t say yours does, anyway... Ehh... Thanks for the hasty reply, although it had little to do with the topic

This topic is closed to new replies.

Advertisement