/*==========================================================================; * * Copyright (C) 1995-2000 Microsoft Corporation. All Rights Reserved. * * File: d3dtempl.hpp * Content: Direct3D templates include file * * ***************************************************************************/ #ifndef __D3DTEMPL_HPP #define __D3DTEMPL_HPP #include #include "d3dmem.h" //-------------------------------------------------------------------------- // // Template for growable arrays // //-------------------------------------------------------------------------- template class GArrayT { public: GArrayT() { m_pArray = NULL; m_dwArraySize = 0; m_dwGrowSize = 8; } ~GArrayT() { if( m_pArray ) { DDASSERT( (m_dwArraySize != 0) && (m_pArray != NULL) ); delete[] m_pArray; } else { DDASSERT( (m_dwArraySize == 0) && (m_pArray == NULL) ); } } LPVOID GetArrayPointer() const {return m_pArray;} virtual void SetGrowSize( DWORD dwGrowSize) { m_dwGrowSize = dwGrowSize; } #if 0 virtual HRESULT Init( DWORD dwInitialSize, DWORD dwGrowSize) { m_pArray = AllocArray( dwInitialSize ); if( m_pArray == NULL ) return E_OUTOFMEMORY; m_dwArraySize = dwInitialSize; m_dwGrowSize = dwGrowSize; return S_OK; } #endif virtual HRESULT Grow( DWORD dwIndex ) { if( dwIndex < m_dwArraySize ) return S_OK; DWORD dwNewArraySize = m_dwArraySize; while( dwNewArraySize <= dwIndex ) dwNewArraySize += m_dwGrowSize; ARRAY_ELEMENT *pNewArray = AllocArray( dwNewArraySize ); if( pNewArray == NULL ) return E_OUTOFMEMORY; for( DWORD i = 0; i