Set Fixed Scale Factor for VisionOS (#10222)
This commit is contained in:
parent
9e331d235f
commit
a16ff651e8
2 changed files with 16 additions and 4 deletions
|
@ -79,16 +79,24 @@ SDL_MetalView UIKit_Metal_CreateView(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
CGFloat scale = 1.0;
|
CGFloat scale = 1.0;
|
||||||
SDL_uikitmetalview *metalview;
|
SDL_uikitmetalview *metalview;
|
||||||
|
|
||||||
#ifndef SDL_PLATFORM_VISIONOS
|
|
||||||
if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) {
|
if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) {
|
||||||
/* Set the scale to the natural scale factor of the screen - then
|
/* Set the scale to the natural scale factor of the screen - then
|
||||||
* the backing dimensions of the Metal view will match the pixel
|
* the backing dimensions of the Metal view will match the pixel
|
||||||
* dimensions of the screen rather than the dimensions in points
|
* dimensions of the screen rather than the dimensions in points
|
||||||
* yielding high resolution on retine displays.
|
* yielding high resolution on retine displays.
|
||||||
*/
|
*/
|
||||||
|
#ifndef SDL_PLATFORM_VISIONOS
|
||||||
scale = data.uiwindow.screen.nativeScale;
|
scale = data.uiwindow.screen.nativeScale;
|
||||||
}
|
#else
|
||||||
|
// VisionOS doesn't use the concept of "nativeScale" like other iOS devices.
|
||||||
|
// We use a fixed scale factor of 2.0 to achieve better pixel density.
|
||||||
|
// This is because VisionOS presents a virtual 1280x720 "screen", but we need
|
||||||
|
// to render at a higher resolution for optimal visual quality.
|
||||||
|
// TODO: Consider making this configurable or determining it dynamically
|
||||||
|
// based on the specific visionOS device capabilities.
|
||||||
|
scale = 2.0;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
metalview = [[SDL_uikitmetalview alloc] initWithFrame:data.uiwindow.bounds
|
metalview = [[SDL_uikitmetalview alloc] initWithFrame:data.uiwindow.bounds
|
||||||
scale:scale];
|
scale:scale];
|
||||||
|
|
|
@ -368,11 +368,15 @@ void UIKit_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int
|
||||||
CGSize size = view.bounds.size;
|
CGSize size = view.bounds.size;
|
||||||
CGFloat scale = 1.0;
|
CGFloat scale = 1.0;
|
||||||
|
|
||||||
#ifndef SDL_PLATFORM_VISIONOS
|
|
||||||
if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) {
|
if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) {
|
||||||
|
#ifndef SDL_PLATFORM_VISIONOS
|
||||||
scale = windata.uiwindow.screen.nativeScale;
|
scale = windata.uiwindow.screen.nativeScale;
|
||||||
}
|
#else
|
||||||
|
scale = 2.0;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Integer truncation of fractional values matches SDL_uikitmetalview and
|
/* Integer truncation of fractional values matches SDL_uikitmetalview and
|
||||||
* SDL_uikitopenglview. */
|
* SDL_uikitopenglview. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue