0% found this document useful (0 votes)
2K views

Visvesvaraya Technological University Belagavi: Computer Graphics Laboratory With Mini Project

This document provides information about a Computer Graphics Laboratory course at AJIET, including a list of 9 experiments to complete in Part A and topics for a mini project in Part B. The experiments cover topics like line drawing algorithms, geometric transformations, lighting and shading, and more. The course aims to teach students to construct 2D and 3D shapes using OpenGL, apply graphics algorithms, add lighting/shading, and develop a graphical model. Students will complete one experiment from Part A and one from Part B as part of their practical exam, and demonstrations and a viva voce will be included.

Uploaded by

Pushpakar L S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

Visvesvaraya Technological University Belagavi: Computer Graphics Laboratory With Mini Project

This document provides information about a Computer Graphics Laboratory course at AJIET, including a list of 9 experiments to complete in Part A and topics for a mini project in Part B. The experiments cover topics like line drawing algorithms, geometric transformations, lighting and shading, and more. The course aims to teach students to construct 2D and 3D shapes using OpenGL, apply graphics algorithms, add lighting/shading, and develop a graphical model. Students will complete one experiment from Part A and one from Part B as part of their practical exam, and demonstrations and a viva voce will be included.

Uploaded by

Pushpakar L S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

BELAGAVI

COMPUTER GRAPHICS LABORATORY WITH


MINI PROJECT
(Subject Code: 18CSL67)

STUDENT MANUAL
VI-SEMESTER

Dr Antony P J
Professor & Head
Department of Computer Science & Engineering

Mrs Saranya Babu


Assistant Professor
Department of Computer Science & Engineering

A J INSTITUTE OF ENGINEERING & TECHNOLOGY


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
(A unit of Laxmi Memorial Education Trust. (R))
NH - 66, KottaraChowki, Kodical Cross, Mangaluru- 575 006.
COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT


[As per Choice Based Credit System (CBCS) scheme]
(Effective from the academic year 2018 -2019)
SEMESTER – VI
Subject Code 18CSL67 IA Marks 40
Number of Lecture Hours/Week 0:2:2 Exam Marks 60
Total Number of Lecture Hours 36 Exam Hours 03
CREDITS – 02
Course objectives: This course will enable students to
 Demonstrate simple algorithms using OpenGL Graphics Primitives and attributes.
 Implementation of line drawing and clipping algorithms using OpenGL functions
 Design and implementation of algorithms Geometric transformations on both 2D and
3D objects.
Description (If any):

Lab Experiments:

PART A
Design, develop, and implement the following programs using OpenGL API

1. Implement Brenham’s line drawing algorithm for all types of slope.


Refer:Text-1: Chapter 3.5
Refer:Text-2: Chapter 8
2. Create and rotate a triangle about the origin and a fixed point.
Refer:Text-1: Chapter 5-4
3. Draw a colour cube and spin it using OpenGL transformation matrices.
Refer:Text-2: Modelling a Coloured Cube
4. Draw a color cube and allow the user to move the camera suitably to experiment
with perspective viewing.
Refer:Text-2: Topic: Positioning of Camera
5. Clip a lines using Cohen-Sutherland algorithm
Refer:Text-1: Chapter 6.7
Refer:Text-2: Chapter 8
6. 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
surfaces of the solid object used in the scene.
Refer:Text-2: Topic: Lighting and Shading
7. Design, develop and implement recursively subdivide a tetrahedron to form 3D
sierpinski gasket. The number of recursive steps is to be specified by the user.
Refer: Text-2: Topic: sierpinski gasket.
8. Develop a menu driven program to animate a flag using Bezier Curve algorithm
Refer: Text-1: Chapter 8-10
9. Develop a menu driven program to fill the polygon using scan line
algorithm

Dept. of CSE, AJIET, Mangaluru Page 1


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

Project:

PART B: MINI PROJECT

