Just like I've been a bit slack with the WebVelocity news, so too have I been lagging with the OpenGL news. There are quite a few lessons there now which cover the basics of how to use OpenGL the "modern" way. I say modern, because really it's the DirectX 9 way.. OpenGL is still catching up.
The people on #opengl at irc.freenode.org have been really helpful, if somewhat brash at times. Here's a list of the lessons that you can read through and try out:
- Geometry
- Colors
- Uniform Vectors
- Uniform Matrices
- Math and Transform Feedback Buffers
- Animation
- Memory Management
- Normals and Basic Lighting
- Textures
- Mipmaps
- Alpha Blending
- Cairo Graphics
- Texture Animation
- RenderState
- Font Textures
- MultiTextures
- FrameBuffers
- Noise Generation
- Particles
- Fragment Animation
- Offscreen Rendering
You can now also render to a Window, a Pixmap or an Image object. This is really important to note too - if you render to a Window, you'll get the accelerated hardware renderer, while if you render to a Pixmap, you're more than likely to get the software renderer.
Why does this matter? Well, the software renderer on Windows is really REALLY old - OpenGL 1.1, not OpenGL 2.1.. so it doesn't even know what a shader is. This is on Windows Vista too! Microsoft is really slack about OpenGL. Luckily the video card vendors make slick hardware accelerated renderers - the catch, you have to not use a Pixmap.
So in steps Image rendering instead. This uses a different technique on each platform. On MacOSX, we create an unbound rendering context and use FrameBufferObjects, then copy the data back in to the Image object on flush - accelerated and fast. On Windows, we create a hidden window and render in to that, then copy the data back in to the Image object on flush - accelerated and fast. I've yet to implement this technique on Linux, but I'll get around to it one day.. may be :)
The result is, you can render a complex scene in to an Image object and draw that Image object in to your regular VisualWorks applications seemlessly and you can even double buffer if you really want to (just swap between two rendering contexts).Lots of bugs have been fixed along the way too.. as well as implementing a really fast copy technique when using transform feedback for physics simulation. It should be noted that most cards do not support transform feedback in the hardware - so you often end up doing it in software. There's a long shpeel about this in Lesson05Math where we benchmark the different techniques of doing floating point arithmetic.
Finally, I now read in the version, renderer and vendor information in to the RenderContext when you create it, so that you can see whether you've got a compatible rendering context or not - compatible means that you're using OpenGL 2.0 or greater... give or take. You're better off with OpenGL 2.1 or OpenGL 3.0 - but the 3.0 drivers are all betas right now.
I'm fast approaching the point where the easy fruit has been picked with the lessons and it'll be time to start exploring the world of models and various model formats. In the previous incarnation of these libraries, I implemented the MilkShape3D format.. this time I think I'll skip that one and go for something more common and perhaps even put together a simple CAD program to edit the models. The fun starts when bones are added for animation and nice curvy surfaces with variable Level Of Detail.