// 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 System.Runtime.InteropServices; using SharpDX.Mathematics.Interop; namespace SharpDX.Direct3D9 { public partial class BaseEffect { /// /// Gets the string. /// /// The parameter. /// /// HRESULT ID3DXBaseEffect::GetString([In] D3DXHANDLE hParameter,[Out] const void** ppString) public string GetString(EffectHandle parameter) { return Marshal.PtrToStringAnsi(GetString_(parameter)); } /// /// Gets the value of the specified parameter. /// /// Handle of the parameter. /// The value of the parameter. /// HRESULT ID3DXBaseEffect::GetValue([In] D3DXHANDLE hParameter,[In] void* pData,[In] unsigned int Bytes) public T GetValue(EffectHandle parameter) where T : struct { unsafe { var value = default(T); GetValue(parameter, (IntPtr)Interop.Fixed(ref value), Utilities.SizeOf()); return value; } } /// /// Gets the value of the specified parameter. /// /// /// Handle of the parameter. /// The count. /// /// The value of the parameter. /// /// HRESULT ID3DXBaseEffect::GetValue([In] D3DXHANDLE hParameter,[In] void* pData,[In] unsigned int Bytes) public T[] GetValue(EffectHandle parameter, int count) where T : struct { unsafe { var value = new T[count]; GetValue(parameter, (IntPtr)Interop.Fixed(value), Utilities.SizeOf()); return value; } } /// /// Sets a bool value. /// /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetBool([In] D3DXHANDLE hConstant,[In] BOOL b) public void SetValue(EffectHandle effectHandle, bool value) { SetBool(effectHandle, value); } /// /// Sets a float value. /// /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetFloat([In] D3DXHANDLE hConstant,[In] float f) public void SetValue(EffectHandle effectHandle, float value) { SetFloat(effectHandle, value); } /// /// Sets an int value. /// /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetInt([In] D3DXHANDLE hConstant,[In] int n) public void SetValue(EffectHandle effectHandle, int value) { SetInt(effectHandle, value); } /// /// Sets a matrix. /// /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetMatrix([In] D3DXHANDLE hConstant,[In] const D3DXMATRIX* pMatrix) public void SetValue(EffectHandle effectHandle, RawMatrix value) { SetMatrix(effectHandle, ref value); } /// /// Sets a 4D vector. /// /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetVector([In] D3DXHANDLE hConstant,[In] const D3DXVECTOR4* pVector) public void SetValue(EffectHandle effectHandle, RawVector4 value) { SetVector(effectHandle, value); } /// /// Sets a typed value. /// /// Type of the value to set /// The effect handle. /// The value. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetValue([In] D3DXHANDLE hConstant,[In] const void* pData,[In] unsigned int Bytes) public void SetValue(EffectHandle effectHandle, T value) where T : struct { unsafe { SetValue(effectHandle, (IntPtr)Interop.Fixed(ref value), Utilities.SizeOf()); } } /// /// Sets an array of bools. /// /// The effect handle. /// The values. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetBoolArray([In] D3DXHANDLE hConstant,[In, Buffer] const BOOL* pb,[In] unsigned int Count) public void SetValue(EffectHandle effectHandle, bool[] values) { var tempArray = Utilities.ConvertToIntArray(values); SetBoolArray(effectHandle, tempArray, values.Length); } /// /// Sets an array of floats. /// /// The effect handle. /// The values. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetFloatArray([In] D3DXHANDLE hConstant,[In, Buffer] const float* pf,[In] unsigned int Count) public void SetValue(EffectHandle effectHandle, float[] values) { SetFloatArray(effectHandle, values, values.Length); } /// /// Sets an array of ints. /// /// The effect handle. /// The values. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetIntArray([In] D3DXHANDLE hConstant,[In, Buffer] const int* pn,[In] unsigned int Count) public void SetValue(EffectHandle effectHandle, int[] values) { SetIntArray(effectHandle, values, values.Length); } /// /// Sets an array of matrices. /// /// The effect handle. /// The values. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetMatrixArray([In] D3DXHANDLE hConstant,[In, Buffer] const D3DXMATRIX* pMatrix,[In] unsigned int Count) public void SetValue(EffectHandle effectHandle, RawMatrix[] values) { SetMatrixArray(effectHandle, values, values.Length); } /// /// Sets an array of 4D vectors. /// /// The effect handle. /// The values. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetVectorArray([In] D3DXHANDLE hConstant,[In, Buffer] const D3DXVECTOR4* pVector,[In] unsigned int Count) public void SetValue(EffectHandle effectHandle, RawVector4[] values) { SetVectorArray(effectHandle, values, values.Length); } /// /// Sets an array of elements. /// /// Type of the array element /// The effect handle. /// The values. /// /// A object describing the result of the operation. /// /// HRESULT ID3DXBaseEffect::SetValue([In] D3DXHANDLE hConstant,[In] const void* pData,[In] unsigned int Bytes) public void SetValue(EffectHandle effectHandle, T[] values) where T : struct { unsafe { SetValue(effectHandle, (IntPtr)Interop.Fixed(values), Utilities.SizeOf() * values.Length); } } } }