I recently started on an fps and have a camera from the apron camera tutorial 3. I got that working and I decided to add some terrain in. I decided to start with a single 1.0f wide strip of terrain and work up from that. I wrote a function for it and call it when drawing, and no terrain shows. Here's the code, at least, the function and the DrawglScene.
function:
void Drawterrainsquare()
{
for(float squares = -500; squares <= 500; squares+=1)
{
float ay = rand()%2;
float by = rand()%2;
float cy = rand()%2;
float dy = rand()%2;
glLoadIdentity();
glBegin(GL_QUADS);
glColor3f(0.1f,1.0f,0.2f);
glVertex3f(0.0f, ay, 10.0f);
glVertex3f(10.0f, by, 10.0f);
glVertex3f(10.0f, cy, 0.0f);
glVertex3f(0.0f, dy, 0.0f);
glEnd();
ay = by;
dy = cy;
by = rand()%2;
cy = rand()%2;
}
}
and the DrawglScene:
int DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(objCamera.mPos.x, objCamera.mPos.y, objCamera.mPos.z,
objCamera.mView.x, objCamera.mView.y, objCamera.mView.z,
objCamera.mUp.x, objCamera.mUp.y, objCamera.mUp.z);
Draw_Grid();
Drawterrainsquare();
glColor3f(1.0f,0.5f,0.0f);
glBegin(GL_QUADS);
glVertex3f(1.0f,1.0f,1.0f);
glVertex3f(-1.0f,1.0f,-1.0f);
glVertex3f(-1.0f,1.0f,1.0f);
glVertex3f(1.0f,1.0f,1.0f);
glEnd();
return TRUE;
}
[Edited by - brandonman on June 23, 2007 12:55:03 PM]