This repository was archived by the owner on Mar 30, 2019. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathEffectVectorVariable.cs
More file actions
249 lines (229 loc) · 11.2 KB
/
Copy pathEffectVectorVariable.cs
File metadata and controls
249 lines (229 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
// 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";
/// <summary>
/// Get a four-component vector that contains integer data.
/// </summary>
/// <returns>Returns a four-component vector that contains integer data </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::GetIntVector([Out] int* pData)</unmanaged>
public RawInt4 GetIntVector()
{
RawInt4 temp;
GetIntVector(out temp);
return temp;
}
/// <summary>
/// Get a four-component vector that contains floating-point data.
/// </summary>
/// <returns>Returns a four-component vector that contains floating-point data.</returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::GetFloatVector([Out] float* pData)</unmanaged>
public RawVector4 GetFloatVector()
{
RawVector4 temp;
GetFloatVector(out temp);
return temp;
}
/// <summary>
/// Get a four-component vector that contains boolean data.
/// </summary>
/// <returns>a four-component vector that contains boolean data. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::GetBoolVector([Out, Buffer] BOOL* pData)</unmanaged>
public RawBool4 GetBoolVector()
{
RawBool4 temp;
GetBoolVector(out temp);
return temp;
}
/// <summary>
/// Get a four-component vector.
/// </summary>
/// <typeparam name="T">Type of the four-component vector</typeparam>
/// <returns>a four-component vector. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::GetFloatVector([Out, Buffer] BOOL* pData)</unmanaged>
public unsafe T GetVector<T>() where T : struct
{
T temp;
GetIntVector(out *(RawInt4*)Interop.CastOut(out temp));
return temp;
}
/// <summary>
/// Set an array of four-component vectors that contain integer data.
/// </summary>
/// <param name="array">A reference to the start of the data to set. </param>
/// <returns>Returns one of the following {{Direct3D 10 Return Codes}}. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::SetIntVectorArray([In, Buffer] int* pData,[None] int Offset,[None] int Count)</unmanaged>
public void Set(RawInt4[] array)
{
Set(array, 0, array.Length);
}
/// <summary>
/// Set an array of four-component vectors that contain floating-point data.
/// </summary>
/// <param name="array">A reference to the start of the data to set. </param>
/// <returns>Returns one of the following {{Direct3D 10 Return Codes}}. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::SetFloatVectorArray([In, Buffer] float* pData,[None] int Offset,[None] int Count)</unmanaged>
public void Set(RawVector4[] array)
{
Set(array, 0, array.Length);
}
/// <summary>
/// Set an array of four-component vectors that contain floating-point data.
/// </summary>
/// <typeparam name="T">Type of the four-component vector</typeparam>
/// <param name="array">A reference to the start of the data to set.</param>
/// <returns>
/// Returns one of the following {{Direct3D 10 Return Codes}}.
/// </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::SetFloatVectorArray([In, Buffer] float* pData,[None] int Offset,[None] int Count)</unmanaged>
public void Set<T>(T[] array) where T : struct
{
System.Diagnostics.Debug.Assert(Utilities.SizeOf<T>() == 16, VectorInvalidSize);
Set(Interop.CastArray<RawVector4,T>(array), 0, array.Length);
}
/// <summary>
/// Set a x-component vector.
/// </summary>
/// <param name="value">A reference to the first component. </param>
/// <returns>Returns one of the following {{Direct3D 10 Return Codes}}. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::SetFloatVector([In] float* pData)</unmanaged>
public void Set<T>(T value) where T : struct
{
Set(ref value);
}
/// <summary>
/// Set a x-component vector.
/// </summary>
/// <param name="value">A reference to the first component. </param>
/// <returns>Returns one of the following {{Direct3D 10 Return Codes}}. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::SetFloatVector([In] float* pData)</unmanaged>
public unsafe void Set<T>(ref T value) where T : struct
{
System.Diagnostics.Debug.Assert(Utilities.SizeOf<T>() <= 16, VectorInvalidSize);
SetRawValue(new IntPtr(Interop.Fixed(ref value)), 0, Utilities.SizeOf<T>());
}
/// <summary>
/// Set a two-component vector that contains floating-point data.
/// </summary>
/// <param name="value">A reference to the first component. </param>
/// <returns>Returns one of the following {{Direct3D 10 Return Codes}}. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::SetFloatVector([In] float* pData)</unmanaged>
public void Set(RawVector2 value)
{
unsafe
{
SetRawValue(new IntPtr(&value), 0, Utilities.SizeOf<RawVector2>());
}
}
/// <summary>
/// Set a three-component vector that contains floating-point data.
/// </summary>
/// <param name="value">A reference to the first component. </param>
/// <returns>Returns one of the following {{Direct3D 10 Return Codes}}. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::SetFloatVector([In] float* pData)</unmanaged>
public void Set(RawVector3 value)
{
unsafe
{
SetRawValue(new IntPtr(&value), 0, Utilities.SizeOf<RawVector3>());
}
}
/// <summary>
/// Set a four-component color that contains floating-point data.
/// </summary>
/// <param name="value">A reference to the first component. </param>
/// <returns>Returns one of the following {{Direct3D 10 Return Codes}}. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::SetFloatVector([In] float* pData)</unmanaged>
public void Set(RawColor4 value)
{
unsafe
{
SetRawValue(new IntPtr(&value), 0, Utilities.SizeOf<RawColor4>());
}
}
/// <summary>
/// Set an array of four-component color that contain floating-point data.
/// </summary>
/// <param name="array">A reference to the start of the data to set. </param>
/// <returns>Returns one of the following {{Direct3D 10 Return Codes}}. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::SetFloatVectorArray([In, Buffer] float* pData,[None] int Offset,[None] int Count)</unmanaged>
public void Set(RawColor4[] array)
{
unsafe
{
fixed (void* pArray = &array[0]) SetRawValue((IntPtr)pArray, 0, array.Length * Utilities.SizeOf<RawColor4>());
}
}
/// <summary>
/// Get an array of four-component vectors that contain integer data.
/// </summary>
/// <param name="count">The number of array elements to set. </param>
/// <returns>Returns an array of four-component vectors that contain integer data. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::GetIntVectorArray([Out, Buffer] int* pData,[None] int Offset,[None] int Count)</unmanaged>
public RawInt4[] GetIntVectorArray(int count)
{
var temp = new RawInt4[count];
GetIntVectorArray(temp, 0, count);
return temp;
}
/// <summary>
/// Get an array of four-component vectors that contain floating-point data.
/// </summary>
/// <param name="count">The number of array elements to set. </param>
/// <returns>Returns an array of four-component vectors that contain floating-point data. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::GetFloatVectorArray([None] float* pData,[None] int Offset,[None] int Count)</unmanaged>
public RawVector4[] GetFloatVectorArray(int count)
{
var temp = new RawVector4[count];
GetFloatVectorArray(temp, 0, count);
return temp;
}
/// <summary>
/// Get an array of four-component vectors that contain boolean data.
/// </summary>
/// <param name="count">The number of array elements to set. </param>
/// <returns>an array of four-component vectors that contain boolean data. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::GetBoolVectorArray([Out, Buffer] BOOL* pData,[None] int Offset,[None] int Count)</unmanaged>
public RawBool4[] GetBoolVectorArray(int count)
{
var temp = new RawBool4[count];
GetBoolVectorArray(temp, 0, count);
return temp;
}
/// <summary>
/// Get an array of four-component vectors that contain boolean data.
/// </summary>
/// <param name="count">The number of array elements to set. </param>
/// <returns>an array of four-component vectors that contain boolean data. </returns>
/// <unmanaged>HRESULT ID3D11EffectVectorVariable::GetBoolVectorArray([Out, Buffer] BOOL* pData,[None] int Offset,[None] int Count)</unmanaged>
public T[] GetVectorArray<T>(int count) where T : struct
{
var temp = new T[count];
GetIntVectorArray(Interop.CastArray<RawInt4,T>(temp), 0, count);
return temp;
}
}
}