PDA

View Full Version : Problem with OpenGL matrices



bstow01
09-30-2005, 01:28 PM
Im relatively new to working with OpenGL and OpenGL matrices, and my code is currently not doing what I would expect it to. Ive looked through OpenGL docs and some online examples and I just cant get this to work as I think it should.

Basically Ive set up a tranform class that holds a 4x4 matrix in a linear array. I want to have functions in this class that manipulate the matrix via OpenGL functions. Ive simplified my code down to whats below. According to this code I would expect the console to output a bunch of different numbers, but instead it outputs the oirginal matrix (1, 1, 1, ...).

Any help or advice would be appreciated. Thanks.

float matrixTest[16] = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f};

glMatrixMode(GL_MODELVIEW);
glPushMatrix();

glLoadMatrixf(matrixTest);

glScalef(20.0f, 20.0f, 20.0f);
glRotatef(20.0f, 3.0f, 3.0f, 3.0f);

glGetFloatv(GL_MODELVIEW_MATRIX, matrixTest);

glPopMatrix();

for (int i = 0; i < 16; i++){
cout << matrixTest[i];
}
Edit/Delete Message

mikael_aronsson
10-01-2005, 04:38 AM
First question, do you have an active rendering context ? if not the functions will not do anything at all, check for opengl errors.

Even though a matrix filled with ones is not a very good one...

Mikael