debugdraw.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  4. */
  5. #ifndef DEBUGDRAW_H_HEADER_GUARD
  6. #define DEBUGDRAW_H_HEADER_GUARD
  7. #include <bx/allocator.h>
  8. #include "../bounds.h"
  9. struct Axis
  10. {
  11. enum Enum
  12. {
  13. X,
  14. Y,
  15. Z,
  16. Count
  17. };
  18. };
  19. struct DdVertex
  20. {
  21. float x, y, z;
  22. };
  23. struct SpriteHandle { uint16_t idx; };
  24. inline bool isValid(SpriteHandle _handle) { return _handle.idx != UINT16_MAX; }
  25. struct GeometryHandle { uint16_t idx; };
  26. inline bool isValid(GeometryHandle _handle) { return _handle.idx != UINT16_MAX; }
  27. ///
  28. void ddInit(bool _depthTestLess = true, bx::AllocatorI* _allocator = NULL);
  29. ///
  30. void ddShutdown();
  31. ///
  32. SpriteHandle ddCreateSprite(uint16_t _width, uint16_t _height, const void* _data);
  33. ///
  34. void ddDestroy(SpriteHandle _handle);
  35. ///
  36. GeometryHandle ddCreateGeometry(uint32_t _numVertices, const DdVertex* _vertices, uint32_t _numIndices = 0, const uint16_t* _indices = NULL);
  37. ///
  38. void ddDestroy(GeometryHandle _handle);
  39. ///
  40. void ddBegin(uint8_t _viewId);
  41. ///
  42. void ddEnd();
  43. ///
  44. void ddPush();
  45. ///
  46. void ddPop();
  47. ///
  48. void ddSetState(bool _depthTest, bool _depthWrite, bool _clockwise);
  49. ///
  50. void ddSetColor(uint32_t _abgr);
  51. ///
  52. void ddSetLod(uint8_t _lod);
  53. ///
  54. void ddSetWireframe(bool _wireframe);
  55. ///
  56. void ddSetStipple(bool _stipple, float _scale = 1.0f, float _offset = 0.0f);
  57. ///
  58. void ddSetSpin(float _spin);
  59. ///
  60. void ddSetTransform(const void* _mtx);
  61. ///
  62. void ddSetTranslate(float _x, float _y, float _z);
  63. ///
  64. void ddMoveTo(float _x, float _y, float _z = 0.0f);
  65. ///
  66. void ddMoveTo(const void* _pos);
  67. ///
  68. void ddLineTo(float _x, float _y, float _z = 0.0f);
  69. ///
  70. void ddLineTo(const void* _pos);
  71. ///
  72. void ddClose();
  73. ///
  74. void ddDraw(const Aabb& _aabb);
  75. ///
  76. void ddDraw(const Cylinder& _cylinder);
  77. ///
  78. void ddDraw(const Capsule& _capsule);
  79. ///
  80. void ddDraw(const Disk& _disk);
  81. ///
  82. void ddDraw(const Obb& _obb);
  83. ///
  84. void ddDraw(const Sphere& _sphere);
  85. ///
  86. void ddDraw(const Cone& _cone);
  87. ///
  88. void ddDraw(GeometryHandle _handle);
  89. ///
  90. void ddDrawLineList(uint32_t _numVertices, const DdVertex* _vertices, uint32_t _numIndices = 0, const uint16_t* _indices = NULL);
  91. ///
  92. void ddDrawTriList(uint32_t _numVertices, const DdVertex* _vertices, uint32_t _numIndices = 0, const uint16_t* _indices = NULL);
  93. ///
  94. void ddDrawFrustum(const void* _viewProj);
  95. ///
  96. void ddDrawArc(Axis::Enum _axis, float _x, float _y, float _z, float _radius, float _degrees);
  97. ///
  98. void ddDrawCircle(const void* _normal, const void* _center, float _radius, float _weight = 0.0f);
  99. ///
  100. void ddDrawCircle(Axis::Enum _axis, float _x, float _y, float _z, float _radius, float _weight = 0.0f);
  101. ///
  102. void ddDrawQuad(const float* _normal, const float* _center, float _size);
  103. ///
  104. void ddDrawQuad(SpriteHandle _handle, const float* _normal, const float* _center, float _size);
  105. ///
  106. void ddDrawQuad(bgfx::TextureHandle _handle, const float* _normal, const float* _center, float _size);
  107. ///
  108. void ddDrawCone(const void* _from, const void* _to, float _radius);
  109. ///
  110. void ddDrawCylinder(const void* _from, const void* _to, float _radius);
  111. ///
  112. void ddDrawCapsule(const void* _from, const void* _to, float _radius);
  113. ///
  114. void ddDrawAxis(float _x, float _y, float _z, float _len = 1.0f, Axis::Enum _highlight = Axis::Count, float _thickness = 0.0f);
  115. ///
  116. void ddDrawGrid(const void* _normal, const void* _center, uint32_t _size = 20, float _step = 1.0f);
  117. ///
  118. void ddDrawGrid(Axis::Enum _axis, const void* _center, uint32_t _size = 20, float _step = 1.0f);
  119. ///
  120. void ddDrawOrb(float _x, float _y, float _z, float _radius, Axis::Enum _highlight = Axis::Count);
  121. #endif // DEBUGDRAW_H_HEADER_GUARD