OpenGL

advertisement
LAB #1: Computer Graphics Framework
IGX is a set of programs which allow you to write graphics
programs in C/C++ from plain text files.
Benefits:
1. You do not need an IDE like visual studio.
(Follows the tradition of early programmers)
2. You can write simple or complex programs.
3. You can write graphics program for modern hardware,
including CG Shaders for direct GPU programming.
Example:
void draw3D ()
{
Vector3DF a;
a.Set ( 5, 4, 2 );
// Define a vector
// Set the vector
glColor3f ( 1, 0, 0 );
// Specify a color to OpenGL
glBegin ( GL_LINES );
glVertex3f ( 0, 0, 0 );
glVertex3f ( a.x, a.y, a.z );
glEnd ();
// Start drawing lines
// Point A of line
// Point B of line
}
This will draw a line from the point 0,0,0 to point 5,4,2.
What does the IGX Framework do?
The underlying programming
language is C/C++.
This defines the syntax for
variables, functions, and loop
The Luna Sandbox is a part of IGX
which provides additional objects such
as vectors, cameras, and images. Not
normally part of OpenGL
OpenGL is a part of IGX which
does the low-level work of
rendering.
Commands are sent to the
graphics hardware to make an
image appear.
calls libraries
written in C/C++
MinGW – Command line compiler for C/C++
The only this you need to do is type “run .”
Example of how to run lab02.
Notice that IGX starts the ‘gcc’ compiler, which “builds” your program.”
GLUT – Library for simple window management
GLUT is a part of
your program code which
creates a display window
for output.
In this class, you do not
need to change this.
GLUT – Library for simple window management
GLUT gives you a function
where you can write 3D code.
Drawing reference grid is done for you.
You only need to write your labs
by creating some
additional code.
Only the required mini-project
involves more programming.
OpenGL – Low-level Graphics API library for rendering commands
Specifies a color
Draws 3 lines, each /w different color, in 3D
This is mainly what you will be learning to write.
Calling low-level graphics command which draw images.
Your textbook is the main reference for writing OpenGL.
LUNA Sandbox – A set of libraries for mathematical objects.
OpenGL is primarily for rendering commands.
LUNA Sandbox provides additional objects not found in
OpenGL. These include:
- Vectors
Vector3DF, Vector4DF
- Matrices
MatrixF, Matrix4F
- 3D Cameras
- Images
- Meshes
- CG Graphics Shaders
Example:
Camera3D my_camera;
Vector3DF camera_vec;
// Create a 3D Camera
// Create a vector
camera_vec = camera.getPos ();
// Set the vector to the
current position of camera.
After you type “run .” you should get this! …. Example from lab #2.
Next week.. Your first OpenGL program!
Lab #2:
How do we draw vectors in 3D?
How might we interact with those vectors
using the mouse?
Download