Sunteți pe pagina 1din 6

COMSATS Institute of Information Technology Sahiwal

Department of Computer Science

Program Name: BS(CS) B13 Course Title: Computer Graphics


Assignment #: 2 Assignment out: 03-04-2017
Topic: Open GL Commands Last date of submission: 10-04-2017

Roll #: SP15-BCS-B13-023 Name: Sumyia Yaseen


Evaluation: Direct Credit: 15 points
Instructions:
1. Submit your assignment to CR in hard form during the 1 st five minutes in class as per format
given in MS Word. It must include
a. Start page(s): print of this sheet
b. Code (if applicable)
c. Results (Input & output if applicable)
2. Late submission policy: deduction @ of 10% of total marks per day.
Problem Statement: Understand the following commands of the OPEN GL and write difference
between commands working.
1)glutWireCube
2)glLoadIdentity
3)glutSolidSphere
4)gluLookAt
5)glutWireSphere
6)glutWireTeapot
1. Glut Wire Cube:
glutWireCube render a wireframe cube respectively. The cube is centered at the
modeling coordinates origin with sides of length size.
void glutWireCube (GLdouble size);

Code:

Output:
2. GlLoadIdentity:
glLoadIdentity replaces the current matrix with the identity matrix. It is semantically
equivalent to calling glLoadMatrix with the identity matrix

but in some cases it is more efficient.

void glLoadIdentity( void);


The identity matrix, in terms of the projection and modelview matrices, essentially resets
the matrix back to its default state. glTranslate and glRotate are always relative to the
matrix's current state. So for instance, if you call glTranslate, you are translating from the
matrix's current 'position', not from the origin. But if you want to start over at the origin,
that's when you call glLoadIdentity(), and then you can glTranslate from the matrix
which is now located at the origin, or glRotate from the matrix which is now oriented in
the default direction.

3. Glut Solid Sphere:


Renders a sphere centered at the modeling coordinates origin of the specified
radius. The sphere is subdivided around the Z axis into slices and along the Z axis
into stacks.
void glutSolidSphere ( GLdouble radius , GLint slices , GLint stacks );
4. Glu Look At:
gluLookAt creates a viewing matrix derived from an eye point, a reference point
indicating the center of the scene, and an UP vector.
The matrix maps the reference point to the negative z axis and the eye point to the
origin. When a typical projection matrix is used, the center of the scene therefore
maps to the center of the viewport. Similarly, the direction described by the UP vector
projected onto the viewing plane is mapped to the positive y axis so that it points
upward in the viewport. The UP vector must not be parallel to the line of sight from
the eye point to the reference point.

void gluLookAt( GLdouble eyeX,


GLdouble eyeY,
GLdouble eyeZ,
GLdouble centerX,
GLdouble centerY,
GLdouble centerZ,
GLdouble upX,
GLdouble upY,
GLdouble upZ);
5. Glut Wire Sphere:
Renders a sphere centered at the modeling coordinates origin of the
specified radius. The sphere is subdivided around the Z axis into slices and along
the Z axis into stacks.
void glutWireSphere(GLdouble radius,
GLint slices, GLint stacks);
radius
The radius of the sphere.
slices
The number of subdivisions around the Z axis (similar to lines of longitude).
stacks
The number of subdivisions along the Z axis (similar to lines of latitude).

6. Glut Wire Teapot:


Render wireframe teapot. Both surface normals and texture coordinates for the
teapot are generated.
void glutWireSphere(GLdouble radius,
GLint slices, GLint stacks);
radius
The radius of the sphere.
slices
The number of subdivisions around the Z axis (similar to lines of longitude).
stacks
The number of subdivisions along the Z axis (similar to lines of latitude).

Code: