OgreD3D9HardwareIndexBuffer.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-2013 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 __D3D9HARDWAREINDEXBUFFER_H__
29 #define __D3D9HARDWAREINDEXBUFFER_H__
30 
31 #include "OgreD3D9Prerequisites.h"
33 #include "OgreD3D9Resource.h"
34 
35 namespace Ogre {
36 
37 
39  {
40 
41  public:
42  D3D9HardwareIndexBuffer(HardwareBufferManagerBase* mgr, IndexType idxType, size_t numIndexes,
43  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 index buffer.
64  void createBuffer(IDirect3DDevice9* d3d9Device, D3DPOOL ePool);
65 
67  IDirect3DIndexBuffer9* getD3DIndexBuffer(void);
68 
69  protected:
71  {
72  IDirect3DIndexBuffer9* 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  protected:
101  typedef DeviceToBufferResourcesMap::iterator DeviceToBufferResourcesIterator;
102 
103  DeviceToBufferResourcesMap mMapDeviceToBufferResources; // Map between device to buffer resources.
104  D3DINDEXBUFFER_DESC mBufferDesc; // Buffer description.
105  BufferResources* mSourceBuffer; // Source buffer resources when working with multiple devices.
106  char* mSourceLockedBytes; // Source buffer locked bytes.
107  };
108 }
109 #endif
110 
unsigned int uint
Specialisation of HardwareBuffer for vertex index buffers, still abstract.
#define _OgreD3D9Export
DeviceToBufferResourcesMap::iterator DeviceToBufferResourcesIterator
Base definition of a hardware buffer manager.
map< IDirect3DDevice9 *, BufferResources * >::type DeviceToBufferResourcesMap
DeviceToBufferResourcesMap mMapDeviceToBufferResources
Usage
Enums describing buffer usage; not mutually exclusive.
LockOptions
Locking options.
This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info...
Represents a Direct3D rendering resource.

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Oct 22 2017 04:04:15