I figured out how to make those edges visible. It’s all about lighting. But still, i cant figure how to set the light fixed. I made a simple object (a box) and even when i push matrix, the light still rotates/translates with the object. here is the code
void GLScene::paintGL()
{
glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef( 0.0, 0.0, -10.0 );
glScalef( scale, scale, scale );
glRotatef( xRot, 1.0, 0.0, 0.0 );
glRotatef( yRot, 0.0, 1.0, 0.0 );
glRotatef( zRot, 0.0, 0.0, 1.0 );
glCallList(object);
glPopMatrix();
glFlush();
}
paintGL - executed everytime I change an angle
next: initialization (lights and stuff)
void GLScene::initializeGL()
{
GLfloat whiteDir[4] = {1.0, 0.0, 0.0, 1.0};
GLfloat whiteAmb[4] = {1.0, 0.0, 0.0, 1.0};
GLfloat lightPos[4] = {2.0, 2.0, 2.0, 0.0};
glEnable(GL_NORMALIZE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
// glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, whiteAmb);
glMaterialfv(GL_FRONT, GL_DIFFUSE, whiteDir);
glMaterialfv(GL_FRONT, GL_SPECULAR, whiteDir);
glMaterialf(GL_FRONT, GL_SHININESS, 100.0);
glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteDir);
glLightfv(GL_LIGHT0, GL_SPECULAR, whiteDir);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
glShadeModel( GL_SMOOTH );
glEnable(GL_DEPTH_TEST);
glClearColor( 0.0, 0.0, 0.0, 0.0 );
object = glGenLists( 1 );
glNewList( object, GL_COMPILE );
drawbox(1.0,1.0,1.0);
glEndList();
}
drawbox function, draws a cube 1x1x1.
What i need is to have the light fixed (like in real world, when illuminating an object that rotates around its own axis, with a fixed light source.)
Anyone has any idea of how can i do this?
Thanks in advance.