source: OGRE/trunk/ogrenew/RenderSystems/GL/src/OgreGLDefaultHardwareBufferManager.cpp @ 692

Revision 692, 6.3 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#include "OgreGLDefaultHardwareBufferManager.h"
26
27namespace Ogre {
28
29        GLDefaultHardwareVertexBuffer::GLDefaultHardwareVertexBuffer(size_t vertexSize, size_t numVertices,
30                HardwareBuffer::Usage usage)
31        : HardwareVertexBuffer(vertexSize, numVertices, usage, true, false) // always software, never shadowed
32        {
33                mpData = new unsigned char[mSizeInBytes];
34        }
35        //-----------------------------------------------------------------------
36    GLDefaultHardwareVertexBuffer::~GLDefaultHardwareVertexBuffer()
37        {
38                delete [] mpData;
39        }
40        //-----------------------------------------------------------------------
41    void* GLDefaultHardwareVertexBuffer::lockImpl(size_t offset, size_t length, LockOptions options)
42        {
43        // Only for use internally, no 'locking' as such
44                return mpData + offset;
45        }
46        //-----------------------------------------------------------------------
47        void GLDefaultHardwareVertexBuffer::unlockImpl(void)
48        {
49        // Nothing to do
50        }
51        //-----------------------------------------------------------------------
52    void* GLDefaultHardwareVertexBuffer::lock(size_t offset, size_t length, LockOptions options)
53        {
54        mIsLocked = true;
55                return mpData + offset;
56        }
57        //-----------------------------------------------------------------------
58        void GLDefaultHardwareVertexBuffer::unlock(void)
59        {
60        mIsLocked = false;
61        // Nothing to do
62        }
63        //-----------------------------------------------------------------------
64    void GLDefaultHardwareVertexBuffer::readData(size_t offset, size_t length, void* pDest)
65        {
66                assert((offset + length) <= mSizeInBytes);
67                memcpy(pDest, mpData + offset, length);
68        }
69        //-----------------------------------------------------------------------
70    void GLDefaultHardwareVertexBuffer::writeData(size_t offset, size_t length, const void* pSource,
71                        bool discardWholeBuffer)
72        {
73                assert((offset + length) <= mSizeInBytes);
74                // ignore discard, memory is not guaranteed to be zeroised
75                memcpy(mpData + offset, pSource, length);
76
77        }
78        //-----------------------------------------------------------------------
79
80        GLDefaultHardwareIndexBuffer::GLDefaultHardwareIndexBuffer(IndexType idxType,
81                size_t numIndexes, HardwareBuffer::Usage usage)
82                : HardwareIndexBuffer(idxType, numIndexes, usage, true, false) // always software, never shadowed
83        {
84                mpData = new unsigned char[mSizeInBytes];
85        }
86        //-----------------------------------------------------------------------
87    GLDefaultHardwareIndexBuffer::~GLDefaultHardwareIndexBuffer()
88        {
89                delete [] mpData;
90        }
91        //-----------------------------------------------------------------------
92    void* GLDefaultHardwareIndexBuffer::lockImpl(size_t offset, size_t length, LockOptions options)
93        {
94        // Only for use internally, no 'locking' as such
95                return mpData + offset;
96        }
97        //-----------------------------------------------------------------------
98        void GLDefaultHardwareIndexBuffer::unlockImpl(void)
99        {
100        // Nothing to do
101        }
102        //-----------------------------------------------------------------------
103    void* GLDefaultHardwareIndexBuffer::lock(size_t offset, size_t length, LockOptions options)
104        {
105        mIsLocked = true;
106                return mpData + offset;
107        }
108        //-----------------------------------------------------------------------
109        void GLDefaultHardwareIndexBuffer::unlock(void)
110        {
111        mIsLocked = false;
112        // Nothing to do
113        }
114        //-----------------------------------------------------------------------
115    void GLDefaultHardwareIndexBuffer::readData(size_t offset, size_t length, void* pDest)
116        {
117                assert((offset + length) <= mSizeInBytes);
118                memcpy(pDest, mpData + offset, length);
119        }
120        //-----------------------------------------------------------------------
121    void GLDefaultHardwareIndexBuffer::writeData(size_t offset, size_t length, const void* pSource,
122                        bool discardWholeBuffer)
123        {
124                assert((offset + length) <= mSizeInBytes);
125                // ignore discard, memory is not guaranteed to be zeroised
126                memcpy(mpData + offset, pSource, length);
127
128        }
129        //-----------------------------------------------------------------------
130       
131       
132    //-----------------------------------------------------------------------
133    GLDefaultHardwareBufferManager::GLDefaultHardwareBufferManager()
134        {
135        }
136    //-----------------------------------------------------------------------
137    GLDefaultHardwareBufferManager::~GLDefaultHardwareBufferManager()
138        {
139        destroyAllDeclarations();
140        destroyAllBindings();
141        }
142    //-----------------------------------------------------------------------
143        HardwareVertexBufferSharedPtr
144        GLDefaultHardwareBufferManager::createVertexBuffer(size_t vertexSize,
145                size_t numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer)
146        {
147                return HardwareVertexBufferSharedPtr(
148                        new GLDefaultHardwareVertexBuffer(vertexSize, numVerts, usage));
149        }
150    //-----------------------------------------------------------------------
151        HardwareIndexBufferSharedPtr
152        GLDefaultHardwareBufferManager::createIndexBuffer(HardwareIndexBuffer::IndexType itype,
153                size_t numIndexes, HardwareBuffer::Usage usage, bool useShadowBuffer)
154        {
155                return HardwareIndexBufferSharedPtr(
156                        new GLDefaultHardwareIndexBuffer(itype, numIndexes, usage) );
157        }
158}
Note: See TracBrowser for help on using the repository browser.