PDA

View Full Version : glLoadMatrix



Blair
12-08-2010, 02:12 PM
Hi, thanks in advance for taking the time to read this.

Recently I have been trying out PyOpenGL (Gotta use python for first year uni..no idea why I prefer java or C++)

So im writing a 3D maze application (or trying too) and have created a 4 x 4 matrix class with methods for multiplying, transposing etc. But when I try and load this with:

glLoadMatrixd(camera.transpose().getMatrix()

(From the documentation it appears I needed a transpose.

But this does not do anything, using glGet to write out the MODEL_VIEW matrix (even tried the PROJECTION matrix just incase) shows that it is always the same matrix - Nowhere near mine.

Any idea what the issue may be?

Thanks ,
Blair

ZbuffeR
12-08-2010, 03:41 PM
Python avoids the traps of C and is much less verbose than Java, so I consider it is useful as learning tool and for prototyping or gluing stuff together.
However when doing OpenGL, it does add a layer, and sometimes you have to struggle with it...

Does this work :


glMatrixMode(GL_MODELVIEW)
matrix=glGetDouble(GL_MODELVIEW_MATRIX)
matrix[3]=123456
glLoadMatrixd(matrix)
matrix=glGetDouble(GL_MODELVIEW_MATRIX)
print matrix[3]
# should display 123456

Blair
12-08-2010, 04:17 PM
What I get from that code above is

[ 0. 0. 0. 0.]

printed out in terminal, seems really really weird.

Edit:
Adding it into a larger block of code, just some cube drawing it prints out :

[ 123456. 123456. 123456. 123456.]

More on track but not quite what I expected, does this help?


Thanks Again,
Blair