Basics of OpenGL Shaders and Vertex Buffer Objects
- Example 0, OpenGL Hello World. This program demonstrates how to setup
GLUT to open an OpenGL window. glClearColor(), glClear(), and glFlush()
are demonstrated. The program only clears the window to green.
Get the code
See the code
- Example 1, This program picks up where example 0 left off.
This program demonstrates how to receive events in GLUT.
glViewport() is demonstrated.
The program also only clears the window, this time to blue.
The 'esc', and 'q' keys exit the program. Mouse and key information
are printed to stderr.
Get the code
See the code
- Example 2, This program picks up where example 1 left off.
This program demonstrates OpenGL shader setup boilerplate.
It includes a very simple GLSL shader.
The program still only clears the window, this time to red.
The 'esc', and 'q' keys exit the program. We are building
to a program which will do real drawing.
Get the code
See the code
- Example 3, This program picks up where example 2 left off.
This program demonstrates how to draw using Vertex Buffer Objects
using the shader from the previous example.
The program draws a single triangle. From here, we can spend some
time exploring and elaborating on the capabilities of VBOs and
GLSL shaders.
Get the code
See the code
- Example 4, This program picks up where example 3 left off.
This program shows that there's only a small difference in the
code from example 3 which draws 1 triangle, to this program which
draws many triangles.
Next, its time for more color.
Get the code
See the code
- Example 5, This program picks up where example 4 left off.
This program adds a second buffer object and adjusts the shaders
so that each triangle in the buffer can have a unique color.
Next, a slighly different version of this program.
Get the code
See the code
- Example 6, This program picks is a variation of example 5.
This program uses one vertex buffer object for both the color
data and the vertex data. This technique is called interleaving,
its been supported in OpenGL for many years. This program
demonstrates one way to do it with modern shaders.
Next, a simple animation.
Get the code
See the code
- Example 7, This program picks up from example 6.
This program demonstrates a simple animation. It isn't how
animation should be done, necessarily. Instead, it demonstrates
how to generate a rudimentary animated sign curve by indexing
into a VBO (the more important part of the example).
Next, viewing.
Get the code
See the code