[home]
Anton's OpenGL 4 Notes
About a year ago I started teaching myself OpenGL 4.2 for teaching.
This was new, because most of my graphics experience was with older "fixed-function"
libraries that work mostly on the CPU. OpenGL 4 is very different to OpenGL 2.1. In code
there is no more glBegin() and glEnd(). The problem-solving approach
is also different, as most algorithms are implemented in shader programmes where your
algorithm is designed to suit the hardware.
It is very hard to find reliable information on programming with OpenGL 4.x, so I intend
to update these pages as a series of mini-tutorials for common techniques, and also to
discuss some of the weird, wonderful, and frustrating coding issues that I run into...
hopefully with solutions!
I usually say something on Twitter
when I write a new article. Please let me know if you spot a mistake.
I'm currently re-writing my tutorials. Only the tutorials with thumbnails are
finished - in the mean-time you might like to check out my previous OpenGL 4
wiki for tutorials on the the missing topics.
I'm also using these techniques in a video game that I'm making called
Crongdor the Barbarian which you can read more about at www.crongdor.com
Latest Changes
10 May 2013 - Normal Mapping tutorial
08 May 2013 - Distance fog tutorial.
07 May 2013 - Spotlights article. Added a diagram to Overlay article. Added notes to Vertex Buffers about how enabling attributes works. Fixed bug in attribute binding code in Overlays tutorial.
03 May 2013 - Overlay Panels.
01 May 2013 - Particle article. Mac notes in Hello Triangle.
Basics
 |
"Hello Triangle" |
easy. 2 hours. |
Minimal code to draw a triangle using simple shaders and vertex buffers. |
 |
Extended Initialisation |
easy. 2 hours. |
Specifying OpenGL version, configuring the display, getting driver information, extension handling with GLEW, and adding a frames-per-second counter. |
 |
Shaders |
moderate. 2 hours. |
Shaders determine the style of rendering. |
 |
Vertex Buffers |
easy. 2 hours. |
Vertex buffers hold the mesh data to render. We add a vertex buffer with colours to our triangle and show
vertex-fragment interpolation. |
Transformation
 |
Matrices and Vectors |
moderate. 2 hours. |
A light introduction to using vectors and matrices in OpenGL 4 for moving, scaling, and rotating, and some basic animation. |
 |
Virtual Camera |
moderate. 2-4 hours. |
Building a transformation pipeline to add viewpoint and perspective to a scene. |
 |
Quaternion Quick-Start |
moderate. 2-4 hours. |
A simple explanation of quaternions, and how to write your own quaternion code for 3d (actually 4d) rotation. Useful for full rotation (rolling balls,
wheels, etc.), and interpolating rotations in animation. |
 |
Ray-Based Picking |
moderate. a couple of hours. |
Cast rays from mouse pointer to various primitive "bounding" shapes. |
Lighting and Texture Maps
 |
Phong Lighting |
moderate. ~1 day. |
Shading a scene with virtual lights. |
 |
Texture Maps |
moderate. 2-3 hours |
Loading images from files. Texture coordinates. Sampling textures in shaders. Mip-maps and filtering. |
Tips and Tricks
 |
Screen Capture |
easy. 1 hour. |
Simple function to save a screenshot to a file. |
 |
Video Capture |
moderate. 2 hours code. 2 hours processing. |
Extending the screen capture function to create a video from a regular series of screen dumps. |
 |
Debugging Shaders |
easy. 2 hours |
Methods for graphically "debugging" a shader programme part-by-part. |
Mesh Files
 |
Importing a Mesh File |
easy. 2-4 hours |
Choosing a file format, exporting a mesh, importing with the AssImp library, and copying into vertex buffers. |
More Advanced Lighting and Texture Effects
New Shader Stages
 |
Geometry Shaders |
easy. a couple of hours. |
Extrude or delete geometry on-the-fly using a geometry shader. |
 |
Tessellation Shaders |
moderate. a few hours. |
Automatically generate more detail inside surfaces using new GPU hardware. |
2D Rendering
Animation
Multi-Pass Rendering
 |
Switching Framebuffer |
moderate. 2-3 hours. |
The foundation of all multi-pass technques. Render to a texture instead of the screen. Reuse that texture. |
Just need to type it up... |
 |
Post-Processing Effects |
fiddly interface. about a day |
Create fancy filters to do effects over the whole screen after everything is rendered. |
Just need to type it up... |
 |
Colour-Based Picking |
fiddly interface. about a day. |
Render unique things to special colours (but don't show them). Test which special colour the mouse cursors is over. |
Just need to type it up... |
 |
Screen-Space Ambient Occlusion (SSAO) |
about a day |
A post-processing effect that fakes subtle shadows around concave areas. |
Just need to type it up... |
 |
Deferred Shading |
fiddly interface. about a day. |
Compute lighting in 2d (once per pixel, not once per overlapping fragment).
Enables use of large numbers of lights per scene. |
Just need to type it up... |
 |
Texture Projection Shadows |
minefield! ~1 week. |
Projecting shadows using the depth buffer. |
Not updated yet - old version here |
Optimisations
Things That I'll Probably Do Eventually
- Self quizes
- A guide for building larger programmes - vaos, vbos, how many, where, diagrams.
- Culling algorithms - frustum culling, portal culling, etc.
- Volumetric/Stencil Shadows
Useful References