GLIM: OpenGL Immediate Mode for OpenGL 3.0

Hi there

A few weeks ago i wrote a library that allows to render geometry very similar to OpenGL's immediate mode, but does so without any deprecated function. This means especially, that it requires you to use GLSL shaders with generic vertex attributes, ie. a purely shader-based approach.

One reason for me to write this library, was that i use generic vertex attributes with VBOs but usually the old-style glNormal / glTexCoord, when using immediate mode, because using generic vertex attributes with OpenGL's immediate mode is pretty annoying. So my library makes this very easy.

After using it for a while i found it worked really well, and thought i should share it with other gl users, that want to break free from the fixed function pipeline.

The readme included gives a more detailed explanation. A small example on how GLIM works:

Code :

// instanciate a GLIM object whenever you need one
GLIM glim;
// set gl states
// begin some geometry with the current state
glim.BeginPart ();
// set some vertex attribute to a start value
glim.Attribute4ub ("Color", 255, 0, 0, 255);
// begin a certain primitive type (just as glBegin)
glim.Begin (GLIM_LINES);
// render one line
glim.Vertex (0, -1);
glim.Vertex (0, 1);
// render next line with different color
glim.Attribute4ub ("Color", 255, 255, 0, 255);
// render another line
glim.Vertex (-1, 0);
glim.Vertex (1, 0);
glim.End ();
// end rendering with the current state
glim.EndPart ();
// change gl states and possibly render more

As you can see, GLIM really only handles geometry. It does not bother about gl states or anything else. That's the reason why it is so easy to just plug it into existing code. It does one thing and nothing more.

GLIM is released as full source code (you need to compile it yourself, but that should be really easy) and you are free to use and modify it as you wish.

the Begin() takes info what primitive-types we'll draw, and a vertex-declaration array (elements in it mean "attrib0 is 3 floats, followed by attrib7 is 4ubyte-color, followed by attrib9 is 2 half-floats". This decl-array can show how many bytes a vertex's attribs take. Then, the subsequent calls specify the vtx-attrib data of each vertex required for a primitive.