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
51
SMCode/SM.OGL/GLDebugging.cs
Normal file
51
SMCode/SM.OGL/GLDebugging.cs
Normal file
|
|
@ -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<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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue