/// <summary> /// Converts the specified MonoGame surface format to DXGI (Direct3D 10/Direct3D 11). /// </summary> /// <param name="format">The MonoGame surface format.</param> /// <returns>The DXGI format.</returns> /// <exception cref="ArgumentException"> /// The surface format is not supported. /// </exception> public static Format ToD3D11(SurfaceFormat format) { switch (format) { case SurfaceFormat.Bgra32: return(Format.B8G8R8A8_UNorm); //case SurfaceFormat.???: // sRGB formats not yet in MonoGame. // return Format.B8G8R8A8_UNorm_SRgb; case SurfaceFormat.Bgr32: return(Format.B8G8R8X8_UNorm); case SurfaceFormat.Color: return(Format.R8G8B8A8_UNorm); //case SurfaceFormat.???: // sRGB formats not yet in MonoGame. // return Format.R8G8B8A8_UNorm_SRgb; case SurfaceFormat.Rgba1010102: return(Format.R10G10B10A2_UNorm); case SurfaceFormat.HalfVector4: return(Format.R16G16B16A16_Float); default: throw new ArgumentException("The specified surface format is not supported."); } }
DrawTargetTexture2D PickRT(ref DrawTargetTexture2D int1, ref DrawTargetTexture2D int2, DrawTargetTexture2D source, int w, int h, Microsoft.Xna.Framework.Graphics.SurfaceFormat targetFormat) { DrawTargetTexture2D target = null; if (int1 != null && int1.Equals(source)) { target = int2; } else if (int2 != null && int2.Equals(source)) { target = int1; } if (target == null) { int tw = ((w + 15) / 16) * 16; int th = ((h + 15) / 16) * 16; target = new DrawTargetTexture2D(source.Camera, tw, th, targetFormat); } else { if (target.Width < w || target.Height < h) { string from = "intermediate"; if (target == int2) { from += "2"; } throw new ArgumentException(string.Format("'{0}' draw target is too small, minimum required size for '{1}' in the current context is {2}x{3}", from, from, w, h)); } } if (int1 == null) { int1 = target; } else { if (int2 == null && target != int1) { int2 = target; } } return(target.Clone(false, false, false)); }
public static UnityEngine.TextureFormat TextureFormat(XSurfaceFormat surfaceFormat) { switch (surfaceFormat) { case XSurfaceFormat.Alpha8: return(UnityEngine.TextureFormat.Alpha8); case XSurfaceFormat.Vector4: return(UnityEngine.TextureFormat.ARGB32); case XSurfaceFormat.Bgra32: return(UnityEngine.TextureFormat.BGRA32); case XSurfaceFormat.Dxt1: return(UnityEngine.TextureFormat.DXT1); case XSurfaceFormat.Dxt5: return(UnityEngine.TextureFormat.DXT5); case XSurfaceFormat.RgbEtc1: return(UnityEngine.TextureFormat.ETC_RGB4); case XSurfaceFormat.RgbPvrtc2Bpp: return(UnityEngine.TextureFormat.PVRTC_RGB2); case XSurfaceFormat.RgbaPvrtc2Bpp: return(UnityEngine.TextureFormat.PVRTC_RGBA2); case XSurfaceFormat.RgbPvrtc4Bpp: return(UnityEngine.TextureFormat.PVRTC_RGB4); case XSurfaceFormat.RgbaPvrtc4Bpp: return(UnityEngine.TextureFormat.PVRTC_RGBA4); default: case XSurfaceFormat.Single: case XSurfaceFormat.Color: return(UnityEngine.TextureFormat.RGBA32); case XSurfaceFormat.HalfSingle: return(UnityEngine.TextureFormat.RGBA4444); case XSurfaceFormat.Bgr32: case XSurfaceFormat.Bgr565: case XSurfaceFormat.Bgra4444: case XSurfaceFormat.Bgra5551: case XSurfaceFormat.Dxt1a: case XSurfaceFormat.Dxt3: case XSurfaceFormat.HalfVector2: case XSurfaceFormat.HalfVector4: case XSurfaceFormat.HdrBlendable: case XSurfaceFormat.NormalizedByte2: case XSurfaceFormat.NormalizedByte4: case XSurfaceFormat.Rg32: case XSurfaceFormat.Rgba1010102: case XSurfaceFormat.Rgba64: case XSurfaceFormat.Vector2: return(UnityEngine.TextureFormat.RGBA32); /* * return UnityEngine.TextureFormat.ARGB4444; * return UnityEngine.TextureFormat.ATC_RGB4; * return UnityEngine.TextureFormat.ATC_RGBA8; * return UnityEngine.TextureFormat.ATF_RGB_DXT1; * return UnityEngine.TextureFormat.ATF_RGB_JPG; * return UnityEngine.TextureFormat.ATF_RGBA_JPG; * return UnityEngine.TextureFormat.PVRTC_RGB2; * return UnityEngine.TextureFormat.PVRTC_RGB4; * return UnityEngine.TextureFormat.PVRTC_RGBA2; * return UnityEngine.TextureFormat.PVRTC_RGBA4; * return UnityEngine.TextureFormat.RGB24; * return UnityEngine.TextureFormat.RGB565;*/ } }
/// <summary> /// Converts the specified MonoGame surface format to DXGI (Direct3D 10/Direct3D 11). /// </summary> /// <param name="format">The MonoGame surface format.</param> /// <returns>The DXGI format.</returns> /// <exception cref="ArgumentException"> /// The surface format is not supported. /// </exception> public static Format ToD3D11(SurfaceFormat format) { switch (format) { case SurfaceFormat.Bgra32: return Format.B8G8R8A8_UNorm; //case SurfaceFormat.???: // sRGB formats not yet in MonoGame. // return Format.B8G8R8A8_UNorm_SRgb; case SurfaceFormat.Bgr32: return Format.B8G8R8X8_UNorm; case SurfaceFormat.Color: return Format.R8G8B8A8_UNorm; //case SurfaceFormat.???: // sRGB formats not yet in MonoGame. // return Format.R8G8B8A8_UNorm_SRgb; case SurfaceFormat.Rgba1010102: return Format.R10G10B10A2_UNorm; case SurfaceFormat.HalfVector4: return Format.R16G16B16A16_Float; default: throw new ArgumentException("The specified surface format is not supported."); } }