49 void Create( RenderBuffer&& a_rRenderBuffer,
TINT a_iSize )
53 m_oRenderBuffer = std::move( a_rRenderBuffer );
54 m_oRenderBuffer.Bind();
55 m_oRenderBuffer.SetData(
TNULL, a_iSize, GL_DYNAMIC_DRAW );
56 m_oRenderBuffer.Unbind();
58 m_iTotalSize = a_iSize;
59 m_iFreeSize = a_iSize;
76 if ( m_iFreeSize < a_iSize )
81 TINT iHoleSize = m_iFreeSize;
83 TINT iNumAllocations = m_vecAllocations.Size();
86 SubBuffer* pPrevAllocation =
TNULL;
87 for (
TINT i = 0; i < iNumAllocations; i++ )
89 SubBuffer* pAllocation = m_vecAllocations[ i ];
91 iHoleSize = pAllocation->offset - iPrevOffset - iPrevSize;
92 iPrevOffset = pAllocation->offset;
93 iPrevSize = pAllocation->size;
94 pPrevAllocation = pAllocation;
96 if ( iHoleSize >= a_iSize )
99 iNextOffset = iPrevOffset + pAllocation->size;
103 if ( pPrevAllocation && iHoleSize < a_iSize && pPrevAllocation == m_vecAllocations[ iNumAllocations - 1 ] )
105 iHoleSize = m_iTotalSize - ( pPrevAllocation->offset + pPrevAllocation->size );
107 if ( iHoleSize < a_iSize )
111 TASSERT( iHoleSize >= a_iSize );
114 SubBuffer* pSubBuffer =
new SubBuffer();
115 pSubBuffer->owner =
this;
116 pSubBuffer->offset = iNextOffset;
117 pSubBuffer->size = a_iSize;
118 m_vecAllocations.Push( pSubBuffer );
121 m_iFreeSize -= a_iSize;