PDA

View Full Version : more for glMatrixMode



V--man
06-21-2001, 07:54 PM
I once again got into trouble because I forgot to set the correct matrix mode. Could we please create separate matrix functions for each matrix type.

example:

glLoadIdentityProjection();
glMultMatrixProjectionf(xxxx);
glTranslateProjectionf(xxxxx);
glRotate well you get the idea.

What's the point of switching matrix modes? It's error prone to work like this.

V-man

Nutty
06-24-2001, 11:40 AM
Couldn't you just make your own wrappers for this? I can't imagine it taking more than 30 mins coding to do. Also cache the state of the modelview matrix, to check for redundant matrix mode changes, and avoid passing them onto the driver.

As a side note, you should do this for all state changes too..

Nutty

V--man
06-24-2001, 06:44 PM
Possible, but I still don't see a reason for not having separate functions. I know that they are all matrices but why go through this mode change business?

Inside opengl there must be code like this for an example:

void GLAPI glLoadIdenity()
{
if(matrixmode==PROJECTION)
{ projmatrix[0]=1.0;
projmatrix..........
}
else if(matrixmode==modelview)

and so..........
}

I want it changed (the new functions added) cause I don't like it like this.

V-man

Nutty
06-25-2001, 04:00 AM
I suppose it could be slightly more efficient that way. But this seems like a very low priority fix, and because of such I doubt it will ever get implemented.

Suggest it to the ARB or something, and see what they say.

Nutty

P.S. do the ARB read this forum at all, for any suggestions for future releases?

Siigron
06-25-2001, 08:36 AM
well, considering this would mean you'd have to add a hundred or so functions to the API, i don't think it's likely to ever happen.
yes, there are lots of matrices in OpenGL (especially if you take into account some extensions like ARB_vertex_blend), and it's much easier and more elegant to add one new #define for a new matrix, rather than a whole bunch of functions.

no offense, but the trouble comes from you forgetting which matrix mode you're in, not OpenGL.

V--man
06-29-2001, 01:11 PM
I don't think 100 functions will be added. Only projection, modelview and texture could have there own functions.

push, pop, translate, scale, rotate, identity, loadmatrix, multmatrix.

Total of 24 new functions.

Anyway, I was wrong about the inefficiency of the current method. It is actually faster according to Mark Kilgard's papers. But I won't retract my suggestion. I'm sure adding a few functions will not interfer with the current method.

V-man

V-man

Siigron
06-30-2001, 04:25 PM
push, pop, translate, scale, rotate, identity, loadmatrix, multmatrix.
that's 8 new matrix functions. multiply that just with the number of modelview matrices supported by ARB_vertex_blend (32), and you have 32*8 = 256 new functions. and remember, that's only for a single extension.
clearly it's not a good idea to have to add 8 new functions when introducing a new matrix.

and returning to your original problem (that is, forgetting what matrix mode you're in) i'd say that it's easier to do the mistake to type "glLoadIdentityModelview1ARB" instead of "glLoadIdentityModelview2ARB" (for example).

Sundy
07-08-2001, 10:43 PM
> Inside opengl there must be code like this for an >example:
>void GLAPI glLoadIdenity()
{
if(matrixmode==PROJECTION)
{ projmatrix[0]=1.0;
projmatrix..........
}
else if(matrixmode==modelview)
and so..........
}

> I want it changed (the new functions added) cause I >don't like it like this.

I dont think this is the way the implementors would do it
it should be somehting like this
void GLAPI glLoadIdenity()
{
GLfloat* pMatrix = GlobalMatrices[MatrixMode];
pMatrix[0] = 1.0;
...

}

Something like this. As such I dont think there will be any performance penaly because of this as it involves just one indexed load. I wouldnt say that this is needed at all.

-Sundar

V--man
07-10-2001, 02:24 PM
I had made a post here but it must have been lost.

It's possible to use tokens for these matrix function instead of having a separate one for each matrix.

Ex:
glLoadIdentity(GLenum matrixmode);

Yes, the previous code I had there is not the way GL goes about. You should read Mark kilgard's paper. "19 pitfalls"

V-man