PDA

View Full Version : wireframe?



BarrelRider
09-05-2001, 05:22 AM
Hi there,

I have just been told I should use a wireframe method to display my terrain instead of triangles. The file that I am reading data from has latitude, longitude and height values. Do you know how I could find out about a wireframe method of doing this? Thanks

Michael Steinberg
09-05-2001, 05:25 AM
Simply call
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

This will display the triangles as wireframe. However this is not the most efficient way, since you're drawing each edge twice. But it's the simplest.

BarrelRider
09-05-2001, 05:44 AM
Thanks for that, but I meant I should do it in a grid method with gridlines,but don't know how to do this,any suggestions or guidelines?,Sorry,I should have been more specific.Thanks

Michael Steinberg
09-05-2001, 06:01 AM
Well, I assume you have a grid of height-values. Then do this:




for( i=0; i<grid_height; i++ ) {
glBegin( GL_LINE_STRIP );

for( j=0; j<grid_width; j++ ) {
glVertex3f( x of grid[i][j], grid[i][j], z of grid[i][j] );
}
glEnd();
}

for( i=0; i<grid_width; i++ ) {
glBegin( GL_LINE_STRIP );

for( j=0; j<grid_height; j++ ) {
glVertex3f( x of grid[j][i], grid[j][i], z of grid[j][i] );
}
glEnd();
}


Shouldn'T do that the trick?