Shader - Added ShaderSource.cs

This commit is contained in:
miku-666
2024-01-19 18:07:33 +01:00
parent e91012bd12
commit 22ba07709b
3 changed files with 26 additions and 4 deletions

View File

@@ -158,6 +158,7 @@
<Compile Include="Rendering\Renderer.cs" />
<Compile Include="Rendering\RenderGroup.cs" />
<Compile Include="Rendering\Shader.cs" />
<Compile Include="Rendering\ShaderSource.cs" />
<Compile Include="Rendering\SkinRenderer.cs">
<SubType>UserControl</SubType>
</Compile>

View File

@@ -98,12 +98,12 @@ namespace PckStudio.Rendering
public static Shader Create(string vertexSource, string fragmentSource)
{
return Create(
new KeyValuePair<ShaderType, string>(ShaderType.VertexShader, vertexSource),
new KeyValuePair<ShaderType, string>(ShaderType.FragmentShader, fragmentSource)
new ShaderSource(ShaderType.VertexShader, vertexSource),
new ShaderSource(ShaderType.FragmentShader, fragmentSource)
);
}
public static Shader Create(params KeyValuePair<ShaderType, string>[] shaderSources)
public static Shader Create(params ShaderSource[] shaderSources)
{
int programId = GL.CreateProgram();
@@ -111,7 +111,7 @@ namespace PckStudio.Rendering
foreach (var shaderSource in shaderSources)
{
int shaderId = CompileShader(shaderSource.Key, shaderSource.Value);
int shaderId = CompileShader(shaderSource.Type, shaderSource.Source);
GL.AttachShader(programId, shaderId);
shaderIds.Add(shaderId);
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenTK.Graphics.OpenGL;
namespace PckStudio.Rendering
{
internal readonly struct ShaderSource
{
public readonly ShaderType Type;
public readonly string Source;
public ShaderSource(ShaderType type, string source)
{
Type = type;
Source = source;
}
}
}