source: OGRE/trunk/ogrenew/RenderSystems/GL/include/OgreGLDefaultHardwareBufferManager.h @ 692

Revision 692, 4.5 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

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 __GLDefaultHardwareBufferManager_H__
27#define __GLDefaultHardwareBufferManager_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 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
Note: See TracBrowser for help on using the repository browser.