// 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.Diagnostics;
using SharpDX.Mathematics.Interop;
namespace SharpDX.Direct3D10
{
public partial class EffectMatrixVariable
{
private const string MatrixInvalidSize = "Invalid Matrix size: Must be 64 bytes, 16 floats";
///
/// Set a floating-point matrix.
///
/// A pointer to the first element in the matrix.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D10EffectMatrixVariable::SetMatrix([In] float* pData)
public void SetMatrix(T matrix) where T : struct
{
SetMatrix(ref matrix);
}
///
/// Get a matrix.
///
/// A reference to the first element in a matrix.
///
/// Note??The DirectX SDK does not supply any compiled binaries for effects. You must use Effects 11 source to build your effects-type application. For more information about using Effects 11 source, see Differences Between Effects 10 and Effects 11.
///
/// HRESULT ID3DX11EffectMatrixVariable::GetMatrix([Out] SHARPDX_MATRIX* pData)
public unsafe T GetMatrix() where T : struct
{
T value;
GetMatrix(out *(RawMatrix*)Interop.CastOut(out value));
return value;
}
///
/// Get a matrix.
///
/// A reference to the first element in a matrix.
///
/// Note??The DirectX SDK does not supply any compiled binaries for effects. You must use Effects 11 source to build your effects-type application. For more information about using Effects 11 source, see Differences Between Effects 10 and Effects 11.
///
/// HRESULT ID3DX11EffectMatrixVariable::GetMatrix([Out] SHARPDX_MATRIX* pData)
public RawMatrix GetMatrix()
{
RawMatrix value;
GetMatrix(out value);
return value;
}
///
/// Set a floating-point matrix.
///
/// A pointer to the first element in the matrix.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D10EffectMatrixVariable::SetMatrix([In] float* pData)
public unsafe void SetMatrix(ref T matrix) where T : struct
{
if (Utilities.SizeOf() != 64)
throw new ArgumentException(MatrixInvalidSize, "matrix");
SetMatrix(ref *(RawMatrix*)Interop.Fixed(ref matrix));
}
///
/// Set an array of floating-point matrices.
///
/// A pointer to the first matrix.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D10EffectMatrixVariable::SetMatrixArray([In, Buffer] float* pData,[None] int Offset,[None] int Count)
public void SetMatrix(T[] matrixArray) where T : struct
{
SetMatrix(matrixArray, 0);
}
///
/// Set an array of floating-point matrices.
///
/// A pointer to the first matrix.
/// The number of matrix elements to skip from the start of the array.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D10EffectMatrixVariable::SetMatrixArray([In, Buffer] float* pData,[None] int Offset,[None] int Count)
public void SetMatrix(T[] matrixArray, int offset) where T : struct
{
if (Utilities.SizeOf() != 64)
throw new ArgumentException(MatrixInvalidSize, "matrixArray");
SetMatrixArray(Interop.CastArray(matrixArray), offset, matrixArray.Length);
}
///
/// Get an array of matrices.
///
/// The number of matrices in the returned array.
/// Returns an array of matrix.
/// HRESULT ID3D10EffectMatrixVariable::GetMatrixArray([Out, Buffer] float* pData,[None] int Offset,[None] int Count)
public T[] GetMatrixArray(int count) where T : struct
{
return GetMatrixArray(0, count);
}
///
/// Get an array of matrices.
///
/// The offset (in number of matrices) between the start of the array and the first matrix returned.
/// The number of matrices in the returned array.
/// Returns an array of matrix.
/// HRESULT ID3D10EffectMatrixVariable::GetMatrixArray([Out, Buffer] float* pData,[None] int Offset,[None] int Count)
public T[] GetMatrixArray(int offset, int count) where T : struct
{
var temp = new T[count];
GetMatrixArray(Interop.CastArray(temp), offset, count);
return temp;
}
///
/// Transpose and set a floating-point matrix.
///
///
/// Transposing a matrix will rearrange the data order from row-column order to column-row order (or vice versa).
///
/// A pointer to the first element of a matrix.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D10EffectMatrixVariable::SetMatrixTranspose([In] float* pData)
public void SetMatrixTranspose(T matrix) where T : struct
{
SetMatrixTranspose(ref matrix);
}
///
/// Transpose and set a floating-point matrix.
///
///
/// Transposing a matrix will rearrange the data order from row-column order to column-row order (or vice versa).
///
/// A pointer to the first element of a matrix.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D10EffectMatrixVariable::SetMatrixTranspose([In] float* pData)
public unsafe void SetMatrixTranspose(ref T matrix) where T : struct
{
if (Utilities.SizeOf() != 64)
throw new ArgumentException(MatrixInvalidSize, "matrix");
SetMatrixTranspose(ref *(RawMatrix*)Interop.Cast(ref matrix));
}
///
/// Transpose and set an array of floating-point matrices.
///
///
/// Transposing a matrix will rearrange the data order from row-column order to column-row order (or vice versa).
///
/// A pointer to an array of matrices.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D10EffectMatrixVariable::SetMatrixTransposeArray([In] float* pData,[None] int Offset,[None] int Count)
public void SetMatrixTranspose(T[] matrixArray) where T : struct
{
SetMatrixTranspose(matrixArray, 0);
}
///
/// Transpose and set an array of floating-point matrices.
///
///
/// Transposing a matrix will rearrange the data order from row-column order to column-row order (or vice versa).
///
/// A pointer to an array of matrices.
/// The offset (in number of matrices) between the start of the array and the first matrix to set.
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// HRESULT ID3D10EffectMatrixVariable::SetMatrixTransposeArray([In] float* pData,[None] int Offset,[None] int Count)
public void SetMatrixTranspose(T[] matrixArray, int offset) where T : struct
{
SetMatrixTransposeArray(Interop.CastArray(matrixArray), offset, matrixArray.Length);
}
///
/// Transpose and get a floating-point matrix.
///
/// The transposed matrix.
///
/// Transposing a matrix will rearrange the data order from row-column order to column-row order (or vice versa).Note??The DirectX SDK does not supply any compiled binaries for effects. You must use Effects 11 source to build your effects-type application. For more information about using Effects 11 source, see Differences Between Effects 10 and Effects 11.
///
/// HRESULT ID3DX11EffectMatrixVariable::GetMatrixTranspose([Out] SHARPDX_MATRIX* pData)
public unsafe T GetMatrixTranspose() where T : struct
{
T value;
GetMatrixTranspose(out *(RawMatrix*)Interop.CastOut(out value));
return value;
}
///
/// Transpose and get a floating-point matrix.
///
/// The transposed matrix.
///
/// Transposing a matrix will rearrange the data order from row-column order to column-row order (or vice versa).Note??The DirectX SDK does not supply any compiled binaries for effects. You must use Effects 11 source to build your effects-type application. For more information about using Effects 11 source, see Differences Between Effects 10 and Effects 11.
///
/// HRESULT ID3DX11EffectMatrixVariable::GetMatrixTranspose([Out] SHARPDX_MATRIX* pData)
public RawMatrix GetMatrixTranspose()
{
RawMatrix value;
GetMatrixTranspose(out value);
return value;
}
///
/// Transpose and get an array of floating-point matrices.
///
///
/// Transposing a matrix will rearrange the data order from row-column order to column-row order (or vice versa).
///
/// The number of matrices in the array to get.
/// Returns an array of transposed .
/// HRESULT ID3D10EffectMatrixVariable::GetMatrixTransposeArray([Out, Buffer] float* pData,[None] int Offset,[None] int Count)
public T[] GetMatrixTransposeArray(int count) where T : struct
{
return GetMatrixTransposeArray(0, count);
}
///
/// Transpose and get an array of floating-point matrices.
///
///
/// Transposing a matrix will rearrange the data order from row-column order to column-row order (or vice versa).
///
/// The offset (in number of matrices) between the start of the array and the first matrix to get.
/// The number of matrices in the array to get.
/// Returns an array of transposed .
/// HRESULT ID3D10EffectMatrixVariable::GetMatrixTransposeArray([Out, Buffer] float* pData,[None] int Offset,[None] int Count)
public T[] GetMatrixTransposeArray(int offset, int count) where T : struct
{
var temp = new T[count];
GetMatrixTransposeArray(Interop.CastArray(temp), offset, count);
return temp;
}
}
}