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

# OgreGLDefaultHardwareBufferManager.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 "OgreGLDefaultHardwareBufferManager.h"
    00026
    00027 namespace Ogre {
    00028
    00029     GLDefaultHardwareVertexBuffer::GLDefaultHardwareVertexBuffer(size_t vertexSize, size_t numVertices,
    00030         HardwareBuffer::Usage usage)
    00031         : HardwareVertexBuffer(vertexSize, numVertices, usage, true, false) // always software, never shadowed
    00032     {
    00033         mpData = new unsigned char[mSizeInBytes];
    00034     }
    00035     //-----------------------------------------------------------------------
    00036     GLDefaultHardwareVertexBuffer::~GLDefaultHardwareVertexBuffer()
    00037     {
    00038         delete [] mpData;
    00039     }
    00040     //-----------------------------------------------------------------------
    00041     void* GLDefaultHardwareVertexBuffer::lockImpl(size_t offset, size_t length, LockOptions options)
    00042     {
    00043         // Only for use internally, no 'locking' as such
    00044         return mpData + offset;
    00045     }
    00046     //-----------------------------------------------------------------------
    00047     void GLDefaultHardwareVertexBuffer::unlockImpl(void)
    00048     {
    00049         // Nothing to do
    00050     }
    00051     //-----------------------------------------------------------------------
    00052     void* GLDefaultHardwareVertexBuffer::lock(size_t offset, size_t length, LockOptions options)
    00053     {
    00054         mIsLocked = true;
    00055         return mpData + offset;
    00056     }
    00057     //-----------------------------------------------------------------------
    00058     void GLDefaultHardwareVertexBuffer::unlock(void)
    00059     {
    00060         mIsLocked = false;
    00061         // Nothing to do
    00062     }
    00063     //-----------------------------------------------------------------------
    00064     void GLDefaultHardwareVertexBuffer::readData(size_t offset, size_t length, void* pDest)
    00065     {
    00066         assert((offset + length) <= mSizeInBytes);
    00067         memcpy(pDest, mpData + offset, length);
    00068     }
    00069     //-----------------------------------------------------------------------
    00070     void GLDefaultHardwareVertexBuffer::writeData(size_t offset, size_t length, const void* pSource,
    00071             bool discardWholeBuffer)
    00072     {
    00073         assert((offset + length) <= mSizeInBytes);
    00074         // ignore discard, memory is not guaranteed to be zeroised
    00075         memcpy(mpData + offset, pSource, length);
    00076
    00077     }
    00078     //-----------------------------------------------------------------------
    00079
    00080     GLDefaultHardwareIndexBuffer::GLDefaultHardwareIndexBuffer(IndexType idxType,
    00081         size_t numIndexes, HardwareBuffer::Usage usage)
    00082         : HardwareIndexBuffer(idxType, numIndexes, usage, true, false) // always software, never shadowed
    00083     {
    00084         mpData = new unsigned char[mSizeInBytes];
    00085     }
    00086     //-----------------------------------------------------------------------
    00087     GLDefaultHardwareIndexBuffer::~GLDefaultHardwareIndexBuffer()
    00088     {
    00089         delete [] mpData;
    00090     }
    00091     //-----------------------------------------------------------------------
    00092     void* GLDefaultHardwareIndexBuffer::lockImpl(size_t offset, size_t length, LockOptions options)
    00093     {
    00094         // Only for use internally, no 'locking' as such
    00095         return mpData + offset;
    00096     }
    00097     //-----------------------------------------------------------------------
    00098     void GLDefaultHardwareIndexBuffer::unlockImpl(void)
    00099     {
    00100         // Nothing to do
    00101     }
    00102     //-----------------------------------------------------------------------
    00103     void* GLDefaultHardwareIndexBuffer::lock(size_t offset, size_t length, LockOptions options)
    00104     {
    00105         mIsLocked = true;
    00106         return mpData + offset;
    00107     }
    00108     //-----------------------------------------------------------------------
    00109     void GLDefaultHardwareIndexBuffer::unlock(void)
    00110     {
    00111         mIsLocked = false;
    00112         // Nothing to do
    00113     }
    00114     //-----------------------------------------------------------------------
    00115     void GLDefaultHardwareIndexBuffer::readData(size_t offset, size_t length, void* pDest)
    00116     {
    00117         assert((offset + length) <= mSizeInBytes);
    00118         memcpy(pDest, mpData + offset, length);
    00119     }
    00120     //-----------------------------------------------------------------------
    00121     void GLDefaultHardwareIndexBuffer::writeData(size_t offset, size_t length, const void* pSource,
    00122             bool discardWholeBuffer)
    00123     {
    00124         assert((offset + length) <= mSizeInBytes);
    00125         // ignore discard, memory is not guaranteed to be zeroised
    00126         memcpy(mpData + offset, pSource, length);
    00127
    00128     }
    00129     //-----------------------------------------------------------------------
    00130
    00131
    00132     //-----------------------------------------------------------------------
    00133     void GLDefaultHardwareBufferManager::destroyVertexBuffer(HardwareVertexBuffer* buf)
    00134     {
    00135         delete buf;
    00136     }
    00137     //-----------------------------------------------------------------------
    00138     void GLDefaultHardwareBufferManager::destroyIndexBuffer(HardwareIndexBuffer* buf)
    00139     {
    00140         delete buf;
    00141     }
    00142     //-----------------------------------------------------------------------
    00143     GLDefaultHardwareBufferManager::GLDefaultHardwareBufferManager()
    00144     {
    00145     }
    00146     //-----------------------------------------------------------------------
    00147     GLDefaultHardwareBufferManager::~GLDefaultHardwareBufferManager()
    00148     {
    00149         destroyAllDeclarations();
    00150         destroyAllBindings();
    00151     }
    00152     //-----------------------------------------------------------------------
    00153     HardwareVertexBufferSharedPtr
    00154         GLDefaultHardwareBufferManager::createVertexBuffer(size_t vertexSize,
    00155         size_t numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer)
    00156     {
    00157         return HardwareVertexBufferSharedPtr(
    00158             new GLDefaultHardwareVertexBuffer(vertexSize, numVerts, usage));
    00159     }
    00160     //-----------------------------------------------------------------------
    00161     HardwareIndexBufferSharedPtr
    00162         GLDefaultHardwareBufferManager::createIndexBuffer(HardwareIndexBuffer::IndexType itype,
    00163         size_t numIndexes, HardwareBuffer::Usage usage, bool useShadowBuffer)
    00164     {
    00165         return HardwareIndexBufferSharedPtr(
    00166             new GLDefaultHardwareIndexBuffer(itype, numIndexes, usage) );
    00167     }
    00168 }

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:24 2004