Vous êtes sur la page 1sur 6

Department of Computer Science & Engineering

M S Ramaiah Institute of Technology, Bangalore -54


List of Lab exercises for CSL712 Computer Graphics & Visualization lab
Term: Aug-Dec 2014

Lab 1:
1)
2)
3)
4)
5)
6)

Create a simple house with windows and door open. Write the reshape function so that the house
is not distorted when the display window is resized.
Create a chessboard.
Create a gingerbread man using iterated function system. Use the equations q.x = M(1 + 2L) p.y + |p.x LM| and q.y = p.x.
Create a scene of fish swimming.
Create a scene of flying kite.
Create a scene of rotating wheel.

Lab 2:
7)
8)
9)
10)

Create 2D Sierpinski gasket by plotting points (IFS)


Create 2D Sierpinski gasket by recursive subdivision of triangle.
Create 3D Sierpinski gasket by plotting points.
Create 3D Sierpinski gasket by recursive subdivision of tetrahedron.

Lab 3:
11)

12)

13)

Write a program to handle mouse events. Plot points in random colors by pressing the mouse left
button. The display window must be cleared when you press the mouse right button. Also write
the reshape callback function which changes the clipping rectangle when window is resized.
Write a program to handle mouse events. Draw rectangles using 2 points, at top left and bottom
right on mouse left-button clicks. On right click, clear window. Use reshape callback to avoid
distortion on window resize.
Write a program to handle mouse events Create a polyline using mouse left-button clicks. The
polyline must be redisplayed on window resize.

Lab 4:
14)
15)
16)
17)
18)

Write a program to simulate free hand drawing using a fat brush. The brush size must be
randomly variable in the range 3-10. The drawing should be multicolored.
Write a program to create a font for the letter C of user input thickness.
Write a program to create a font for the letter D of user input thickness
Write a program to create a font for the letter O of user input thickness
Write a program to create a font for the letter S of user input thickness

Lab 5:
19)

Write a program to display a hierarchical menu as below using popup menu. When an option is
selected, display the option on output window.
View _______ normal
| _print

20)

|_web
Edit_________cut
|_ copy
|_paste
Write a program to draw a square. Use popup menu with options to quit or resize the square. The
resize option has submenu with increase size and decrease size as options. The increase size must
double the size of the square and the decrease size option must reduce the size by 2. (half size) .
Min size is 1.

Lab 6:
21)
22)
23)
24)

Write a program to rotate a square using both single and double buffering.
Write a program to demonstrate picking using selection mode.
Write a program to perform rotation of a cube using color interpolation.
Write a program to perform rotation of a cube using vertex arrays.

Lab 7:
25)
26)
27)
28)

Write a program that generates approximations to a sphere by recursive subdivision generation.


Write a program to draw a line using Bresenhams algorithm.
Write a program to demonstrate the usage of display lists. The list should define either various
geometric objects like square, rectangle, circle, etc. or some alphabetic characters
Write a program to demo the usage of viewports. The program should define a viewport in the
left half of the display window and the original triangle is displayed in blue color. Define another
viewport for the right half of the window. The color of the triangle is changed to red and the
triangle is rotated about its centroid and displayed in the second viewport.

Lab 8:
29)

30)
31)

Write a program to implement the Cohen Sutherland line clipping algorithm in 2D. Make
provision to specify the input line, window for clipping and view port for displaying the clipped
image.
Program to draw a color cube and allow the user to move the camera suitably to experiment with
perspective viewing. Use OpenGL functions.
Program to fill any given polygon using scan-line area filling algorithm. (Use appropriate data
structures.)

Installing OpenGL on Windows

Windows versions:
7 Enterprise
Vista x64 Enterprise Edition SP2 (Build 6002)
Vista Enterprise Edition SP2 (Build 6002)
XP Professional Edition SP3 5.1 (Build 2600)
Visual Studio
2010 version 10.0.420219.1 SP1Rel
.NET Framework version 4.0.30319 SP1 Rel
2008 version 9.0.21022.8.RTM
.NET Framework version 3.5 SP1

Installation/verification:
OpenGL comes with the OS and Visual Studio 2010/2008 installations, to verify:
o runtime libraries:
C:\Windows\System32\{opengl,glu}32.dll

on 64-bit Windows:
C:\Windows\SysWOW64\{opengl,glu}32.dll
o

header files:
C:\Program Files\Microsoft
SDKs\Windows\v7.0A\Include\GL\{GL,GLU}.h
["Program Files (x86)" for 64-bit Windows; VS2008:
v6.0A]

linker library:
C:\Program Files\Microsoft
SDKs\Windows\v7.0A\Lib\OpenGL32.Lib
["Program Files (x86)" for 64-bit Windows; VS2008:
v6.0A]

