Wireframe

I’m just trying out simple things in opengl to get started.

For example wireframe(GL_LINES) 3d objects, though it looks a bit messy. How would i go about to make wireframes that have a different color when the wire is viewed from the backside.

Do i have to calculate the rotation and projection myself with pseudo faces and determine which color to use(front face or back face) or could opengl help with that on lines?

how about using lights? you can use 2 different colors (or any other materials) for the front and back faces with their respective normals. See if that helps

yes u can supply different materials for front + back, use glPolyMode( GL_LINE );

I had success with using lights, having different colors to ambient and diffuse.

No luck with materials though, i set up as described below before sending normal and vertex information. if i change the ambient light color the results are that backfaced lines will change color, but not if it’s pure white and i set up materials.

glDisable(GL_CULL_FACE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat light_ambient[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat light_position[] = { 0.0, 0.0, -100.0, 0.0 };

glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
GLfloat frontcol[] = { 1,1,1,1 };
GLfloat backcol[] = { 1,0,0,1 };

glMaterialfv(GL_FRONT,GL_DIFFUSE,frontcol);
glMaterialfv(GL_BACK,GL_AMBIENT,backcol);
glMaterialfv(GL_BACK,GL_DIFFUSE,backcol);