KeosD3D9Buffer.h

Go to the documentation of this file.
00001 /*
00002  * This source file is part of KEOS (Free 3D Engine)
00003  * For the latest info, see http://www.keosengine.org/
00004  * E-mails : thierry.vouriot@keosengine.org, yeri@keosengine.org
00005  *
00006  * This program is free software; you can redistribute it and/or modify it under
00007  * the terms of the GNU Lesser General Public License as published by the Free Software
00008  * Foundation; either version 2 of the License, or (at your option) any later
00009  * version.
00010  *
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00018  * http://www.gnu.org/copyleft/lesser.txt.
00019  *
00020  */
00021 
00022 #ifndef KEOS_D3D9BUFFER_H
00023 #define KEOS_D3D9BUFFER_H
00024 
00025 #include "KeosD3D9Prerequisites.h"
00026 #include "KeosBufferBase.h"
00027 #include "KeosD3D9Enum.h"
00028 
00029 struct IDirect3DVertexBuffer9;
00030 struct IDirect3DIndexBuffer9;
00031 
00032 namespace Keos
00033 {
00034   //-----------------------------------------------------------------------
00037   template <class T>
00038   class CD3D9Buffer : public IBufferBase
00039   {
00040   public :
00041 
00046     CD3D9Buffer(ulong nCount, T* pBuffer);
00047 
00050     T* GetBuffer() const;
00051 
00052   private :
00053 
00056     virtual void* Lock(ulong nOffset, ulong nSize, ulong nFlags);
00057 
00060     virtual void Unlock();
00061 
00063     CSmartPtr<T, CCOMRefCounted> m_pBuffer;
00064   };
00065 
00066   // Index and vertex buffer definition from CD3D9Buffer template
00067   typedef CD3D9Buffer<IDirect3DVertexBuffer9> CD3D9VertexBuffer;
00068   typedef CD3D9Buffer<IDirect3DIndexBuffer9>  CD3D9IndexBuffer;
00069 
00070 
00071 
00072   //=======================================================================
00073   // CD3D9Buffer inline functions
00074   //=======================================================================
00075 
00076   //-----------------------------------------------------------------------
00077   template <class T>
00078   inline CD3D9Buffer<T>::CD3D9Buffer(ulong nCount, T* pBuffer) :
00079       IBufferBase(nCount),
00080       m_pBuffer  (pBuffer)
00081   {}
00082 
00083   //-----------------------------------------------------------------------
00084   template <class T>
00085   inline T* CD3D9Buffer<T>::GetBuffer() const
00086   {
00087     return m_pBuffer;
00088   }
00089 
00090   //-----------------------------------------------------------------------
00091   template <class T>
00092   inline void* CD3D9Buffer<T>::Lock(ulong nOffset, ulong nSize, ulong nFlags)
00093   {
00094     void* pData = NULL;
00095     m_pBuffer->Lock(nOffset, nSize, &pData, CD3D9Enum::LockFlags(nFlags));
00096 
00097     return pData;
00098   }
00099 
00100   //-----------------------------------------------------------------------
00101   template <class T>
00102   inline void CD3D9Buffer<T>::Unlock()
00103   {
00104     m_pBuffer->Unlock();
00105   }
00106 
00107 } // namespace Keos
00108 
00109 #endif // KEOS_D3D9BUFFER_H

Generated on Fri Mar 9 14:29:03 2007 for Keos by  doxygen 1.5.1-p1