1 // ImGui - standalone example application for Marmalade
2 // If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
3
4 // Copyright (C) 2015 by Giovanni Zito
5 // This file is part of ImGui
6
7 #include "imgui.h"
8 #include "imgui_impl_marmalade.h"
9 #include <stdio.h>
10
11 #include <s3eKeyboard.h>
12 #include <s3ePointer.h>
13 #include <IwGx.h>
14
main(int,char **)15 int main(int, char**)
16 {
17 IwGxInit();
18
19 // Setup Dear ImGui binding
20 IMGUI_CHECKVERSION();
21 ImGui::CreateContext();
22 ImGuiIO& io = ImGui::GetIO(); (void)io;
23 //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
24 ImGui_Marmalade_Init(true);
25
26 // Setup style
27 ImGui::StyleColorsDark();
28 //ImGui::StyleColorsClassic();
29
30 // Load Fonts
31 // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
32 // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
33 // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
34 // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
35 // - Read 'misc/fonts/README.txt' for more instructions and details.
36 // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
37 //io.Fonts->AddFontDefault();
38 //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
39 //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
40 //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
41 //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
42 //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
43 //IM_ASSERT(font != NULL);
44
45 bool show_demo_window = true;
46 bool show_another_window = false;
47 ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
48
49 // Main loop
50 while (true)
51 {
52 if (s3eDeviceCheckQuitRequest())
53 break;
54
55 // Poll and handle inputs
56 // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
57 // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
58 // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
59 // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
60 s3eKeyboardUpdate();
61 s3ePointerUpdate();
62
63 // Start the Dear ImGui frame
64 ImGui_Marmalade_NewFrame();
65 ImGui::NewFrame();
66
67 // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
68 if (show_demo_window)
69 ImGui::ShowDemoWindow(&show_demo_window);
70
71 // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
72 {
73 static float f = 0.0f;
74 static int counter = 0;
75
76 ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
77
78 ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
79 ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
80 ImGui::Checkbox("Another Window", &show_another_window);
81
82 ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
83 ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
84
85 if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
86 counter++;
87 ImGui::SameLine();
88 ImGui::Text("counter = %d", counter);
89
90 ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
91 ImGui::End();
92 }
93
94 // 3. Show another simple window.
95 if (show_another_window)
96 {
97 ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
98 ImGui::Text("Hello from another window!");
99 if (ImGui::Button("Close Me"))
100 show_another_window = false;
101 ImGui::End();
102 }
103
104 // Rendering
105 ImGui::Render();
106 IwGxSetColClear(clear_color.x * 255, clear_color.y * 255, clear_color.z * 255, clear_color.w * 255);
107 IwGxClear();
108 ImGui_Marmalade_RenderDrawData(ImGui::GetDrawData());
109 IwGxSwapBuffers();
110
111 s3eDeviceYield(0);
112 }
113
114 // Cleanup
115 ImGui_Marmalade_Shutdown();
116 ImGui::DestroyContext();
117 IwGxTerminate();
118
119 return 0;
120 }
121