Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/RenderSystems/GL/include/OgreGLDefaultHardwareBufferManager.h @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

File size: 4.6 KB
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-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29
30#ifndef __GLDefaultHardwareBufferManager_H__
31#define __GLDefaultHardwareBufferManager_H__
32
33#include "OgrePrerequisites.h"
34#include "OgreHardwareBufferManager.h"
35#include "OgreHardwareVertexBuffer.h"
36#include "OgreHardwareIndexBuffer.h"
37
38namespace Ogre {
39
40    /// Specialisation of HardwareVertexBuffer for emulation
41    class _OgrePrivate GLDefaultHardwareVertexBuffer : public HardwareVertexBuffer
42    {
43        protected:
44                unsigned char* mpData;
45        /** See HardwareBuffer. */
46        void* lockImpl(size_t offset, size_t length, LockOptions options);
47        /** See HardwareBuffer. */
48                void unlockImpl(void);
49
50    public:
51                GLDefaultHardwareVertexBuffer(size_t vertexSize, size_t numVertices, 
52            HardwareBuffer::Usage usage);
53        ~GLDefaultHardwareVertexBuffer();
54        /** See HardwareBuffer. */
55        void readData(size_t offset, size_t length, void* pDest);
56        /** See HardwareBuffer. */
57        void writeData(size_t offset, size_t length, const void* pSource,
58                                bool discardWholeBuffer = false);
59        /** Override HardwareBuffer to turn off all shadowing. */
60        void* lock(size_t offset, size_t length, LockOptions options);
61        /** Override HardwareBuffer to turn off all shadowing. */
62                void unlock(void);
63
64        //void* getDataPtr(void) const { return (void*)mpData; }
65        void* getDataPtr(size_t offset) const { return (void*)(mpData + offset); }
66    };
67
68        /// Specialisation of HardwareIndexBuffer for emulation
69    class _OgrePrivate GLDefaultHardwareIndexBuffer : public HardwareIndexBuffer
70    {
71        protected:
72                unsigned char* mpData;
73        /** See HardwareBuffer. */
74        void* lockImpl(size_t offset, size_t length, LockOptions options);
75        /** See HardwareBuffer. */
76                void unlockImpl(void);
77    public:
78                GLDefaultHardwareIndexBuffer(IndexType idxType, size_t numIndexes, HardwareBuffer::Usage usage);
79        ~GLDefaultHardwareIndexBuffer();
80        /** See HardwareBuffer. */
81        void readData(size_t offset, size_t length, void* pDest);
82        /** See HardwareBuffer. */
83        void writeData(size_t offset, size_t length, const void* pSource,
84                                bool discardWholeBuffer = false);
85        /** Override HardwareBuffer to turn off all shadowing. */
86        void* lock(size_t offset, size_t length, LockOptions options);
87        /** Override HardwareBuffer to turn off all shadowing. */
88                void unlock(void);
89
90        void* getDataPtr(size_t offset) const { return (void*)(mpData + offset); }
91    };
92
93        /** Specialisation of HardwareBufferManager to emulate hardware buffers.
94        @remarks
95                You might want to instantiate this class if you want to utilise
96                classes like MeshSerializer without having initialised the
97                rendering system (which is required to create a 'real' hardware
98                buffer manager.
99        */
100        class _OgrePrivate GLDefaultHardwareBufferManager : public HardwareBufferManager
101        {
102    public:
103        GLDefaultHardwareBufferManager();
104        ~GLDefaultHardwareBufferManager();
105        /// Creates a vertex buffer
106                HardwareVertexBufferSharedPtr
107            createVertexBuffer(size_t vertexSize, size_t numVerts, 
108                                HardwareBuffer::Usage usage, bool useShadowBuffer = false);
109                /// Create a hardware vertex buffer
110                HardwareIndexBufferSharedPtr
111            createIndexBuffer(HardwareIndexBuffer::IndexType itype, size_t numIndexes, 
112                                HardwareBuffer::Usage usage, bool useShadowBuffer = false);
113
114    };
115
116
117}
118
119#endif
Note: See TracBrowser for help on using the repository browser.