Student should develop mini project on the topics mentioned below or similar applications
using Open GL API. Consider all types of attributes like color, thickness, styles, font,
background, speed etc., while doing mini project.
(During the practical exam: the students should demonstrate and answer Viva-Voce)
Sample Topics:
 Simulation of concepts of OS, Data structures, algorithms etc.
Course outcomes: The students should be able to:
 Construct 2D and 3D shapes using basic graphic primitives and animating the same
using OpenGL
 Apply line drawing ,clipping and curve generating algorithms using OpenGL functions
 Create the objects by adding lighting and shading effects
 Develop objects that includes user interaction using input device functions (like
keyboard and mouse ) for transforming the object
 Develop a graphical model using the concepts learnt in theory and lab exercises.
Conduction of Practical Examination:
Experiment distribution
o For laboratories having only one part: Students are allowed to pick one experiment
from the lot with equal opportunity.
o For laboratories having PART A and PART B: Students are allowed to pick one
experiment from PART A and one experiment from PART B, with equal opportunity.
• Change of experiment is allowed only once and marks allotted for procedure to be
made zero of the changed part only.
• Marks Distribution (Courseed to change in accoradance with university regulations)
o) For laboratories having only one part – Procedure + Execution + Viva-Voce:
15+70+15 =100 Marks
p) For laboratories having PART A and PART B
i. Part A – Procedure + Execution + Viva = 6 + 28 + 6 = 40 Marks
ii. Part B – Procedure + Execution + Viva = 9 + 42 + 9 = 60 Marks
Reference books:
1. Donald Hearn & Pauline Baker: Computer Graphics-OpenGL Version,3rd Edition,
Pearson Education,2011
2. Edward Angel: Interactive computer graphics- A Top Down approach with OpenGL,
5th edition. Pearson Education, 2011
3. M MRaikar, Computer Graphics using OpenGL, Fillip Learning / Elsevier,
Bangalore / New Delhi (2013)

Dept. of CSE, AJIET, Mangaluru Page 2


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

Introduction to OpenGL

OpenGL is a low-level graphics library specification. It makes available to the programmer a small
set of geometric primitives - points, lines, polygons, images, and bitmaps. OpenGL provides a set of
commands that allow the specification of geometric objects in two or three dimensions, using the
provided primitives, together with commands that control how these objects are rendered (drawn).
Since OpenGL drawing commands are limited to those that generate simple geometric primitives
(points, lines, and polygons), the OpenGL Utility Toolkit (GLUT) has been created to aid in the
development of more complicated three-dimensional objects such as a sphere, a torus, and even a
teapot. GLUT may not be satisfactory for full-featured OpenGL applications, but it is a useful starting
point for learning OpenGL.
GLUT is designed to fill the need for a window system independent programming interface for
OpenGL programs. The interface is designed to be simple yet still meet the needs of useful OpenGL
programs. Removing window system operations from OpenGL is a sound decision because it allows
the OpenGL graphics system to be retargeted to various systems including powerful but expensive
graphics workstations as well as mass-production graphics systems like video games, set-top boxes
for interactive television, and PCs.
GLUT simplifies the implementation of programs using OpenGL rendering. The GLUT application
programming interface (API) requires very few routines to display a graphics scene rendered using
OpenGL. The GLUT routines also take relatively few parameters.

1.1 Rendering Pipeline


Most implementations of OpenGL have a similar order of operations, a series of processing stages
called the OpenGL rendering pipeline. Although this is not a strict rule of how OpenGL is
implemented, it provides a reliable guide for predicting what OpenGL will do. Geometric data
(vertices, line, and polygons) follow a path through the row of boxes that includes evaluators and per-
vertex operations, while pixel data (pixels, images and bitmaps) are treated differently for part of the
process. Both types of data undergo the same final step (rasterization) before the final pixel data is
written to the frame buffer.

Dept. of CSE, AJIET, Mangaluru Page 3


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

