Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
4.5 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: debug.h
  3. *
  4. * OpenGL debugging macros.
  5. *
  6. * Created: 23-Oct-1993 18:33:23
  7. * Author: Gilman Wong [gilmanw]
  8. *
  9. * Copyright (c) 1992 Microsoft Corporation
  10. *
  11. \**************************************************************************/
  12. #ifndef __DEBUG_H__
  13. #define __DEBUG_H__
  14. //
  15. // LEVEL_ALLOC is the highest level of debug output. For alloc,free, etc.
  16. // LEVEL_ENTRY is for function entry.
  17. // LEVEL_INFO is for general debug information.
  18. // LEVEL_ERROR is for debug error information.
  19. //
  20. #define LEVEL_ERROR 1L
  21. #define LEVEL_INFO 2L
  22. #define LEVEL_ENTRY 8L
  23. #define LEVEL_ALLOC 10L
  24. #if DBG
  25. extern long glDebugLevel;
  26. extern ULONG glDebugFlags;
  27. #define GLDEBUG_DISABLEMCD 0x00000001 // disable MCD driver
  28. #define GLDEBUG_DISABLEPRIM 0x00000002 // disable MCD primitives
  29. #define GLDEBUG_DISABLEDCI 0x00000004 // disable DCI buffer access
  30. // These debug macros are useful for assertions. They are not controlled
  31. // by the warning level.
  32. #define WARNING(str) DbgPrint("%s(%d): " str,__FILE__,__LINE__)
  33. #define WARNING1(str,a) DbgPrint("%s(%d): " str,__FILE__,__LINE__,a)
  34. #define WARNING2(str,a,b) DbgPrint("%s(%d): " str,__FILE__,__LINE__,a,b)
  35. #define WARNING3(str,a,b,c) DbgPrint("%s(%d): " str,__FILE__,__LINE__,a,b,c)
  36. #define WARNING4(str,a,b,c,d) DbgPrint("%s(%d): " str,__FILE__,__LINE__,a,b,c,d)
  37. #define RIP(str) {WARNING(str); DebugBreak();}
  38. #define RIP1(str,a) {WARNING1(str,a); DebugBreak();}
  39. #define RIP2(str,a,b) {WARNING2(str,a,b); DebugBreak();}
  40. #define ASSERTOPENGL(expr,str) if(!(expr)) RIP(str)
  41. #define ASSERTOPENGL1(expr,str,a) if(!(expr)) RIP1(str,a)
  42. #define ASSERTOPENGL2(expr,str,a,b) if(!(expr)) RIP2(str,a,b)
  43. //
  44. // Use DBGPRINT for general purpose debug message that are NOT
  45. // controlled by the warning level.
  46. //
  47. #define DBGPRINT(str) DbgPrint("OPENGL32: " str)
  48. #define DBGPRINT1(str,a) DbgPrint("OPENGL32: " str,a)
  49. #define DBGPRINT2(str,a,b) DbgPrint("OPENGL32: " str,a,b)
  50. #define DBGPRINT3(str,a,b,c) DbgPrint("OPENGL32: " str,a,b,c)
  51. #define DBGPRINT4(str,a,b,c,d) DbgPrint("OPENGL32: " str,a,b,c,d)
  52. #define DBGPRINT5(str,a,b,c,d,e) DbgPrint("OPENGL32: " str,a,b,c,d,e)
  53. //
  54. // Use DBGLEVEL for general purpose debug messages gated by an
  55. // arbitrary warning level.
  56. //
  57. #define DBGLEVEL(n,str) if (glDebugLevel >= (n)) DBGPRINT(str)
  58. #define DBGLEVEL1(n,str,a) if (glDebugLevel >= (n)) DBGPRINT1(str,a)
  59. #define DBGLEVEL2(n,str,a,b) if (glDebugLevel >= (n)) DBGPRINT2(str,a,b)
  60. #define DBGLEVEL3(n,str,a,b,c) if (glDebugLevel >= (n)) DBGPRINT3(str,a,b,c)
  61. #define DBGLEVEL4(n,str,a,b,c,d) if (glDebugLevel >= (n)) DBGPRINT4(str,a,b,c,d)
  62. #define DBGLEVEL5(n,str,a,b,c,d,e) if (glDebugLevel >= (n)) DBGPRINT5(str,a,b,c,d,e)
  63. //
  64. // Use DBGERROR for error info. Debug string must not have arguments.
  65. //
  66. #define DBGERROR(s) if (glDebugLevel >= LEVEL_ERROR) DbgPrint("%s(%d): %s", __FILE__, __LINE__, s)
  67. //
  68. // Use DBGINFO for general debug info. Debug string must not have
  69. // arguments.
  70. //
  71. #define DBGINFO(s) if (glDebugLevel >= LEVEL_INFO) DBGPRINT(s)
  72. //
  73. // Use DBGENTRY for function entry. Debug string must not have
  74. // arguments.
  75. //
  76. #define DBGENTRY(s) if (glDebugLevel >= LEVEL_ENTRY) DBGPRINT(s)
  77. //
  78. // DBGBEGIN/DBGEND for more complex debugging output (for
  79. // example, those requiring formatting arguments--%ld, %s, etc.).
  80. //
  81. // Note: DBGBEGIN/END blocks must be bracketed by #if DBG/#endif. To
  82. // enforce this, we will not define these macros in the DBG == 0 case.
  83. // Therefore, without the #if DBG bracketing use of this macro, a
  84. // compiler (or linker) error will be generated. This is by design.
  85. //
  86. #define DBGBEGIN(n) if (glDebugLevel >= (n)) {
  87. #define DBGEND }
  88. #else
  89. #define WARNING(str)
  90. #define WARNING1(str,a)
  91. #define WARNING2(str,a,b)
  92. #define WARNING3(str,a,b,c)
  93. #define WARNING4(str,a,b,c,d)
  94. #define RIP(str)
  95. #define RIP1(str,a)
  96. #define RIP2(str,a,b)
  97. #define ASSERTOPENGL(expr,str)
  98. #define ASSERTOPENGL1(expr,str,a)
  99. #define ASSERTOPENGL2(expr,str,a,b)
  100. #define DBGPRINT(str)
  101. #define DBGPRINT1(str,a)
  102. #define DBGPRINT2(str,a,b)
  103. #define DBGPRINT3(str,a,b,c)
  104. #define DBGPRINT4(str,a,b,c,d)
  105. #define DBGPRINT5(str,a,b,c,d,e)
  106. #define DBGLEVEL(n,str)
  107. #define DBGLEVEL1(n,str,a)
  108. #define DBGLEVEL2(n,str,a,b)
  109. #define DBGLEVEL3(n,str,a,b,c)
  110. #define DBGLEVEL4(n,str,a,b,c,d)
  111. #define DBGLEVEL5(n,str,a,b,c,d,e)
  112. #define DBGERROR(s)
  113. #define DBGINFO(s)
  114. #define DBGENTRY(s)
  115. #endif /* DBG */
  116. #endif /* __DEBUG_H__ */