/// <summary> /// Default debug callback /// </summary> /// <param name="source"></param> /// <param name="type"></param> /// <param name="id"></param> /// <param name="severity"></param> /// <param name="length"></param> /// <param name="messagePtr"></param> /// <param name="userParam"></param> /// <exception cref="GLErrorException"></exception> private static void DebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr messagePtr, IntPtr userParam) { #if DEBUG switch (id) { // Ignore these message IDs case 131185: return; } var message = Marshal.PtrToStringAnsi(messagePtr, length); if (type == DebugType.DebugTypeError) { Log.Error( $"(Source: {source.GetSimpleName()}, Severity: {severity.GetSimpleName()}) {message}\n", "GL" ); throw new GLErrorException(message); } else if ( type == DebugType.DebugTypePerformance || type == DebugType.DebugTypePortability || type == DebugType.DebugTypeUndefinedBehavior ) { Log.Warning( $"(Source: {source.GetSimpleName()} Severity: {severity.GetSimpleName()}) {message}\n", "GL" ); } else { Log.Info( $"(Source: {source.GetSimpleName()}) {message}\n", "GL" ); } #endif }