You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
111
127
//io.ConfigViewportsNoAutoMerge = true;
112
128
//io.ConfigViewportsNoTaskBarIcon = true;
113
129
114
130
// Setup Dear ImGui style
115
131
ImGui::StyleColorsDark();
116
-
//ImGui::StyleColorsClassic();
132
+
//ImGui::StyleColorsLight();
117
133
118
-
//When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
134
+
//Setup scaling
119
135
ImGuiStyle& style = ImGui::GetStyle();
136
+
style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
137
+
style.FontScaleDpi = main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
io.ConfigDpiScaleFonts = true; // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
140
+
io.ConfigDpiScaleViewports = true; // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.
141
+
#endif
142
+
143
+
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
120
144
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
121
145
{
122
146
style.WindowRounding = 0.0f;
@@ -125,22 +149,27 @@ int main(int argc, char **argv)
// - 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.
132
159
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
133
-
// - 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).
134
-
// - 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.
160
+
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
161
+
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
135
162
// - Read 'docs/FONTS.md' for more instructions and details.
136
163
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
164
+
// - Our Emscripten build process allows embedding fonts to be accessible at runtime from the "fonts/" folder. See Makefile.emscripten for details.
// Poll and handle events (inputs, window resize, etc.)
168
207
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
169
-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
170
-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
208
+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
209
+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
171
210
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
172
211
glfwPollEvents();
173
-
174
-
NetImguiServer::App::Update(); // @SAMPLE_EDIT (Request each client to update their drawing content )
212
+
if (glfwGetWindowAttrib(window, GLFW_ICONIFIED) != 0)
213
+
{
214
+
ImGui_ImplGlfw_Sleep(10);
215
+
continue;
216
+
}
175
217
176
218
// Start the Dear ImGui frame
219
+
NetImguiServer::App::Update(); // @SAMPLE_EDIT (Request each client to update their drawing content )
177
220
ImGui_ImplOpenGL3_NewFrame();
178
221
ImGui_ImplGlfw_NewFrame();
179
222
ImGui::NewFrame();
@@ -188,7 +231,7 @@ int main(int argc, char **argv)
188
231
if (show_demo_window)
189
232
ImGui::ShowDemoWindow(&show_demo_window);
190
233
191
-
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
234
+
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window.
192
235
{
193
236
static float f = 0.0f;
194
237
static int counter = 0;
@@ -207,7 +250,7 @@ int main(int argc, char **argv)
207
250
ImGui::SameLine();
208
251
ImGui::Text("counter = %d", counter);
209
252
210
-
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
253
+
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
211
254
ImGui::End();
212
255
}
213
256
@@ -231,7 +274,7 @@ int main(int argc, char **argv)
0 commit comments