15.09.2020
Everything currently don't work / can't be tested. + Generic Shader-Implermentation + Mesh-System + Plate-Mesh
This commit is contained in:
parent
551d393ac2
commit
421d03f91d
24 changed files with 726 additions and 4 deletions
40
SM.Core/Shaders/ShaderFile.cs
Normal file
40
SM.Core/Shaders/ShaderFile.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
|
||||
namespace SM.OGL.Shaders
|
||||
{
|
||||
public class ShaderFile : GLObject
|
||||
{
|
||||
private string _data;
|
||||
|
||||
public override ObjectLabelIdentifier TypeIdentifier { get; } = ObjectLabelIdentifier.Shader;
|
||||
|
||||
public Dictionary<string, string> StringOverrides = new Dictionary<string, string>();
|
||||
public List<ShaderFile> GLSLExtensions = new List<ShaderFile>();
|
||||
|
||||
public ShaderFile(string data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
private void GenerateSource()
|
||||
{
|
||||
foreach (KeyValuePair<string, string> kvp in StringOverrides)
|
||||
_data = _data.Replace("//! " + kvp.Key, kvp.Value);
|
||||
}
|
||||
|
||||
internal void Compile(GenericShader shader, ShaderType type)
|
||||
{
|
||||
if (_id < 0)
|
||||
{
|
||||
GenerateSource();
|
||||
|
||||
_id = GL.CreateShader(type);
|
||||
GL.ShaderSource(_id, _data);
|
||||
GL.CompileShader(_id);
|
||||
}
|
||||
GL.AttachShader(_id, shader);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue