tags:

views:

23

answers:

1

Hey all,

I'm having an awful time trying to get these triangle strips to show up.

Where am I going wrong?

InitGL:

InitGL()
{

glEnable(GL_DEPTH_TEST);    // Enables Depth Testing
glDepthFunc(GL_LEQUAL);

glMatrixMode(GL_PROJECTION);    
glLoadIdentity();//
gluPerspective(45, //view angle
    WINDOW_WIDTH/WINDOW_HEIGHT, //aspect ratio
    1.0, //near clip
    2000.0);//far clip

glMatrixMode(GL_MODELVIEW);
glClearColor(0, 0, 0, 0);

}

and Display:

void display ( void )   // Create The Display Function
{
int height = sourceImage->nx;
int width = sourceImage->ny;

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLoadIdentity();
glScalef(.005, .004, .005); //all vertices are in the range x[0,200], y[0,255], z[0,200]
glTranslatef(0, 0, -2); //so scale to put all vertices in the range [0,1] and move the z coord from [0,1] to the -z axis [-1,-2]
glColor3f(0, 0, 0);

glPushMatrix(); //save this view

float cell_height = 0;
for(float z = 0; z < width; z++)
{
    glBegin(GL_TRIANGLE_STRIP);
    for(float x = 0; x < height; x++)
    {
        cell_height = cellHeight(x, z);
        glVertex3f(x, cell_height, z);

        cell_height = cellHeight(x, z+1);
        glVertex3f(x, cell_height,(z+1));

        cell_height = cellHeight(x+1, z);
        glVertex3f(x+1, cell_height, z);

        cell_height = cellHeight(x+1, z+1);
        glVertex3f(x+1, cell_height, (z+1));
    }
    glEnd();
}
glPopMatrix(); //restore view
+2  A: 

Set your color to something other than pure black:

glColor3f(1.0f, 1.0f, 1.0f);
genpfault