Professional Documents
Culture Documents
OPENGL Introduction: Question 3: Drawing in 3D
OPENGL Introduction: Question 3: Drawing in 3D
OPENGL Introduction: Question 3: Drawing in 3D
OPENGL introduction
This is a hands-on session of OpenGL. Using the template project called graphicsTest,
you will progressively build your own OpenGL application.
Why is the graphics window blue ? How do you quit the program ?
Question 3: Drawing in 3D
The skeleton program contains everything to draw a cube but you need to change and edit a
few things!
Identify the routine that draws a cube and insert a call at the right location
The coordinates of the cube vertices need to be initialized !
1
Jean-Marc Vzien
International Masters in biometrics
3D modeling and Augmented Reality
Notice the lighting instructions and camera positioning. Try to comment out the calls to
glTranslatef() and glRotatef() and look at the result.
A horizontal motion with left button pressed rotates the object around vertical axis
A vertical motion with left button pressed rotates object around horizontal axis
Any mouse motion with Ctrl + button pressed zooms in and out (translation of
camera)
Question 5: Animation
Exploiting question 4, design an automatic animation where the cube rotates around
the Z axis at the speed of 10 degrees per second.
Animate the cube so that it rotates for 5 seconds around the Z axis, then around the X
axis for for 5 more seconds, then cycle again.
Note: You must make use of glutTimerFunc() to make sure the drawing takes place at the
correct time.