Archived

This topic is now archived and is closed to further replies.

Kimmen

why won't glGetDoublev return a matrix

Recommended Posts

Hi I have a little problem. I want opengl do some matrix multiplications for me, but glGetDoublev won''t return the matrix. the code lies in a class and looks like this: glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadMatrixd(m_baseMatrix); glMultMatrixd(g); glGetDoublev(GL_MODELVIEW_MATRIX, g); glPopMatrix(); where both m_baseMatrix and g are 16 element arrays. after glGetDoublev(GL_MODELVIEW_MATRIX, g); is called, g is unchanged. what can be wrong?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Are you sure you are correctly passing the array ?

double g[16];

glGetDoublev(GL_MODELVIEW_MATRIX, (double*) &g);

Share this post


Link to post
Share on other sites
Question: Is there any purpose to getting the values as doubles? Doesn''t the video card store matrices as floats, internally?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
that depends on your graphicscard.
Some convert to float others use doubles.
Actually at the time when OpenGL was defined using silicon graphics'' irisGL I bet no graphicsadapter supported doubles...

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Are you sure you are correctly passing the array ?

double g[16];

glGetDoublev(GL_MODELVIEW_MATRIX, (double*) &g);


Er no, that would pass the address of g. Since g is already a pointer to the first element in the array, you''d just be passing a pointer to the pointer, which would cause glGetDoublev to try to write 16*64 bits into a 32-bit space. In this case it probably wouldn''t make any difference, but in general that''s a really bad thing to do.

Share this post


Link to post
Share on other sites