0% found this document useful (0 votes)
79 views2 pages

OPENGL Introduction: Question 3: Drawing in 3D

This document provides instructions for an OpenGL tutorial to teach 3D modeling and graphics. It contains 5 questions that incrementally build an OpenGL application: 1) Getting started with the template project, 2) 2D drawing in orthographic mode, 3) Drawing in 3D by initializing cube vertices and changing the projection, 4) Modifying the camera view with mouse input, and 5) Adding animation using glutTimerFunc() to rotate a cube around axes over time.

Uploaded by

Gunnie Pandher
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views2 pages

OPENGL Introduction: Question 3: Drawing in 3D

This document provides instructions for an OpenGL tutorial to teach 3D modeling and graphics. It contains 5 questions that incrementally build an OpenGL application: 1) Getting started with the template project, 2) 2D drawing in orthographic mode, 3) Drawing in 3D by initializing cube vertices and changing the projection, 4) Modifying the camera view with mouse input, and 5) Adding animation using glutTimerFunc() to rotate a cube around axes over time.

Uploaded by

Gunnie Pandher
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Jean-Marc Vzien

International Masters in biometrics


3D modeling and Augmented Reality

OPENGL introduction
This is a hands-on session of OpenGL. Using the template project called graphicsTest,
you will progressively build your own OpenGL application.

Question 1: Getting started


Download the GraphicsTest projet. Make sure GLUT is installed on your computer. Open
the graphicsTest.cpp file. Identify :

The rendering routine


The initialization routine
The interaction routines (mouse, keyboard)

Why is the graphics window blue ? How do you quit the program ?

Question 2: 2D drawing (Orthographic mode)


Important : For 2D drawing, set the GL_PROJECTION with glOrtho() in GLUTResize()
func !
Using the proper calls in GL_LINES mode:

Draw a red triangle in the middle of the window


Draw a green spring:

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

The GLUTResize function needs to be changed. No calls to glOrtho() here !

Notice the lighting instructions and camera positioning. Try to comment out the calls to
glTranslatef() and glRotatef() and look at the result.

Question 4: modify the camera view


Starting from the result of question 3, change the GLUTMotion() routine to capture the mouse
motion, so that :
-

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.

You might also like