// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; namespace SharpDX.Direct3D9 { public partial class IndexBuffer { /// /// Initializes a new instance of the class. /// /// The device. /// The size in bytes. /// The usage. /// The pool. /// if set to true use 16bit index buffer, otherwise, use 32bit index buffer. /// bb174357 /// HRESULT IDirect3DDevice9::CreateIndexBuffer([In] unsigned int Length,[In] unsigned int Usage,[In] D3DFORMAT Format,[In] D3DPOOL Pool,[Out, Fast] IDirect3DIndexBuffer9** ppIndexBuffer,[In] void** pSharedHandle) /// IDirect3DDevice9::CreateIndexBuffer public IndexBuffer(Device device, int sizeInBytes, Usage usage, Pool pool, bool sixteenBit) : base(IntPtr.Zero) { device.CreateIndexBuffer(sizeInBytes, (int)usage, sixteenBit ? Format.Index16 : Format.Index32, pool, this, IntPtr.Zero); } /// /// Initializes a new instance of the class. /// /// The device. /// The size in bytes. /// The usage. /// The pool. /// if set to true use 16bit index buffer, otherwise, use 32bit index buffer. /// The shared handle. /// bb174357 /// HRESULT IDirect3DDevice9::CreateIndexBuffer([In] unsigned int Length,[In] unsigned int Usage,[In] D3DFORMAT Format,[In] D3DPOOL Pool,[Out, Fast] IDirect3DIndexBuffer9** ppIndexBuffer,[In] void** pSharedHandle) /// IDirect3DDevice9::CreateIndexBuffer public IndexBuffer(Device device, int sizeInBytes, Usage usage, Pool pool, bool sixteenBit, ref IntPtr sharedHandle) : base(IntPtr.Zero) { unsafe { fixed (void* pSharedHandle = &sharedHandle) device.CreateIndexBuffer(sizeInBytes, (int)usage, sixteenBit ? Format.Index16 : Format.Index32, pool, this, (IntPtr)pSharedHandle); } } /// /// Locks the specified index buffer. /// /// The offset in the buffer. /// The size of the buffer to lock. /// The lock flags. /// A containing the locked index buffer. /// bb205867 /// HRESULT IDirect3DIndexBuffer9::Lock([In] unsigned int OffsetToLock,[In] unsigned int SizeToLock,[Out] void** ppbData,[In] D3DLOCK Flags) /// IDirect3DIndexBuffer9::Lock public SharpDX.DataStream Lock(int offsetToLock, int sizeToLock, LockFlags lockFlags) { IntPtr pOut; if (sizeToLock == 0) sizeToLock = Description.Size; Lock(offsetToLock, sizeToLock, out pOut, lockFlags); return new DataStream(pOut, sizeToLock, true, (lockFlags & LockFlags.ReadOnly) == 0); } /// /// Locks the specified index buffer. /// /// The offset in the buffer. /// The size of the buffer to lock. /// The lock flags. /// A containing the locked index buffer. /// bb205867 /// HRESULT IDirect3DIndexBuffer9::Lock([In] unsigned int OffsetToLock,[In] unsigned int SizeToLock,[Out] void** ppbData,[In] D3DLOCK Flags) /// IDirect3DIndexBuffer9::Lock public IntPtr LockToPointer(int offsetToLock, int sizeToLock, LockFlags lockFlags) { IntPtr pOut; if (sizeToLock == 0) sizeToLock = Description.Size; Lock(offsetToLock, sizeToLock, out pOut, lockFlags); return pOut; } } }