示例#1
0
        private static void DebugCallback(DebugSource source,
                                          DebugType type,
                                          int id,
                                          DebugSeverity severity,
                                          int length,
                                          IntPtr message,
                                          IntPtr userParam)
        {
            string messageString = Marshal.PtrToStringAnsi(message, length);

            DebugMessage?.Invoke(messageString, source, type, severity, id);

            _log.Debug($"{severity.GetName()} {type.GetName()} | {messageString}");

            // if (type == DebugType.DebugTypePerformance)
            // {
            //     throw new Exception("Performance Error");
            // }


            if (type == DebugType.DebugTypeError && severity == DebugSeverity.DebugSeverityHigh)
            {
                throw new Exception(messageString);
            }
        }
示例#2
0
        //-----------------------------------------------------------------------------------------
        static void DebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length,
                                  IntPtr message, IntPtr userParam)
        {
            string msg = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(message);

            Console.WriteLine("{0}[GL] {1}; {2}; {3}; {4}; {5}", Program.ElapsedTimeSeconds, source, type, id, severity, msg);
        }
示例#3
0
        private void GL_ErrorCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int lenght, IntPtr message, IntPtr userParam)
        {
            Log.Level level;

            switch (severity)
            {
            case DebugSeverity.DebugSeverityHigh:
                level = Log.Level.Error;
                break;

            case DebugSeverity.DebugSeverityMedium:
                level = Log.Level.Error;
                break;

            case DebugSeverity.DebugSeverityLow:
                level = Log.Level.Warning;
                break;

            default:
                level = Log.Level.Info;
                break;
            }
            string strMessage = null;

            if (message != IntPtr.Zero)
            {
                strMessage = System.Runtime.InteropServices.Marshal.PtrToStringUTF8(message);
            }
            Log.Print(level, strMessage, $"GL {source}");
        }
