public void CreateBuffer(D3D9.Device d3d9Device, D3D9.Pool ePool) { // Find the vertex buffer of this device. BufferResources bufferResources; if (this._mapDeviceToBufferResources.TryGetValue(d3d9Device, out bufferResources)) { bufferResources.VertexBuffer.SafeDispose(); } else { bufferResources = new BufferResources(); this._mapDeviceToBufferResources.Add(d3d9Device, bufferResources); } bufferResources.VertexBuffer = null; bufferResources.IsOutOfDate = true; bufferResources.LockOffset = 0; bufferResources.LockLength = sizeInBytes; bufferResources.LockOptions = BufferLocking.Normal; bufferResources.LastUsedFrame = Root.Instance.NextFrameNumber; // Create the vertex buffer try { bufferResources.VertexBuffer = new D3D9.VertexBuffer(d3d9Device, sizeInBytes, D3D9Helper.ConvertEnum(usage), 0, ePool); } catch (Exception ex) { throw new AxiomException("Cannot restore D3D9 vertex buffer", ex); } this._bufferDesc = bufferResources.VertexBuffer.Description; }
public void CreateBuffer( D3D9.Device d3d9Device, D3D9.Pool ePool ) { // Find the vertex buffer of this device. BufferResources bufferResources; if ( this._mapDeviceToBufferResources.TryGetValue( d3d9Device, out bufferResources ) ) { bufferResources.VertexBuffer.SafeDispose(); } else { bufferResources = new BufferResources(); this._mapDeviceToBufferResources.Add( d3d9Device, bufferResources ); } bufferResources.VertexBuffer = null; bufferResources.IsOutOfDate = true; bufferResources.LockOffset = 0; bufferResources.LockLength = sizeInBytes; bufferResources.LockOptions = BufferLocking.Normal; bufferResources.LastUsedFrame = Root.Instance.NextFrameNumber; // Create the vertex buffer try { bufferResources.VertexBuffer = new D3D9.VertexBuffer( d3d9Device, sizeInBytes, D3D9Helper.ConvertEnum( usage ), 0, ePool ); } catch ( Exception ex ) { throw new AxiomException( "Cannot restore D3D9 vertex buffer", ex ); } this._bufferDesc = bufferResources.VertexBuffer.Description; }