Need a bit of help with ublas matrix

Started by
1 comment, last by aarbron 13 years ago
I'm tying to replace the array matrix used here with a boost matrix.
I've tried using column major and/or exchanging the two last elements without success. The mesh shows fine with the array version but not my matrix.

float fFrustumScale = 1.0f; float fzNear = 0.5f; float fzFar = 3.0f;

float theMatrix[16];
memset(theMatrix, 0, sizeof(float) * 16);

matrix<float> bmatrix(4,4);

theMatrix[0] = fFrustumScale;
theMatrix[5] = fFrustumScale;
theMatrix[10] = (fzFar + fzNear) / (fzNear - fzFar);
theMatrix[14] = (2 * fzFar * fzNear) / (fzNear - fzFar);
theMatrix[11] = -1.0f;

bmatrix(0,0) = fFrustumScale;
bmatrix(1,1) = fFrustumScale;
bmatrix(2,2) = (fzFar + fzNear) / (fzNear - fzFar);
bmatrix(2,3) = (2 * fzFar * fzNear) / (fzNear - fzFar);
bmatrix(3,2) = -1.0f;

glUseProgram(program);
//glUniformMatrix4fv(perspectiveMatrixUnif, 1, GL_FALSE, theMatrix); //This works
glUniformMatrix4fv(perspectiveMatrixUnif,1, GL_FALSE, &bmatrix.data()[0]);//Doesn't


Thanks in advance.
Advertisement
Print out the 16 values pointed to by theMatrix and &bmatrix.data()[0] to verify that they are in fact identical. If not, what elements are different, and why could they be different?

You also need to define what you mean by "doesn't work". There are plenty of ways something can "not work", and many of them requires entirely different solutions. "Doesn't work" can be. for example, crashing the program, nothing at all is rendered, something entirely different is rendered, something slightly different is rendered, and so on. Each of these are likely entirely different problems which requires different solutions or approaches to find the source of the problem.
bmatrix.clear() it is. I thought it was auto zeroed all that time.

This topic is closed to new replies.

Advertisement