Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
VertexDeclaration.cs
Go to the documentation of this file.
1using System;
5
7
9{
11
12 internal int _vertexStride;
13
15
17
18 public VertexDeclaration(int vertexStride, params VertexElement[] elements)
19 {
20 try
21 {
22 if (elements != null && elements.Length != 0)
23 {
24 VertexElement[] elements2 = (_elements = (VertexElement[])elements.Clone());
25 _vertexStride = vertexStride;
26 VertexElementValidator.Validate(vertexStride, elements2);
27 goto IL_005a;
28 }
29 }
30 catch
31 {
32 //try-fault
33 base.Dispose(true);
34 throw;
35 }
36 try
37 {
39 }
40 catch
41 {
42 //try-fault
43 base.Dispose(true);
44 throw;
45 }
46 IL_005a:
47 try
48 {
49 return;
50 }
51 catch
52 {
53 //try-fault
54 base.Dispose(true);
55 throw;
56 }
57 }
58
59 public VertexDeclaration(params VertexElement[] elements)
60 {
61 try
62 {
63 if (elements != null && elements.Length != 0)
64 {
66 goto IL_0066;
67 }
68 }
69 catch
70 {
71 //try-fault
72 base.Dispose(true);
73 throw;
74 }
75 try
76 {
78 }
79 catch
80 {
81 //try-fault
82 base.Dispose(true);
83 throw;
84 }
85 IL_0066:
86 try
87 {
88 return;
89 }
90 catch
91 {
92 //try-fault
93 base.Dispose(true);
94 throw;
95 }
96 }
97
99 {
100 Unbind();
101 }
102
104 {
105 Unbind();
106 }
107
109 {
110 return (VertexElement[])_elements.Clone();
111 }
112
113 internal void Bind(GraphicsDevice device)
114 {
115 if (isDisposed)
116 {
118 }
121 if (binding != null)
122 {
124 _binding = null;
125 }
127 _parent = device;
128 }
129
130 internal void Unbind()
131 {
133 if (binding != null)
134 {
136 _binding = null;
137 }
138 }
139
140 internal static VertexDeclaration FromType(Type vertexType)
141 {
142 if (vertexType == null)
143 {
145 }
146 if (!vertexType.IsValueType)
147 {
148 throw new ArgumentException(string.Format(args: new object[1] { vertexType }, provider: CultureInfo.CurrentCulture, format: FrameworkResources.VertexTypeNotValueType));
149 }
150 if (!(Activator.CreateInstance(vertexType) is IVertexType { VertexDeclaration: var vertexDeclaration }))
151 {
152 throw new ArgumentException(string.Format(args: new object[1] { vertexType }, provider: CultureInfo.CurrentCulture, format: FrameworkResources.VertexTypeNotIVertexType));
153 }
154 if (vertexDeclaration == null)
155 {
156 throw new InvalidOperationException(string.Format(args: new object[1] { vertexType }, provider: CultureInfo.CurrentCulture, format: FrameworkResources.VertexTypeNullDeclaration));
157 }
158 if (Marshal.SizeOf(vertexType) != vertexDeclaration._vertexStride)
159 {
160 throw new InvalidOperationException(string.Format(args: new object[1] { vertexType }, provider: CultureInfo.CurrentCulture, format: FrameworkResources.VertexTypeWrongSize));
161 }
162 return vertexDeclaration;
163 }
164
165 [HandleProcessCorruptedStateExceptions]
166 protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool P_0)
167 {
168 if (P_0)
169 {
170 try
171 {
173 return;
174 }
175 finally
176 {
177 base.Dispose(true);
178 }
179 }
180 try
181 {
183 }
184 finally
185 {
186 base.Dispose(false);
187 }
188 }
189}
DeclarationBinding CreateBinding(VertexDeclaration declaration)
VertexDeclaration(int vertexStride, params VertexElement[] elements)
VertexDeclaration(params VertexElement[] elements)
static VertexDeclaration FromType(Type vertexType)
override void Dispose([MarshalAs(UnmanagedType.U1)] bool P_0)
static void Validate(int vertexStride, VertexElement[] elements)
static ? object CreateInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, BindingFlags bindingAttr, Binder? binder, object?[]? args, CultureInfo? culture)
Definition Activator.cs:17
static CultureInfo CurrentCulture
static int SizeOf(object structure)
Definition Marshal.cs:697
bool IsValueType
Definition Type.cs:234