From e1f7a49cba376c202935d34fef0f7f7c1ddcbb65 Mon Sep 17 00:00:00 2001 From: redthing1 Date: Mon, 15 Jul 2024 14:44:27 -0700 Subject: [PATCH] nuidemo: oversample ui render scale --- demo/nuidemo/source/app.d | 3 ++- demo/nuidemo/source/gui_root.d | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/demo/nuidemo/source/app.d b/demo/nuidemo/source/app.d index 90cc0d3b..4cbe0e9b 100644 --- a/demo/nuidemo/source/app.d +++ b/demo/nuidemo/source/app.d @@ -16,7 +16,8 @@ class Game : Core { this() { window_resizable = true; - render_oversample_factor = 1; + render_oversample_factor = 2; + default_filter_mode = raylib.TextureFilter.TEXTURE_FILTER_ANISOTROPIC_16X; sync_render_target_to_window_resolution = true; super(WIDTH, HEIGHT, "nuidemo"); diff --git a/demo/nuidemo/source/gui_root.d b/demo/nuidemo/source/gui_root.d index 491381d2..eed9c653 100644 --- a/demo/nuidemo/source/gui_root.d +++ b/demo/nuidemo/source/gui_root.d @@ -44,12 +44,14 @@ class GuiRoot : Component, Renderable2D, Updatable { nk_context* ctx; nk_colorf bg; + float ui_scale = 1.0; override void setup() { bg = ColorToNuklearF(Colors.SKYBLUE); auto ui_font = raylib.LoadFontEx("./res/SourceSansPro-Regular.ttf", UI_FS, null, 0); ctx = InitNuklearEx(ui_font, UI_FS); - SetNuklearScaling(ctx, cast(int) Core.render_oversample_factor); + ui_scale = Core.window.dpi_scale * Core.render_oversample_factor; + SetNuklearScaling(ctx, ui_scale); apply_style(ctx); status("ready."); @@ -80,7 +82,10 @@ class GuiRoot : Component, Renderable2D, Updatable { UpdateNuklear(ctx); // GUI - auto window_bounds = Rectangle(0, 0, Core.window.render_width, Core.window.render_height); + auto window_bounds = Rectangle( + 0, 0, + Core.window.screen_width * ui_scale, Core.window.screen_height * ui_scale + ); if (nk_begin(ctx, "Demo", RectangleToNuklear(ctx, window_bounds), nk_panel_flags.NK_WINDOW_BORDER | nk_panel_flags.NK_WINDOW_TITLE)) { enum EASY = 0;