/// <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" }); }
/// <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(); }
/// <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 }); }
/// <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(); }