Display Lists: All data, whether it describes geometry or pixels, can be saved in a display list for
current or later use. (The alternative to retaining data in a display list is processing the data
immediately-known as immediate mode.) When a display list is executed, the retained data is sent
from the display list just as if it were sent by the application in immediate mode.
Evaluators: All geometric primitives are eventually described by vertices. Evaluators provide a
method for deriving the vertices used to represent the surface from the control points. The method is
a polynomial mapping, which can produce surface normal, colors, and spatial coordinate values from
the control points.

Per-Vertex and Primitive Assembly: For vertex data, the next step converts the vertices into
primitives. Some types of vertex data are transformed by 4x4 floating-point matrices. Spatial
coordinates are projected from a position in the 3D world to a position on your screen. In some cases,
this is followed by perspective division, which makes distant geometric objects appear smaller than
closer objects. Then view port and depth operations are applied. The results at this point are geometric
primitives, which are transformed with related color and depth values and guidelines for the
rasterization step.

Pixel Operations: While geometric data takes one path through the OpenGL rendering pipeline, pixel
data takes a different route. Pixels from an array in system memory are first unpacked form one of a
variety of formats into the proper number of components. Next the data is scaled, biased, processed
by a pixel map, and sent to the rasterization step.

Rasterization: Rasterization is the conversion of both geometric and pixel data into fragments. Each
fragment square corresponds to a pixel in the frame buffer. Line width, point size, shading model,
and coverage calculations to support antialiasing are taken it to consideration as vertices are
connected into lines or the interior pixels are calculated for a filled polygon. Color and depth values
are assigned for each fragment square. The processed fragment is then drawn into the appropriate
buffer, where it has finally advanced to be a pixel and achieved its final resting place.

1.2 Libraries
OpenGL provides a powerful but primitive set of rendering command, and all higher-level drawing
must be done in terms of these commands. There are several libraries that allow you to simplify your
programming tasks, including the following:
 OpenGL Utility Library (GLU) contains several routines that use lower-level OpenGL commands
to perform such tasks as setting up matrices for specific viewing orientations and projections and
rendering surfaces.
 OpenGL Utility Toolkit (GLUT) is a window-system-independent toolkit, written by Mark
Kilgard, to hide the complexities of differing window APIs.

1.3 Include Files


For all OpenGL applications, you want to include the gl.h header file in every file. Almost all OpenGL
applications use GLU, the aforementioned OpenGL Utility Library, which also requires inclusion of
the glu.h header file. So almost every OpenGL source file begins with:
#include<GL/gl.h> #include <GL/glu.h>

Dept. of CSE, AJIET, Mangaluru Page 4


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

If you are using the OpenGL Utility Toolkit (GLUT) for managing your window manager tasks, you
should include:
#include <GL/glut.h>
Note that glut.h guarantees that gl.h and glu.h are properly included for you so including these three
files is redundant. To make your GLUT programs portable, include glut.h and do not include gl.h or
glu.h explicitly.

1.4 Setting up Compilers


 Windows Using MS Visual C++
