I have loaded your code into visual studio and given it a few tweeks. It works fine. You have not filled in the blanks though… Here is an example of how to get your code working.
#include <GL/glut.h>
GLfloat mat_specular[] = {1.0, 1.0,1.0,1.0};
GLfloat mat_shininess[] = {50.0};
GLfloat light_position[] = {1.0,1.0,1.0,0.0};
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glLoadIdentity();
gluLookAt(0.0,1.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0);
glShadeModel(GL_SMOOTH);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
glLightfv(GL_LIGHT0,GL_POSITION,light_position); // This has to be light not material
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glTranslatef(0.5,0,0);
glutSolidSphere(0.5,100,100);
glTranslatef(-1.0,0,0);
glutSolidSphere(0.5,100,100);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void resize(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho(-2.0,2.0,-2.0*h/w,2.0*h/w,-10.0,10.0);
else
glOrtho(-2.0*w/h,2.0*w/h,-2.0,2.0,-10.0,10.0);
glMatrixMode(GL_MODELVIEW);
}
void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(500, 500);
glutCreateWindow("Spheres");
glutReshapeFunc(resize);
glutDisplayFunc(display);
glEnable(GL_DEPTH_TEST);
glutMainLoop();
}
This uses the glut library, but it is possible to do all of this with the standard gl library, you just need to look up some tutorials