Exemple #1
0
        /// <summary>News the render target description.</summary>
        /// <param name="size">The size.</param>
        /// <param name="format">The format.</param>
        /// <param name="flags">The flags.</param>
        /// <param name="mipCount">The mip count.</param>
        /// <returns>Texture2DDescription.</returns>
        protected static Texture2DDescription NewRenderTargetDescription(int size, PixelFormat format, TextureFlags flags, int mipCount)
        {
            var desc = Texture2DBase.NewDescription(size, size, format, flags, mipCount, 6, ResourceUsage.Default);

            desc.OptionFlags = ResourceOptionFlags.TextureCube;
            return(desc);
        }
Exemple #2
0
 public ShipModel(VisionContent vContent)
     : base(vContent.LoadEffect("effects/SimpleTextureEffect"))
 {
     _model = vContent.Load<Model>(@"Models/galleonmodel");
     _texture = vContent.Load<Texture2D>(@"Models/galleon");
     _boundingSphere = _model.CalculateBounds();
 }
Exemple #3
0
 public SkySphere(
     VisionContent vtContent,
     Texture2DBase texture)
     : base(new VisionEffect(vtContent.Load<Effect>("effects/skysphere")))
 {
     _sphere = new SpherePrimitive<VertexPosition>(vtContent.GraphicsDevice, (p, n, t, tx) => new VertexPosition(p), 20000, 10, false);
     Effect.Texture = texture;
 }
Exemple #4
0
        internal static Texture2DDescription CreateDescription(GraphicsDevice device, int width, int height, PixelFormat format, TextureFlags textureFlags, int mipCount, int arraySize, MSAALevel multiSampleCount)
        {
            // Make sure that the texture to create is a render target
            textureFlags |= TextureFlags.RenderTarget;
            var desc = Texture2DBase.NewDescription(width, height, format, textureFlags, mipCount, arraySize, ResourceUsage.Default);

            // Sets the MSAALevel
            int maximumMSAA = (int)device.Features[format].MSAALevelMax;

            desc.SampleDescription.Count = Math.Max(1, Math.Min((int)multiSampleCount, maximumMSAA));
            return(desc);
        }
Exemple #5
0
        protected static Texture2DDescription NewDepthStencilBufferDescription(GraphicsDevice device, int width, int height, DepthFormat format, MSAALevel multiSampleCount, int arraySize, bool shaderResource)
        {
            var desc = Texture2DBase.NewDescription(width, height, DXGI.Format.Unknown, TextureFlags.None, 1, arraySize, ResourceUsage.Default);

            desc.BindFlags |= BindFlags.DepthStencil;
            if (shaderResource)
            {
                desc.BindFlags |= BindFlags.ShaderResource;
            }
            // Sets the MSAALevel
            int maximumMSAA = (int)device.Features[(DXGI.Format)format].MSAALevelMax;

            desc.SampleDescription.Count = Math.Max(1, Math.Min((int)multiSampleCount, maximumMSAA));

            var typelessDepthFormat = (SharpDX.DXGI.Format)format;

            // If shader resource view are not required, don't use a TypeLess format
            if (shaderResource)
            {
                // Determine TypeLess Format and ShaderResourceView Format
                switch (format)
                {
                case DepthFormat.Depth16:
                    typelessDepthFormat = SharpDX.DXGI.Format.R16_Typeless;
                    break;

                case DepthFormat.Depth32:
                    typelessDepthFormat = SharpDX.DXGI.Format.R32_Typeless;
                    break;

                case DepthFormat.Depth24Stencil8:
                    typelessDepthFormat = SharpDX.DXGI.Format.R24G8_Typeless;
                    break;

                case DepthFormat.Depth32Stencil8X24:
                    typelessDepthFormat = SharpDX.DXGI.Format.R32G8X24_Typeless;
                    break;

                default:
                    throw new InvalidOperationException(string.Format("Unsupported DepthFormat [{0}] for depth buffer", format));
                }
            }

            desc.Format = typelessDepthFormat;

            return(desc);
        }