Computer Graphics Labbook Tybcs
Computer Graphics Labbook Tybcs
In this assignment we will use basic OpenGL functions to draw some basic graphical figures.
Example:
Consider following program to draw a point on screen.
Functions used:
1. glClearColor(1.0,1.0,1.0,0.0);
set the background color to bright white, 0.0 indicates no transparency
6. glBegin and glEnd are used to delimit the vertices of a primitive operation. single
argument to glBegin specifies the mode in which the vertices are to be interpreted.
a. GL_POINTS treats each vertex as a single point
b.GL_LINES treats each pair of vertices as an independent line segment
c.GL_LINE_STRIP draws a connected group of line segments
d.GL_LINE_LOOP draws a connected group from first to last
e.The other possibilities are - GL_TRIANGLES, GL_TRIANGLE_SRIP,
GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, GL_POLYGON
7. glVertex2i(40,40); // plot the point with two integer arguments
8. glEnd() has no arguments.
9. glFlush(); //the entire data is to be processed and sent for display.
Set A
3. Display random 50 points (4x4 pixel size) with random colours (use rand() function.
Set B
c) Display a grid along with axis that divides the entire area into 50 by 50 size
boxes. The grid should be in light green colour.
d) Display a picture containing a two storied house
e) Display sine/cosine function
Assignment 2
Using graphics primitives to display graphics
Set A
Set B
Write a program to draw a scene. Program should use graphics primitives to draw
objects. Program should have routines to create complex objects using graphics
primitives. These routines should be invoked to create the final scene.
Assignment 3
Window to viewport transformations and other transformations
Set A
Implement basic transformations as functions and apply these transformations on
basic objects (triangle, square) and display the transformed objects
a) Translation
b) Rotation about the origin/pivot point
c) Scaling about the origin/ fixed point
d) Reflection about x-axis/ y-axis/ line y=x
e) Sheer along x-axis/y-axis
Set B
Implement following clipping algorithms as functions and apply these functions on
some polygons,
a) Sutherland Hodgman algorithm
b) Weiler-Atherton Algorithm
Assignment 4
Using simple Keyboard and Mouse interaction
Set A
1. Write OpenGL program to draw points at positions clicked by mouse.
2. Accept names of ten different colours from user and draw star shapes with those
colours using OpenGL.
Set B
1. Create dancing human figure using OpenGL.
Graphics mini-Project Guidelines
The project is to be carried out with a team size of Two or Three. The graphics mini project
should solve a small problem completely or a larger problem partially. There should be use
of display graphics using Open GL primitives.
1. Write a program to read data from a file and displays the picture. Generate few such
interesting files. You can design your own file format. For example if your picture
contains only polylines then the only entry on first line of the file will specify number
of polylines. This will be followed by line entries for each polyline. The first line
entry will indicate number of points in the polyline followed by coordinates of each
point on the polyline in successive line entries. You can generalize the file format to
include the other primitive types, colour values etc.
2. Write a program that generates a Maze of R rows and C columns and find and
display the path from start to end .
3. Write a program that creates tiles that is a square window with some interesting
geometrical pattern /motif onto it. Produce tiling of the display screen by placing
tiles all over the screen .
4. Write functions to draw scatter plot, bar chart, line chart and pie chart for a given
set of data points as input or in a file. Write a program that can demonstrate
these functions.
5. Write functions to draw some basic objects. Write scaling transformations so that
picture can be enlarged to large size or compressed to smaller size. Accept an
integer argument, the object type, the size(low, medium, large) and colour codes
(RGB) as input and display n objects of the given size and colour in a line.