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

◆ ValidateCreationParameters()

static void Microsoft.Xna.Framework.Graphics.Texture2D.ValidateCreationParameters ( ProfileCapabilities profile,
int width,
int height,
SurfaceFormat format,
[MarshalAs(UnmanagedType.U1)] bool mipMap )
inlinestaticprotected

Definition at line 633 of file Texture2D.cs.

634 {
635 if (width <= 0)
636 {
637 throw new ArgumentOutOfRangeException("width", FrameworkResources.ResourcesMustBeGreaterThanZeroSize);
638 }
639 if (height <= 0)
640 {
641 throw new ArgumentOutOfRangeException("height", FrameworkResources.ResourcesMustBeGreaterThanZeroSize);
642 }
643 bool flag = Texture.CheckCompressedTexture(_003CModule_003E.ConvertXnaFormatToWindows(format));
644 if (!profile.ValidTextureFormats.Contains(format))
645 {
646 profile.ThrowNotSupportedException(FrameworkResources.ProfileFormatNotSupported, typeof(Texture2D).Name, format);
647 }
648 int maxTextureSize = profile.MaxTextureSize;
649 if (width > maxTextureSize || height > maxTextureSize)
650 {
651 profile.ThrowNotSupportedException(FrameworkResources.ProfileTooBig, typeof(Texture2D).Name, maxTextureSize);
652 }
653 int num = Math.Max(width, height);
654 int num2 = Math.Min(width, height);
655 int num3 = (num + num2 - 1) / num2;
656 int maxTextureAspectRatio = profile.MaxTextureAspectRatio;
657 if (num3 > maxTextureAspectRatio)
658 {
659 profile.ThrowNotSupportedException(FrameworkResources.ProfileAspectRatio, typeof(Texture2D).Name, maxTextureAspectRatio);
660 }
661 if (!profile.NonPow2Unconditional && (!Texture.IsPowerOfTwo((uint)width) || !Texture.IsPowerOfTwo((uint)height)))
662 {
663 if (mipMap)
664 {
665 profile.ThrowNotSupportedException(FrameworkResources.ProfileNotPowerOfTwoMipped, typeof(Texture2D).Name);
666 }
667 if (!flag)
668 {
669 return;
670 }
671 profile.ThrowNotSupportedException(FrameworkResources.ProfileNotPowerOfTwoDXT, typeof(Texture2D).Name);
672 }
673 if (flag && (((uint)width & 3u) != 0 || ((uint)height & 3u) != 0))
674 {
675 throw new ArgumentException(FrameworkResources.DxtNotMultipleOfFour);
676 }
677 }
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.Texture.CheckCompressedTexture(), System.Collections.Generic.List< T >.Contains(), Microsoft.Xna.Framework.FrameworkResources.DxtNotMultipleOfFour, System.format, Microsoft.Xna.Framework.Graphics.Texture.IsPowerOfTwo(), System.Math.Max(), Microsoft.Xna.Framework.Graphics.ProfileCapabilities.MaxTextureAspectRatio, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.MaxTextureSize, System.Math.Min(), Microsoft.Xna.Framework.Graphics.GraphicsResource.Name, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.NonPow2Unconditional, Microsoft.Xna.Framework.FrameworkResources.ProfileAspectRatio, Microsoft.Xna.Framework.FrameworkResources.ProfileFormatNotSupported, Microsoft.Xna.Framework.FrameworkResources.ProfileNotPowerOfTwoDXT, Microsoft.Xna.Framework.FrameworkResources.ProfileNotPowerOfTwoMipped, Microsoft.Xna.Framework.FrameworkResources.ProfileTooBig, Microsoft.Xna.Framework.FrameworkResources.ResourcesMustBeGreaterThanZeroSize, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ThrowNotSupportedException(), and Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ValidTextureFormats.

Referenced by Microsoft.Xna.Framework.Graphics.Texture2D.Texture2D(), Microsoft.Xna.Framework.Graphics.RenderTarget2D.CreateRenderTarget(), and Microsoft.Xna.Framework.Graphics.Texture2D.CreateTexture().