Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreD3D9HardwareBufferManager.cpp

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright © 2000-2003 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #include "OgreD3D9HardwareBufferManager.h"
00026 #include "OgreD3D9HardwareVertexBuffer.h"
00027 #include "OgreD3D9HardwareIndexBuffer.h"
00028 #include "OgreD3D9VertexDeclaration.h"
00029 
00030 namespace Ogre {
00031     //-----------------------------------------------------------------------
00032     D3D9HardwareBufferManager::D3D9HardwareBufferManager(LPDIRECT3DDEVICE9 device)
00033         : mlpD3DDevice(device)
00034     {
00035     }
00036     //-----------------------------------------------------------------------
00037     D3D9HardwareBufferManager::~D3D9HardwareBufferManager()
00038     {
00039         destroyAllDeclarations();
00040         destroyAllBindings();
00041     }
00042     //-----------------------------------------------------------------------
00043     HardwareVertexBufferSharedPtr 
00044     D3D9HardwareBufferManager::
00045     createVertexBuffer(size_t vertexSize, size_t numVerts, HardwareBuffer::Usage usage,
00046         bool useShadowBuffer)
00047     {
00048         return HardwareVertexBufferSharedPtr(
00049             new D3D9HardwareVertexBuffer(vertexSize, 
00050             numVerts, usage, mlpD3DDevice, false, useShadowBuffer) );
00051     }
00052     //-----------------------------------------------------------------------
00053     void D3D9HardwareBufferManager::destroyVertexBuffer(HardwareVertexBuffer* buf)
00054     {
00055         delete buf;
00056     }
00057     //-----------------------------------------------------------------------
00058     void D3D9HardwareBufferManager::destroyAllDeclarations(void)
00059     {
00060         VertexDeclarationList::iterator decl;
00061         for (decl = mVertexDeclarations.begin(); decl != mVertexDeclarations.end(); ++decl)
00062         {
00063             delete *decl;
00064         }
00065         mVertexDeclarations.clear();
00066     }
00067     //-----------------------------------------------------------------------
00068     HardwareIndexBufferSharedPtr 
00069     D3D9HardwareBufferManager::
00070     createIndexBuffer(HardwareIndexBuffer::IndexType itype, size_t numIndexes, 
00071         HardwareBuffer::Usage usage, bool useShadowBuffer)
00072     {
00073         // NB no longer store the buffer in a local list since reference counted
00074         return HardwareIndexBufferSharedPtr(
00075                 new D3D9HardwareIndexBuffer(itype, numIndexes, 
00076                 usage, mlpD3DDevice, false, useShadowBuffer) );
00077             
00078     }
00079     //-----------------------------------------------------------------------
00080     void D3D9HardwareBufferManager::destroyIndexBuffer(HardwareIndexBuffer* buf)
00081     {
00082         delete buf;
00083     }
00084     //-----------------------------------------------------------------------
00085     VertexDeclaration* D3D9HardwareBufferManager::createVertexDeclaration(void)
00086     {
00087         VertexDeclaration* decl = new D3D9VertexDeclaration(mlpD3DDevice);
00088         mVertexDeclarations.push_back(decl);
00089         return decl;
00090         
00091     }
00092     //-----------------------------------------------------------------------
00093     void D3D9HardwareBufferManager::destroyVertexDeclaration(VertexDeclaration* decl)
00094     {
00095         mVertexDeclarations.remove(decl);
00096         delete decl;
00097     }
00098 
00099 }

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:07 2004