Sie sind auf Seite 1von 10

Assignment No.

1 (Computer Graphics Lab)


Deadline:
Your assignment must be uploaded/submitted before or on Saturday the
31
st
of March, 2007.
Objectie:
he ob!ecti"e of this assignment is to enable the students to use #pen$%
using &e" c'' so that they can implement computer graphics algorithms
discussed later in this course using #pen $%.
Computer Graphics Lab
!tep 1: "a#ing Glut $roject in De c%%
1. Select ne( pro!ect from &e" c'' menu bar, select multimedia tab in the
ne( pro!ect options, select glut )*t (ill appear only (hen you ha"e glut
pac+age installed you can get it from ,-%MS announcement.
2. *n pro!ect options gi"e your id as the name to the pro!ect and select #/.
3. &e" c'' (ill as+ the location (here you (ant to sa"e your pro!ect, ma+e
ne( folder (ith name of your id and select it &e" c'' (ill ma+e the
pro!ect (ith a main.cpp file (ith some code there.
0. 1o( compile the pro!ect you (ill be as+ed to sa"e the file 2main.cpp3,
sa"e it in the same directory.
4. *f the pro!ect is compiled and e5ecuted correctly it (ill sho( some
graphic shapes in the display (indo(, it means e"erything is (or+ing
fine.
&hat is Glut:
$lut stands for #pen $% -tility ool +it.
*t is used due to the follo(ing reasons6
*t is freely distributable (ithout licensing fees.
*t pro"ides platform independent interface for #pen $% it means
that the code of #pen $% (ritten using $lut is portable across
many platforms using different operating systems.
7oding using $lut is easy as compared to other 89*:s.
Now we can write our code.
!tep ': &riting code
Now delete all the code of main.cpp file except the first line it is:
With this line we have included all the necessary files for using OpenGL and glut
functions.
;rite main function
Write main function as we write in a c++ program as follows:
Initialie Glut and set the initial window sie
Initialie Glut in main and set the initial window sie as follows:
!reate display window as follows and pass your id separated "y you your
name as the window title#
$egister %isplay &unction
'elling Glut to use this function to draw graphics in display window (We will write
this function later on in this La")
$egister $eshape &unction
'elling Glut to use this function when we reshape our display window (We will
write this function later on in this La")
<andle control of the &isplay (indo( to $lut using the function

Now we have completed our main function the main function will loo* li*e#
!tep(: &riting implementations o) *unctions
Now we can write the code to draw graphics for this we will use the display
function we register in main as our display function.
Writing code in our registered display function
We write as code given in our display function the description of each function is
given with it in the form of comments study the comments also.

(!ontinued+ on next page)
Now writing the implementation of our pixel drawing function
*n this function (e are dra(ing the pi5els according to the id:s of ,- students for
e5ample (e ha"e (ritten the code for the ,- id bc+,+'++'-+ as gi"en belo(
you (ill ha"e to change this code according the your o(n id,
;e ha"e used blue color for =ero and green color for other digits and ha"e
dra(n number of pi5els according to the id.
0 4 0 2 0 0 2 5 0
Writing implementation of our registered $eshape function
Writing the prototypes of our implemented functions in the start of the
program to avoid any compiler error in case we have used them "efore
giving their implementation.(for example if we have written our main
function a"ove other functions.)
7ompile and >un this pro!ect it should display (indo( li+e gi"e belo(,
Assignment !ubmission .nstructions:
Now you have to first perform this La" and then change the code in pixel
drawing functions as mentioned in the La" so that it displays the pixels
according to your ,- id.
'hen clean your pro.ect "y going to /xecute0 !lean option in %ev c++ and ip
the complete folder containing your pro.ect file and cpp files and upload it.
End of Lab

Das könnte Ihnen auch gefallen