// 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 SharpDX.Mathematics.Interop;
using System;
using System.Diagnostics;
namespace SharpDX.Direct3D11
{
public partial class EffectVectorVariable
{
private const string VectorInvalidSize = "Invalid Vector size: Must be 16 bytes or 4 x 4 bytes";
///
/// Get a four-component vector that contains integer data.
///
/// Returns a four-component vector that contains integer data
/// HRESULT ID3D11EffectVectorVariable::GetIntVector([Out] int* pData)
public RawInt4 GetIntVector()
{
RawInt4 temp;
GetIntVector(out temp);
return temp;
}
///
/// Get a four-component vector that contains floating-point data.
///
/// Returns a four-component vector that contains floating-point data.
/// HRESULT ID3D11EffectVectorVariable::GetFloatVector([Out] float* pData)
public RawVector4 GetFloatVector()
{
RawVector4 temp;
GetFloatVector(out temp);
return temp;
}
///
/// Get a four-component vector that contains boolean data.
///
/// a four-component vector that contains boolean data.
/// HRESULT ID3D11EffectVectorVariable::GetBoolVector([Out, Buffer] BOOL* pData)
public RawBool4 GetBoolVector()
{
RawBool4 temp;
GetBoolVector(out temp);
return temp;
}
///
/// Get a four-component vector.
///
/// Type of the four-component vector
/// a four-component vector.
/// HRESULT ID3D11EffectVectorVariable::GetFloatVector([Out, Buffer] BOOL* pData)
public unsafe T GetVector() where T : struct
{
T temp;
GetIntVector(out *(RawInt4*)Interop.CastOut(out temp));
return temp;
}
///
/// Set an array of four-component vectors that contain integer data.
///
/// A reference to the start of the data to set.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D11EffectVectorVariable::SetIntVectorArray([In, Buffer] int* pData,[None] int Offset,[None] int Count)
public void Set(RawInt4[] array)
{
Set(array, 0, array.Length);
}
///
/// Set an array of four-component vectors that contain floating-point data.
///
/// A reference to the start of the data to set.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D11EffectVectorVariable::SetFloatVectorArray([In, Buffer] float* pData,[None] int Offset,[None] int Count)
public void Set(RawVector4[] array)
{
Set(array, 0, array.Length);
}
///
/// Set an array of four-component vectors that contain floating-point data.
///
/// Type of the four-component vector
/// A reference to the start of the data to set.
///
/// Returns one of the following {{Direct3D 10 Return Codes}}.
///
/// HRESULT ID3D11EffectVectorVariable::SetFloatVectorArray([In, Buffer] float* pData,[None] int Offset,[None] int Count)
public void Set(T[] array) where T : struct
{
System.Diagnostics.Debug.Assert(Utilities.SizeOf() == 16, VectorInvalidSize);
Set(Interop.CastArray(array), 0, array.Length);
}
///
/// Set a x-component vector.
///
/// A reference to the first component.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D11EffectVectorVariable::SetFloatVector([In] float* pData)
public void Set(T value) where T : struct
{
Set(ref value);
}
///
/// Set a x-component vector.
///
/// A reference to the first component.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D11EffectVectorVariable::SetFloatVector([In] float* pData)
public unsafe void Set(ref T value) where T : struct
{
System.Diagnostics.Debug.Assert(Utilities.SizeOf() <= 16, VectorInvalidSize);
SetRawValue(new IntPtr(Interop.Fixed(ref value)), 0, Utilities.SizeOf());
}
///
/// Set a two-component vector that contains floating-point data.
///
/// A reference to the first component.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D11EffectVectorVariable::SetFloatVector([In] float* pData)
public void Set(RawVector2 value)
{
unsafe
{
SetRawValue(new IntPtr(&value), 0, Utilities.SizeOf());
}
}
///
/// Set a three-component vector that contains floating-point data.
///
/// A reference to the first component.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D11EffectVectorVariable::SetFloatVector([In] float* pData)
public void Set(RawVector3 value)
{
unsafe
{
SetRawValue(new IntPtr(&value), 0, Utilities.SizeOf());
}
}
///
/// Set a four-component color that contains floating-point data.
///
/// A reference to the first component.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D11EffectVectorVariable::SetFloatVector([In] float* pData)
public void Set(RawColor4 value)
{
unsafe
{
SetRawValue(new IntPtr(&value), 0, Utilities.SizeOf());
}
}
///
/// Set an array of four-component color that contain floating-point data.
///
/// A reference to the start of the data to set.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D11EffectVectorVariable::SetFloatVectorArray([In, Buffer] float* pData,[None] int Offset,[None] int Count)
public void Set(RawColor4[] array)
{
unsafe
{
fixed (void* pArray = &array[0]) SetRawValue((IntPtr)pArray, 0, array.Length * Utilities.SizeOf());
}
}
///
/// Get an array of four-component vectors that contain integer data.
///
/// The number of array elements to set.
/// Returns an array of four-component vectors that contain integer data.
/// HRESULT ID3D11EffectVectorVariable::GetIntVectorArray([Out, Buffer] int* pData,[None] int Offset,[None] int Count)
public RawInt4[] GetIntVectorArray(int count)
{
var temp = new RawInt4[count];
GetIntVectorArray(temp, 0, count);
return temp;
}
///
/// Get an array of four-component vectors that contain floating-point data.
///
/// The number of array elements to set.
/// Returns an array of four-component vectors that contain floating-point data.
/// HRESULT ID3D11EffectVectorVariable::GetFloatVectorArray([None] float* pData,[None] int Offset,[None] int Count)
public RawVector4[] GetFloatVectorArray(int count)
{
var temp = new RawVector4[count];
GetFloatVectorArray(temp, 0, count);
return temp;
}
///
/// Get an array of four-component vectors that contain boolean data.
///
/// The number of array elements to set.
/// an array of four-component vectors that contain boolean data.
/// HRESULT ID3D11EffectVectorVariable::GetBoolVectorArray([Out, Buffer] BOOL* pData,[None] int Offset,[None] int Count)
public RawBool4[] GetBoolVectorArray(int count)
{
var temp = new RawBool4[count];
GetBoolVectorArray(temp, 0, count);
return temp;
}
///
/// Get an array of four-component vectors that contain boolean data.
///
/// The number of array elements to set.
/// an array of four-component vectors that contain boolean data.
/// HRESULT ID3D11EffectVectorVariable::GetBoolVectorArray([Out, Buffer] BOOL* pData,[None] int Offset,[None] int Count)
public T[] GetVectorArray(int count) where T : struct
{
var temp = new T[count];
GetIntVectorArray(Interop.CastArray(temp), 0, count);
return temp;
}
}
}