|OpenGL and the more advanced way of doing things|
August 23, 2008, 6:43:14 pm
Over the last few nights I've been trying to get my head around how you're meant to use OpenGL in the era of 3.1, when all the stuff deprecated in 3.0 is actually removed. Currently, there's no spec available to give you a good glimpse of how that world is going to be - so when you start searching for answers on how to do things the modern way, you're constantly confronted with techniques that are deprecated.
For example, there's no longer any camera.. which means you have to do your projection transformation yourself inside a vertex shader. That's fine, you can combine vertex shaders together in to a 'pipeline' that will process all your vertices.
One thing that puzzled me today though was the idea of vertex arrays and buffer objects. Buffer objects tell OpenGL where a bunch of your data is. That data can be just vertexes, or it can be interleaved with other stuff, like colours and texture coordinates.. however, OpenGL, at this point, doesn't really know what you've got in there.
Prior to the deprecations, you'd tell it - with glVertexPointer, glNormalPointer, glColorPointer, so on and so forth, giving it distinct "inputs" to the fixed pipeline of operations. These methods are gone now.. and with them their corresponding OpenGL Shader Language variables, gl_Color, gl_Normal, so on and so forth.
Instead, what you do is take a buffer object filled with your data and assign it to a -generic- vertex attribute. Vertex attributes are the inputs in to the GLSL (shader) program. That and uniform variables. Vertex attributes come in per-vertex, while uniform variables are constants over the execution of your program.
The build-in vertex attributes, gl_Color, gl_Normal, etc, which are now deprecated, were sourced from the glColorPointer, glNormalPointer functions, etc... so since those build in vertex attributes are gone, the only data sources you have are the "generic" vertex attributes. I was all ready to give this a go when I started to notice that the functions I needed to do this were missing from the Smalltalk implementation of OpenGL. Specifically, glVertexAttribPointer. That's a bit of a problem. In fact, so are the functions for dealing with uniform variables. Another slightly problem there.
Some how, in parsing the various OpenGL header files, back a while ago - these functions were missed. I don't know how that has happened, but when I get the time to give this another go, I'll have to start from the fundamentals again - parsing the darn header files.
On another note - because it's such a mine field figuring out what is and isn't deprecated.. once I have the header files parsed properly, with all the missing functions added... I'll start trimming away the fixed-pipeline functions as I go. I'll be doing this in a new branch of OpenGL which will begin with a 3.0, the first version will be 3.0 0. I'll be doing the same with the MacOSX, Windows and Linux interfaces as well as the Lessons and Examples (which will both reset back to being empty).
It'll be a long struggling road ahead trying to unlearn everything I"ve learnt about OpenGL - but in the end, it'll be worth it to aid bringing the Smalltalk community in to the modern age of 3d graphics.
By the time I'm finished.. they'll probably be deprecating all this stuff too in favor of ray tracing ;)