GL setting of identity matrices

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

GL setting of identity matrices

Post by hendu »

All GL performance guides say that when you want to reset a matrix, you use glLoadIdentity instead of uploading your own identity matrix.

In Irr currently, only the texture matrices do this, the other matrices upload their own.


Why is this?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: GL setting of identity matrices

Post by hybrid »

Well, where would you assume to find the identity matrix? Or do you say that one should always first call LoadIdentity first?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: GL setting of identity matrices

Post by hendu »

It would call the isIdentity method, just like is done for the texture matrices, see line COpenGLDriver.cpp:980 in current svn.

I mean, if one calls setTransform(ETS_WORLD, IdentityMatrix), irr spends time uploading its own identity matrix instead of calling the faster glLoadIdentity. But if setting a texture matrix instead, it detects it's an identity matrix and correctly uses the faster function.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: GL setting of identity matrices

Post by hybrid »

The reason is that for texture matrices, about 99.9% will be identity, but for transformation, only 0.1% will be. So a check will be probably counter productive, as it will almost always fail and cost a few cycles each time.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: GL setting of identity matrices

Post by hendu »

Then maybe add a setTransformIdentity call, only taking the target matrix as a parameter?
Post Reply