VSML is a small math library for matrix manipulation in OpenGL. Actually it’s not a complete matrix lib like the groovy GLM but a matrix lib focused on two particular matrices: the projection and view matrices. The goal of VSML is to bring OpenGL 1.x matrix functionalities (GL_PROJECTION and GL_MODELVIEW) to modern OpenGL 3.x / 4.x.
In OpenGL 1.x and 2.x you can write this code:
glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, w, h); gluPerspective(45.0f, ratio, 0.1f, 100.0f); glMatrixMode(GL_MODELVIEW);
This code is no longer possible with an OpenGL 3.x / 4.x core profile. Using VSML you can write a similar code:
vsml->loadIdentity(VSML::PROJECTION); glViewport(0, 0, w, h); vsml->perspective(45.0f, ratio, 0.1f, 100.0f);
The vsml->loadIdentity() initializes a projection matrix and send this matrix to the currently bound shader program:
// p is a shader program glLinkProgram(p); projMatrixLoc = glGetUniformLocation(p, "projMatrix"); modelviewMatrixLoc = glGetUniformLocation(p, "modelviewMatrix"); ... glUseProgram(p); vsml->initUniformLocs(modelviewMatrixLoc, projMatrixLoc); ... vsml->loadIdentity(VSML::PROJECTION); glViewport(0, 0, w, h); vsml->perspective(45.0f, ratio, 0.1f, 100.0f);
As usual to make our life a bit easier, I packed the lib in a very small zip file:
[download#232#image]
The -> arrow looks kinda weird.
Wouldn’t it be better if the author of the program just uses “::” or does using vsml?
And about the newer versions of OpenGL.
The reason they do away with old fixed function stuff is to make room for the programmable shaders. The benefits are that the developer can have full control over the projections with libraries like these.
Don’t forget OpenGL is NOT a graphics toolkit or graphics engine. It’s a way to present the building blocks of GPU’s to programmers.
This allows for better integration between the different things in game engines. Now that programmers control that too.
Yes it’s right, chop new opengl from 1.x/2.x but add external lib which implements 1.x/2.x functions to make old code working and newbies life easer. I definetly agree, good idea.