Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing Boost uBLAS matrices to OpenGL shader

I'm writing an OpenGL program where I compute my own matrices and pass them to shaders. I want to use Boost's uBLAS library for the matrices, but I have little idea how to get a uBLAS matrix into OpenGL's shader uniform functions.

matrix<GLfloat, column_major> projection(4, 4);
// Fill matrix
...

GLuint projectionU = glGetUniformLocation(shaderProgram, "projection");
glUniformMatrix4fv(projectionU, 1, 0, (GLfloat *)... Um ...);

Trying to cast the matrix to a GLfloat pointer causes an invalid cast error on compile.

like image 288
AJM Avatar asked Jun 09 '10 02:06

AJM


1 Answers

That should do it:

glUniformMatrix4fv(projectionU, 1, GL_FALSE, &projection.data()[0]);
like image 147
Ivan Baldin Avatar answered Nov 15 '22 08:11

Ivan Baldin