60 likes | 287 Views
Introduction to Computer Graphics (CMPS 160-Lab, Fall -2007) http://www.soe.ucsc.edu/classes/cmps160/Fall07/. Professor: James Davis Email: davis@cs.ucsc.edu TA : Indrani Chakravarty Email: ichakrav@ucsc.edu Lab Tutors: Bryan Harris and Chirag Dave
E N D
Introduction to Computer Graphics (CMPS 160-Lab, Fall -2007)http://www.soe.ucsc.edu/classes/cmps160/Fall07/ Professor: James Davis Email: davis@cs.ucsc.edu TA : Indrani Chakravarty Email: ichakrav@ucsc.edu Lab Tutors: Bryan Harris and Chirag Dave Email: bryan.harris@gmail.com, chirage@gmail.com Required Lab: M 10-12 or T 11-1 Optional Lab: W 10-12, Th 11-1
Objective: To learn how to build an example program using open Graphics Library(openGL), and to compile and run it. Example of output from gltest.c Lab 0
OpenGL and GLUT • OpenGL provides commands for • specifying geometric objects in 2 or 3 dimensions, e.g. points, lines, polygons, images etc, and • for controlling how these objects are drawn on the display (e.g. color). • OpenGL does not provide commands for performing windowing tasks or for obtaining user input. GLUT (the OpenGL Utility Toolkit) does. • The starter code gltest.c is a decent template for making any basic OpenGL program -- • it has callbacks to support mouse, keyboard (currently empty function bodies) and • it demonstrates some animations and transformations.
Tasks (1) Compiling and Running the code • Download prog0.tgz from http://www.soe.ucsc.edu/classes/cmps160/Fall07/labs/lab0.html • Untar and unzip the file onto the local directory using • tar -xzvf prog0.tgz • Change the directory to prog0 • cd prog0 • Run the following and see the output • make • ./gltest • If you get an error while compiling • Open Makefile using any editor • Comment the following line and go back to Step 4 • CFLAGS += -O3 -ffast-math -mtune=G5 -mcpu=G5
Tasks (2) Playing around with the code • See the effect of the following changes to the code, and try understanding what’s happening -- • Change the arguments of the Translation function and Rotation function • Change the • color of the teapot • color of the animations around the teapot • size of the teapot and the size of the animating cubes around the teapot • Find out what the following functions from the code do, and see their effect on the GUI -- • cb_reshape • cb_keyboard • Understand the code gltest.c
For Online help • To know more about the openGL and GLUT functions used in this code, • Do a “man”. For example • $ man glRotatef • See the online copy of the RedBook on openGL at • http://www.opengl.org/documentation/red_book/