I am using z-buffer to render my 3D triangular mesh. However, when I rendered the model as a wireframe mesh, I also saw the triangle faces which should have been hidden by the front face. So, I used the back face culling as follows:
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
drawWireFrame();
glDisable(GL_CULL_FACE);
The drawWireFrame function is as follows:
void drawWireFrame()
{
int i, j;
glColor3d(1., 0., 0.);
HE_edge *curr;
for (int i = 0; i < he_f_count; i++)
{
glBegin(GL_LINE_LOOP);
curr = m_HE_face[i].edge;
glNormal3f(curr->prev->vert->vnx, curr->prev->vert->vny, curr->prev->vert->vnz);
glVertex3f(curr->prev->vert->x, curr->prev->vert->y, curr->prev->vert->z);
glNormal3f(curr->vert->vnx, curr->vert->vny, curr->vert->vnz);
glVertex3f(curr->vert->x, curr->vert->y, curr->vert->z);
glNormal3f(curr->next->vert->vnx, curr->next->vert->vny, curr->next->vert->vnz);
glVertex3f(curr->next->vert->x, curr->next->vert->y, curr->next->vert->z);
glEnd();
}
}
However, I am still getting the same result I got before adding back face culling. Could you please help me identify what am I missing here.
Thank you.