#include <GL/glut.h>

static int spin = 0;
float dr=1.0;
float dg=0.0;
float db=0.0;
float ar=0.0;
float ag=0.0;
float ab=0.0;
static float s1=20;
void init1(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
}

void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glShadeModel (GL_SMOOTH);
}
void display(void)
{
	
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glPushMatrix();
glLoadIdentity();
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_DIFF[] = { dr, dg, db };
GLfloat mat_AMB[] = { ar, ag, ab };
GLfloat mat_shininess[] = {s1};
GLfloat light_position[] = { 1.0, 0.0, 0.0, 0.0 };


glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_DIFF);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_AMB);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glTranslatef (0.0, 0.0, -5.0);
//gluLookAt(0,0,5,0,0,0,0,1,0);

glutSolidSphere (1.0, 20, 16);

//glPopMatrix();
glFlush ();
}
void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 100.0);
//glFrustum(-5.0,5.0,-5.0,5.0,1.0,100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void key1(unsigned char key,int x,int y){
	
	if(key=='s')
	 s1+=5.0;
	 else  	if(key=='d')
	 s1-=5.0;
if(key=='b') {
dr=0.0;
dg=0.0;
db=1.0;

}
if(key=='g') {
dr=0.0;
dg=1.0;
db=0.0;

}
if(key=='a') {
dr=0.0;
dg=0.0;
db=0.0;

}
	glutPostRedisplay();
	
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(key1);
glutMainLoop();
return 0;
}
