Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateTexture()

unsafe void Microsoft.Xna.Framework.Graphics.Texture3D.CreateTexture ( GraphicsDevice graphicsDevice,
int width,
int height,
int depth,
[MarshalAs(UnmanagedType.U1)] bool mipMap,
SurfaceFormat format )
inlineprivate

Definition at line 262 of file Texture3D.cs.

263 {
264 if (graphicsDevice == null)
265 {
266 throw new ArgumentNullException("graphicsDevice", FrameworkResources.DeviceCannotBeNullOnResourceCreate);
267 }
268 if (width <= 0)
269 {
270 throw new ArgumentOutOfRangeException("width", FrameworkResources.ResourcesMustBeGreaterThanZeroSize);
271 }
272 if (height <= 0)
273 {
274 throw new ArgumentOutOfRangeException("height", FrameworkResources.ResourcesMustBeGreaterThanZeroSize);
275 }
276 if (depth <= 0)
277 {
278 throw new ArgumentOutOfRangeException("depth", FrameworkResources.ResourcesMustBeGreaterThanZeroSize);
279 }
280 ProfileCapabilities profileCapabilities = graphicsDevice._profileCapabilities;
281 if (profileCapabilities.MaxVolumeExtent == 0)
282 {
283 profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileFeatureNotSupported, typeof(Texture3D).Name);
284 }
285 if (!profileCapabilities.ValidVolumeFormats.Contains(format))
286 {
287 profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileFormatNotSupported, typeof(Texture3D).Name, format);
288 }
289 int maxVolumeExtent = profileCapabilities.MaxVolumeExtent;
290 if (width > maxVolumeExtent || height > maxVolumeExtent || depth > maxVolumeExtent)
291 {
292 profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileTooBig, typeof(Texture3D).Name, maxVolumeExtent);
293 }
294 int num = Math.Max(Math.Max(width, height), depth);
295 int num2 = Math.Min(Math.Min(width, height), depth);
296 int num3 = (num + num2 - 1) / num2;
297 int maxTextureAspectRatio = profileCapabilities.MaxTextureAspectRatio;
298 if (num3 > maxTextureAspectRatio)
299 {
300 profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileAspectRatio, typeof(Texture3D).Name, maxTextureAspectRatio);
301 }
302 if (!profileCapabilities.NonPow2Volume && (!Texture.IsPowerOfTwo((uint)width) || !Texture.IsPowerOfTwo((uint)height) || !Texture.IsPowerOfTwo((uint)depth)))
303 {
304 profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileNotPowerOfTwo, typeof(Texture3D).Name);
305 }
306 int num4 = ((!mipMap) ? 1 : 0);
307 fixed (IDirect3DVolumeTexture9** ptr = &pComPtr)
308 {
309 int num5 = *(int*)graphicsDevice.pComPtr + 96;
310 int num6 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, uint, uint, uint, uint, _D3DFORMAT, _D3DPOOL, IDirect3DVolumeTexture9**, void**, int>)(int)(*(uint*)num5))((nint)graphicsDevice.pComPtr, (uint)width, (uint)height, (uint)depth, (uint)num4, 0u, _003CModule_003E.ConvertXnaFormatToWindows(format), (_D3DPOOL)1, ptr, null);
311 if (num6 < 0)
312 {
313 throw GraphicsHelpers.GetExceptionFromResult((uint)num6);
314 }
315 isDisposed = false;
316 _parent = graphicsDevice;
317 SurfaceFormat? format2 = format;
318 InitializeDescription(format2);
319 graphicsDevice.Resources.AddTrackedObject(this, pComPtr, 1u, _internalHandle, ref _internalHandle);
320 }
321 }
unsafe IDirect3DVolumeTexture9 * pComPtr
Definition Texture3D.cs:18
unsafe void InitializeDescription(SurfaceFormat? format)
Definition Texture3D.cs:26
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static byte Max(byte val1, byte val2)
Definition Math.cs:738

References Microsoft.Xna.Framework.Graphics.GraphicsResource._internalHandle, Microsoft.Xna.Framework.Graphics.GraphicsResource._parent, Microsoft.Xna.Framework.Graphics.GraphicsDevice._profileCapabilities, Microsoft.Xna.Framework.Graphics.DeviceResourceManager.AddTrackedObject(), System.Collections.Generic.List< T >.Contains(), Microsoft.Xna.Framework.FrameworkResources.DeviceCannotBeNullOnResourceCreate, System.format, Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.Graphics.Texture3D.InitializeDescription(), Microsoft.Xna.Framework.Graphics.GraphicsResource.isDisposed, Microsoft.Xna.Framework.Graphics.Texture.IsPowerOfTwo(), System.Math.Max(), Microsoft.Xna.Framework.Graphics.ProfileCapabilities.MaxTextureAspectRatio, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.MaxVolumeExtent, System.Math.Min(), Microsoft.Xna.Framework.Graphics.GraphicsResource.Name, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.NonPow2Volume, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pComPtr, Microsoft.Xna.Framework.Graphics.Texture3D.pComPtr, Microsoft.Xna.Framework.FrameworkResources.ProfileAspectRatio, Microsoft.Xna.Framework.FrameworkResources.ProfileFeatureNotSupported, Microsoft.Xna.Framework.FrameworkResources.ProfileFormatNotSupported, Microsoft.Xna.Framework.FrameworkResources.ProfileNotPowerOfTwo, Microsoft.Xna.Framework.FrameworkResources.ProfileTooBig, Microsoft.Xna.Framework.Graphics.GraphicsDevice.Resources, Microsoft.Xna.Framework.FrameworkResources.ResourcesMustBeGreaterThanZeroSize, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ThrowNotSupportedException(), and Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ValidVolumeFormats.

Referenced by Microsoft.Xna.Framework.Graphics.Texture3D.Texture3D().