First off, how I plan on creating my terrain is by reading in the data from the image file into a two dimensional array, and then using that data in some nested loops. Here is the code I am envisioning:
// Imagine these variables as having been initialized...
int MAP_WIDTH;
int MAP_HEIGHT;
unsigned char HEIGHT_DATA[MAP_WIDTH + 1][MAP_HEIGHT + 1];
// create the quads that make up the terrain
for (int i = 0; i < MAP_WIDTH; i++)
{
glBegin(GL_QUAD_STRIP);
glVertex3f(i, HEIGHT_DATA[i][0], 0);
glVertex3f(i + 1, HEIGHT_DATA[i + 1][0], 0);
for (int j = 1; j < MAP_HEIGHT; j++)
{
glVertex3f(i, HEIGHT_DATA[i][j], j);
glVertex3f(i + 1, HEIGHT_DATA[i + 1][j], j);
}
glEnd();
}
Now, what I see as being an issue is that I know when you define a GL_QUAD the order of the points matters. You want the points to be going in a counterclockwise order, but there is no way to do that when defining a strip. Are all of the normals going to be messed up and will my ground be looking all funny? If so, how do I fix this? If not, why is that?
EDIT: Noticed I forgot my glEnd() call!
This post has been edited by ghillieLEAD: 26 February 2011 - 08:49 PM

New Topic/Question
Reply




MultiQuote






|