Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/cute_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,23 +369,23 @@ CF_API int CF_CALL cf_app_draw_onto_screen(bool clear);
* @brief Gets the size of the window in logical points (called "points" on Retina/HiDPI displays; use `cf_app_get_pixel_scale` to convert to physical pixels).
* @param w The width of the window in logical points.
* @param h The height of the window in logical points.
* @related cf_app_set_size cf_app_get_position cf_app_set_position cf_app_get_width cf_app_get_height cf_app_get_dpi_scale
* @related cf_app_set_size cf_app_get_position cf_app_set_position cf_app_get_width cf_app_get_height cf_app_get_dpi_scale cf_app_get_pixel_scale
*/
CF_API void CF_CALL cf_app_get_size(int* w, int* h);

/**
* @function cf_app_get_width
* @category app
* @brief Returns the size of the window width in logical points (use `cf_app_get_pixel_scale` to convert to physical pixels).
* @related cf_app_set_size cf_app_get_position cf_app_set_position cf_app_get_width cf_app_get_height cf_app_get_dpi_scale
* @related cf_app_set_size cf_app_get_position cf_app_set_position cf_app_get_width cf_app_get_height cf_app_get_dpi_scale cf_app_get_pixel_scale
*/
CF_API int CF_CALL cf_app_get_width(void);

/**
* @function cf_app_get_height
* @category app
* @brief Returns the size of the window height in logical points (use `cf_app_get_pixel_scale` to convert to physical pixels).
* @related cf_app_set_size cf_app_get_position cf_app_set_position cf_app_get_width cf_app_get_height cf_app_get_dpi_scale
* @related cf_app_set_size cf_app_get_position cf_app_set_position cf_app_get_width cf_app_get_height cf_app_get_dpi_scale cf_app_get_pixel_scale
*/
CF_API int CF_CALL cf_app_get_height(void);

Expand Down
2 changes: 1 addition & 1 deletion samples/window_resizing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int main(int argc, char* argv[])
// blit is 1:1 and stays crisp on HiDPI displays. The projection below
// stays in logical units, so game content doesn't move.
float pixel_scale = app_get_pixel_scale();
app_set_canvas_size((int)(window_w * pixel_scale), (int)(window_h * pixel_scale));
app_set_canvas_size((int)CF_ROUNDF(window_w * pixel_scale), (int)CF_ROUNDF(window_h * pixel_scale));
CF_V2 dest = calculate_dest_size(game_w, game_h, window_w, window_h, scale_mode);

// Draw the canvas scaled and centered in the window.
Expand Down
6 changes: 5 additions & 1 deletion src/cute_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,11 @@ bool cf_app_set_msaa(int sample_count)

if (supported && app->sample_count != sample_count) {
app->sample_count = sample_count;
cf_app_recreate_default_canvas_if_needed();
if (app->canvas_pinned) {
s_canvas(app->canvas_w, app->canvas_h);
} else {
cf_app_recreate_default_canvas_if_needed();
}
}
Comment on lines 757 to 764

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 234e94b.


return supported;
Expand Down
3 changes: 3 additions & 0 deletions src/cute_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,16 @@ void cf_begin_frame_input()

// Re-queries the window's physical pixel density and, if it changed, updates
// app->pixel_scale and recreates the default canvas to match (unless pinned).
// No-ops entirely when CF_APP_OPTIONS_NO_HIGH_DPI_BIT is set, since pixel_scale
// must stay pinned at 1.0f in that mode.
// Called from both SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED and
// SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED -- the former is the OS's content-scale
// signal and the latter is the authoritative physical-pixel-size signal;
// either can fire without the other depending on platform/monitor setup, so
// both are handled the same way and this is idempotent when both fire together.
static void s_refresh_pixel_scale()
{
if (app->options & CF_APP_OPTIONS_NO_HIGH_DPI_BIT) return;
float pixel_scale = SDL_GetWindowPixelDensity(app->window);
if (pixel_scale <= 0.0f) pixel_scale = 1.0f;
if (pixel_scale != app->pixel_scale) {
Expand Down
Loading