After enabling lighting in OpenGL, color in lines and polygons are no longer rendering. (Created color from glColor3f() )
This is code:
glLightModelf(GL_LIGHT_MODEL_AMBIENT, GL_TRUE);
GLfloat light1_position[] = { 5000, 2000, 1000,1 };
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, light1_position);
GLfloat light_ambient[] = { 1,1,1,1 };
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glEnable(GL_LIGHTING);
What am I doing wrong?
You must enable these things before using them :
glEnable ( GL_LIGHTING);
glEnable( GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glShadeModel( GL_SMOOTH);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With