diff --git a/SM.Base/GenericWindow.cs b/SM.Base/GenericWindow.cs
new file mode 100644
index 0000000..1103d7c
--- /dev/null
+++ b/SM.Base/GenericWindow.cs
@@ -0,0 +1,38 @@
+using System;
+using System.IO;
+using OpenTK;
+using OpenTK.Graphics.OpenGL4;
+using SM.OGL.Shaders;
+
+namespace SM.Base
+{
+ public class GenericWindow : GameWindow
+ {
+ private TestShader shader;
+ private Matrix4 _viewMatrix;
+
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+ shader = new TestShader(new ShaderFileCollection(File.ReadAllText("test/vert.glsl"), File.ReadAllText("test/frag.glsl")));
+ shader.Compile();
+ }
+
+ protected override void OnRenderFrame(FrameEventArgs e)
+ {
+ base.OnRenderFrame(e);
+
+ shader.Draw();
+
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+
+ GL.Viewport(ClientRectangle);
+ _viewMatrix = Matrix4.CreatePerspectiveFieldOfView(90, Width / Height, 0.1f, 100) *
+ Matrix4.LookAt(new Vector3(2f, 1f, -5f), Vector3.Zero, Vector3.UnitY);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SM.Base/OpenTK.dll.config b/SM.Base/OpenTK.dll.config
new file mode 100644
index 0000000..7098d39
--- /dev/null
+++ b/SM.Base/OpenTK.dll.config
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SM.Base/SM.Base.csproj b/SM.Base/SM.Base.csproj
index fed5569..01a4ca1 100644
--- a/SM.Base/SM.Base.csproj
+++ b/SM.Base/SM.Base.csproj
@@ -31,8 +31,12 @@
4
+
+ ..\packages\OpenTK.3.2\lib\net20\OpenTK.dll
+
+
@@ -41,7 +45,21 @@
+
+
+
+
+
+
+
+
+
+ {f604d684-bc1d-4819-88b5-8b5d03a17be0}
+ SM.OGL
+
+
+
\ No newline at end of file
diff --git a/SM.Base/StaticObjects/Plate.cs b/SM.Base/StaticObjects/Plate.cs
new file mode 100644
index 0000000..cd9eef1
--- /dev/null
+++ b/SM.Base/StaticObjects/Plate.cs
@@ -0,0 +1,22 @@
+using OpenTK.Graphics.OpenGL4;
+using SM.OGL.Mesh;
+
+namespace SM.Base.StaticObjects
+{
+ public class Plate : Mesh
+ {
+ public static Plate Object = new Plate();
+
+ public override VBO Vertex { get; } = new VBO()
+ {
+ {-.5f, -.5f, 0},
+ {-.5f, .5f, 0},
+ {.5f, .5f, 0},
+ {.5f, -.5f, 0},
+ };
+
+ public override PrimitiveType PrimitiveType { get; } = PrimitiveType.Quads;
+
+ private Plate() {}
+ }
+}
\ No newline at end of file
diff --git a/SM.Base/TestShader.cs b/SM.Base/TestShader.cs
new file mode 100644
index 0000000..b23cb33
--- /dev/null
+++ b/SM.Base/TestShader.cs
@@ -0,0 +1,24 @@
+using OpenTK.Graphics.OpenGL4;
+using SM.Base.StaticObjects;
+using SM.OGL.Shaders;
+
+namespace SM.Base
+{
+ public class TestShader : GenericShader
+ {
+ public TestShader(ShaderFileCollection shaderFileFiles) : base(shaderFileFiles)
+ {
+ }
+
+ public void Draw()
+ {
+ GL.UseProgram(this);
+
+
+
+ DrawObject(Plate.Object, true);
+
+ GL.UseProgram(0);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SM.Base/packages.config b/SM.Base/packages.config
new file mode 100644
index 0000000..75397e4
--- /dev/null
+++ b/SM.Base/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/SM.Core/GLDebugging.cs b/SM.Core/GLDebugging.cs
new file mode 100644
index 0000000..7250f02
--- /dev/null
+++ b/SM.Core/GLDebugging.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Diagnostics;
+using System.Net.Http;
+using System.Runtime.InteropServices;
+using OpenTK.Graphics.OpenGL4;
+using OpenTK.Platform.Egl;
+
+namespace SM.OGL
+{
+ public static class GLDebugging
+ {
+ private static DebugProc _debugProc = DebugCallback;
+ private static GCHandle _debugGcHandle;
+
+ public static Action DebugAction = DefaultDebugAction;
+
+ [DebuggerStepThrough]
+ private static void DebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity,
+ int length, IntPtr message, IntPtr userparam)
+ {
+ string msg = Marshal.PtrToStringAnsi(message, length);
+ DebugAction?.Invoke(source, type, severity, msg);
+ }
+
+ public static void EnableDebugging()
+ {
+ try
+ {
+ _debugGcHandle = GCHandle.Alloc(_debugProc);
+
+ GL.DebugMessageCallback(_debugProc, IntPtr.Zero);
+ GL.Enable(EnableCap.DebugOutput);
+ GL.Enable(EnableCap.DebugOutputSynchronous);
+ }
+ catch
+ {
+ Console.WriteLine("Enableing proper GLDebugging failed. \n" +
+ "Often it fails, because your hardware doesn't provied proper OpenGL 4 \n" +
+ " or KHR_debug extension support.");
+
+ }
+ }
+
+ public static void DefaultDebugAction(DebugSource source, DebugType type, DebugSeverity severity, string msg)
+ {
+ Console.WriteLine($"{severity}, {type}, {source} -> {msg}");
+
+ if (type == DebugType.DebugTypeError) throw new Exception(msg);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SM.Core/GLObject.cs b/SM.Core/GLObject.cs
new file mode 100644
index 0000000..f448a08
--- /dev/null
+++ b/SM.Core/GLObject.cs
@@ -0,0 +1,33 @@
+using OpenTK.Graphics.OpenGL4;
+
+namespace SM.OGL
+{
+ public abstract class GLObject
+ {
+ protected int _id = -1;
+ protected virtual bool AutoCompile { get; } = false;
+
+ public virtual int ID
+ {
+ get
+ {
+ if (AutoCompile && _id < 0) Compile();
+ return _id;
+ }
+ }
+
+ public abstract ObjectLabelIdentifier TypeIdentifier { get; }
+
+ protected virtual void Compile()
+ {
+
+ }
+
+ public void Name(string name)
+ {
+ GL.ObjectLabel(TypeIdentifier, _id, name.Length, name);
+ }
+
+ public static implicit operator int(GLObject glo) => glo.ID;
+ }
+}
\ No newline at end of file
diff --git a/SM.Core/Mesh/Mesh.cs b/SM.Core/Mesh/Mesh.cs
new file mode 100644
index 0000000..edc9de5
--- /dev/null
+++ b/SM.Core/Mesh/Mesh.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using OpenTK.Graphics.OpenGL4;
+
+namespace SM.OGL.Mesh
+{
+ public class Mesh : GLObject
+ {
+ public static int BufferSizeMultiplier = 3;
+
+ protected override bool AutoCompile { get; } = true;
+ public override ObjectLabelIdentifier TypeIdentifier { get; } = ObjectLabelIdentifier.VertexArray;
+
+ public virtual PrimitiveType PrimitiveType { get; } = PrimitiveType.Triangles;
+
+ public virtual VBO Vertex { get; }
+ public virtual VBO UVs { get; }
+ public virtual VBO Normals { get; }
+
+ public virtual Dictionary AttribDataIndex { get; }
+
+ public Mesh()
+ {
+ AttribDataIndex = new Dictionary()
+ {
+ {0, Vertex},
+ {1, UVs},
+ {2, Normals},
+ };
+ }
+
+ protected override void Compile()
+ {
+ _id = GL.GenVertexArray();
+ GL.BindVertexArray(_id);
+
+ if (AttribDataIndex == null) throw new Exception("[Critical] The model requires a attribute data index.");
+
+ foreach (KeyValuePair kvp in AttribDataIndex) kvp.Value?.BindBuffer(kvp.Key);
+
+ GL.BindVertexArray(0);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SM.Core/Mesh/TypeDefinition.cs b/SM.Core/Mesh/TypeDefinition.cs
new file mode 100644
index 0000000..901efc6
--- /dev/null
+++ b/SM.Core/Mesh/TypeDefinition.cs
@@ -0,0 +1,14 @@
+using System;
+
+namespace SM.OGL.Mesh
+{
+ public struct TypeDefinition
+ {
+ internal int PointerSize;
+
+ public TypeDefinition(int pointerSize)
+ {
+ PointerSize = pointerSize;
+ }
+ }
+}
\ No newline at end of file
diff --git a/SM.Core/Mesh/VBO.cs b/SM.Core/Mesh/VBO.cs
new file mode 100644
index 0000000..3e483bc
--- /dev/null
+++ b/SM.Core/Mesh/VBO.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using OpenTK;
+using OpenTK.Graphics.OpenGL4;
+
+namespace SM.OGL.Mesh
+{
+ public class VBO : List
+ {
+ public BufferUsageHint BufferUsageHint = BufferUsageHint.StaticDraw;
+ public VertexAttribPointerType PointerType = VertexAttribPointerType.Float;
+ public int PointerSize = 3;
+ public bool Normalised = false;
+ public int PointerStride = 0;
+ public int PointerOffset = 0;
+
+ public void Add(float x, float y) => AddRange(new[] {x,y});
+ public void Add(float x, float y, float z) => AddRange(new[] {x,y,z});
+ public void Add(float x, float y, float z, float w) => AddRange(new[] {x,y,z,w});
+
+ public void BindBuffer(int attribID)
+ {
+ float[] data = ToArray();
+
+ int buffer = GL.GenBuffer();
+ GL.BindBuffer(BufferTarget.ArrayBuffer, buffer);
+ GL.BufferData(BufferTarget.ArrayBuffer, data.Length * Mesh.BufferSizeMultiplier, data, BufferUsageHint);
+
+ GL.VertexAttribPointer(attribID, PointerSize, PointerType, Normalised, PointerStride, PointerOffset);
+ GL.EnableVertexAttribArray(attribID);
+ GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SM.Core/OpenTK.dll.config b/SM.Core/OpenTK.dll.config
new file mode 100644
index 0000000..7098d39
--- /dev/null
+++ b/SM.Core/OpenTK.dll.config
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SM.Core/SM.Core.csproj b/SM.Core/SM.OGL.csproj
similarity index 69%
rename from SM.Core/SM.Core.csproj
rename to SM.Core/SM.OGL.csproj
index e272877..686419b 100644
--- a/SM.Core/SM.Core.csproj
+++ b/SM.Core/SM.OGL.csproj
@@ -7,8 +7,8 @@
{F604D684-BC1D-4819-88B5-8B5D03A17BE0}
Library
Properties
- SM.Core
- SM.Core
+ SM.OGL
+ SM.OGL
v4.5.2
512
true
@@ -31,6 +31,9 @@
4
+
+ ..\packages\OpenTK.3.2\lib\net20\OpenTK.dll
+
@@ -41,7 +44,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SM.Core/Shaders/GenericShader.cs b/SM.Core/Shaders/GenericShader.cs
new file mode 100644
index 0000000..7a8d100
--- /dev/null
+++ b/SM.Core/Shaders/GenericShader.cs
@@ -0,0 +1,50 @@
+using System;
+using OpenTK.Graphics.OpenGL4;
+
+namespace SM.OGL.Shaders
+{
+ public class GenericShader : GLObject
+ {
+ protected ShaderFileCollection ShaderFileFiles;
+ protected UniformCollection Uniforms;
+
+ public override ObjectLabelIdentifier TypeIdentifier { get; } = ObjectLabelIdentifier.Program;
+
+ public GenericShader(ShaderFileCollection shaderFileFiles)
+ {
+ ShaderFileFiles = shaderFileFiles;
+ }
+
+ public void Compile()
+ {
+
+ _id = GL.CreateProgram();
+
+ ShaderFileFiles.Append(this);
+ GL.LinkProgram(_id);
+ this.Name(GetType().Name);
+ ShaderFileFiles.Detach(this);
+
+ GL.GetProgram(_id, GetProgramParameterName.ActiveUniforms, out int uniformCount);
+ if (uniformCount < 1)
+ throw new Exception("[Critical] No uniforms has been found.");
+
+ Uniforms = new UniformCollection();
+ for (int i = 0; i < uniformCount; i++)
+ {
+ string key = GL.GetActiveUniform(_id, i, out _, out _);
+ int loc = GL.GetUniformLocation(_id, key);
+
+ if (key.StartsWith("[")) key = key.Split('[', ']')[0];
+ Uniforms.Add(key, loc);
+ }
+
+ }
+
+ public void DrawObject(Mesh.Mesh mesh, bool bindVAO)
+ {
+ if (bindVAO) GL.BindVertexArray(mesh);
+ GL.DrawArrays(mesh.PrimitiveType, 0, mesh.Vertex.Count);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SM.Core/Shaders/ShaderFile.cs b/SM.Core/Shaders/ShaderFile.cs
new file mode 100644
index 0000000..68dd5bd
--- /dev/null
+++ b/SM.Core/Shaders/ShaderFile.cs
@@ -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 StringOverrides = new Dictionary();
+ public List GLSLExtensions = new List();
+
+ public ShaderFile(string data)
+ {
+ _data = data;
+ }
+
+ private void GenerateSource()
+ {
+ foreach (KeyValuePair 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);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SM.Core/Shaders/ShaderFileCollection.cs b/SM.Core/Shaders/ShaderFileCollection.cs
new file mode 100644
index 0000000..ad58e53
--- /dev/null
+++ b/SM.Core/Shaders/ShaderFileCollection.cs
@@ -0,0 +1,34 @@
+using OpenTK.Graphics.OpenGL4;
+
+namespace SM.OGL.Shaders
+{
+ public struct ShaderFileCollection
+ {
+ public ShaderFile Vertex;
+ public ShaderFile Geometry;
+ public ShaderFile Fragment;
+
+ public ShaderFileCollection(string vertex, string fragment) : this(new ShaderFile(vertex), new ShaderFile(fragment)) {}
+
+ public ShaderFileCollection(ShaderFile vertex, ShaderFile fragment, ShaderFile geometry = default)
+ {
+ Vertex = vertex;
+ Geometry = geometry;
+ Fragment = fragment;
+ }
+
+ internal void Append(GenericShader shader)
+ {
+ Vertex.Compile(shader, ShaderType.VertexShader);
+ Geometry?.Compile(shader, ShaderType.GeometryShader);
+ Fragment.Compile(shader, ShaderType.FragmentShader);
+ }
+
+ internal void Detach(GenericShader shader)
+ {
+ GL.DetachShader(Vertex, shader);
+ if (Geometry != null) GL.DetachShader(Geometry, shader);
+ GL.DetachShader(Fragment, shader);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SM.Core/Shaders/Uniform.cs b/SM.Core/Shaders/Uniform.cs
new file mode 100644
index 0000000..be3e5c7
--- /dev/null
+++ b/SM.Core/Shaders/Uniform.cs
@@ -0,0 +1,164 @@
+using OpenTK;
+using OpenTK.Graphics;
+using OpenTK.Graphics.OpenGL4;
+
+namespace SM.OGL.Shaders
+{
+ public struct Uniform
+ {
+ ///
+ /// This contains the location for the uniform.
+ ///
+ private int Location;
+ ///
+ /// This contains the Parent collection of this uniform.
+ ///
+ internal UniformCollection Parent;
+
+
+ ///
+ /// This create a new uniform manager
+ ///
+ /// Location id
+ /// Parent collection
+ public Uniform(int location, UniformCollection parent)
+ {
+ Location = location;
+ Parent = parent;
+ }
+
+ #region Uniform1
+
+ public void SetUniform1(bool value)
+ {
+ GL.Uniform1(Location, value ? 1 : 0);
+ }
+
+ public void SetUniform1(int value) { GL.Uniform1(Location, value); }
+ public void SetUniform1(int count, params int[] values) { GL.Uniform1(Location, count, values); }
+ public void SetUniform1(int count, ref int values) { GL.Uniform1(Location, count, ref values); }
+
+
+ public void SetUniform1(uint value) { GL.Uniform1(Location, value); }
+ public void SetUniform1(int count, params uint[] values) { GL.Uniform1(Location, count, values); }
+ public void SetUniform1(int count, ref uint values) { GL.Uniform1(Location, count, ref values); }
+
+
+ public void SetUniform1(float value) { GL.Uniform1(Location, value); }
+ public void SetUniform1(int count, params float[] values) { GL.Uniform1(Location, count, values); }
+ public void SetUniform1(int count, ref float value) { GL.Uniform1(Location, count, ref value); }
+
+
+ public void SetUniform1(double value) { GL.Uniform1(Location, value); }
+ public void SetUniform1(int count, params double[] values) { GL.Uniform1(Location, count, values); }
+ public void SetUniform1(int count, ref double value) { GL.Uniform1(Location, count, ref value); }
+
+ #endregion
+
+ #region Uniform2
+
+ public void SetUniform2(float x, float y) { GL.Uniform2(Location, x, y); }
+ public void SetUniform2(double x, double y) { GL.Uniform2(Location, x, y); }
+ public void SetUniform2(uint x, uint y) { GL.Uniform2(Location, x, y); }
+ public void SetUniform2(int x, int y) { GL.Uniform2(Location, x, y); }
+
+ public void SetUniform2(int count, params float[] values) { GL.Uniform2(Location, count, values); }
+ public void SetUniform2(int count, params double[] values) { GL.Uniform2(Location, count, values); }
+ public void SetUniform2(int count, params int[] values) { GL.Uniform2(Location, count, values); }
+ public void SetUniform2(int count, params uint[] values) { GL.Uniform2(Location, count, values); }
+
+ public void SetUniform2(int count, ref float values) { GL.Uniform2(Location, count, ref values); }
+ public void SetUniform2(int count, ref double values) { GL.Uniform2(Location, count, ref values); }
+ public void SetUniform2(int count, ref uint values) { GL.Uniform2(Location, count, ref values); }
+
+ public void SetUniform2(Vector2 vector2) { GL.Uniform2(Location, vector2); }
+ public void SetUniform2(ref Vector2 vector2) { GL.Uniform2(Location, ref vector2); }
+
+ #endregion
+
+ #region Uniform3
+
+ public void SetUniform3(float x, float y, float z) { GL.Uniform3(Location, x, y, z); }
+ public void SetUniform3(double x, double y, double z) { GL.Uniform3(Location, x, y, z); }
+ public void SetUniform3(uint x, uint y, uint z) { GL.Uniform3(Location, x, y, z); }
+ public void SetUniform3(int x, int y, int z) { GL.Uniform3(Location, x, y, z); }
+
+ public void SetUniform3(int count, params float[] values) { GL.Uniform3(Location, count, values); }
+ public void SetUniform3(int count, params double[] values) { GL.Uniform3(Location, count, values); }
+ public void SetUniform3(int count, params int[] values) { GL.Uniform3(Location, count, values); }
+ public void SetUniform3(int count, params uint[] values) { GL.Uniform3(Location, count, values); }
+
+ public void SetUniform3(int count, ref float values) { GL.Uniform3(Location, count, ref values); }
+ public void SetUniform3(int count, ref double values) { GL.Uniform3(Location, count, ref values); }
+ public void SetUniform3(int count, ref uint values) { GL.Uniform3(Location, count, ref values); }
+
+ public void SetUniform3(Vector3 vector) { GL.Uniform3(Location, vector); }
+ public void SetUniform3(ref Vector3 vector) { GL.Uniform3(Location, ref vector); }
+
+ #endregion
+
+ #region Uniform4
+
+ public void SetUniform4(float x, float y, float z, float w) { GL.Uniform4(Location, x, y, z, w); }
+ public void SetUniform4(double x, double y, double z, double w) { GL.Uniform4(Location, x, y, z, w); }
+ public void SetUniform4(uint x, uint y, uint z, uint w) { GL.Uniform4(Location, x, y, z, w); }
+ public void SetUniform4(int x, int y, int z, int w) { GL.Uniform4(Location, x, y, z, w); }
+
+ public void SetUniform4(int count, params float[] values) { GL.Uniform4(Location, count, values); }
+ public void SetUniform4(int count, params double[] values) { GL.Uniform4(Location, count, values); }
+ public void SetUniform4(int count, params int[] values) { GL.Uniform4(Location, count, values); }
+ public void SetUniform4(int count, params uint[] values) { GL.Uniform4(Location, count, values); }
+
+ public void SetUniform4(int count, ref float values) { GL.Uniform4(Location, count, ref values); }
+ public void SetUniform4(int count, ref double values) { GL.Uniform4(Location, count, ref values); }
+ public void SetUniform4(int count, ref uint values) { GL.Uniform4(Location, count, ref values); }
+
+ public void SetUniform4(Vector4 vector) { GL.Uniform4(Location, vector); }
+ public void SetUniform4(ref Vector4 vector) { GL.Uniform4(Location, ref vector); }
+
+ public void SetUniform4(Color4 color) { GL.Uniform4(Location, color); }
+ public void SetUniform4(Quaternion quaternion) { GL.Uniform4(Location, quaternion); }
+
+ #endregion
+
+ #region Matrix2
+
+ public void SetMatrix2(ref Matrix2 matrix, bool transpose = false) { GL.UniformMatrix2(Location, transpose, ref matrix); }
+
+ public void SetMatrix2(int count, ref double value, bool transpose = false) { GL.UniformMatrix2(Location, count, transpose, ref value); }
+ public void SetMatrix2(int count, ref float value, bool transpose = false) { GL.UniformMatrix2(Location, count, transpose, ref value); }
+
+ public void SetMatrix2(int count, double[] value, bool transpose = false) { GL.UniformMatrix2(Location, count, transpose, value); }
+ public void SetMatrix2(int count, float[] value, bool transpose = false) { GL.UniformMatrix2(Location, count, transpose, value); }
+
+ #endregion
+
+ #region Matrix3
+
+ public void SetMatrix3(ref Matrix3 matrix, bool transpose = false) { GL.UniformMatrix3(Location, transpose, ref matrix); }
+
+ public void SetMatrix3(int count, ref double value, bool transpose = false) { GL.UniformMatrix3(Location, count, transpose, ref value); }
+ public void SetMatrix3(int count, ref float value, bool transpose = false) { GL.UniformMatrix3(Location, count, transpose, ref value); }
+
+ public void SetMatrix3(int count, double[] value, bool transpose = false) { GL.UniformMatrix3(Location, count, transpose, value); }
+ public void SetMatrix3(int count, float[] value, bool transpose = false) { GL.UniformMatrix3(Location, count, transpose, value); }
+
+ #endregion
+
+ #region Matrix4
+
+ public void SetMatrix4(Matrix4 matrix, bool transpose = false)
+ {
+ GL.UniformMatrix4(Location, transpose, ref matrix);
+ }
+ public void SetMatrix4(ref Matrix4 matrix, bool transpose = false) { GL.UniformMatrix4(Location, transpose, ref matrix); }
+
+ public void SetMatrix4(int count, ref double value, bool transpose = false) { GL.UniformMatrix4(Location, count, transpose, ref value); }
+ public void SetMatrix4(int count, ref float value, bool transpose = false) { GL.UniformMatrix4(Location, count, transpose, ref value); }
+
+ public void SetMatrix4(int count, double[] value, bool transpose = false) { GL.UniformMatrix4(Location, count, transpose, value); }
+ public void SetMatrix4(int count, float[] value, bool transpose = false) { GL.UniformMatrix4(Location, count, transpose, value); }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/SM.Core/Shaders/UniformCollection.cs b/SM.Core/Shaders/UniformCollection.cs
new file mode 100644
index 0000000..8bba1ca
--- /dev/null
+++ b/SM.Core/Shaders/UniformCollection.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using OpenTK.Graphics.OpenGL4;
+
+namespace SM.OGL.Shaders
+{
+ public class UniformCollection : Dictionary
+ {
+ internal GenericShader _parentShader;
+
+ public new Uniform this[string key]
+ {
+ get
+ {
+ try
+ {
+ return base[key];
+ }
+ catch (KeyNotFoundException)
+ {
+ Console.WriteLine("[Error] Uniform '"+key+"' was not found. Tried to recreate it.");
+ Uniform u = new Uniform(GL.GetUniformLocation(_parentShader, key), this);
+ Add(key, u);
+ return u;
+ }
+ }
+ }
+
+ public void Add(string key, int location)
+ {
+ base.Add(key, new Uniform(location, this));
+ }
+ }
+}
\ No newline at end of file
diff --git a/SM.Core/packages.config b/SM.Core/packages.config
new file mode 100644
index 0000000..75397e4
--- /dev/null
+++ b/SM.Core/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/SMRendererV3.sln b/SMRendererV3.sln
index 1e775c0..7e7e9e3 100644
--- a/SMRendererV3.sln
+++ b/SMRendererV3.sln
@@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.30413.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SMRenderer", "SMRenderer", "{47EA2879-1D40-4683-BA6C-AB51F286EBDE}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Core", "SM.Core\SM.Core.csproj", "{F604D684-BC1D-4819-88B5-8B5D03A17BE0}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.OGL", "SM.Core\SM.OGL.csproj", "{F604D684-BC1D-4819-88B5-8B5D03A17BE0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SM.Base", "SM.Base\SM.Base.csproj", "{8E733844-4204-43E7-B3DC-3913CDDABB0D}"
EndProject
diff --git a/SM_TEST/OpenTK.dll.config b/SM_TEST/OpenTK.dll.config
new file mode 100644
index 0000000..7098d39
--- /dev/null
+++ b/SM_TEST/OpenTK.dll.config
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SM_TEST/Program.cs b/SM_TEST/Program.cs
index 6bed9b7..1362f8b 100644
--- a/SM_TEST/Program.cs
+++ b/SM_TEST/Program.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using SM.Base;
namespace SM_TEST
{
@@ -10,7 +11,8 @@ namespace SM_TEST
{
static void Main(string[] args)
{
- Console.Write("");
+ GenericWindow window = new GenericWindow();
+ window.Run();
}
}
}
diff --git a/SM_TEST/SM_TEST.csproj b/SM_TEST/SM_TEST.csproj
index c455aec..1c6d4db 100644
--- a/SM_TEST/SM_TEST.csproj
+++ b/SM_TEST/SM_TEST.csproj
@@ -33,6 +33,9 @@
4
+
+ ..\packages\OpenTK.3.2\lib\net20\OpenTK.dll
+
@@ -48,6 +51,18 @@
+
+
+
+
+
+ {8e733844-4204-43e7-b3dc-3913cddabb0d}
+ SM.Base
+
+
+ {f604d684-bc1d-4819-88b5-8b5d03a17be0}
+ SM.OGL
+
\ No newline at end of file
diff --git a/SM_TEST/packages.config b/SM_TEST/packages.config
new file mode 100644
index 0000000..75397e4
--- /dev/null
+++ b/SM_TEST/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file