Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. #include "imgui/imgui.h"
  2. #include "imgui/imgui_internal.h"
  3. #include "Renderer.h"
  4.  
  5. Renderer* Renderer::m_pInstance;
  6.  
  7. Renderer::Renderer()
  8. {
  9. }
  10.  
  11. Renderer::~Renderer()
  12. {
  13. }
  14.  
  15. void Renderer::Initialize()
  16. {
  17. ImGuiIO& io = ImGui::GetIO();
  18.  
  19.  
  20. }
  21.  
  22. void Renderer::BeginScene()
  23. {
  24. ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
  25. ImGui::Begin("BackBuffer", reinterpret_cast<bool*>(true), ImVec2(0, 0), 0.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs);
  26.  
  27. ImGui::SetWindowPos(ImVec2(0, 0), ImGuiSetCond_Always);
  28. ImGui::SetWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x, ImGui::GetIO().DisplaySize.y), ImGuiSetCond_Always);
  29. }
  30.  
  31. void Renderer::DrawScene()
  32. {
  33. ImGuiIO& io = ImGui::GetIO();
  34.  
  35. }
  36.  
  37. void Renderer::EndScene()
  38. {
  39. ImGuiWindow* window = ImGui::GetCurrentWindow();
  40. window->DrawList->PushClipRectFullScreen();
  41.  
  42. ImGui::End();
  43. ImGui::PopStyleColor();
  44. }
  45.  
  46.  
  47.  
  48. void Renderer::DrawLine(const ImVec2& from, const ImVec2& to, uint32_t color, float thickness)
  49. {
  50. ImGuiWindow* window = ImGui::GetCurrentWindow();
  51.  
  52. float a = (color >> 24) & 0xff;
  53. float r = (color >> 16) & 0xff;
  54. float g = (color >> 8) & 0xff;
  55. float b = (color) & 0xff;
  56.  
  57. window->DrawList->AddLine(from, to, ImGui::GetColorU32(ImVec4(r / 255, g / 255, b / 255, a / 255)), thickness);
  58. }
  59.  
  60. void Renderer::DrawCircle(const ImVec2& position, float radius, uint32_t color, float thickness)
  61. {
  62. ImGuiWindow* window = ImGui::GetCurrentWindow();
  63.  
  64. float a = (color >> 24) & 0xff;
  65. float r = (color >> 16) & 0xff;
  66. float g = (color >> 8) & 0xff;
  67. float b = (color) & 0xff;
  68.  
  69. window->DrawList->AddCircle(position, radius, ImGui::GetColorU32(ImVec4(r / 255, g / 255, b / 255, a / 255)), 12, thickness);
  70. }
  71.  
  72. void Renderer::DrawCircleFilled(const ImVec2& position, float radius, uint32_t color)
  73. {
  74. ImGuiWindow* window = ImGui::GetCurrentWindow();
  75.  
  76. float a = (color >> 24) & 0xff;
  77. float r = (color >> 16) & 0xff;
  78. float g = (color >> 8) & 0xff;
  79. float b = (color) & 0xff;
  80.  
  81. window->DrawList->AddCircleFilled(position, radius, ImGui::GetColorU32(ImVec4(r / 255, g / 255, b / 255, a / 255)), 12);
  82. }
  83.  
  84. Renderer* Renderer::GetInstance()
  85. {
  86. if (!m_pInstance)
  87. m_pInstance = new Renderer();
  88.  
  89. return m_pInstance;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement