Skip to content

[rcore] FLAG_WINDOW_HIGHDPI is broken in macOS #5185

@vegerot

Description

@vegerot

Please, before submitting a new issue verify and check:

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

Background

In May I posted a bug on another Issue #4908 (comment) but the OP doesn't own a Mac so couldn't repro the bug #4908 (comment)

Issue description

👋🏼 I updated Raylib back in May and my game doesn't work anymore.

Steps to reproduce:

  1. git clone --recurse-submodules git@github.com:vegerot/snek.git
  2. git switch --detach 0159ab6ce084e189baf8f91abe3f39ec58ec5a08
  3. git submodule update --init
  4. zig build play
  5. Take a break and play the game for a bit. It's fun!

This should work!

Image

Now

  1. cd raylib && git switch -d 5c954c1f (this is the next commit!)
  2. zig build play

Expected: Should also work

Actual: it looks wrong. It's super zoomed in

Image

I found two workarounds:

  1. Resize the window. If you resize the window, the game will fix itself and look correct
  2. In snek.zig:682, set raylib.FLAG_WINDOW_HIGHDPI. This makes the first frame look right but breaks the scale when resizing!

My issue was introduced in 5c954c1 which seems related...


I tried setting HIGHDPI but now I have the opposite problem! The game size is correct at first, but when resizing the window the game gets shrunk to exactly quarter the size of the window.

Steps to reproduce:

  1. Buy a Mac and set up developer tools
$ git clone --recurse-submodules ssh://git@github.com/vegerot/snek.git
$ git switch --detach 1697cf603654745ecc6ea21bf25f6aa20d732254
$ git submodule update
$ zig build play
  1. Note that the game looks great.
    2.5. Take a break and play the game for a bit. It's a lot of fun!

  2. Just slightly change the size of the window

  3. Note that the game is now a quarter of the size.

I'm assuming my bug must either be in https://github.com/vegerot/snek/blob/0d8d298bc79a2ab5de6a7a76be4482c6d0abd362/snek.zig#L684 or https://github.com/vegerot/snek/blob/0d8d298bc79a2ab5de6a7a76be4482c6d0abd362/snek.zig#L533 but I don't know what the bug is.

What does this mean?

Fundamentally, you should be drawing things according to the window size and not the render size

Sorry, I don't know what that means. Does it mean I'm doing something more fundamentally wrong with how I calculate the options.gameSize?

I think this is a bug in Raylib. Can you confirm? The regression in my game is either from 4bed374 or 5c954c1

NOTE: Also, I reverted the raylib upgrade after getting the bug reports, so make sure to checkout vegerot/snek@1697cf6 (and run git submodule update --init) before reproducing 🙂

Environment

macOS 15.7, M3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions