OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreD3D9HardwareVertexBuffer.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __D3D9HARDWAREVERTEXBUFFER_H__
29 #define __D3D9HARDWAREVERTEXBUFFER_H__
30 
31 #include "OgreD3D9Prerequisites.h"
33 #include "OgreD3D9Resource.h"
34 
35 namespace Ogre {
36 
39  {
40 
41  public:
42  D3D9HardwareVertexBuffer(HardwareBufferManagerBase* mgr, size_t vertexSize,
43  size_t numVertices, HardwareBuffer::Usage usage, bool useSystemMem, bool useShadowBuffer);
46  void readData(size_t offset, size_t length, void* pDest);
48  void writeData(size_t offset, size_t length, const void* pSource,
49  bool discardWholeBuffer = false);
50 
51  // Called immediately after the Direct3D device has been created.
52  virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
53 
54  // Called before the Direct3D device is going to be destroyed.
55  virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
56 
57  // Called immediately after the Direct3D device has entered a lost state.
58  virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
59 
60  // Called immediately after the Direct3D device has been reset
61  virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
62 
63  // Create the actual vertex buffer.
64  void createBuffer(IDirect3DDevice9* d3d9Device, D3DPOOL ePool);
65 
67  IDirect3DVertexBuffer9* getD3D9VertexBuffer(void);
68 
69  protected:
71  {
72  IDirect3DVertexBuffer9* mBuffer;
73  bool mOutOfDate;
74  size_t mLockOffset;
75  size_t mLockLength;
78  };
79 
80  protected:
82  void* lockImpl(size_t offset, size_t length, LockOptions options);
83 
85  void unlockImpl(void);
86 
88  void updateBufferContent(BufferResources* bufferResources);
89 
90  // updates buffer resources from system memory buffer.
91  bool updateBufferResources(const char* systemMemoryBuffer, BufferResources* bufferResources);
92 
94  char* _lockBuffer(BufferResources* bufferResources, size_t offset, size_t length);
95 
97  void _unlockBuffer(BufferResources* bufferResources);
98 
99 
100  protected:
102  typedef DeviceToBufferResourcesMap::iterator DeviceToBufferResourcesIterator;
103 
104  DeviceToBufferResourcesMap mMapDeviceToBufferResources; // Map between device to buffer resources.
105  D3DVERTEXBUFFER_DESC mBufferDesc; // Buffer description.
106  BufferResources* mSourceBuffer; // Source buffer resources when working with multiple devices.
107  char* mSourceLockedBytes; // Source buffer locked bytes.
108  };
109 }
110 #endif
111 
DeviceToBufferResourcesMap::iterator DeviceToBufferResourcesIterator
LockOptions
Locking options.
DeviceToBufferResourcesMap mMapDeviceToBufferResources
Specialisation of HardwareVertexBuffer for D3D9.
map< IDirect3DDevice9 *, BufferResources * >::type DeviceToBufferResourcesMap
#define _OgreD3D9Export
Base definition of a hardware buffer manager.
Usage
Enums describing buffer usage; not mutually exclusive.
Specialisation of HardwareBuffer for a vertex buffer.
unsigned int uint
Represents a Direct3D rendering resource.