Installing GLUT
Most of the following files (ie. OpenGL and GLU) will already be present if you have installed
MS Visual C++ v5.0 or later. The following GLUT files will need to be copied into the
specified directories.
1. To install:
 right-click each link
 choose Save Link As...
 accept the default name (just click Save)
 libraries (place in the lib\ subdirectory of Visual C++)
 opengl32.lib
 glu32.lib
 glut32.lib
 include files (place in the include\GL\ subdirectory of Visual C++)
 gl.h
 glu.h
 glut.h

 dynamically-linked libraries (place in the \Windows\System subdirectory


 opengl32.dll
 glu32.dll
 glut32.dll

Compiling OpenGL/GLUT Programs

1. Create a new project: o choose File | New from the File Menu

o select the Projects tab


o choose Win32 Console Application
o fill in your Project name

2. Designate library files for the linker to use: o choose Project | Settings from the File Menu

o under Oject/library modules: enter "opengl32.lib glu32.lib glut32.lib"

Dept. of CSE, AJIET, Mangaluru Page 5


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

3. Add/Create files to the project: o choose Project | Add to Project | Files from the File
menu

o add the required program files

4. Build and Execute

1.5 Initialization
The first thing we need to do is call the glutInit() procedure. It should be called before any other
GLUT routine because it initializes the GLUT library. The parameters to glutInit() should be the same
as those to main(), specifically main(intargc, char** argv) and glutInit(&argc, argv), where argcp is
a pointer to the program's unmodified argc variable from main. Upon return, the value pointed to by
argcp will be updated, and argv is the program's unmodified argv variable from main. Like argcp, the
data for argv will be updated.
The next thing we need to do is call the glutInitDisplayMode() procedure to specify the display mode
for a window. You must first decide whether you want to use an RGBA (GLUT_RGBA) or color-
index (GLUT_INDEX) color model. The RGBA mode stores its color buffers as red, green, blue, and
alpha color components. The forth color component, alpha, corresponds to the notion of opacity. An
alpha value of 1.0 implies complete opacity, and an alpha value of 0.0 complete transparancy. Color-
index mode, in contrast, stores color buffers in indices. Your decision on color mode should be based
on hardware availability and what you application requires. More colors can usually be
simultaneously represented with RGBA mode than with color-index mode. And for special effects,
such as shading, lighting, and fog, RGBA mode provides more flexibility. In general, use RGBA
mode whenever possible. RGBA mode is the default.
Another decision you need to make when setting up the display mode is whether you want to use
single buffering (GLUT_SINGLE) or double buffering (GLUT_DOUBLE). Applications that use
both front and back color buffers are double-buffered. Smooth animation is accomplished by
rendering into only the back buffer (which isn't displayed), then causing the front and back buffers to
be swapped. If you aren't using animation, stick with single buffering, which is the default.
Finally, you must decide if you want to use a depth buffer (GLUT_DEPTH), a stencil buffer
(GLUT_STENCIL) and/or an accumulation buffer (GLUT_ACCUM). The depth buffer stores a
depth value for each pixel. By using a "depth test", the depth buffer can be used to display objects
with a smaller depth value in front of objects with a larger depth value. The second buffer, the stencil
buffer is used to restrict drawing to certain portions of the screen, just as a cardboard stencil can be
used with a can of spray paint to make a printed image. Finally, the accumulation buffer is used for
accumulating a series of images into a final composed image. None of these are default buffers.
We need to create the characteristics of our window. A call to glutInitWindowSize() will be used to
specify the size, in pixels, of your initial window. The arguments indicate the height and width (in
pixels) of the requested window. Similarly, glutInitWindowPosition() is used to specify the screen
location for the upper-left corner of your initial window. The arguments, x and y, indicate the location
of the window relative to the entire display.

1.6 Creating a Window


To actually create a window, the with the previously set characteristics (display mode, size, location,
etc), the programmer uses the glutCreateWindow() command. The command takes a string as a

Dept. of CSE, AJIET, Mangaluru Page 6


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

parameter which may appear in the title bar if the window system you are using supports it. The
window is not actually displayed until the glutMainLoop() is entered.

1.7 Display Function


The glutDisplayFunc() procedure is the first and most important event callback function you will see.
A callback function is one where a programmer-specified routine can be registered to be called in
response to a specific type of event. For example, the argument of glutDisplayFunc() is the function
that is called whenever GLUT determines that the contents ofthe window needs to be redisplayed.
Therefore, you should put all the routines that you need to draw a scene in this display callback
function.

1.8 Reshape Function


The glutReshapeFunc() is a callback function that specifies the function that is called whenever the
window is resized or moved. Typically, the function that is called when needed by the reshape
function displays the window to the new size and redefines the viewing characteristics as desired. If
glutReshapeFunc() is not called, a default reshape function is called which sets the view to minimize
distortion and sets the display to the new height and width.

1.9 Main Loop


The very last thing you must do is call glutMainLoop(). All windows that have been created can now
be shown, and rendering those windows is now effective. The program will now be able to handle
events as they occur (mouse clicks, window resizing, etc). In addition, the registered display callback
(from our glutDisplayFunc()) is triggered. Once this loop is entered, it is never exited!

Geometric Objects used in graphics

2.1 Point, Lines and Polygons


Each geometric object is described by a set of vertices and the type of primitive to be drawn. A vertex
is no more than a point defined in three dimensional space. Whether and how these vertices are
connected is determined by the primitive type. Every geometric object is ultimately described as an
ordered set of vertices. We use the glVertex*() command to specify a vertex. The '*' is used to indicate
that there are variations to the base command glVertex().
Some OpenGL command names have one, two, or three letters at the end to denote the number and
type of parameters to the command. The first character indicates the number of values of the indicated
type that must be presented to the command. The second character indicates the specific type of the
arguments. The final character, if present, is 'v', indicating that the command takes a pointer to an
array (a vector) of values rather than a series of individual agreements.
For example, in the command glVertex3fv(), '3' is used to indicate three arguments, 'f' is used to
indicate the arguments are floating point, and 'v' indicates that the arguments are in vector format.

Points: A point is represented by a single vertex. Vertices specified by the user as two-dimensional
(only x- and y-coordinates) are assigned a z-coordinate equal to zero. To control the size of a rendered
point, use glPointSize() and supply the desired size in pixels as the argument. The default is as 1 pixel
by 1 pixel point. If the width specified is 2.0, the point will be a square of 2 by 2 pixels. glVertex*()
is used to describe a point, but it is only effective between a glBegin() and a glEnd() pair. The

Dept. of CSE, AJIET, Mangaluru Page 7


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

argument passed to glBegin() determines what sort of geometric primitive is constructed from the
vertices.

Lines: In OpenGL, the term line refers to a line segment, not the mathematician's version that extends
to infinity in both directions. The easiest way to specify a line is in terms of the vertices at the
endpoints. As with the points above, the argument passed to glBegin() tells it what to do with the
vertices. The option for lines includes:
GL_LINES: Draws a series of unconnected line segments drawn between each set of vertices. An
extraneous vertex is ignored. GL_LINE_STRIP: Draws a line segment from the first vertex to the
last. Lines can intersect arbitrarily.
GL_LINE_LOOP: Same as GL_STRIP, except that a final line segment is drawn from the last vertex
back to the first.
With OpenGL, the description of the shape of an object being drawn is independent of the description
of its color. When a particular geometric object is drawn, it's drawn using the currently specified
coloring scheme. In general, an OpenGL programmer first sets the color, using glColor*() and then
draws the objects. Until the color is changed, all objects are drawn in that color or using that color
scheme.

Polygons: Polygons are the areas enclosed by single closed loops of line segments, where the line
segments are specified by the vertices at their endpoints. Polygons are typically drawn with the pixels
in the interior filled in, but you can also draw them as outlines or a set of points. In OpenGL, there
are a few restrictions on what constitutes a primitive polygon. For example, the edges of a polygon
cannot intersect and they must be convex (no indentations). There are special commands for a three-
sided (triangle) and four-sided (quadrilateral) polygons, glBegin(GL_TRIANGLES) and
glBegin(GL_QUADS), respectively. However, the general case of a polygon can be defined using
glBegin(GL_POLYGON).

2.2 Drawing 3-D Objects


GLUT has a series of drawing routines that are used to create three-dimensional models. This means
we don't have to reproduce the code necessary to draw these models in each program. These routines
render all their graphics in immediate mode. Each object comes in two flavors, wire or solid.
Available objects are:

2.3 Transformations
A modeling transformation is used to position and orient the model. For example, you can rotate,
translate, or scale the model - or some combination of these operations. To make an object appear
further away from the viewer, two options are available - the viewer can move closer to the object or
the object can be moved further away from the viewer. Moving the viewer will be discussed later
when we talk about viewing transformations. For right now, we will keep the default "camera"
location at the origin, pointing toward the negative z-axis, which goes into the screen perpendicular
to the viewing plane.

Dept. of CSE, AJIET, Mangaluru Page 8


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

When transformations are performed, a series of matrix multiplications are actually performed to
affect the position, orientation, and scaling of the model. You must, however, think of these matrix
multiplications occuring in the opposite order from how they appear in the code. The order of
transformations is critical. If you perform transformation A and then perform transformation B, you
almost always get something different than if you do them in the opposite order.

Scaling: The scaling command glScale() multiplies the current matrix by a matrix that stretches,
shrinks, or reflects an object along the axes. Each x-, y-, and z-coordinate of every point in the object
is multiplied by the corresponding argument x, y, or z. The glScale*() is the only one of the three
modeling transformations that changes the apparent size of an object: scaling with values greater than
1.0 stretches an object, and using values less than 1.0 shrinks it. Scaling with a -1.0 value reflects an
object across an axis.

Translation: The translation command glTranslate() multiplies the current matrix by a matrix that
moves (translates) an object by the given x-, y-, and z-values.

Rotation: The rotation command glRotate() multiplies the current matrix that rotates an object in a
counterclockwise direction about the ray from the origin through the point (x,y,z). The angle
parameter specifies the angle of rotation in degrees. An object that lies farther from the axis of rotation
is more dramatically rotated (has a larger orbit) than an object drawn near the axis.

Sample Programs

Sample Program: 01
/* A basic Open GL window*/

#include<GL/glut.h>
void display (void)
{
glClearColor (0.0,0.0,0.0,1.0);
glClear (GL_COLOR_BUFFER_BIT);
glLoadIdentity ();
gluLookAt (0.0,0.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0);
glFlush ();
}

Dept. of CSE, AJIET, Mangaluru Page 9


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

int main (intargc,char **argv)


{
glutInit (&argc,argv);
glutInitDisplayMode (GLUT_SINGLE);
glutInitWindowSize (500,500);
glutInitWindowPosition (100,100);
glutCreateWindow ("A basic open GL window");
glutDisplayFunc (display);
glutMainLoop ();
return 0;
}

Sample Program: 02
/*point.c
/* Program to draw/display points */

#include<GL/glut.h>
#include<stdlib.h>
voidmyInit(void)
{
glClearColor(2.0,2.0,2.0,4.0);
glColor3f(0.0f,0.0f,0.0f);
glPointSize(4.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,640.0,0.0,480.0);
}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
glVertex2i(100,200);
glVertex2i(400,200);
glVertex2i(200,100);
glVertex2i(200,400);
glEnd();
glFlush();
}

void main(intargc, char** argv)


{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(100,150);
glutCreateWindow("My First Attempt");
glutDisplayFunc(display);
myInit();
glutMainLoop();
}

Sample Program: 03
/*program to implement horizontal and vertical lines*/

#include<GL/glut.h>
#include<stdlib.h>
voidmyInit(void)

Dept. of CSE, AJIET, Mangaluru Page 10


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

{
glClearColor(2.0,2.0,2.0,4.0);
glColor3f(0.0f,0.0f,0.0f);
glLineWidth(4.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,640.0,0.0,480.0);
}

voiddrawLineInt(GLint x1,GLint y1,GLint x2,GLint y2)


{
glBegin(GL_LINES);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glEnd();
}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glVertex2i(100,200);
glVertex2i(400,200);
glVertex2i(200,100);
glVertex2i(200,400);
glEnd();
glFlush();
}

