main.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // ImGui - standalone example application for Marmalade
  2. // Copyright (C) 2015 by Giovanni Zito
  3. // This file is part of ImGui
  4. // https://github.com/ocornut/imgui
  5. #include <imgui.h>
  6. #include "imgui_impl_marmalade.h"
  7. #include <stdio.h>
  8. #include <s3eKeyboard.h>
  9. #include <s3ePointer.h>
  10. #include <IwGx.h>
  11. int main(int, char**)
  12. {
  13. // Setup ImGui binding
  14. ImGui_Marmalade_Init(true);
  15. // Load Fonts
  16. // (see extra_fonts/README.txt for more details)
  17. //ImGuiIO& io = ImGui::GetIO();
  18. //io.Fonts->AddFontDefault();
  19. //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
  20. //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
  21. //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
  22. //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
  23. //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
  24. // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons)
  25. //static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; // will not be copied by AddFont* so keep in scope.
  26. //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true;
  27. //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f);
  28. //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges);
  29. bool show_test_window = true;
  30. bool show_another_window = false;
  31. ImVec4 clear_color = ImColor(114, 144, 154);
  32. // Main loop
  33. while (true)
  34. {
  35. if (s3eDeviceCheckQuitRequest())
  36. break;
  37. s3eKeyboardUpdate();
  38. s3ePointerUpdate();
  39. ImGui_Marmalade_NewFrame();
  40. // 1. Show a simple window
  41. // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
  42. {
  43. static float f = 0.0f;
  44. ImGui::Text("Hello, world!");
  45. ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
  46. ImGui::ColorEdit3("clear color", (float*)&clear_color);
  47. if (ImGui::Button("Test Window")) show_test_window ^= 1;
  48. if (ImGui::Button("Another Window")) show_another_window ^= 1;
  49. ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
  50. }
  51. // 2. Show another simple window, this time using an explicit Begin/End pair
  52. if (show_another_window)
  53. {
  54. ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
  55. ImGui::Begin("Another Window", &show_another_window);
  56. ImGui::Text("Hello");
  57. ImGui::End();
  58. }
  59. // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
  60. if (show_test_window)
  61. {
  62. ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
  63. ImGui::ShowTestWindow(&show_test_window);
  64. }
  65. // Rendering
  66. IwGxSetColClear(clear_color.x*255,clear_color.y*255,clear_color.z*255,clear_color.w*255) ;
  67. IwGxClear();
  68. ImGui::Render();
  69. IwGxSwapBuffers();
  70. s3eDeviceYield(0);
  71. }
  72. // Cleanup
  73. ImGui_Marmalade_Shutdown();
  74. return 0;
  75. }