Computer Graphics - CS602 Spring 2007 Assignment 01

Embed Size (px)

Citation preview

  • 8/12/2019 Computer Graphics - CS602 Spring 2007 Assignment 01

    1/10

    Assignment No.1 (Computer Graphics Lab)

    Deadline:

    Your assignment must be uploaded/submitted before or on Saturday the31stof 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 algorithmsdiscussed 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 thene( pro!ect options, select glut )*t (ill appear only (hen you ha"e glutpac+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.. o( compile the pro!ect you (ill be as+ed to sa"e the file main.cpp,sa"e it in the same directory.

    4. *f the pro!ect is compiled and e5ecuted correctly it (ill sho( somegraphic shapes in the display (indo(, it means e"erything is (or+ingfine.

    &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 meansthat the code of #pen $% (ritten using $lut is portable acrossmany platforms using different operating systems.

    oding using $lut is easy as compared to other 89*:s.

  • 8/12/2019 Computer Graphics - CS602 Spring 2007 Assignment 01

    2/10

    Now we can write our code.

    !tep ': &riting code

    Now delete all the code of main.cppfile except the first line it is:

    With this line we have included all the necessary files for using OpenGL and glutfunctions.

    ;rite main function

    Write main function as we write in a c++ program as follows:

    Initialie Glut and set the initial window sie

  • 8/12/2019 Computer Graphics - CS602 Spring 2007 Assignment 01

    3/10

    Initialie Glut in main and set the initial window sie as follows:

    !reate display window as follows and pass your id separated "y you yourname as the window title#

    $egister %isplay &unction

    'elling Glut to use this function to draw graphics in display window (We will writethis function later on in this La")

  • 8/12/2019 Computer Graphics - CS602 Spring 2007 Assignment 01

    4/10

    $egister $eshape &unction

    'elling Glut to use this function when we reshape our display window (We willwrite this function later on in this La")

  • 8/12/2019 Computer Graphics - CS602 Spring 2007 Assignment 01

    5/10

    !tep: &riting implementations o *unctions

    Now we can write the code to draw graphics for this we will use the displayfunction we register in main as our display function.

    Writing code in our registered display functionWe write as code given in our display function the description of each function isgiven with it in the form of comments study the comments also.

  • 8/12/2019 Computer Graphics - CS602 Spring 2007 Assignment 01

    6/10

    (!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 fore5ample (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"edra(n number of pi5els according to the id.

    0 4 0 2 0 0 2 5 0

  • 8/12/2019 Computer Graphics - CS602 Spring 2007 Assignment 01

    7/10

  • 8/12/2019 Computer Graphics - CS602 Spring 2007 Assignment 01

    8/10

  • 8/12/2019 Computer Graphics - CS602 Spring 2007 Assignment 01

    9/10

    Writing implementation of our registered $eshape function

    Writing the prototypes of our implemented functions in the start of theprogram to avoid any compiler error in case we have used them "eforegiving their implementation.(for example if we have written our mainfunction a"ove other functions.)

  • 8/12/2019 Computer Graphics - CS602 Spring 2007 Assignment 01

    10/10

    ompile 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 pixeldrawing functions as mentioned in the La" so that it displays the pixelsaccording to your ,- id.'hen clean your proect "y going to /xecute0 !lean option in %ev c++ and ipthe completefolder containing your proect file and cpp files and upload it.

    End of Lab