您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

105 行
2.9 KiB

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