source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreDefaultHardwareBufferManager.h @ 1812

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