You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // Lol Engine — Dear ImGui tutorial
  3. //
  4. // Copyright © 2012—2019 Sam Hocevar <sam@hocevar.net>
  5. // © 2002—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
  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. gui::init();
  27. }
  28. ~LolImGuiDemo()
  29. {
  30. gui::shutdown();
  31. }
  32. virtual void tick_game(float seconds)
  33. {
  34. WorldEntity::tick_game(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", gui::clipboard().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 tick_draw(float seconds, Scene &scene)
  82. {
  83. WorldEntity::tick_draw(seconds, scene);
  84. }
  85. };
  86. int main(int argc, char **argv)
  87. {
  88. sys::init(argc, argv);
  89. Application app("Tutorial 15: ImGui", ivec2(800, 600), 60.0f);
  90. new LolImGuiDemo();
  91. app.Run();
  92. return EXIT_SUCCESS;
  93. }