GL = graphics library
OpenGL started in 1992 to replace proprietary SGI "IRIS GL".
Sub-libraries:
GLU | GL Utilities | Basic objects, textures, some transformations |
GLUT | GL Utility Toolkit | Set up windows and handle events. No longer used. |
GLEW | GL Extension Wrangler | Maps OpenGL API functions to internal implementation |
GLFW | Graphics Library Framework | Windows and events. Good. |
GLAD | Maps API functions to implementations. Good. | |
GLM | GL math | Lots of graphics-oriented math functions. Somewhat messy. |
Main graphics loop:
Events can be:
Each event is processed by a 'handler', which is just a function.
Each event handler is registered during initialization with (in our case) GLFW.
OpenGL usually has two drawing buffers:
One shows what's on the screen (the "front buffer").
The other is used to draw the next image (the "back buffer").
Once drawing in the back buffer is finished, the buffers are swapped so that the new image appears on the screen all at once, rather than bit-by-bit as it was being drawn.
See 00-intro/src/demo1.cpp in openGL.zip
Object vertices are stored in a "vertex buffer object" or VBO.
Each vertex can have many attributes, such as
The VBO is just a buffer and could be set out like this:
In OpenGL, you must:
See 00-intro/src/demo2.cpp in openGL.zip
Maintain a "world state" that contains all the information necessary to provide a snapshot of the world at a particular instant.
For example, if the world consists of a rotating square, the world state would contain the square's:
To animate, update the state as a function of either (a) the relative time since the last update or (b) the absolute current time.
See 00-intro/src/demo3.cpp in openGL.zip