I can’t seem to get specular lighting to turn on in my little OGL program. Well, to me it looks off. Take a look here:
http://users.bestweb.net/~jandl/snapshot1.png
Note (in the above pic):
red == (+) x-axis
green == (+) y-axis
blue == (+) z-axis
The axes are about 10 units long.
Also, the direction of the lighting (as seen in the pic) seems a bit different than what I’ve specified in the code – not sure if this is related. Here’s the relevant code:
glClearColor( 0.0 , 0.0 , 0.0 , 0.0 );
glShadeModel( GL_SMOOTH ); // Yes, this is redundant.
glDepthFunc( GL_LESS ); // Yes, this is redundant.
glPolygonMode( GL_FRONT , GL_FILL ); // Yes, this is redundant.
glPolygonMode( GL_BACK , GL_LINE );
// The material:
float mat_specular[] = { 1.0 , 1.0 , 1.0 , 1.0 }; // Bright specular reflections.
int mat_shininess[] = { 100 } ; // Very shiny.
// Material is mostly green, that is to say, the ambient and diffuse light
// reflected off of the material is mostly green.
float mat_amb_and_diffuse[] = { 0.0 , 0.8 , 0.2 , 1.0 };
glMaterialfv( GL_FRONT_AND_BACK , GL_SPECULAR , mat_specular );
glMaterialiv( GL_FRONT_AND_BACK , GL_SHININESS , mat_shininess );
glMaterialfv( GL_FRONT_AND_BACK , GL_AMBIENT_AND_DIFFUSE , mat_amb_and_diffuse );
// The light:
float light_ambient[] = { 0.2 , 0.2 , 0.2 , 1.0 };
float white_light[] = { 1.0 , 1.0 , 1.0 , 1.0 };
glLightfv( GL_LIGHT0 , GL_AMBIENT , light_ambient ); // redundant
glLightfv( GL_LIGHT0 , GL_DIFFUSE , white_light ); // redundant
glLightfv( GL_LIGHT0 , GL_SPECULAR , white_light ); // redundant
// This one's funny... The light doesn't seem to be shining in the
// -1,-1,-1 direction but rather the -1,-1,0 dir... ******
float light_dir[] = { -1.0 , -1.0 , -1.0 , 0.0 }; // Directional.
glLightfv( GL_LIGHT0 , GL_POSITION , light_dir );
glLightModeli( GL_LIGHT_MODEL_LOCAL_VIEWER , GL_TRUE );
glLightModeli( GL_LIGHT_MODEL_TWO_SIDE , GL_TRUE );
// And finally, enable everything.
glEnable( GL_LIGHTING );
glEnable( GL_LIGHT0 );
glEnable( GL_DEPTH_TEST );
I’m on slackware 8, using software rendering with the following libraries:
john@puffin:~/dev/rawView$ ldd rawView
libglut.so.3 => /usr/local/lib/libglut.so.3 (0x40021000)
libGLU.so.1 => /usr/local/lib/libGLU.so.1 (0x40054000)
libGL.so.1 => /usr/lib/libGL.so.1 (0x40106000)
libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x402ed000)
libXmu.so.6 => /usr/X11R6/lib/libXmu.so.6 (0x402f5000)
libstdc+±libc6.2-2.so.3 => /usr/lib/libstdc+±libc6.2-2.so.3 (0x4030a000)
libm.so.6 => /lib/libm.so.6 (0x40351000)
libc.so.6 => /lib/libc.so.6 (0x40373000)
libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x40484000)
libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x4048d000)
libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x404a3000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x404ed000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x404fb000)
libvga.so.1 => /usr/lib/libvga.so.1 (0x405d4000)
libpthread.so.0 => /lib/libpthread.so.0 (0x4062b000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
—j
[This message has been edited by jmg (edited 04-24-2002).]