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