16.09.2020
~ Fixed shading import ~ Fixed "Plate" mesh ~ Move the dll files into "SMCode"
This commit is contained in:
parent
421d03f91d
commit
9889366317
27 changed files with 30 additions and 17 deletions
40
SMCode/SM.OGL/Shaders/ShaderFile.cs
Normal file
40
SMCode/SM.OGL/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(shader, _id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue