OpenGL® Examples

GLUT - Examples

View Image Description View Source
abgr.jpg Demonstrates the use of the extension EXT_abgr. The same image data is used for both ABGR and RGBA formats in glDrawPixels and glTexImage2D. The left side uses ABGR, the right side RGBA. The top polygon demonstrates use of texture, and the bottom image is drawn with glDrawPixels. Note that the textures are defined as 3 component, so the alpha value is not used in applying the DECAL environment. abgr.c
bitfont.jpg Example of using GLUT bitmap fonts. bitfont.c
blender.jpg Renders two spinning icosahedrons (red and green). The blending factors for the two icosahedrons vary sinusoidally and slightly out of phase. blender also renders two lines of text in a stroke font: one line antialiased, the other not. blender.c
cube.jpg A simple red cube drawn with minimal OpenGL calls. cube.c
dinoshade.jpg Example for PC game developers to show how to combine texturing, reflections, and projected shadows all in real-time with OpenGL. Robust reflections use stenciling. Robust projected shadows use both stenciling and polygon offset. dinoshade.c
dinospin.jpg Arcball like rotation of a chunky dinosaur. dinospin.c
evaltest.jpg OpenGL evaluators simple example with lots of options. evaltest.c
fogtst.jpg Demonstration program exhibiting fog techniques. fogtst.c
fontdemo.jpg Bitmap and stroke fonts demonstration program. fontdemo.c
glpuzzle.jpg 3D puzzle that can solve itself automatically. glpuzzle.c
glutplane.jpg OpenGL planes a plenty - add and subtract them. glutplane.c
halomagic1.jpg (dinosaur)
Neat haloing effect using the stencil buffer. halomagic.c
highlight.jpg This program demonstrates the use of the GL lighting model. Objects are drawn using a grey material characteristic. A single light source illuminates the objects. highlight.c
lightlab.jpg Lighting laboratory to experiment with different material properties and lights. lightlab.c
mjkwarp.jpg Texture warping example to show many texturing options of OpenGL. mjkwarp.c
molehill.jpg Really, really shiny nurbs/evaluators example. molehill.c
movelight.jpg This program demonstrates when to issue lighting and transformation commands to render a model with a light which is moved by a modeling transformation (rotate or translate). The light position is reset after the modeling transformation is called. The eye position does not change.

A sphere is drawn using a grey material characteristic. A single light source illuminates the object.

Interaction: pressing the left or middle mouse button alters the modeling transformation (x rotation) by 30 degrees. The scene is then redrawn with the light in a new position.
oclip.jpg The main intent of this program is to demo the arbitrary clipping functionality, hence the rendering is kept simple (wireframe) and only one clipping plane is used. oclip.c
ohidden.jpg The main intent of this program is to demo the stencil plane functionality, hence the rendering is kept simple (wireframe). ohidden.c
(final image)
OpenGL example showing how to do hardware lighting including two-sided lighting. olight.c
olympic.jpg Flyging olympic logo. Press spacebar to animate. olympic.c
origami.jpg Origami folding example (paper airplane). origami.c
sb2db.jpg This program demonstrates switching between single buffered and double buffered windows when using GLUT. Use the pop-up menu to change the buffering style used. On machine that split the screen's color resolution in half when double buffering, you should notice better coloration (less or no dithering) in single buffer mode (but flicker on redraws, particularly when rotation is toggled on). sb2db.c
reflectdino.jpg Very simple example of how to achieve reflections on a flat surface using OpenGL blending. The example has a mode using OpenGL stenciling to avoid drawing the reflection not on the top of the floor. Initially, stenciling is not used so if you look (by holding down the left mouse button and moving) at the dinosaur from "below" the floor, you'll see a bogus dinosaur and appreciate how the basic technique works. Enable stenciling with the popup menu and the bogus dinosaur goes away! Also, notice that OpenGL lighting works correctly with reflections. reflectdino.c
scene.jpg This program demonstrates the use of the GL lighting model. Objects are drawn using a grey material characteristic. A single light source illuminates the objects. scene.c
screendoor.jpg Demonstrates "screen door" transparency using OpenGL's polygon stipple feature. screendoor.c
scube.jpg (rgb)
scube1.jpg (olor index..)
Spinning cube with dynamic shadow (runs in color index mode too!). scube.c
simple.jpg Very simple example of how to draw a single triangle with OpenGL. simple.c
sphere.jpg Multiple windows example with GLUT. sphere.c
splatlogo.jpg Fun with bitmaps (and pixel transfer maps) in OpenGL. splatlogo.c
spots.jpg Excellent spotlight example showing direction of lights too. spots.c
stars.jpg Stars example program with turbo and crazy mode. stars.c
stenciltst.jpg An example of how to use the stencil test. stenciltst.c
stroke.jpg Stroke fonts using GLUT (antialiased). stroke.c
subwin.jpg Subwindows with GLUT - each gets its own color. subwin.c
surfgrid.jpg A surface with the grid that it is defined by highlighted. surfgrid.c
triselect.jpg Triangle selection program. Click on the triangles to change their color. triselect.c