VSML: Very Simple Matrix Lib for OpenGL



VSML: Very Simple Matrix Lib for OpenGL


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 VSML - Very Simple Matrix Library Version 2011.05.12

You can find more details about VSML HERE and HERE.





[ Subscribe to Geeks3D latest news by email ]

Geeks3D.com

↑ Grab this Headline Animator