The GLUT Samples
Most of the small OpenGL programs in this collection had been written years ago. They were intended to explore OpenGL programming and now can serve as code snippets when the basic structure of a GLUT program or some OpenGL code fragment is needed.
If a program does more than one thing the available choices are presented to the user in a pop-up menu attached to the right mouse button.
SimpleGLUT
Giving each vertex of the triangle a different color the colors for the interior are interpolated between the vertex colors. Since smooth shading, as compared to flat shading, is the default in OpenGL, the program draws a smooth-shaded triangle.
For the viewing volume defined with gluPerspective the aspect ratio can be chosen to be either a fixed value of 1 or, as generally used, the width of the viewport divided by its height. In the latter case the triangle gets displayed without distortion.
| Download | Description |
| simpleglut.exe | Standalone executable for Windows. |
| simpleglut.sln.zip | Visual Studio project files including all source codes. |
| Source Codes | ||||||
|
First3D
This sample uses depth testing and double buffering for smooth animation of objects in 3D space. Basic keyboard handling allows to terminate the program with the ESC key. As a bauble the view angle of the viewing volume (projection transformation) can be increased with every new image drawn yielding a zoom effect. The current view angle is displayed in the upper left corner. To have this information always in the same position on the screen an orthographic projection is used temporarily for text rendering.
Animation is achieved by rendering the next image whenever the application is idle, thus the frame rate depends on CPU load. See the Frame-Rate Independent Animation using GLUT tutorial for a solution with constant-speed animation.
| Download | Description |
| first3d.exe | Standalone executable for Windows. |
| first3d.sln.zip | Visual Studio project files including all source codes. |
| Source Codes | ||||||
|
Previous page: OpenGL with GLUT
Next page: The Cinema4D Samples