CG Lab P6
CG Lab P6
CG Lab P6
6. Program to draw a simple shaded scene consisting of a tea pot on a table. Define suitably
the position and properties of the light source along with the properties of the properties of
the surfaces of the solid object used in the scene.
#include<GL/glut.h>
void teapot(GLfloat x, GLfloat y, GLfloat z)
{
glPushMatrix (); //save the current state
glTranslatef (x, y, z); //move your item appropriately
glutSolidTeapot (0.1); //render your teapot
glPopMatrix (); //get back your state with the recent changes that you have done
}
BMSIT & M, Bengaluru -560064 | Author: Mr. Shankar R, Asst. Prof, CSE 6
15CSL68 – Computer Graphics Lab Manual
wall (0, 0, wallP); //Create 2nd wall pname specifies one of ten light
glRotatef (90, 0, 1, 0); source parameters, again by
symbolic name.
wall (0, 0, wallP); //Create 3rd wall params is either a single value or
a pointer to an array that
glFlush (); // show the output to the user contains the new values.
}
void init()
{
glClearColor (0, 0, 0, 1); // black colour background
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (-1, 1, -1, 1, -1, 10);
glMatrixMode (GL_MODELVIEW);
}
BMSIT & M, Bengaluru -560064 | Author: Mr. Shankar R, Asst. Prof, CSE 7
15CSL68 – Computer Graphics Lab Manual
init();
glutDisplayFunc(display);
glutMainLoop();
}
***********************************************************************************
OUTPUT
BMSIT & M, Bengaluru -560064 | Author: Mr. Shankar R, Asst. Prof, CSE 8