void main(intargc, char** argv)


{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(100,150);
glutCreateWindow("My First Attempt");
glutDisplayFunc(display);
myInit();
drawLineInt(100,200,40,60);
glutMainLoop(); }

Dept. of CSE, AJIET, Mangaluru Page 11


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

Laboratory Programs

1. Implement Brenham’s line drawing algorithm for all types of slope.

OUTPUT:

Viva questions:

1. What is Bresenham's line drawing algorithm?

2. What is DDA algorithm for line drawing?

3. What is the difference between DDA and Bresenham line drawing algorithm?

4. What are basic requirements of line drawing algorithm?

Dept. of CSE, AJIET, Mangaluru Page 12


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

2. Create and rotate a triangle about the origin and a fixed point.

OUTPUT:

Viva Questions:

1. What is transformation?

2. Explain the OpenGL functions used for translation, rotation and scaling?

3. What is the order of transformation?

4. State the difference between modelview and projection?

5. What is Homogeneous-coordinate representation?

Dept. of CSE, AJIET, Mangaluru Page 13


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

3. Draw a colour cube and spin it using OpenGL transformation matrices.

OUTPUT:

Viva Questions:
1. What are vertex arrays?

2. How are the faces of the color cube modeled?

3. How do you consider the inward and outward pointing of the faces?

