source: OGRE/trunk/ogrenew/OgreMain/src/OgreDefaultHardwareBufferManager.cpp @ 692

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