Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

109 wiersze
3.0 KiB

  1. //
  2. // Lol Engine — Imgui tutorial
  3. //
  4. // Copyright © 2002—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
  5. // © 2012—2018 Sam Hocevar <sam@hocevar.net>
  6. //
  7. // Lol Engine is free software. It comes without any warranty, to
  8. // the extent permitted by applicable law. You can redistribute it
  9. // and/or modify it under the terms of the Do What the Fuck You Want
  10. // to Public License, Version 2, as published by the WTFPL Task Force.
  11. // See http://www.wtfpl.net/ for more details.
  12. //
  13. #if HAVE_CONFIG_H
  14. # include "config.h"
  15. #endif
  16. #include <lol/engine.h>
  17. #include <cstdio>
  18. #include <string>
  19. #include "loldebug.h"
  20. using namespace lol;
  21. class LolImGuiDemo : public WorldEntity
  22. {
  23. public:
  24. LolImGuiDemo()
  25. {
  26. LolImGui::Init();
  27. }
  28. ~LolImGuiDemo()
  29. {
  30. LolImGui::Shutdown();
  31. }
  32. virtual void TickGame(float seconds)
  33. {
  34. WorldEntity::TickGame(seconds);
  35. static float f;
  36. static vec3 clear_color;
  37. static char buf[512];
  38. ImGuiIO& io = ImGui::GetIO();
  39. ImGui::SetNextWindowFocus();
  40. ImGui::Begin("testature");
  41. {
  42. if (ImGui::IsWindowHovered())
  43. ImGui::Text("Hovered: true");
  44. else
  45. ImGui::Text("Hovered: false");
  46. if (ImGui::IsWindowFocused())
  47. ImGui::Text("Focused: true");
  48. else
  49. ImGui::Text("Focused: false");
  50. ImGui::Text("Hello, world!");
  51. ImGui::Text("prout!");
  52. ImGui::Text("prout!%i", 100);
  53. ImGui::Text("MousePos!%.2f/%.2f", io.MousePos.x, io.MousePos.y);
  54. ImGui::Button("Test Window");
  55. ImGui::Text("Slider: %.2f", f);
  56. ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
  57. //ImGui::ColorEdit3("clear color", (float*)&clear_color);
  58. ImGui::Text("Left Mouse: %s", io.MouseDown[0] ? "true" : "false");
  59. ImGui::Text("Scroll: %f", io.MouseWheel);
  60. ImGui::Text("Maj: %s", io.KeyShift ? "true" : "false");
  61. ImGui::Text("Ctrl: %s", io.KeyCtrl ? "true" : "false");
  62. ImGui::Text("Clipboard %s", LolImGui::GetClipboard().c_str());
  63. ImGui::InputText("base input", buf, 512);
  64. }
  65. ImGui::End();
  66. ImGui::Begin("SO FUN !!");
  67. {
  68. if (ImGui::IsWindowHovered())
  69. ImGui::Text("Hovered: true");
  70. else
  71. ImGui::Text("Hovered: false");
  72. if (ImGui::IsWindowFocused())
  73. ImGui::Text("Focused: true");
  74. else
  75. ImGui::Text("Focused: false");
  76. ImGui::Text("poucka!");
  77. ImGui::Text(" poucka!");
  78. }
  79. ImGui::End();
  80. }
  81. virtual void TickDraw(float seconds, Scene &scene)
  82. {
  83. WorldEntity::TickDraw(seconds, scene);
  84. }
  85. };
  86. int main(int argc, char **argv)
  87. {
  88. sys::init(argc, argv);
  89. Application app("Tutorial 15: LolImGui", ivec2(800, 600), 60.0f);
  90. new LolImGuiDemo();
  91. app.Run();
  92. return EXIT_SUCCESS;
  93. }