Windows does not include GLUT standard. Thus, getting your OpenGL programs to compile
and run if it is not already installed is slightly more difficult. However by following the
following steps, you should be able to figure out how to make it work:
1. Download GLUT from http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip
2. Unzip the file.
3. Put the file "glut32.dll" into the system path.
o This can be in the same directory as your executable file.
o On Windows XP or earlier, this can be in "C:\WINDOWS\system32"
o Or you can create a directory like "C:\DLLs", put the file in this directory and
change your system path to include this new directory.
Do this by opening Control Panel -> System, clicking on "Advanced
System Settings", followed by "Environment Variables", and editing the
"Path" variable.
4. Put the file "glut.h" into the standard Visual C++ include directoy
o (For Visual Studio 2010, this should be:
"C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\gl")
o (For Visual Studio 2008, this should be:

o
o

"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl")


(For Visual Studio 2005, this should be:
"C:\Program Files\Microsoft Visual Studio.NET\Vc7\PlatformSDK\Include\gl")
You've got the right directory if you see a copy of "gl.h"

5. Put the file "glut32.lib" into the standard Visual C++ library directory
o (For Visual Studio 2010, this should be:
"C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib")
o (For Visual Studio 2008, this should be:
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib")
o (For Visual Studio 2005, this should be:
"C:\Program Files\Microsoft Visual Studio.NET\Vc7\PlatformSDK\lib")
o There should be lots of .lib files here, including "opengl32.lib" and "glu32.lib".
6. Make sure your Visual C++ project links in the GLUT/gl/glu libraries (see also this
page). This is located in:
o Menu: "Project -> (your-project-name) Properties"
o Tab: "Configuration Properties -> Linker -> Input"
o Under "Additional Dependancies", add "glut32.lib glu32.lib opengl32.lib"
7. #include < GL/glut.h > in your program.
o Note: This needs to come after you #include < stdio.h > and < stdlib.h >.
o Note: This needs to come before you #include < GL/gl.h >.
o Also note that glut.h includes gl.h for you (so you need not explicitly #include <
GL/gl.h >).
8. You should not include windows.h or any other Windows-specific header files.
9. If you get compilation errors because of multiple conflicting definitions of "exit()", then
"stdio.h" and "glut.h" have been #include'd in the wrong order. You may fix this by:
o Reordering your #include files (see step #7). This is the "right" way.
o Add "#define GLUT_DISABLE_ATEXIT_HACK" to glut.h on the line
immediately after the first "#if defined(_WIN32)".
10. If you happen to have a 64-bit version of Windows and Visual Studio, make sure you
compile a 32-bit executable.

Compiling OpenGL Programs Using Visual Studio

The key things you need to do are:

Tell Visual Studio where your code resides (or will reside).
Tell Visual Studio which code files to compile.
Tell Visual Studio what libraries you need.
Tell Visual Studio where to find those libraries.

These instructions work for Visual Studio 2008, though they are mostly similar for other versions:

1. Open Visual Studio 2008.


o If this is your first time, select "Visual C++" as the default configuration.
2. Once it has completely opened, select from the menu "File" followed by "New" followed
by "Project".
3. In the New Project dialog box:
o Type a name for your project and a location where you want your project
directory.
o For the project type, select "Visual C++" then "Win32" then "Win32 Console
Application"
o Click "Ok"
4. In the Win32 Application Wizard dialog box:
o Click "Application Settings"
o De-select "precompiled header" (unless you know what they are)
o Select "empty project"
o Keep the application type as "Console application"
o Click "Finish"
5. You will now return to the main Visual Studio window, where a subwindow entitled
"Solution Explorer" will appear. This contains information about "Solution <
myTestProject >" (where < myTestProject > is whatever you named your project). Visual
Studio should also have created a project directory where it will store the files. Open up
the directory "< myTestProject >" and its subdirectory (also called "< myTestProject
>"). There you should see a file called < myTestProject >.vcproj (or labeled "VC++
Project"). Copy any code you would like to use into this subdirectory.
6. Back in the Visual Studio subwindow (the "Solution Explorer"), you should see folders
labeled "Header Files" and "Source Files."
o Right click on "Source Files," select "Add," select "Existing File" and then select
the C/C++ file you wish to use (e.g., my "glut_template.c" file). Alternately,
create a new file and start typing in code from scratch.
o Right click on "Header Files," select "Add," select "Existing File" and then select
the header file you wish to use (e.g., my "glut_template.h" file).
o If you find it easier, you can drag and drop files directly onto the solution
explorer.
7. Right click on the BOLD name of your project in the "Solution Explorer."
o Select "Properties" (all the way at the bottom of the pop-up menu)
o Click the plus (+) next to "Linker" to see more linker options
Click on "Input" and add an entry to "Additional Dependencies." This
entry should be "opengl32.lib glu32.lib glut32.lib" (without the quotes).
o Click "OK" to confirm your changes and close the properties dialog.
8. Double click on any of the listed code files to open them and begin editing.
9. Once you have finished coding, press "F7" to compile (or build) your project.
10. Your executable will be in the "Debug" subdirectory of the project's directory. If your
executable requires no command-line parameters, you can run it directly from inside
Visual Studio by pressing "F5."
References :

[1] http://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/#win
[2] http://homepage.cs.uiowa.edu/~cwyman/classes/common/howto/winGLUT.html
[3] http://homepage.cs.uiowa.edu/~cwyman/classes/common/howto/compileVS.html

Vous aimerez peut-être aussi