DrawListWrapper.cpp 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #include "imguiWrappedHeader.h"
  2. #include "DrawListWrapper.h"
  3. #include "WrapperConverter.h"
  4. int iggDrawListGetCommandCount(IggDrawList handle) {
  5. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  6. return list->CmdBuffer.Size;
  7. }
  8. IggDrawCmd iggDrawListGetCommand(IggDrawList handle, int index) {
  9. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  10. return reinterpret_cast<IggDrawCmd>(&list->CmdBuffer.Data[index]);
  11. }
  12. void iggDrawListGetRawIndexBuffer(IggDrawList handle, void **data,
  13. int *byteSize) {
  14. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  15. *data = list->IdxBuffer.Data;
  16. *byteSize = static_cast<int>(sizeof(ImDrawIdx)) * list->IdxBuffer.Size;
  17. }
  18. void iggDrawListGetRawVertexBuffer(IggDrawList handle, void **data,
  19. int *byteSize) {
  20. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  21. *data = list->VtxBuffer.Data;
  22. *byteSize = static_cast<int>(sizeof(ImDrawVert)) * list->VtxBuffer.Size;
  23. }
  24. void iggGetIndexBufferLayout(size_t *entrySize) {
  25. *entrySize = sizeof(ImDrawIdx);
  26. }
  27. void iggGetVertexBufferLayout(size_t *entrySize, size_t *posOffset,
  28. size_t *uvOffset, size_t *colOffset) {
  29. *entrySize = sizeof(ImDrawVert);
  30. *posOffset = IM_OFFSETOF(ImDrawVert, pos);
  31. *uvOffset = IM_OFFSETOF(ImDrawVert, uv);
  32. *colOffset = IM_OFFSETOF(ImDrawVert, col);
  33. }
  34. void iggDrawListAddLine(IggDrawList handle, IggVec2 *p1, IggVec2 *p2,
  35. unsigned int col, float thickness) {
  36. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  37. Vec2Wrapper p1Arg(p1);
  38. Vec2Wrapper p2Arg(p2);
  39. list->AddLine(*p1Arg, *p2Arg, col, thickness);
  40. }
  41. void iggDrawListAddRect(IggDrawList handle, IggVec2 *p_min, IggVec2 *p_max,
  42. unsigned int col, float rounding, int rounding_corners,
  43. float thickness) {
  44. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  45. Vec2Wrapper p1Arg(p_min);
  46. Vec2Wrapper p2Arg(p_max);
  47. list->AddRect(*p1Arg, *p2Arg, col, rounding, rounding_corners, thickness);
  48. }
  49. void iggDrawListAddRectFilled(IggDrawList handle, IggVec2 *p_min,
  50. IggVec2 *p_max, unsigned int col, float rounding,
  51. int rounding_corners) {
  52. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  53. Vec2Wrapper p1Arg(p_min);
  54. Vec2Wrapper p2Arg(p_max);
  55. list->AddRectFilled(*p1Arg, *p2Arg, col, rounding, rounding_corners);
  56. }
  57. void iggDrawListAddText(IggDrawList handle, IggVec2 *pos, unsigned int col,
  58. const char *text) {
  59. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  60. Vec2Wrapper posArg(pos);
  61. list->AddText(*posArg, col, text);
  62. }
  63. void iggDrawListAddBezierCubic(IggDrawList handle, IggVec2 *pos0, IggVec2 *cp0,
  64. IggVec2 *cp1, IggVec2 *pos1, unsigned int col,
  65. float thickness, int num_segments) {
  66. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  67. Vec2Wrapper pos0Arg(pos0);
  68. Vec2Wrapper pos1Arg(pos1);
  69. Vec2Wrapper cp0Arg(cp0);
  70. Vec2Wrapper cp1Arg(cp1);
  71. list->AddBezierCubic(*pos0Arg, *cp0Arg, *cp1Arg, *pos1Arg, col, thickness,
  72. num_segments);
  73. }
  74. void iggDrawListAddTriangle(IggDrawList handle, IggVec2 *p1, IggVec2 *p2,
  75. IggVec2 *p3, unsigned int col, float thickness) {
  76. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  77. Vec2Wrapper p1Arg(p1);
  78. Vec2Wrapper p2Arg(p2);
  79. Vec2Wrapper p3Arg(p3);
  80. list->AddTriangle(*p1Arg, *p2Arg, *p3Arg, col, thickness);
  81. }
  82. void iggDrawListAddTriangleFilled(IggDrawList handle, IggVec2 *p1, IggVec2 *p2,
  83. IggVec2 *p3, unsigned int col) {
  84. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  85. Vec2Wrapper p1Arg(p1);
  86. Vec2Wrapper p2Arg(p2);
  87. Vec2Wrapper p3Arg(p3);
  88. list->AddTriangleFilled(*p1Arg, *p2Arg, *p3Arg, col);
  89. }
  90. void iggDrawListAddCircle(IggDrawList handle, IggVec2 *center, float radius,
  91. unsigned int col, int num_segments, float thickness) {
  92. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  93. Vec2Wrapper centerArg(center);
  94. list->AddCircle(*centerArg, radius, col, num_segments, thickness);
  95. }
  96. void iggDrawListAddCircleFilled(IggDrawList handle, IggVec2 *center,
  97. float radius, unsigned int col,
  98. int num_segments) {
  99. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  100. Vec2Wrapper centerArg(center);
  101. list->AddCircleFilled(*centerArg, radius, col, num_segments);
  102. }
  103. void iggDrawListAddQuad(IggDrawList handle, IggVec2 *p1, IggVec2 *p2,
  104. IggVec2 *p3, IggVec2 *p4, unsigned int col,
  105. float thickness) {
  106. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  107. Vec2Wrapper p1Arg(p1);
  108. Vec2Wrapper p2Arg(p2);
  109. Vec2Wrapper p3Arg(p3);
  110. Vec2Wrapper p4Arg(p4);
  111. list->AddQuad(*p1Arg, *p2Arg, *p3Arg, *p4Arg, col, thickness);
  112. }
  113. void iggDrawListAddQuadFilled(IggDrawList handle, IggVec2 *p1, IggVec2 *p2,
  114. IggVec2 *p3, IggVec2 *p4, unsigned int col) {
  115. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  116. Vec2Wrapper p1Arg(p1);
  117. Vec2Wrapper p2Arg(p2);
  118. Vec2Wrapper p3Arg(p3);
  119. Vec2Wrapper p4Arg(p4);
  120. list->AddQuadFilled(*p1Arg, *p2Arg, *p3Arg, *p4Arg, col);
  121. }
  122. void iggDrawListPathClear(IggDrawList handle) {
  123. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  124. list->PathClear();
  125. }
  126. void iggDrawListPathLineTo(IggDrawList handle, IggVec2 *pos) {
  127. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  128. Vec2Wrapper posArg(pos);
  129. list->PathLineTo(*posArg);
  130. }
  131. void iggDrawListPathLineToMergeDuplicate(IggDrawList handle, IggVec2 *pos) {
  132. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  133. Vec2Wrapper posArg(pos);
  134. list->PathLineToMergeDuplicate(*posArg);
  135. }
  136. void iggDrawListPathFillConvex(IggDrawList handle, unsigned int col) {
  137. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  138. list->PathFillConvex(col);
  139. }
  140. void iggDrawListPathStroke(IggDrawList handle, unsigned int col, IggBool closed,
  141. float thickness) {
  142. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  143. list->PathStroke(col, closed != 0, thickness);
  144. }
  145. void iggDrawListPathArcTo(IggDrawList handle, IggVec2 *center, float radius,
  146. float a_min, float a_max, int num_segments) {
  147. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  148. Vec2Wrapper centerArg(center);
  149. list->PathArcTo(*centerArg, radius, a_min, a_max, num_segments);
  150. }
  151. void iggDrawListPathArcToFast(IggDrawList handle, IggVec2 *center, float radius,
  152. int a_min_of_12, int a_max_of_12) {
  153. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  154. Vec2Wrapper centerArg(center);
  155. list->PathArcToFast(*centerArg, radius, a_min_of_12, a_max_of_12);
  156. }
  157. void iggDrawListPathBezierCubicCurveTo(IggDrawList handle, IggVec2 *p1, IggVec2 *p2,
  158. IggVec2 *p3, int num_segments) {
  159. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  160. Vec2Wrapper p1Arg(p1);
  161. Vec2Wrapper p2Arg(p2);
  162. Vec2Wrapper p3Arg(p3);
  163. list->PathBezierCubicCurveTo(*p1Arg, *p2Arg, *p3Arg, num_segments);
  164. }
  165. void iggDrawListAddImage(IggDrawList handle, IggTextureID id, IggVec2 *p_min,
  166. IggVec2 *p_max) {
  167. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  168. Vec2Wrapper pMinArg(p_min);
  169. Vec2Wrapper pMaxArg(p_max);
  170. list->AddImage(ImTextureID(id), *pMinArg, *pMaxArg);
  171. }
  172. void iggDrawListAddImageV(IggDrawList handle, IggTextureID id, IggVec2 *p_min,
  173. IggVec2 *p_max, IggVec2 *uv_min, IggVec2 *uv_max, unsigned int color) {
  174. ImDrawList *list = reinterpret_cast<ImDrawList *>(handle);
  175. Vec2Wrapper pMinArg(p_min);
  176. Vec2Wrapper pMaxArg(p_max);
  177. Vec2Wrapper uvMinArg(uv_min);
  178. Vec2Wrapper uvMaxArg(uv_max);
  179. list->AddImage(ImTextureID(id), *pMinArg, *pMaxArg, *uvMinArg, *uvMaxArg, color);
  180. }