iOS: implement SDL_GetWindowSizeInPixels.
parent
fa7ffa4e88
commit
d2160c29d1
|
@ -98,6 +98,7 @@ UIKit_CreateDevice(void)
|
|||
device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
|
||||
device->GetDisplayUsableBounds = UIKit_GetDisplayUsableBounds;
|
||||
device->GetDisplayDPI = UIKit_GetDisplayDPI;
|
||||
device->GetWindowSizeInPixels = UIKit_GetWindowSizeInPixels;
|
||||
|
||||
#if SDL_IPHONE_KEYBOARD
|
||||
device->HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
|
||||
|
|
|
@ -36,6 +36,7 @@ extern void UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDispl
|
|||
extern void UIKit_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
extern void UIKit_UpdatePointerLock(_THIS, SDL_Window * window);
|
||||
extern void UIKit_DestroyWindow(_THIS, SDL_Window * window);
|
||||
extern void UIKit_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h);
|
||||
extern SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo * info);
|
||||
|
||||
|
|
|
@ -369,6 +369,25 @@ UIKit_DestroyWindow(_THIS, SDL_Window * window)
|
|||
window->driverdata = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
UIKit_GetWindowSizeInPixels(_THIS, SDL_Window * window, int *w, int *h)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata;
|
||||
UIView *view = windata.viewcontroller.view;
|
||||
CGSize size = view.bounds.size;
|
||||
CGFloat scale = 1.0;
|
||||
|
||||
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||
scale = windata.uiwindow.screen.nativeScale;
|
||||
}
|
||||
|
||||
/* Integer truncation of fractional values matches SDL_uikitmetalview and
|
||||
* SDL_uikitopenglview. */
|
||||
*w = size.width * scale;
|
||||
*h = size.height * scale;
|
||||
}}
|
||||
|
||||
SDL_bool
|
||||
UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue