Пример #1
0
        // TODO: 此函数的'try to remove unused items from rc2ProcDict'部分尚需检测。
        /// <summary>
        /// 设置Debug模式的回调函数。
        /// <para>此函数的'try to remove unused items from rc2ProcDict'部分尚需检测。</para>
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="userParam">建议使用<see cref="UnmanagedArray.Header"/></param>
        public static void DebugMessageCallback(DebugProc callback, IntPtr userParam)
        {
            if (innerCallbackProc == null)
            {
                innerCallbackProc = new DEBUGPROC(innerCallback);
            }

            IntPtr renderContext = Win32.wglGetCurrentContext();
            IntPtr deviceContext = Win32.wglGetCurrentDC();

            if (rc2ProcDict.ContainsKey(renderContext))
            {
                rc2ProcDict[renderContext] = callback;
                rc2dcDict[renderContext]   = deviceContext;
            }
            else
            {
                rc2ProcDict.Add(renderContext, callback);
                rc2dcDict.Add(renderContext, deviceContext);
                debugProcDictCount++;
                // try to remove unused items from rc2ProcDict
                if (debugProcDictCount > maxDebugProcDictCount)
                {
                    List <IntPtr> unusedRCList = new List <IntPtr>();
                    foreach (var item in rc2dcDict)
                    {
                        if (!Win32.wglMakeCurrent(item.Value, item.Key))// 这种检测方式可行吗?
                        {
                            unusedRCList.Add(item.Key);
                        }
                    }
                    foreach (var item in unusedRCList)
                    {
                        rc2ProcDict.Remove(item);
                        rc2dcDict.Remove(item);
                    }

                    debugProcDictCount -= unusedRCList.Count;

                    maxDebugProcDictCount = debugProcDictCount + 100;

                    Win32.wglMakeCurrent(renderContext, deviceContext);
                }
            }

            GetDelegateFor <glDebugMessageCallback>()(innerCallbackProc, userParam);
        }
Пример #2
0
        // TODO: 此函数的'try to remove unused items from rc2ProcDict'部分尚需检测。
        /// <summary>
        /// 设置Debug模式的回调函数。
        /// <para>此函数的'try to remove unused items from rc2ProcDict'部分尚需检测。</para>
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="userParam">建议使用<see cref="UnmanagedArray.Header"/></param>
        public static void DebugMessageCallback(DebugProc callback, IntPtr userParam)
        {
            if (innerCallbackProc == null)
            {
                innerCallbackProc = new DEBUGPROC(innerCallback);
            }

            IntPtr renderContext = Win32.wglGetCurrentContext();
            IntPtr deviceContext = Win32.wglGetCurrentDC();
            if (rc2ProcDict.ContainsKey(renderContext))
            {
                rc2ProcDict[renderContext] = callback;
                rc2dcDict[renderContext] = deviceContext;
            }
            else
            {
                rc2ProcDict.Add(renderContext, callback);
                rc2dcDict.Add(renderContext, deviceContext);
                debugProcDictCount++;
                // try to remove unused items from rc2ProcDict
                if (debugProcDictCount > maxDebugProcDictCount)
                {
                    List<IntPtr> unusedRCList = new List<IntPtr>();
                    foreach (var item in rc2dcDict)
                    {
                        if (!Win32.wglMakeCurrent(item.Value, item.Key))// 这种检测方式可行吗?
                        {
                            unusedRCList.Add(item.Key);
                        }
                    }
                    foreach (var item in unusedRCList)
                    {
                        rc2ProcDict.Remove(item);
                        rc2dcDict.Remove(item);
                    }

                    debugProcDictCount -= unusedRCList.Count;

                    maxDebugProcDictCount = debugProcDictCount + 100;

                    Win32.wglMakeCurrent(renderContext, deviceContext);
                }
            }

            GetDelegateFor<glDebugMessageCallback>()(innerCallbackProc, userParam);
        }
Пример #3
0
 // https://www.opengl.org/registry/specs/ARB/debug_output.txt
 // https://www.opengl.org/wiki/Debug_Output
 /// <summary>
 /// 设置Debug模式的回调函数。
 /// </summary>
 /// <param name="callback">使用一个字段来持有
 /// <para>callback = new GL.DEBUGPROC(this.callbackProc);</para>
 /// 这样就可以避免垃圾回收的问题。
 /// </param>
 /// <param name="userParam">建议使用<see cref="UnmanagedArray.Header"/></param>
 public static void DebugMessageCallback(DEBUGPROC callback, IntPtr userParam)
 {
     GetDelegateFor<glDebugMessageCallback>()(callback, userParam);
 }