Skip to content

Conversation

@scribam
Copy link
Contributor

@scribam scribam commented Sep 8, 2024

Follow-up for issue #3190

Currently, when using Vulkan, SDL_GL_GetDrawableSize will call SDL_GetWindowSizeInPixels (since GL_GetDrawableSize is NULL).
This works fine except on Cocoa, KMSDRM and UiKit as they have a Vulkan_GetDrawableSize defined and so they don't call SDL_GetWindowSizeInPixels. That's why SDL_Vulkan_GetDrawableSize is required instead of SDL_GL_GetDrawableSize

void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h)
{
    CHECK_WINDOW_MAGIC(window, );

    if (_this->GL_GetDrawableSize) {
        _this->GL_GetDrawableSize(_this, window, w, h);
    } else {
        SDL_GetWindowSizeInPixels(window, w, h);
    }
}
[...]
void SDL_Vulkan_GetDrawableSize(SDL_Window *window, int *w, int *h)
{
    CHECK_WINDOW_MAGIC(window, );

    if (_this->Vulkan_GetDrawableSize) {
        _this->Vulkan_GetDrawableSize(_this, window, w, h);
    } else {
        SDL_GetWindowSizeInPixels(window, w, h);
    }
}
device->Vulkan_GetDrawableSize = UIKit_Vulkan_GetDrawableSize;

device->Vulkan_GetDrawableSize = KMSDRM_Vulkan_GetDrawableSize;

device->Vulkan_GetDrawableSize = UIKit_Vulkan_GetDrawableSize;

Sources:

@ocornut
Copy link
Owner

ocornut commented Sep 8, 2024

Thank you. I’ll look at this tomorrow but can you confirm it is intentional that you are testing for two different defines?

Would the SDL3 backend require the same change?

@scribam
Copy link
Contributor Author

scribam commented Sep 8, 2024

Thank you. I’ll look at this tomorrow but can you confirm it is intentional that you are testing for two different defines?

This was a mistake, fixed.

Would the SDL3 backend require the same change?

No, SDL_GL_GetDrawableSize and SDL_Vulkan_GetDrawableSize have been removed with SDL3, SDL_GetWindowSizeInPixels must be used (which is currently the case).

ocornut pushed a commit that referenced this pull request Sep 9, 2024
@ocornut
Copy link
Owner

ocornut commented Sep 9, 2024

Merged as 4236bc0, thank you!

@ocornut ocornut closed this Sep 9, 2024
@scribam scribam deleted the SDL_Vulkan_GetDrawableSize branch September 9, 2024 15:56
ocornut pushed a commit that referenced this pull request Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants