Lab#1:  A Simple Static Scene Viewed from a Static Camera with Orthographic Projection

 

Step 1: Study the display function in simple.cpp and the earth function in earch.cpp to see how they draw geometric objects. Read "OpenGL Geometric Drawing Primitives" in  chapter 2 of the red book for OpenGL 1.1. You may also find it helpful to play with shapes.exe in Nate Robin’s tutorials, and check the online reference manual about these functions.

 

Step 2: Modify the display function in simple.cpp such that you can (approximately) display a circle centered at the origin (0,0,0) and with the radius 0.5 on the plane z=0 by drawing line segments to connect a large number (say 360 or more ) of adjacent vertices on the circle.  (You may consider using the GL_LINE_LOOP geometric primitive for connecting the vertices described in chapter 2.) You need to have #include <cmath> in the beginning the code in order to call the trigonometric functions cos and sin in <cmath> for the computation of the cosine value and the sine value given an angle.

 

Step 3: Add similar code to (approximately) draw circles centered at the origin (0,0,0) and with radiuses  0.75, 1, 2, and 5 on the plane z=0. Are they all visible? If not, examine and modify the parameter values used when calling the glOrtho function within the init function to make them all visible.

 

Step 4:  Implement a function

void myCircle(float x, float y, float z , float r, int numPoints)

such that it will draw line segments to connect numPoints points on the circle to approximate a circle centered at the (x,y,z) and with the radius r on the plane z = z. Then modify the display function to generate the circles in step 3 by calling this function, replacing the previous code from Step 2 and Step 3. 

 

Step 5:  Implement a function

void myFancyCircle(float x, float y, float  z, float r, int numPoints)

such that it can draw line segments to connect numPoints of points to approximate a circle centered at the (x,y,z) with the radius r on the plane z = z, and in addition, it use various colors for the vertices when drawing the circle.  (Optionally you may also try to use stipple patterns and different line width in the function.). Add code into the display function to demonstrate some fancy circles.

 

Step 6: Submit your work:

Submit all your source code files (.cpp and .h files) together with the self-evaluation report as a single zip file under Canvas.

 

 

 

 

 

/******************************************************************/

gl functions for geometric primitives: first exposure to the basics

 

/******************************************************************/

 

gl functions for handling the (color) buffer: first exposure to the basics

 

gl functions for handling the color settings: first exposure to the basics

 

Some additional gl functions to fine tune the attributes of geometric primitives

 

 

 

/******************************************************************/

gl functions for the setting of image projection: first exposure to the basics

 

 

/******************************************************************/

glut functions: first exposure to the basics in glut

 

Some additional glut functions to fine tune the parameters of the graphics window

 

/******************************************************************/