natiny_window_get_scale

C
float natiny_window_get_scale(NatinyWindow id);

Returns the display scaling factor captured when the window was created.

Parameters

Name Type Description
id NatinyWindow Window handle from natiny_window_create

Returns

Type Description
float Display scale: 1 for 100%, 1.5 for 150%, 2 for 200%, or 0 if the window does not exist

Example

Manual display scaling in the default pixel-for-pixel mode:

C
NatinyWindow win = natiny_window_create("My Game", 1280, 720);
float        s   = natiny_window_get_scale(win);

NatinyFont font = natiny_font_create(ttf, 16.0f * s);

natiny_render_text(font, 20.0f * s, 20.0f * s, "hello");

Notes

  • NATINY_SCALE_MODE_STRETCH and NATINY_SCALE_MODE_HIDPI apply this factor automatically. NATINY_SCALE_MODE_PIXELS ignores it.
  • The value is captured when the window is created. Moving the window to another display does not update it.
  • This function only reads the factor; it does not change the window's mode.