Page 1 of 1

Platform\API independent architecture.

PostPosted: Fri Nov 02, 2012 10:17 am
by daniel
I've read your article about achieving API independence by using link-time polymorphism and i liked it alot!

But looking at your doxygen documentation, i ran into a whole bunch of methods like this one:

Code: Select all
00694         LSE_INLINE LSVOID LSE_CALL CVertexBuffer::SetVertex( LSUINT32 _ui32Index, LSREAL _fX, LSREAL _fY, LSREAL _fZ, LSUINT32 _ui32Stream ) {
00695                 assert( m_ui32Lock );
00696
00697                 LSGREAL * pfLoc = reinterpret_cast<LSGREAL *>(&m_vData[m_vAttributeOffsets[LSG_VA_POSITION][_ui32Stream]+_ui32Index*m_ui32Stride]);
00698                 (*pfLoc++) = static_cast<LSGREAL>(_fX);
00699                 (*pfLoc++) = static_cast<LSGREAL>(_fY);
00700                 (*pfLoc) = static_cast<LSGREAL>(_fZ);
00701         }


Why are you accessing the data directly instead of going through the parent? is it because of performance?

Re: Platform\API independent architecture.

PostPosted: Sat Nov 03, 2012 1:15 am
by L. Spiro
The parent of CVertexBuffer is an API-dependent class, which means if I accessed it through there I would have to reimplement it 5 times.
Instead, the parent class compiles a list of offsets which CVertexBuffer can use to modify the data directly. The performance is approximately the same, but much easier to implement since it has to be done only once.
That is the purpose of m_vAttributeOffsets.

So the offsets may change depending on the platform, but I don’t have to rewrite the same thing repeatedly.


L. Spiro