// 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; using SharpDX.Mathematics.Interop; namespace SharpDX.Direct3D9 { public partial class ConstantTable { /// /// Gets the buffer. /// public DataStream Buffer { get { return new DataStream(BufferPointer, BufferSize, true, true); } } /// /// Gets a single constant description in the constant table. /// /// The effect handle. /// The constant description /// HRESULT ID3DXConstantTable::GetConstantDesc([In] D3DXHANDLE hConstant,[Out, Buffer] D3DXCONSTANT_DESC* pConstantDesc,[InOut] unsigned int* pCount) public ConstantDescription GetConstantDescription(SharpDX.Direct3D9.EffectHandle effectHandle) { int count = 1; var descriptions = new ConstantDescription[1]; GetConstantDescription(effectHandle, descriptions, ref count); return descriptions[0]; } /// /// Gets an array of constant descriptions in the constant table. /// /// The effect handle. /// An array of constant descriptions /// HRESULT ID3DXConstantTable::GetConstantDesc([In] D3DXHANDLE hConstant,[Out, Buffer] D3DXCONSTANT_DESC* pConstantDesc,[InOut] unsigned int* pCount) public ConstantDescription[] GetConstantDescriptionArray(SharpDX.Direct3D9.EffectHandle effectHandle) { int count = 0; GetConstantDescription(effectHandle, null, ref count); var descriptions = new ConstantDescription[count]; GetConstantDescription(effectHandle, descriptions, ref count); return descriptions; } /// /// Sets a bool value. /// /// The device. /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXConstantTable::SetBool([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] BOOL b) public void SetValue(Device device, EffectHandle effectHandle, bool value) { SetBool(device, effectHandle, value); } /// /// Sets a float value. /// /// The device. /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXConstantTable::SetFloat([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] float f) public void SetValue(Device device, EffectHandle effectHandle, float value) { SetFloat(device, effectHandle, value); } /// /// Sets an int value. /// /// The device. /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXConstantTable::SetInt([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] int n) public void SetValue(Device device, EffectHandle effectHandle, int value) { SetInt(device, effectHandle, value); } /// /// Sets a matrix. /// /// The device. /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXConstantTable::SetMatrix([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] const D3DXMATRIX* pMatrix) public void SetValue(Device device, EffectHandle effectHandle, RawMatrix value) { SetMatrix(device, effectHandle, ref value); } /// /// Sets a 4D vector. /// /// The device. /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXConstantTable::SetVector([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] const D3DXVECTOR4* pVector) public void SetValue(Device device, EffectHandle effectHandle, RawVector4 value) { SetVector(device, effectHandle, value); } /// /// Sets a typed value. /// /// Type of the value to set /// The device. /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXConstantTable::SetValue([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] const void* pData,[In] unsigned int Bytes) public void SetValue(Device device, EffectHandle effectHandle, T value) where T : struct { unsafe { SetValue(device, effectHandle, (IntPtr)Interop.Fixed(ref value), Utilities.SizeOf()); } } /// /// Sets an array of bools. /// /// The device. /// The effect handle. /// The values. /// A object describing the result of the operation. /// HRESULT ID3DXConstantTable::SetBoolArray([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In, Buffer] const BOOL* pb,[In] unsigned int Count) public void SetValue(Device device, EffectHandle effectHandle, bool[] values) { var tempArray = Utilities.ConvertToIntArray(values); SetBoolArray(device, effectHandle, tempArray, values.Length); } /// /// Sets an array of floats. /// /// The device. /// The effect handle. /// The values. /// A object describing the result of the operation. /// HRESULT ID3DXConstantTable::SetFloatArray([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In, Buffer] const float* pf,[In] unsigned int Count) public void SetValue(Device device, EffectHandle effectHandle, float[] values) { SetFloatArray(device, effectHandle, values, values.Length); } /// /// Sets an array of ints. /// /// The device. /// The effect handle. /// The values. /// A object describing the result of the operation. /// HRESULT ID3DXConstantTable::SetIntArray([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In, Buffer] const int* pn,[In] unsigned int Count) public void SetValue(Device device, EffectHandle effectHandle, int[] values) { SetIntArray(device, effectHandle, values, values.Length); } /// /// Sets an array of matrices. /// /// The device. /// The effect handle. /// The values. /// A object describing the result of the operation. /// HRESULT ID3DXConstantTable::SetMatrixArray([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In, Buffer] const D3DXMATRIX* pMatrix,[In] unsigned int Count) public void SetValue(Device device, EffectHandle effectHandle, RawMatrix[] values) { SetMatrixArray(device, effectHandle, values, values.Length); } /// /// Sets an array of 4D vectors. /// /// The device. /// The effect handle. /// The values. /// A object describing the result of the operation. /// HRESULT ID3DXConstantTable::SetVectorArray([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In, Buffer] const D3DXVECTOR4* pVector,[In] unsigned int Count) public void SetValue(Device device, EffectHandle effectHandle, RawVector4[] values) { SetVectorArray(device, effectHandle, values, values.Length); } /// /// Sets an array of elements. /// /// Type of the array element /// The device. /// The effect handle. /// The values. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXConstantTable::SetValue([In] IDirect3DDevice9* pDevice,[In] D3DXHANDLE hConstant,[In] const void* pData,[In] unsigned int Bytes) public void SetValue(Device device, EffectHandle effectHandle, T[] values) where T : struct { unsafe { SetValue(device, effectHandle, (IntPtr)Interop.Fixed(values), Utilities.SizeOf() * values.Length); } } } }