objarni's picture

A step towards GL3

I'm a traditional OpenGL developer in the sense that I keep using immediate mode because I think it is so intuitive and easy-to-use.

I know this mode of GL operation is deprecated (maybe even removed?) with GL3, hence I am trying to "take the leap" and start using vertex array, vertex buffer objects and so on.

So I thought: can't I use the best of both worlds? Why not have a "vertex array builder" object that operates much like traditional immediate mode, and then creates/draws the vertex array for me?

My thoughts then went on to "should I create VAs or VBOs or even generate source code to draw VAs and so on"? Since I do know how VAs work already, I think this is a good start to build this "builder object".

I will begin with support for vertex position, color, normals and texture coordinate. That is the "bread and butter" of OpenGL, and I can expand on that when I need to.

Some pseudocode to show what I mean:

// code to build a multi coloured triangle vertex array
VABuilder builder = new VABuilder();
builder.Color(1,0,0);
builder.Vertex(0,0,0); // a red vertex
builder.Vertex(100,0,0); // this vertex will be red too
builder.Color(0,0,1);
builder.Vertex(100,100,0); // blue
[some data format I have not yet decided on] va = builder.GetVertexArray();
[ - " - ] ca = builder.GetColorArray();

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Indeed.