示例#4
0
 private static void DebugCallback(DebugSource source, DebugType type, int id,
 DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
 {
     string msg = Marshal.PtrToStringAnsi(message);
     Console.WriteLine("[GL] {0}; {1}; {2}; {3}; {4}",
         source, type, id, severity, msg);
 }
示例#5
0
        private static void GLDebugHandler(
            DebugSource source,
            DebugType type,
            int id,
            DebugSeverity severity,
            int length,
            IntPtr message,
            IntPtr userParam)
        {
            string fullMessage = $"{type} {severity} {source} {Marshal.PtrToStringAnsi(message)}";

            switch (type)
            {
            case DebugType.DebugTypeError:
                Logger.PrintDebug(LogClass.Gpu, fullMessage);
                break;

            case DebugType.DebugTypePerformance:
                Logger.PrintWarning(LogClass.Gpu, fullMessage);
                break;

            default:
                Logger.PrintDebug(LogClass.Gpu, fullMessage);
                break;
            }
        }
示例#6
0
 public static void DebugMessageInsertAMD(Int32 category, DebugSeverity severity, UInt32 id, Int32 length, String buf)
 {
     Debug.Assert(Delegates.pglDebugMessageInsertAMD != null, "pglDebugMessageInsertAMD not implemented");
     Delegates.pglDebugMessageInsertAMD(category, (Int32)severity, id, length, buf);
     LogCommand("glDebugMessageInsertAMD", null, category, severity, id, length, buf);
     DebugCheckErrors(null);
 }
示例#7
0
 private void DebugProc(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
 {
     string msg = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(message, length);
     Console.WriteLine(
         "{0} {1} {2} {3}: {4}",
         source, type, id, severity, msg);
 }
示例#8
0
        private static void GLDebugHandler(
            DebugSource source,
            DebugType type,
            int id,
            DebugSeverity severity,
            int length,
            IntPtr message,
            IntPtr userParam)
        {
            string msg = Marshal.PtrToStringUTF8(message).Replace('\n', ' ');

            switch (type)
            {
            case DebugType.DebugTypeError: Logger.Error?.Print(LogClass.Gpu, $"{severity}: {msg}\nCallStack={Environment.StackTrace}", "GLERROR"); break;

            case DebugType.DebugTypePerformance: Logger.Warning?.Print(LogClass.Gpu, $"{severity}: {msg}", "GLPERF"); break;

            case DebugType.DebugTypePushGroup: Logger.Info?.Print(LogClass.Gpu, $"{{ ({id}) {severity}: {msg}", "GLINFO"); break;

            case DebugType.DebugTypePopGroup: Logger.Info?.Print(LogClass.Gpu, $"}} ({id}) {severity}: {msg}", "GLINFO"); break;

            default:
                if (source == DebugSource.DebugSourceApplication)
                {
                    Logger.Info?.Print(LogClass.Gpu, $"{type} {severity}: {msg}", "GLINFO");
                }
                else
                {
                    Logger.Debug?.Print(LogClass.Gpu, $"{type} {severity}: {msg}", "GLDEBUG");
                }
                break;
            }
        }
示例#9
0
        static void OnDebugOutput(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
        {
            byte[] chars = new byte[length];
            System.Runtime.InteropServices.Marshal.Copy(message, chars, 0, length);
            var msg = System.Text.Encoding.ASCII.GetString(chars);

            Console.WriteLine("[GL] " + msg);
        }
示例#10
0
 private static void GLDebugAction(DebugSource source, DebugType type, DebugSeverity severity, string msg)
 {
     if (type.HasFlag(DebugType.DebugTypeError))
     {
         throw new Exception("[GLError] " + msg);
     }
     Write("GL" + (type != DebugType.DontCare ? type.ToString().Substring(9) : "DontCare"), ConsoleColor.Gray, msg);
 }
示例#11
0
        private static void DebugCallback(DebugSource source, DebugType type, int id,
                                          DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
        {
            string msg = Marshal.PtrToStringAnsi(message);

            Console.WriteLine("[GL] {0}; {1}; {2}; {3}; {4}",
                              source, type, id, severity, msg);
        }
示例#12
0
 /// <summary>
 /// Create a new instance
 /// </summary>
 /// <param name="source">The <see cref="DebugSource"/> for this debug message.</param>
 /// <param name="type">The <see cref="DebugType"/> for this debug message.</param>
 /// <param name="id">The id for this debug message.</param>
 /// <param name="severity">The <see cref="DebugSeverity"/> for this debug message.</param>
 /// <param name="message">The debug message.</param>
 public DebugEventArgs(DebugSource source, DebugType type, int id, DebugSeverity severity, string message)
 {
     Source   = source;
     Type     = type;
     Id       = id;
     Severity = severity;
     Message  = message;
 }
示例#13
0
        private void DebugProc(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
        {
            string msg = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(message, length);

            Console.WriteLine(
                "{0} {1} {2} {3}: {4}",
                source, type, id, severity, msg);
        }
 static void PCCallbackHandler(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
 {
     if (severity == DebugSeverity.DebugSeverityHigh || severity == DebugSeverity.DebugSeverityMedium)
     {
         string msg = Marshal.PtrToStringAnsi(message);
         Console.WriteLine("[GL] {0}; {1}; {2}; {3}; {4}", source, type, id, severity, msg);
     }
 }
示例#15
0
    public static void GLDebugProc(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
    {
        string strMessage = Marshal.PtrToStringAnsi(message);


        Console.WriteLine($"[{ (type == DebugType.DebugTypeError ? "**GL ERROR**" : type.ToString())}; {severity.ToString()}]: {strMessage}; From: {source.ToString()}");
        Debugger.Break();
    }
 static void PCCallbackHandler(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
 {
     if (severity == DebugSeverity.DebugSeverityHigh || severity == DebugSeverity.DebugSeverityMedium)
     {
         string msg = Marshal.PtrToStringAnsi(message);
         Console.WriteLine("[GL] {0}; {1}; {2}; {3}; {4}", source, type, id, severity, msg);
     }
 }
        /// <summary>
        ///     Default action for 'AtKHRDebug'.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="type"></param>
        /// <param name="severity"></param>
        /// <param name="msg"></param>
        private 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);
            }
        }
示例#18
0
 public DebugMessageEventArgs(DebugSource source, DebugType type, int id, DebugSeverity severity, string msg, IntPtr userParam)
 {
     Source    = source;
     Type      = type;
     ID        = id;
     Severity  = severity;
     Message   = msg;
     UserParam = userParam;
 }
示例#19
0
        private static void DebugLog(DebugSource source, DebugType type, int id, DebugSeverity severity,
                                     int length, IntPtr message, IntPtr userParam)
        {
            var src = source switch
            {
                DebugSource.DebugSourceApi => "API",
                DebugSource.DebugSourceApplication => "App",
                DebugSource.DebugSourceOther => "???",
                DebugSource.DebugSourceShaderCompiler => "ShC",
                DebugSource.DebugSourceThirdParty => "3rd",
                DebugSource.DebugSourceWindowSystem => "DWM",
                DebugSource.DontCare => "WTF",
                _ => "WTF"
            };

            var sev = severity switch
            {
                DebugSeverity.DebugSeverityHigh => "HIGH",
                DebugSeverity.DebugSeverityLow => "Low ",
                DebugSeverity.DebugSeverityMedium => "Med.",
                DebugSeverity.DebugSeverityNotification => "Note",
                _ => "????"
            };

            var msg = Marshal.PtrToStringAnsi(message);

            if (msg.Contains("unknown") && msg.Contains("object"))
            {
                return; // God is dead, and this shitty hack has killed him
            }
            // I beg you, future graphics programmers that will be inheriting this codebase,
            // please fix this.

            var shouldError = false;

            switch (type)
            {
            case DebugType.DebugTypeUndefinedBehavior:
            case DebugType.DebugTypeDeprecatedBehavior:
            case DebugType.DebugTypeError:
                Log.Error("OpenGL reported an error!");
                Log.Error("-------------------------\n");
                Log.Error($"[{src}] ({sev}) {msg}");
                Log.Error("\nThis is a bug. Report this.\n");
                shouldError = true;
                break;

            case DebugType.DebugTypePerformance:
                Log.Info($"OpenGL (performance): [{src}] ({sev}) {msg}");
                break;
            }

            if (!Engine.Running && shouldError)
            {
                throw new Exception($"OpenGL error! (before engine rendered frame 1): [{src}] ({sev}) {msg}");
            }
        }
示例#20
0
        private void OnDebugMessage(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr user)
        {
            // Ignores
            if (id == 0x00020071)
            {
                return;                   // memory usage
            }
            if (id == 0x00020084)
            {
                return;                   // Texture state usage warning: Texture 0 is base level inconsistent. Check texture size.
            }
            if (id == 0x00020061)
            {
                return;                   // Framebuffer detailed info: The driver allocated storage for renderbuffer 1.
            }
            if (id == 0x00020004)
            {
                return;                   // Usage warning: Generic vertex attribute array ... uses a pointer with a small value (...). Is this intended to be used as an offset into a buffer object?
            }
            if (id == 0x00020072)
            {
                return;                   // Buffer performance warning: Buffer object ... (bound to ..., usage hint is GL_STATIC_DRAW) is being copied/moved from VIDEO memory to HOST memory.
            }
            if (id == 0x00020074)
            {
                return;                   // Buffer usage warning: Analysis of buffer object ... (bound to ...) usage indicates that the GPU is the primary producer and consumer of data for this buffer object.  The usage hint s upplied with this buffer object, GL_STATIC_DRAW, is inconsistent with this usage pattern.  Try using GL_STREAM_COPY_ARB, GL_STATIC_COPY_ARB, or GL_DYNAMIC_COPY_ARB instead.
            }
            string sourceString = source.ToString();

            if (sourceString.StartsWith("DebugSource"))
            {
                sourceString = sourceString.Remove(0, "DebugSource".Length);
            }

            string typeString = type.ToString();

            if (typeString.StartsWith("DebugType"))
            {
                typeString = typeString.Remove(0, "DebugType".Length);
            }

            string severityString = severity.ToString();

            if (severityString.StartsWith("DebugSeverity"))
            {
                severityString = severityString.Remove(0, "DebugSeverity".Length);
            }

            string messageString = string.Format("(OpenGL) ({0}) ({1}) ({2}) {3}", severityString, sourceString, typeString, Marshal.PtrToStringAnsi(message, length));


            Log.Debug(messageString);
            Log.FlushBuffer();
        }
示例#21
0
        private static void GLDebugProc(DebugSource source, DebugType type, uint id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
        {
            string strMessage;

            // Decode message string
            unsafe {
                strMessage = Encoding.ASCII.GetString((byte *)message.ToPointer(), length);
            }

            Console.WriteLine($"{source}, {type}, {severity}: {strMessage}");
        }
示例#22
0
        private void DebugCallback(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
        {
            var errorMessage = Marshal.PtrToStringAnsi(message, length);
            var meta         = $"OpenGL {type} from {source} with id={id} of {severity} with message";

            Debug.WriteLine(meta);
            Debug.Indent();
            Debug.WriteLine(errorMessage);
            Debug.Unindent();
            //if(DebugSeverity.DebugSeverityNotification != severity) throw new GLException($"{meta} {errorMessage}");
        }
 private DebugProc DefaultDebugCallback(DebugSeverity minimumSeverity)
 {
     return((DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam) =>
     {
         if (severity >= minimumSeverity)
         {
             string messageString = Marshal.PtrToStringAnsi(message, length);
             System.Diagnostics.Debug.WriteLine($"GL DEBUG MESSAGE: {source}, {type}, {id}. {severity}: {messageString}");
         }
     });
 }
示例#24
0
        private static void OnGlMessage(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userparam)
        {
            if (severity == DebugSeverity.DebugSeverityNotification || SuppressedGlMessages.Contains(id))
            {
                return;
            }

            var msg = Marshal.PtrToStringAnsi(message, length);

            Lumberjack.Debug("OpenGL", msg);
        }
        private static void OnGlMessage(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userparam)
        {
            if (severity == DebugSeverity.DebugSeverityNotification)
            {
                return;
            }

            var msg = Marshal.PtrToStringAnsi(message, length);

            _glLogger.Debug(msg);
        }
示例#26
0
 public static string GetName(this DebugSeverity severity)
 {
     return(severity switch
     {
         DebugSeverity.DontCare => "Don't Care",
         DebugSeverity.DebugSeverityHigh => "High",
         DebugSeverity.DebugSeverityMedium => "Medium",
         DebugSeverity.DebugSeverityLow => "Low",
         DebugSeverity.DebugSeverityNotification => "Notif",
         _ => "???",
     });
示例#27
0
        static void GLDebugProc(DebugSource source, DebugType type, uint id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
        {
            string strMessage;

            unsafe
            {
                strMessage = Encoding.ASCII.GetString((byte *)message.ToPointer(), length);
            }

            TheLiveCoders.DebugTrace($"{source}, {type}, {severity}: {strMessage}");
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DebugOutputGL"/> class.
        /// </summary>
        /// <param name="filterDebugSeverity">The lowest severity type that should cause a <see cref="DebugEvent"/></param>
        public DebugOutputGL(DebugSeverity filterDebugSeverity = DebugSeverity.DebugSeverityLow)
        {
            Version version = new(GL.GetInteger(GetPName.MajorVersion), GL.GetInteger(GetPName.MinorVersion));

            if (version < new Version(4, 3))
            {
                throw new Exception("OpenGL version too low for debug output. Use glError instead.");
            }
            ContextFlagMask flags     = (ContextFlagMask)GL.GetInteger(GetPName.ContextFlags);
            var             debugFlag = ContextFlagMask.ContextFlagDebugBit & flags;

            if (0 == debugFlag)
            {
                throw new Exception("OpenGL context is not in debug mode.");
            }
            _debugCallback = DebugCallback;             //need to keep an instance, otherwise delegate is garbage collected
            GL.Enable(EnableCap.DebugOutput);
            GL.Enable(EnableCap.DebugOutputSynchronous);
            GL.DebugMessageCallback(_debugCallback, IntPtr.Zero);
            switch (filterDebugSeverity)
            {
            case DebugSeverity.DebugSeverityHigh:
                _filter.Add(DebugSeverity.DebugSeverityHigh);
                break;

            case DebugSeverity.DebugSeverityMedium:
                _filter.Add(DebugSeverity.DebugSeverityHigh);
                _filter.Add(DebugSeverity.DebugSeverityMedium);
                break;

            case DebugSeverity.DebugSeverityLow:
                _filter.Add(DebugSeverity.DebugSeverityHigh);
                _filter.Add(DebugSeverity.DebugSeverityMedium);
                _filter.Add(DebugSeverity.DebugSeverityLow);
                break;

            case DebugSeverity.DebugSeverityNotification:
                _filter.Add(DebugSeverity.DebugSeverityHigh);
                _filter.Add(DebugSeverity.DebugSeverityMedium);
                _filter.Add(DebugSeverity.DebugSeverityLow);
                _filter.Add(DebugSeverity.DebugSeverityNotification);
                break;

            case DebugSeverity.DontCare:
                _filter.Add(DebugSeverity.DebugSeverityHigh);
                _filter.Add(DebugSeverity.DebugSeverityMedium);
                _filter.Add(DebugSeverity.DebugSeverityLow);
                _filter.Add(DebugSeverity.DebugSeverityNotification);
                _filter.Add(DebugSeverity.DontCare);
                break;
            }
        }
示例#29
0
 public static void DebugMessageEnableAMD(Int32 category, DebugSeverity severity, Int32 count, UInt32[] ids, bool enabled)
 {
     unsafe
     {
         fixed(UInt32 *p_ids = ids)
         {
             Debug.Assert(Delegates.pglDebugMessageEnableAMD != null, "pglDebugMessageEnableAMD not implemented");
             Delegates.pglDebugMessageEnableAMD(category, (Int32)severity, count, p_ids, enabled);
             LogCommand("glDebugMessageEnableAMD", null, category, severity, count, ids, enabled);
         }
     }
     DebugCheckErrors(null);
 }
示例#30
0
 public static void DebugMessageEnableAMD(int category, DebugSeverity severity, uint[] ids, bool enabled)
 {
     unsafe
     {
         fixed(uint *p_ids = ids)
         {
             Debug.Assert(Delegates.pglDebugMessageEnableAMD != null, "pglDebugMessageEnableAMD not implemented");
             Delegates.pglDebugMessageEnableAMD(category, (int)severity, ids.Length, p_ids, enabled);
             LogCommand("glDebugMessageEnableAMD", null, category, severity, ids.Length, ids, enabled);
         }
     }
     DebugCheckErrors(null);
 }
示例#31
0
        private void DebugLog(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userParam)
        {
            string msg = Marshal.PtrToStringAnsi(message, length);

            Console.WriteLine("[Graphics] {0} {1} {4}", source, type, id, severity, msg);

#if DEBUG
            if (severity == DebugSeverity.DebugSeverityHigh)
            {
                // Force break point on debug build
                System.Diagnostics.Debugger.Break();
            }
#endif
        }
示例#32
0
        private static string FormatMsg(DebugSeverity severity, string msg, object[] param)
        {
            string retVal = msg;
            if (param != null)
            {
                for (int i = 0; i < param.Length; i++)
                {
                    msg.Replace("{" + i + "}", param[i].ToString());
                }
            }

            return String.Format("{2} [{3}] :{0} #{1}", msg, Thread.CurrentThread.ManagedThreadId,
                                                                DateTime.Now.ToString("g"), severity.ToString());
        }
示例#33
0
        private static string FormatMsg(DebugSeverity severity, string msg, object[] param)
        {
            string retVal = msg;

            if (param != null)
            {
                for (int i = 0; i < param.Length; i++)
                {
                    msg.Replace("{" + i + "}", param[i].ToString());
                }
            }

            return(String.Format("{2} [{3}] :{0} #{1}", msg, Thread.CurrentThread.ManagedThreadId,
                                 DateTime.Now.ToString("g"), severity.ToString()));
        }
示例#34
0
        private static void DebugCallback(DebugSource source,
            DebugType type,
            int id,
            DebugSeverity severity,
            int length,
            IntPtr message,
            IntPtr userParam)
        {
            string messageString = Marshal.PtrToStringAnsi(message, length);

            Console.WriteLine($"{severity} {type} | {messageString}");

            if (type == DebugType.DebugTypeError)
            {
                throw new Exception(messageString);
            }
        }
示例#35
0
        public static void Log(DebugSeverity severity, string msg, params object[] param)
        {
            Func<String, DebugSeverity, bool> logFunction = null;

            if((severity & DebugSeverity.MessageBox) == DebugSeverity.MessageBox)
            {
                logFunction = LogInDialog;
            }
            else if((severity & DebugSeverity.Trace) == DebugSeverity.Trace)
            {
                logFunction = LogTrace;
            }

            if(logFunction != null)
            {
                msg = FormatMsg(severity, msg, param);
                logFunction(msg, severity);
                LogInFile(msg);
            }
        }
 /// <summary>
 /// To easily support custom application timestamps, applications can inject their own messages to the debug message stream
 /// </summary>        
 /// <param name="severity">indicates its severity level as defined by the application.</param>
 /// <param name="id">ID is defined by the application.</param>
 /// <param name="message">message</param>
 /// <param name="category">must be DEBUG_CATEGORY_APPLICATION_AMD</param>
 public static void DebugMessageInsertAMD(DebugSeverity severity, uint id, string message, DebugCategoryAMD category = DebugCategoryAMD.APPLICATION_AMD)
 {
     Delegates.glDebugMessageInsertAMD(category, severity, id, message.Length, message);
 }
示例#37
0
 /// <summary>
 /// Insert a new debug message in the debug message log array.
 /// </summary>
 /// <param name="source">Source of inserted message.</param>
 /// <param name="type">type of inserted message.</param>
 /// <param name="id">id of inserted message. Userid has own range of ids.</param>
 /// <param name="severity">Severity of inserted message.</param>
 /// <param name="Text">The text of inserted message.</param>
 public static void DebugMessageInsertARB(DebugSource source, DebugType type, uint id, DebugSeverity severity, string Text)
 {
     Delegates.glDebugMessageInsertARB(source, type, id, severity, Text.Length, Text);
 }
示例#38
0
 /// <summary>
 /// Changes the properties of an array of debug message ids.
 /// This might be source, type, severity or just enable/disable them.
 /// Enables or Disables an array of Debug Messages ids
 /// </summary>
 /// <param name="source">Source of ids.</param>
 /// <param name="type">Type of ids</param>
 /// <param name="severity">Severity of ids.</param>
 /// <param name="ids">array of ids to change.</param>
 /// <param name="Enabled">Enables or disables the ids.</param>
 public static void DebugMessageControlARB(DebugSource source, DebugType type, DebugSeverity severity, uint[] ids, bool Enabled)
 {
     Delegates.glDebugMessageControlARB(source, type, severity, ids.Length, ref ids[0], Enabled);
 }
示例#39
0
        /// <summary>
        /// Retrives a number of messages from message log.
        /// How many retrives is determined by Math.Min([all arrays]) and availible messages.
        /// </summary>
        /// <param name="sources"></param>
        /// <param name="types"></param>
        /// <param name="ids"></param>
        /// <param name="severities"></param>
        /// <param name="lengths"></param>
        /// <param name="messageLog">A single preallocated stringbuilder with enough capacity to contain all the messages?</param>
        /// <returns></returns>
        public static uint GetDebugMessageLogARB(DebugSource[] sources, DebugType[] types, uint[] ids, DebugSeverity[] severities, int[] lengths, StringBuilder messageLog)
        {
            var count = Math.Min(sources.Length, Math.Min(types.Length, Math.Min(ids.Length, Math.Min(severities.Length, lengths.Length))));

            return Delegates.glGetDebugMessageLogARB((uint)count, messageLog.Capacity, ref sources[0], ref types[0], ref ids[0], ref severities[0], ref lengths[0], messageLog);
        }
示例#40
0
 private static bool LogTrace(string msg, DebugSeverity severity)
 {
     Trace.WriteLine(msg);
     return true;
 }
示例#41
0
        /// <summary>
        /// Retrives a number of messages from message log and return the messages in array.
        /// </summary>
        /// <param name="sources"></param>
        /// <param name="types"></param>
        /// <param name="ids"></param>
        /// <param name="severities"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public static string[] GetDebugMessageLog(DebugSource[] sources, DebugType[] types, uint[] ids, DebugSeverity[] severities, int count = -1)
        {
            if (count == -1)
            {
                count = GetIntegerv(GetParameters.DebugLoggedMessages);
            }
            else
                count = Math.Min(sources.Length, Math.Min(types.Length, Math.Min(ids.Length, severities.Length))); // , MessageLogs.Length))));

            var maxmessagelength = GetIntegerv(GetParameters.MaxDebugMessageLength);
            var sb = new StringBuilder(count * maxmessagelength + 4);

            var lengths = new int[count];

            var result = (int)Delegates.glGetDebugMessageLog((uint)count, sb.Capacity - 2, ref sources[0], ref types[0], ref ids[0], ref severities[0], ref lengths[0], sb);

            if (result > 0)
            {
                var messages = new string[Math.Min(result, lengths.Length)];
                int lastpos = 0;
                for (int i = 0; i < messages.Length; i++)
                {
                    messages[i] = sb.ToString(lastpos, lengths[i] - 1);
                    lastpos = lengths[i];
                }

                return messages;
            }
            else
                return new string[0];
        }
 /// <summary>
 /// Applications can control which messages are generated
 /// </summary>
 /// <param name="category">Zero means all categories.</param>
 /// <param name="severity">Zero means all severities.</param>
 /// <param name="ids">if category or serverity is zero, ids is ignored.</param>
 /// <param name="enabled">Enables or disables the debug messages matched</param>
 /// <remarks>
 /// All messages of severity level DEBUG_SEVERITY_MEDIUM_AMD and DEBUG_SEVERITY_HIGH_AMD in all categories are initially enabled, and all messages at DEBUG_SEVERITY_LOW_AMD are initially disabled.
 /// </remarks>
 public static void DebugMessageEnableAMD(DebugCategoryAMD category, DebugSeverity severity, uint[] ids, bool enabled)
 {
     Delegates.glDebugMessageEnableAMD(category, severity, ids.Length, ref ids[0], enabled);
 }
        public static uint GetDebugMessageLogAMD(DebugCategoryAMD[] categories, DebugSeverity[] severities, uint[] ids, int[] lengths, StringBuilder message, uint count = 1)
        {
            count = (uint)Math.Min(categories.Length, Math.Min(severities.Length, Math.Min(ids.Length, Math.Min(lengths.Length, (int)count))));

            return Delegates.glGetDebugMessageLogAMD(count, message.Capacity, ref categories[0], ref severities[0], ref ids[0], ref lengths[0], message);
            //if (count < 1)
            //{
            //    count = (uint)GL.GetIntegerv(GetParameters.DebugLoggedMessages);
            //}

            //count = (uint)Math.Min(categories.Length, Math.Min(severities.Length, Math.Min(ids.Length, Math.Min(lengths.Length, (int)count))));

            //if (count > 0)
            //{
            //    var sb
            //}
        }
示例#44
0
 private static bool LogInDialog(string msg, DebugSeverity severity)
 {
     MessageBox.Show(msg);
     return true;
 }