Holidays 12.10. -> 25.10.2020
~ Moved code around in files. SM.Base: + PostProcessing-system + OnInitialization() for Scenes. + Shader-Extensions + Added option to not react while unfocused to the window. + Added Screenshots to the window. + Connected the log system to the SM.OGL-action system. ~ Replaced IShader with abstract MaterialShader. ~ When a log compression folder doesn't exist, it will create one. SM.OGL: + Added support for UniformArrays + Added ShaderPreProcessing + Added Shader Extensions. + Added Debug actions. + SM.OGL settings ~ Framebuffer Size is automaticly changed, when the window and scale is set. SM2D: + Added easy shader drawing.
This commit is contained in:
parent
2c00dbd31a
commit
03b3942732
102 changed files with 2683 additions and 1398 deletions
|
|
@ -1,36 +1,33 @@
|
|||
using System;
|
||||
#region usings
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.InteropServices;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Platform.Egl;
|
||||
using ErrorCode = OpenTK.Graphics.OpenGL4.ErrorCode;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace SM.OGL
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains everything that is needed to debug OpenGL
|
||||
/// Contains everything that is needed to debug OpenGL
|
||||
/// </summary>
|
||||
public static class GLDebugging
|
||||
{
|
||||
private static DebugProc _debugProc = DebugCallback;
|
||||
private static GCHandle _debugGcHandle;
|
||||
|
||||
/// <summary>
|
||||
/// A action that is performed, when a OpenGL-error occurs.
|
||||
/// </summary>
|
||||
public static Action<DebugSource, DebugType, DebugSeverity, string> 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);
|
||||
var msg = Marshal.PtrToStringAnsi(message, length);
|
||||
GLCustomActions.AtKHRDebug?.Invoke(source, type, severity, msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the debugging.
|
||||
/// Enables the debugging.
|
||||
/// </summary>
|
||||
public static void EnableDebugging()
|
||||
{
|
||||
|
|
@ -47,40 +44,33 @@ namespace SM.OGL
|
|||
Console.WriteLine("Enableing proper GLDebugging failed. \n" +
|
||||
"Often it fails, because your hardware doesn't provide proper OpenGL 4 \n" +
|
||||
" or KHR_debug extension support.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default action for 'DebugAction'.
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="severity"></param>
|
||||
/// <param name="msg"></param>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A action, that is performed, when <see cref="GLDebugging.CheckGLErrors"/> find an error.
|
||||
/// </summary>
|
||||
public static Action<ErrorCode> GlErrorAction;
|
||||
|
||||
/// <summary>
|
||||
/// Checks for OpenGL errors.
|
||||
/// Checks for OpenGL errors.
|
||||
/// </summary>
|
||||
public static bool CheckGLErrors()
|
||||
{
|
||||
bool hasError = false;
|
||||
var hasError = false;
|
||||
ErrorCode c;
|
||||
while ((c = GL.GetError()) != ErrorCode.NoError)
|
||||
{
|
||||
hasError = true;
|
||||
GlErrorAction?.Invoke(c);
|
||||
GLCustomActions.AtError?.Invoke("A GLError occurred: " + c);
|
||||
}
|
||||
|
||||
return hasError;
|
||||
}
|
||||
|
||||
public static bool CheckGLErrors(string formating)
|
||||
{
|
||||
var hasError = false;
|
||||
ErrorCode c;
|
||||
while ((c = GL.GetError()) != ErrorCode.NoError)
|
||||
{
|
||||
hasError = true;
|
||||
GLCustomActions.AtError?.Invoke(formating.Replace("%code%", c.ToString()));
|
||||
}
|
||||
|
||||
return hasError;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue