Skip to content

Blurry SDL2 rendering on macOS with Retina displays (with fix) #233

Description

@conker-rsc

I noticed this when running a self-compiled binary of rsc-c on my m1 macos air laptop: when using SDL2 as the renderer, the overall image displays rather blurry. I was able to track down the root cause, which can be attributed to using a Retina display.

I found an article which describes a fix, located here: https://www.studyplan.dev/sdl-dev/sdl-setup-mac/q/sdl2-macos-retina-display

I tried this out myself, by setting the following flag within mudclient-sdl2.c:

SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");

and adding the second mask to the following line:

uint32_t windowflags = SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI;

Doing so does result in correcting the issue, which may be seen in the following annotated screenshots:

Screenshot 2024-11-10 at 12 55 43 PM

Unfortunately I don't have enough time to create a proper PR at the moment, which I imagine would only apply these changes if the process is running on macOS with a retina display (as to avoid possible unintended side-effects with things like non-retina displays or native Windows OS scaling). As such, I wanted to at least document this issue and my findings here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions