@@ -103,16 +103,46 @@ void window_size_callback(GLFWwindow* window, const int width, const int height)
103103 state->height = static_cast <float >(height);
104104}
105105
106+ void apply_resolution_scaling (int current_height) {
107+ if (current_height <= 0 ) return ;
108+
109+ ImGuiIO& io = ImGui::GetIO ();
110+ float base_height = 1080 .0f ;
111+ float raw_scale = static_cast <float >(current_height) / base_height;
112+
113+ if (raw_scale < 0 .75f ) raw_scale = 0 .75f ;
114+ if (raw_scale > 2 .5f ) raw_scale = 2 .5f ;
115+
116+ float scale = std::round (raw_scale * 4 .0f ) / 4 .0f ;
117+
118+ io.FontGlobalScale = scale;
119+
120+ ImGui::GetStyle () = ImGuiStyle ();
121+ ImGui::GetStyle ().ScaleAllSizes (scale);
122+
123+ ImGuiStyle& style = ImGui::GetStyle ();
124+ if (style.WindowBorderSize < 1 .0f ) style.WindowBorderSize = 1 .0f ;
125+ if (style.FrameBorderSize < 1 .0f ) style.FrameBorderSize = 1 .0f ;
126+ if (style.PopupBorderSize < 1 .0f ) style.PopupBorderSize = 1 .0f ;
127+ if (style.ChildBorderSize < 1 .0f ) style.ChildBorderSize = 1 .0f ;
128+ if (style.TabBorderSize < 1 .0f ) style.TabBorderSize = 1 .0f ;
129+
130+ #if IMGUI_VERSION_NUM >= 18900
131+ if (style.SeparatorTextBorderSize < 1 .0f ) style.SeparatorTextBorderSize = 1 .0f ;
132+ #endif
133+ }
134+
106135void framebuffer_size_callback (GLFWwindow* window, const int width, const int height) {
107136 glViewport (0 , 0 , width, height);
137+ // apply_resolution_scaling(height);
108138}
109139
110140#ifdef __EMSCRIPTEN__
111141EM_BOOL browser_resize_callback (int event_type, const EmscriptenUiEvent* ui_event, void * data) {
112142 GLFWwindow* window = static_cast <GLFWwindow*>(data);
113143 const double width = ui_event->windowInnerWidth ;
114144 const double height = ui_event->windowInnerHeight ;
115- const double ratio = emscripten_get_device_pixel_ratio () ;
145+ const double ratio = 2 ;
116146
117147 emscripten_set_canvas_element_size (" #canvas" , width * ratio, height * ratio);
118148
0 commit comments