[692] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | #ifndef __GLDefaultHardwareBufferManager_H__
|
---|
| 27 | #define __GLDefaultHardwareBufferManager_H__
|
---|
| 28 |
|
---|
| 29 | #include "OgrePrerequisites.h"
|
---|
| 30 | #include "OgreHardwareBufferManager.h"
|
---|
| 31 | #include "OgreHardwareVertexBuffer.h"
|
---|
| 32 | #include "OgreHardwareIndexBuffer.h"
|
---|
| 33 |
|
---|
| 34 | namespace Ogre {
|
---|
| 35 |
|
---|
| 36 | /// Specialisation of HardwareVertexBuffer for emulation
|
---|
| 37 | class GLDefaultHardwareVertexBuffer : public HardwareVertexBuffer
|
---|
| 38 | {
|
---|
| 39 | protected:
|
---|
| 40 | unsigned char* mpData;
|
---|
| 41 | /** See HardwareBuffer. */
|
---|
| 42 | void* lockImpl(size_t offset, size_t length, LockOptions options);
|
---|
| 43 | /** See HardwareBuffer. */
|
---|
| 44 | void unlockImpl(void);
|
---|
| 45 |
|
---|
| 46 | public:
|
---|
| 47 | GLDefaultHardwareVertexBuffer(size_t vertexSize, size_t numVertices,
|
---|
| 48 | HardwareBuffer::Usage usage);
|
---|
| 49 | ~GLDefaultHardwareVertexBuffer();
|
---|
| 50 | /** See HardwareBuffer. */
|
---|
| 51 | void readData(size_t offset, size_t length, void* pDest);
|
---|
| 52 | /** See HardwareBuffer. */
|
---|
| 53 | void writeData(size_t offset, size_t length, const void* pSource,
|
---|
| 54 | bool discardWholeBuffer = false);
|
---|
| 55 | /** Override HardwareBuffer to turn off all shadowing. */
|
---|
| 56 | void* lock(size_t offset, size_t length, LockOptions options);
|
---|
| 57 | /** Override HardwareBuffer to turn off all shadowing. */
|
---|
| 58 | void unlock(void);
|
---|
| 59 |
|
---|
| 60 | //void* getDataPtr(void) const { return (void*)mpData; }
|
---|
| 61 | void* getDataPtr(size_t offset) const { return (void*)(mpData + offset); }
|
---|
| 62 | };
|
---|
| 63 |
|
---|
| 64 | /// Specialisation of HardwareIndexBuffer for emulation
|
---|
| 65 | class GLDefaultHardwareIndexBuffer : public HardwareIndexBuffer
|
---|
| 66 | {
|
---|
| 67 | protected:
|
---|
| 68 | unsigned char* mpData;
|
---|
| 69 | /** See HardwareBuffer. */
|
---|
| 70 | void* lockImpl(size_t offset, size_t length, LockOptions options);
|
---|
| 71 | /** See HardwareBuffer. */
|
---|
| 72 | void unlockImpl(void);
|
---|
| 73 | public:
|
---|
| 74 | GLDefaultHardwareIndexBuffer(IndexType idxType, size_t numIndexes, HardwareBuffer::Usage usage);
|
---|
| 75 | ~GLDefaultHardwareIndexBuffer();
|
---|
| 76 | /** See HardwareBuffer. */
|
---|
| 77 | void readData(size_t offset, size_t length, void* pDest);
|
---|
| 78 | /** See HardwareBuffer. */
|
---|
| 79 | void writeData(size_t offset, size_t length, const void* pSource,
|
---|
| 80 | bool discardWholeBuffer = false);
|
---|
| 81 | /** Override HardwareBuffer to turn off all shadowing. */
|
---|
| 82 | void* lock(size_t offset, size_t length, LockOptions options);
|
---|
| 83 | /** Override HardwareBuffer to turn off all shadowing. */
|
---|
| 84 | void unlock(void);
|
---|
| 85 |
|
---|
| 86 | void* getDataPtr(size_t offset) const { return (void*)(mpData + offset); }
|
---|
| 87 | };
|
---|
| 88 |
|
---|
| 89 | /** Specialisation of HardwareBufferManager to emulate hardware buffers.
|
---|
| 90 | @remarks
|
---|
| 91 | You might want to instantiate this class if you want to utilise
|
---|
| 92 | classes like MeshSerializer without having initialised the
|
---|
| 93 | rendering system (which is required to create a 'real' hardware
|
---|
| 94 | buffer manager.
|
---|
| 95 | */
|
---|
| 96 | class GLDefaultHardwareBufferManager : public HardwareBufferManager
|
---|
| 97 | {
|
---|
| 98 | public:
|
---|
| 99 | GLDefaultHardwareBufferManager();
|
---|
| 100 | ~GLDefaultHardwareBufferManager();
|
---|
| 101 | /// Creates a vertex buffer
|
---|
| 102 | HardwareVertexBufferSharedPtr
|
---|
| 103 | createVertexBuffer(size_t vertexSize, size_t numVerts,
|
---|
| 104 | HardwareBuffer::Usage usage, bool useShadowBuffer = false);
|
---|
| 105 | /// Create a hardware vertex buffer
|
---|
| 106 | HardwareIndexBufferSharedPtr
|
---|
| 107 | createIndexBuffer(HardwareIndexBuffer::IndexType itype, size_t numIndexes,
|
---|
| 108 | HardwareBuffer::Usage usage, bool useShadowBuffer = false);
|
---|
| 109 |
|
---|
| 110 | };
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | #endif
|
---|