Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UIBatch"/> class.
        /// </summary>
        /// <param name="device">A valid instance of <see cref="GraphicsDevice"/>.</param>
        public UIBatch(GraphicsDevice device, object context, object layout)
            : base(device, UIEffect.Bytecode, UIEffect.BytecodeSRgb,
                   ResourceBufferInfo.CreateDynamicIndexBufferInfo("UIBatch.VertexIndexBuffers", MaxIndicesCount, MaxVerticesCount),
                   VertexPositionColorTextureSwizzle.Layout)
        {
            // Create a 1x1 pixel white texture
            whiteTexture = graphicsDevice.GetSharedWhiteTexture();

            renderingContext = context;
            layoutingContext = layout;

            //  Load custom font rendering effects here

            // For signed distance field font rendering
            signedDistanceFieldFontEffect = new EffectInstance(new Effect(device, SignedDistanceFieldFontShader.Bytecode)
            {
                Name = "UIBatchSignedDistanceFieldFontEffect"
            });

            // For signed distance field thumbnail rendering
            sdfSpriteFontEffect = new EffectInstance(new Effect(device, SpriteSignedDistanceFieldFontShader.Bytecode)
            {
                Name = "UIBatchSDFSpriteFontEffect"
            });
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of <see cref="UIBatch"/>.
 /// </summary>
 /// <param name="device">A valid instance of <see cref="GraphicsDevice"/>.</param>
 public UIBatch(GraphicsDevice device)
     : base(device, UIEffect.Bytecode, UIEffect.BytecodeSRgb,
            ResourceBufferInfo.CreateDynamicIndexBufferInfo("UIBatch.VertexIndexBuffers", MaxIndicesCount, MaxVerticesCount),
            VertexPositionColorTextureSwizzle.Layout)
 {
     // Create a 1x1 pixel white texture
     whiteTexture = GraphicsDevice.GetSharedWhiteTexture();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new instance of <see cref="UIBatch"/>.
        /// </summary>
        /// <param name="device">A valid instance of <see cref="GraphicsDevice"/>.</param>
        public UIBatch(GraphicsDevice device)
            : base(device, UIEffect.Bytecode,
                   ResourceBufferInfo.CreateDynamicIndexBufferInfo("UIBatch.VertexIndexBuffers", MaxIndicesCount, MaxVerticesCount),
                   VertexPositionColorTextureSwizzle.Layout)
        {
            // Create the two ui effects
            uiSeparateAlphaEffect = new Effect(GraphicsDevice, UIEffectSeparateAlpha.Bytecode)
            {
                Name = "SeparatedAlphaBatchEffect"
            };

            // Create a 1x1 pixel white texture
            whiteTexture = Texture.New2D(GraphicsDevice, 1, 1, PixelFormat.R8G8B8A8_UNorm, new Byte[] { 255, 255, 255, 255 });
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new instance of <see cref="UIBatch"/>.
        /// </summary>
        /// <param name="device">A valid instance of <see cref="GraphicsDevice"/>.</param>
        public UIBatch(GraphicsDevice device)
            : base(device, UIEffect.Bytecode,
                   ResourceBufferInfo.CreateDynamicIndexBufferInfo("UIBatch.VertexIndexBuffers", MaxIndicesCount, MaxVerticesCount),
                   VertexPositionColorTextureSwizzle.Layout)
        {
            // Create the two ui effects
            uiSeparateAlphaEffect = new Effect(GraphicsDevice, UIEffectSeparateAlpha.Bytecode)
            {
                Name = "SeparatedAlphaBatchEffect"
            };
            uiSeparateAlphaParameterCollectionGroup = new EffectParameterCollectionGroup(device, uiSeparateAlphaEffect, new[] { Parameters });

            // Create a 1x1 pixel white texture
            whiteTexture = GraphicsDevice.GetSharedWhiteTexture();
        }