123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using Veldrid;
- namespace TextRender
- {
- public class TextShader : ShaderAbstract
- {
- public DeviceBuffer ProjectionBuffer;
- public DeviceBuffer WorldBuffer;
- public ResourceLayout ProjViewLayout;
- public ResourceLayout TextureLayout;
- public ResourceSet ProjViewSet;
- public TextShader(VeldridChart.VeldridResource resource) : base(resource, "Text")
- {
- Layout = new VertexLayoutDescription(
- new VertexElementDescription("Position", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2),
- new VertexElementDescription("TexCoords", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2),
- new VertexElementDescription("Color", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float4));
- ProjectionBuffer = resource.Graphics.ResourceFactory.CreateBuffer(new BufferDescription(64, BufferUsage.UniformBuffer));
- WorldBuffer = resource.Graphics.ResourceFactory.CreateBuffer(new BufferDescription(64, BufferUsage.UniformBuffer));
- ProjViewLayout = resource.Graphics.ResourceFactory.CreateResourceLayout(
- new ResourceLayoutDescription(
- new ResourceLayoutElementDescription("Projection", ResourceKind.UniformBuffer, ShaderStages.Vertex),
- new ResourceLayoutElementDescription("World", ResourceKind.UniformBuffer, ShaderStages.Vertex))
- );
- TextureLayout = resource.Graphics.ResourceFactory.CreateResourceLayout(
- new ResourceLayoutDescription(
- new ResourceLayoutElementDescription("SourceTexture", ResourceKind.TextureReadOnly, ShaderStages.Fragment),
- new ResourceLayoutElementDescription("SourceSampler", ResourceKind.Sampler, ShaderStages.Fragment)));
- ProjViewSet = resource.Graphics.ResourceFactory.CreateResourceSet(new ResourceSetDescription(
- ProjViewLayout,
- ProjectionBuffer,
- WorldBuffer));
- }
- public void UpdateBuffers()
- {
- }
- public override void Dispose()
- {
- base.Dispose();
- ProjectionBuffer.Dispose();
- WorldBuffer.Dispose();
- TextureLayout.Dispose();
- ProjViewLayout.Dispose();
- ProjViewSet.Dispose();
- }
- }
- }
|