4. Define Computer Graphics.

5. What Is Frame Buffer?

Dept. of CSE, AJIET, Mangaluru Page 14


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

4. Draw a color cube and allow the user to move the camera suitably to experiment with
perspective viewing.

OUTPUT:

Viva Questions:
1. Explain the keyboard and mouse events used in this program?

2. What is Hidden surface Removal? How do you achieve this in OpenGL?

3. What are the functions for creating Menus in OpenGL?

4. Explain about fonts in GLUT?

5. Explain about glutPostRedisplay()?

Dept. of CSE, AJIET, Mangaluru Page 15


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

5. Clip a lines using Cohen-Sutherland algorithm

OUTPUT:

Viva Questions:

1. What do you mean by clipping?

2. What is the principle of Cohen-Sutherland Algorithm?

3. State the advantages and disadvantages of Cohen-Sutherland Algorithm?

4. What is an outcode?

5. What is Synthetic Camera Model?

6. What Is Frame Buffer?

Dept. of CSE, AJIET, Mangaluru Page 16


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

6. 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 surfaces of the
solid object used in the scene.

OUTPUT:

Viva Questions:

1. Explain Specular, Diffuse and Translucent surfaces.

2. What is ambient light?

3. What is umbra, penumbra?

4. Explain Phong lighting model.

5. What Is Transformation?

Dept. of CSE, AJIET, Mangaluru Page 17


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

7. Design, develop and implement recursively subdivide a tetrahedron to form 3D sierpinski


gasket. The number of recursive steps is to be specified by the user.

OUTPUT:

Viva Questions:

1. What is the principle of Sierpinski gasket?

2. Difference between additive and subtractive color?

3. What is the Graphics Architecture used in OpenGL?

4. What is Rasterisation?

Dept. of CSE, AJIET, Mangaluru Page 18


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

8. Develop a menu driven program to animate a flag using Bezier Curve

OUTPUT:

Viva Questions:

1. What is scan conversion?

2. Write the properties of video display devices?

3. Define clipping?

4. What is the need of homogeneous coordinates?

Dept. of CSE, AJIET, Mangaluru Page 19


COMPUTER GRAPHICS LABORATORY WITH MINI PROJECT (18CSL67)

9. Develop a menu driven program to fill the polygon using scan line algorithm

OUTPUT:

Viva Questions:
1. Explain scanline filling algorithm?

2. What is AspectRatio, Viewport?

3. How do you use timer?

4. What are the different frames in OpenGL?

5. What is fragment processing?

*****
Dept. of CSE, AJIET, Mangaluru Page 20

You might also like