View Full Version : GLM on Linux

Leith Bade
02-03-2011, 01:28 PM
Has anyone managed to get GLM working on Linux?

It seems to fail on the SSE stuff... must be some Visual C++ only code in it.

If it wont work, can someone tell me how to create a glOrtho matrix for OpenGL 3.

Leith Bade
02-03-2011, 02:05 PM
Just realized that the definition of glOrtho gives the matrix.
So is this correct:

void glOrtho(GLfloat left, GLfloat right,
GLfloat bottom, GLfloat top,
GLfloat nearVal, GLfloat farVal)
GLfloat matrix[4][4];

matrix[0][0] = 2.0f / (right - left);
matrix[0][1] = 0.0f;
matrix[0][2] = 0.0f;
matrix[0][3] = 0.0f;

matrix[1][0] = 0.0f
matrix[1][1] = 2.0f / (top - bottom);
matrix[1][2] = 0.0f;
matrix[1][3] = 0.0f;

matrix[2][0] = 0.0f
matrix[2][1] = 0.0f;
matrix[2][2] = -2.0f / (farVal - nearVal);
matrix[2][3] = 0.0f;

matrix[3][0] = -(right + left) / (right - left);
matrix[3][1] = -(top + bottom) / (top - bottom);
matrix[3][2] = -(farVal + nearVal) / (farVal - nearVal);
matrix[3][3] = 1.0f;

glUniformMatrix4fv(projectionMatrixUniform, 1, GL_FALSE, matrix);

02-03-2011, 02:10 PM
Hi Leith,

It seems that you are using the GLM 0.9.1 alpha.

Have a look at GLM, the last stable release which should work fine on Linux.

PS: Also, the SSE code is isolated in GLM. Do you include everything?

Leith Bade
02-03-2011, 02:27 PM
I just ran:
cmake .; make

So I guess it must build everything.

02-03-2011, 02:32 PM
Humm oki I see. GLM is a header only library, there is nothing to build, this is probably just development build or tests.

Don't build, and just include GLM: #include <glm/glm.hpp> in your project and enjoy!

You are not the first to encounter this issue. I need to hide these CMake files which are not meant for GLM users.


02-03-2011, 04:30 PM
Yes the latest works fine on Linux -- I manually copied the headers to /usr/local/include/glm and ignored the cmake stuff like groovenet said before. Note that the latest glm*zip file has the confusing tree structure glm/glm/ -- ie

unzip glm-
cd glm
sudo cp -r glm/ /usr/local/include/

Take a look at Post290926 (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&amp;Number=290926#Post2909 26) from yesterday -- there is a discussion on how to use glm there for ortho etc.

02-03-2011, 05:05 PM
Thanks to a friend advice, I have added a CMake option that need to be enable to generate the projects.

Otherwise, it will simply display the error message:
"GLM is a header only library, no need to build it"

I hope that would avoid further experiences of that kind.

Leith Bade
02-03-2011, 06:37 PM

I am so used to building libraries that I didn't notice it was header only.

Plus the readme doesn't have any usage instructions...

Since this library is so awesome can I suggest this for a future feature:
Replacement for GLU tesselation that allows you to use VBOs. I have been looking around for ages to find a tesselation library that can do this as GLU does not work very well these days.

It needs to be fast and simple as most existing libraries are aimed at computational geometry so they tend to use overkill Delauney algorithms, when all I need is a simple polygon to triangle conversion for GL3.

The closest one I have found is poly2tris, as it was written by a 2D game programmer, but it is still a bit difficult to integrate into GL vertex & index buffers, as I have to use non-indexed triangles rather than indexed triangle strips.

02-04-2011, 03:19 AM
"Adding usage instructions" -> ToDoList

However, the tessellation is not really in the scope of GLM I am afraid.