Skip to content

Commit

Permalink
nuidemo: oversample ui render scale
Browse files Browse the repository at this point in the history
  • Loading branch information
redthing1 committed Jul 15, 2024
1 parent 95da32d commit e1f7a49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion demo/nuidemo/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
9 changes: 7 additions & 2 deletions demo/nuidemo/source/gui_root.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e1f7a49

Please sign in to comment.