OpenGL bug?

xwindows resets itself if i do
float matrix[4][4]; and init its data. then do glMultMatrixf((GLuint*)matrix);
they data it crashes with is
(4.34403e-44 , 4.48416e-44 , 4.62428e-44 , 4.76441e-44)
(4.90454e-44 , 5.04467e-44 , 5.1848e-44 , 5.32493e-44)
(5.46506e-44 , 5.60519e-44 , 5.74532e-44 , 5.88545e-44)
(6.02558e-44 , 6.16571e-44 , 6.30584e-44 , 6.44597e-44)

What is the current state of the matrix you are using to multiply your matrix with? Has it been initialized with glLoadIdentity? Was it already in an acceptable state? Are the values within you matrix extremely low (all of the values you showed for the resulting matrix were very near zero and would likely be equivalent to a zero matrix which I would expect to cause some issues)? It is possible that the initial values of a particular matrix (i.e. GL_PROJECTION_MATRIX, GL_MODELVIEW_MATRIX, etc) may be all 0s (zeroes) if you did not initialize it using glLoadIdentity. You may be better off usng glLoadMatrix to specify the matrix you created instead of using the glMultMatrix.

If none of this helps, what are the values of the matrix you passed to glMultMatrix? Also what are the values of the GL matrix before the matrix multiply?

If you ask me, you are running into a driver bug.
Not because of whatever output, but because I doubt that a weird matrix is supposed to be a valid reason for a crash. Writes outside of the viewport aren’t supposed to happen anyway.

As an aside:

glMultMatrixf((GLuint*)matrix);
  

So, let’s get this straight: you cast a float pointer to a GLuint pointer and pass that to a function expecting a GLfloat pointer.
Not that that causes a problem - glMultMatrixf will still treat the pointer as a pointer to GLfloats, but it’s bad style.

There is one potential pitfall with declaring your matrix as float, instead of GLfloat, and that is if a GLfloat is not the same as a float.
I believe that they normally are the same.
But the alternatives:

  1. GLfloat has less precision than float. Expect the transformation to be all over the place.
  2. GLfloat has more precision than float. Expect a crash, since the array is smaller in bytes than the function expects. This crash would not be the driver’s fault.

To make a long story short: I don’t believe this is causing the crash, but to be on the safe side, just declare your matrix as GLfloat matrix[4][4].

ok, thanks very much for last point. also it does seem to be a driver crash.

Which driver is this? Which version of X-Windows? Is it X.org? XFree86? Something else?

If your matrix was declared as:

float matrix[4][4];

then you should cast and multiply it as follows:

glMultMatrixf((GLfloat*)(&matrix[0][0]));

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.