Skip to content

Commit

Permalink
refactory string rendering shader
Browse files Browse the repository at this point in the history
  • Loading branch information
MikiraSora committed Oct 29, 2024
1 parent 9470833 commit 885ab3d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 127 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FontStashSharp.Interfaces;
using OngekiFumenEditor.Kernel.Graphics.Base;
using OpenTK.Graphics.OpenGL;
using OpenTK.Mathematics;
using System;
Expand Down Expand Up @@ -57,7 +58,7 @@ void main()
private const int MAX_VERTICES = MAX_SPRITES * 4;
private const int MAX_INDICES = MAX_SPRITES * 6;

private readonly Shader _shader;
private readonly StringShader _shader;
private readonly BufferObject<VertexPositionColorTexture> _vertexBuffer;
private readonly BufferObject<short> _indexBuffer;
private readonly VertexArrayObject _vao;
Expand All @@ -80,8 +81,9 @@ public unsafe Renderer()
_indexBuffer = new BufferObject<short>(indexData.Length, BufferTarget.ElementArrayBuffer, false);
_indexBuffer.SetData(indexData, 0, indexData.Length);

_shader = new Shader(vert, frag);
_shader.Use();
_shader = new (vert, frag);
_shader.Compile();
_shader.Begin();

_vao = new VertexArrayObject(sizeof(VertexPositionColorTexture));
_vao.Bind();
Expand Down Expand Up @@ -117,10 +119,10 @@ public void Begin(Matrix4 mvp, IPerfomenceMonitor perfomenceMonitor, IDrawing re
performenceMonitor = perfomenceMonitor;
this.refDrawing = refDrawing;

_shader.Use();
_shader.SetUniform("TextureSampler", 0);
_shader.Begin();

_shader.SetUniform("MVP", mvp);
_shader.PassUniform("TextureSampler", 0);
_shader.PassUniform("MVP", mvp);

_vao.Bind();
_indexBuffer.Bind();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OngekiFumenEditor.Kernel.Graphics.Drawing.DefaultDrawingImpl.StringDrawing.String
{
public class StringShader : Base.Shader
{
public StringShader(string vertexContent, string fragmentContent)
{
VertexProgram = vertexContent;
FragmentProgram = fragmentContent;
}
}
}

0 comments on commit 885ab3d

Please sign in to comment.