Platform\API independent architecture.

General Discussions Regarding L. Spiro Engine

Platform\API independent architecture.

Postby daniel » Fri Nov 02, 2012 10:17 am

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?
daniel
I Have a Question
 
Posts: 4
Joined: Fri Nov 02, 2012 10:11 am

Re: Platform\API independent architecture.

Postby L. Spiro » Sat Nov 03, 2012 1:15 am

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
It is amazing how often people try to be unique, and yet they are always trying to make others be like them.
- L. Spiro 2011
L. Spiro
Site Admin
 
Posts: 54
Joined: Thu Jul 21, 2011 2:59 pm
Location: Tokyo, Japan


Return to General Related

Who is online

Users browsing this forum: No registered users and 0 guests

cron