Question regarding SDL3 High Pixel Density w/ OpenGL

Hello! I hope this type of question is alright here.

I am migrating my application to SDL3 and am running into an inconsistency on macOS vs Windows which is puzzling me.

In SDL2 I was using these hints to enable high pixel density on Windows:

SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "permonitorv2");
SDL_SetHint(SDL_HINT_WINDOWS_DPI_SCALING, "1");

These appear to have been removed in SDL3 (although when I scan through the source it seems I can still set the DPI_AWARENESS hint using the string literal associated).

Regardless, I am seeing a discrepancy between macOS and Windows where on Windows no matter if I set the HIGH_PIXEL_DENSITY window flag, my framebuffer remains at the size of the window.

If anyone has any insight here, am I missing something obvious?

Here is my example source:

#include <iostream>
#include <SDL.h>

int main() {
    SDL_SetHint("SDL_WINDOWS_DPI_AWARENESS", "permonitorv2");

    SDL_Init(SDL_INIT_VIDEO);

    SDL_Window* window = SDL_CreateWindow("Test", 500, 500, SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_OPENGL);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
    SDL_GLContext context = SDL_GL_CreateContext(window);
    SDL_GL_SetSwapInterval(1);
    SDL_Event event;


    bool should_quit = false;
    while (!should_quit) {
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_EVENT_QUIT)
                should_quit = true;
        }
        int w, h;
        SDL_GetWindowSize(window, &w, &h);
        printf("Window size: %d x %d\n", w, h);

        SDL_GetWindowSizeInPixels(window, &w, &h);
        printf("Window size in pixels: %d x %d\n", w, h);

        float scale = SDL_GetWindowDisplayScale(window);
        printf("Window display scale: %f\n", scale);

        float pixel_density = SDL_GetWindowPixelDensity(window);
        printf("Window pixel density: %f\n", pixel_density);

        SDL_GL_SwapWindow(window);
    }

    SDL_DestroyWindow(window);
    SDL_GL_DeleteContext(context);
    SDL_Quit();
}

Output on macOS in Retina mode:

Window size: 500 x 500
Window size in pixels: 1000 x 1000
Window display scale: 2.000000
Window pixel density: 2.000000

Output on Windows at 1.5x display scaling:

Window size: 500 x 500
Window size in pixels: 500 x 500
Window display scale: 1.500000
Window pixel density: 1.000000

Am I meant to handle this manually inside of my program?

Thanks.

Check this out and please let us know if it’s not clear:

I tried the example with Linux Mint Cinnamon and experimentally set the scaling to 200%.
This gives me the following output:

Window size: 500 x 500
Window size in pixels: 500 x 500
Window display scale: 1.000000
Window pixel density: 1.000000

Thanks. I read through that prior to posting, but I guess not closely enough.

I think where I misunderstood was that I assumed the SDL_GetWindowSize() would return the effective size that I should be using in my renderer (in points rather than pixels), but I see now I will have to do the conversion myself based on the information returned from the various functions. Thanks.