rlImGui.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /**********************************************************************************************
  2. *
  3. * raylibExtras * Utilities and Shared Components for Raylib
  4. *
  5. * rlImGui * basic ImGui integration
  6. *
  7. * LICENSE: ZLIB
  8. *
  9. * Copyright (c) 2020 Jeffery Myers
  10. *
  11. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12. * of this software and associated documentation files (the "Software"), to deal
  13. * in the Software without restriction, including without limitation the rights
  14. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15. * copies of the Software, and to permit persons to whom the Software is
  16. * furnished to do so, subject to the following conditions:
  17. *
  18. * The above copyright notice and this permission notice shall be included in all
  19. * copies or substantial portions of the Software.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  27. * SOFTWARE.
  28. *
  29. **********************************************************************************************/
  30. #pragma once
  31. #include "raylib.h"
  32. #ifndef NO_FONT_AWESOME
  33. #include "extras/IconsFontAwesome6.h"
  34. #define FONT_AWESOME_ICON_SIZE 11
  35. #endif
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. // Basic API
  40. /// <summary>
  41. /// Sets up ImGui, loads fonts and themes
  42. /// </summary>
  43. /// <param name="darkTheme">when true(default) the dark theme is used, when false the light theme is used</param>
  44. void rlImGuiSetup(bool darkTheme);
  45. /// <summary>
  46. /// Starts a new ImGui Frame
  47. /// </summary>
  48. void rlImGuiBegin();
  49. /// <summary>
  50. /// Ends an ImGui frame and submits all ImGui drawing to raylib for processing.
  51. /// </summary>
  52. void rlImGuiEnd();
  53. /// <summary>
  54. /// Cleanup ImGui and unload font atlas
  55. /// </summary>
  56. void rlImGuiShutdown();
  57. // Advanced StartupAPI
  58. /// <summary>
  59. /// Custom initialization. Not needed if you call rlImGuiSetup. Only needed if you want to add custom setup code.
  60. /// must be followed by rlImGuiEndInitImGui
  61. /// </summary>
  62. void rlImGuiBeginInitImGui();
  63. /// <summary>
  64. /// End Custom initialization. Not needed if you call rlImGuiSetup. Only needed if you want to add custom setup code.
  65. /// must be proceeded by rlImGuiBeginInitImGui
  66. /// </summary>
  67. void rlImGuiEndInitImGui();
  68. /// <summary>
  69. /// Forces the font texture atlas to be recomputed and re-cached
  70. /// </summary>
  71. void rlImGuiReloadFonts();
  72. // Advanced Update API
  73. /// <summary>
  74. /// Starts a new ImGui Frame with a specified delta time
  75. /// </summary>
  76. /// <param name="dt">delta time, any value < 0 will use raylib GetFrameTime</param>
  77. void rlImGuiBeginDelta(float deltaTime);
  78. // image API
  79. /// <summary>
  80. /// Draw a texture as an image in an ImGui Context
  81. /// Uses the current ImGui Cursor position and the full texture size.
  82. /// </summary>
  83. /// <param name="image">The raylib texture to draw</param>
  84. void rlImGuiImage(const Texture *image);
  85. /// <summary>
  86. /// Draw a texture as an image in an ImGui Context at a specific size
  87. /// Uses the current ImGui Cursor position and the specified width and height
  88. /// The image will be scaled up or down to fit as needed
  89. /// </summary>
  90. /// <param name="image">The raylib texture to draw</param>
  91. /// <param name="width">The width of the drawn image</param>
  92. /// <param name="height">The height of the drawn image</param>
  93. void rlImGuiImageSize(const Texture *image, int width, int height);
  94. /// <summary>
  95. /// Draw a texture as an image in an ImGui Context at a specific size
  96. /// Uses the current ImGui Cursor position and the specified size
  97. /// The image will be scaled up or down to fit as needed
  98. /// </summary>
  99. /// <param name="image">The raylib texture to draw</param>
  100. /// <param name="size">The size of drawn image</param>
  101. void rlImGuiImageSizeV(const Texture* image, Vector2 size);
  102. /// <summary>
  103. /// Draw a portion texture as an image in an ImGui Context at a defined size
  104. /// Uses the current ImGui Cursor position and the specified size
  105. /// The image will be scaled up or down to fit as needed
  106. /// </summary>
  107. /// <param name="image">The raylib texture to draw</param>
  108. /// <param name="destWidth">The width of the drawn image</param>
  109. /// <param name="destHeight">The height of the drawn image</param>
  110. /// <param name="sourceRect">The portion of the texture to draw as an image. Negative values for the width and height will flip the image</param>
  111. void rlImGuiImageRect(const Texture* image, int destWidth, int destHeight, Rectangle sourceRect);
  112. /// <summary>
  113. /// Draws a render texture as an image an ImGui Context, automatically flipping the Y axis so it will show correctly on screen
  114. /// </summary>
  115. /// <param name="image">The render texture to draw</param>
  116. void rlImGuiImageRenderTexture(const RenderTexture* image);
  117. /// <summary>
  118. /// Draws a render texture as an image an ImGui Context, automatically flipping the Y axis so it will show correctly on screen
  119. /// Fits the render texture to the available content area
  120. /// </summary>
  121. /// <param name="image">The render texture to draw</param>
  122. /// <param name="center">When true the image will be centered in the content area</param>
  123. void rlImGuiImageRenderTextureFit(const RenderTexture* image, bool center);
  124. /// <summary>
  125. /// Draws a texture as an image button in an ImGui context. Uses the current ImGui cursor position and the full size of the texture
  126. /// </summary>
  127. /// <param name="name">The display name and ImGui ID for the button</param>
  128. /// <param name="image">The texture to draw</param>
  129. /// <returns>True if the button was clicked</returns>
  130. bool rlImGuiImageButton(const char* name, const Texture* image);
  131. /// <summary>
  132. /// Draws a texture as an image button in an ImGui context. Uses the current ImGui cursor position and the specified size.
  133. /// </summary>
  134. /// <param name="name">The display name and ImGui ID for the button</param>
  135. /// <param name="image">The texture to draw</param>
  136. /// <param name="size">The size of the button/param>
  137. /// <returns>True if the button was clicked</returns>
  138. bool rlImGuiImageButtonSize(const char* name, const Texture* image, struct ImVec2 size);
  139. #ifdef __cplusplus
  140. }
  141. #endif