OpenGL Transformations & Callbacks Lab: 3D Object Drawing in C++, Lecture notes of Computer Graphics

OpenGL common function in 2d and 3d

Typology: Lecture notes

2020/2021

Uploaded on 03/13/2021

hani-ghanim
hani-ghanim 🇪🇬

3 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
DT228 Graphics & Image Processing
Lab 4: OpenGL Transformations & Callbacks
In this lab we will take a look at drawing 3-D objects in OpenGL.
Task 1: Begin a new C++ Win32 Console Application Project in Visual Studio
.NET called Lab4GlutPolyhedra, setting the root folder to a Graphics folder on your
student storage. Paste in the code from the Lab4GlutPolyhedra.cpp file on the
course website.
Task 2: Examine the application code. The important functions to take a look at in
this application are glFrustum, gluLookAt and the 3-D shape drawing functions
(only some of these are used in the sample application):
glutSolidSphere
glutWireSphere
glutSolidCube
glutWireCube
glutSolidCone
glutWireCone
glutSolidTorus
glutWireTorus
glutSolidDodecahedron
glutWireDodecahedron
glutSolidOctahedron
glutWireOctahedron
glutSolidTetrahedron
glutWireTetrahedron
glutSolidIcosahedron
glutWireIcosahedron
glutSolidTeapot
glutWireTeapot
Build this application now and run it - it should look like this:
pf2

Partial preview of the text

Download OpenGL Transformations & Callbacks Lab: 3D Object Drawing in C++ and more Lecture notes Computer Graphics in PDF only on Docsity!

DT228 Graphics & Image Processing

Lab 4: OpenGL Transformations & Callbacks

In this lab we will take a look at drawing 3-D objects in OpenGL.

Task 1: Begin a new C++ Win32 Console Application Project in Visual Studio .NET called Lab4GlutPolyhedra , setting the root folder to a Graphics folder on your student storage. Paste in the code from the Lab4GlutPolyhedra.cpp file on the course website.

Task 2: Examine the application code. The important functions to take a look at in this application are glFrustum , gluLookAt and the 3-D shape drawing functions (only some of these are used in the sample application):

  • glutSolidSphere
  • glutWireSphere
  • glutSolidCube
  • glutWireCube
  • glutSolidCone
  • glutWireCone
  • glutSolidTorus
  • glutWireTorus
  • glutSolidDodecahedron
    • glutWireDodecahedron
    • glutSolidOctahedron
    • glutWireOctahedron
    • glutSolidTetrahedron
    • glutWireTetrahedron
    • glutSolidIcosahedron
    • glutWireIcosahedron
    • glutSolidTeapot
    • glutWireTeapot

Build this application now and run it - it should look like this:

Task 3: Build a new application that displays a 3-D wireframe teapot and rotates it continuously around the y-axis. It should look like the application shown below:

Task 4: Add a mouse button handler so that when you press the left mouse button the animation starts and stops.

Task 5: Add a keyboard handler so that pressing the ‘a’ key zooms in on the teapot and the ‘z’ key zooms out from the teapot. HINT: The key to this will be changing the parameters passes to the gluLookAt function. To get an idea of how this application should behave, the finished version is available for download on the labs webpage.