在 SDL2 中,window 相对于 window 所在的屏幕大小(在多显示器的情况下)的大小

Size a window relative to the size of the screen the window is in (in case of multiple displays) in SDL2

我正在编写一些封装 SDL2 部分的代码。我想处理 window 在创建后移动到另一个显示器的情况,适当地放大 window。

我正在使用 C.

我无法弄清楚的部分是如何在给定 SDL_Window 对象的情况下,在多显示器设置中找出 window 所在的显示器。如果我能找到它,找到该显示器的尺寸并适当地设置 window 尺寸就很简单了。

// Width and height of display that myWindow is in (myWindow some previously created SDL_Window)
int disp_x_size_px;
int disp_y_size_px;

/* Need code to get values for disp_x_size_px and disp_y_size_px.
    With these values I can set the window size correctly. */

根据 genpfault 的评论,答案是使用 SDL_GetWindowDisplayIndex() 来显示 window。然后当然可以使用 SDL_GetDisplayBounds() 来获取显示大小,并使用 SDL_SetWindowPosition() 来适当地设置 window 位置。

注意:我把这个放在一个答案中,所以这个问题可以有一个可接受的答案:毕竟它已经被接受地回答了。