Skip to content

Commit 885ab3d

Browse files
committed
refactory string rendering shader
1 parent 9470833 commit 885ab3d

File tree

3 files changed

+25
-127
lines changed

3 files changed

+25
-127
lines changed

OngekiFumenEditor/Kernel/Graphics/Drawing/DefaultDrawingImpl/StringDrawing/String/Platform/Renderer.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using FontStashSharp.Interfaces;
2+
using OngekiFumenEditor.Kernel.Graphics.Base;
23
using OpenTK.Graphics.OpenGL;
34
using OpenTK.Mathematics;
45
using System;
@@ -57,7 +58,7 @@ void main()
5758
private const int MAX_VERTICES = MAX_SPRITES * 4;
5859
private const int MAX_INDICES = MAX_SPRITES * 6;
5960

60-
private readonly Shader _shader;
61+
private readonly StringShader _shader;
6162
private readonly BufferObject<VertexPositionColorTexture> _vertexBuffer;
6263
private readonly BufferObject<short> _indexBuffer;
6364
private readonly VertexArrayObject _vao;
@@ -80,8 +81,9 @@ public unsafe Renderer()
8081
_indexBuffer = new BufferObject<short>(indexData.Length, BufferTarget.ElementArrayBuffer, false);
8182
_indexBuffer.SetData(indexData, 0, indexData.Length);
8283

83-
_shader = new Shader(vert, frag);
84-
_shader.Use();
84+
_shader = new (vert, frag);
85+
_shader.Compile();
86+
_shader.Begin();
8587

8688
_vao = new VertexArrayObject(sizeof(VertexPositionColorTexture));
8789
_vao.Bind();
@@ -117,10 +119,10 @@ public void Begin(Matrix4 mvp, IPerfomenceMonitor perfomenceMonitor, IDrawing re
117119
performenceMonitor = perfomenceMonitor;
118120
this.refDrawing = refDrawing;
119121

120-
_shader.Use();
121-
_shader.SetUniform("TextureSampler", 0);
122+
_shader.Begin();
122123

123-
_shader.SetUniform("MVP", mvp);
124+
_shader.PassUniform("TextureSampler", 0);
125+
_shader.PassUniform("MVP", mvp);
124126

125127
_vao.Bind();
126128
_indexBuffer.Bind();

OngekiFumenEditor/Kernel/Graphics/Drawing/DefaultDrawingImpl/StringDrawing/String/Shader.cs

Lines changed: 0 additions & 121 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace OngekiFumenEditor.Kernel.Graphics.Drawing.DefaultDrawingImpl.StringDrawing.String
8+
{
9+
public class StringShader : Base.Shader
10+
{
11+
public StringShader(string vertexContent, string fragmentContent)
12+
{
13+
VertexProgram = vertexContent;
14+
FragmentProgram = fragmentContent;
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)