mirror of https://github.com/encounter/SDL.git
Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
This commit is contained in:
parent
3071128deb
commit
ba565622aa
|
@ -189,12 +189,19 @@ UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
||||||
SDL_bool addRotation = (data.uiscreen == [UIScreen mainScreen]);
|
SDL_bool addRotation = (data.uiscreen == [UIScreen mainScreen]);
|
||||||
CGFloat scale = data.uiscreen.scale;
|
CGFloat scale = data.uiscreen.scale;
|
||||||
|
|
||||||
|
#ifdef __IPHONE_8_0
|
||||||
|
/* The UIScreenMode of an iPhone 6 Plus should be 1080x1920 rather than
|
||||||
|
* 1242x2208 (414x736@3x), so we should use the native scale. */
|
||||||
|
if ([data.uiscreen respondsToSelector:@selector(nativeScale)]) {
|
||||||
|
scale = data.uiscreen.nativeScale;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (UIScreenMode *uimode in [data.uiscreen availableModes]) {
|
for (UIScreenMode *uimode in [data.uiscreen availableModes]) {
|
||||||
/* The size of a UIScreenMode is in pixels, but we deal exclusively in
|
/* The size of a UIScreenMode is in pixels, but we deal exclusively
|
||||||
* points (except in SDL_GL_GetDrawableSize.) */
|
* in points (except in SDL_GL_GetDrawableSize.) */
|
||||||
CGSize size = [uimode size];
|
int w = (int)(uimode.size.width / scale);
|
||||||
int w = (int)(size.width / scale);
|
int h = (int)(uimode.size.height / scale);
|
||||||
int h = (int)(size.height / scale);
|
|
||||||
|
|
||||||
/* Make sure the width/height are oriented correctly */
|
/* Make sure the width/height are oriented correctly */
|
||||||
if (isLandscape != (w > h)) {
|
if (isLandscape != (w > h)) {
|
||||||
|
|
|
@ -121,11 +121,18 @@ UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
CGFloat scale = 1.0;
|
CGFloat scale = 1.0;
|
||||||
|
|
||||||
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||||
/* Set the scale to the natural scale factor of the screen - the backing
|
/* Set the scale to the natural scale factor of the screen - the
|
||||||
dimensions of the OpenGL view will match the pixel dimensions of the
|
backing dimensions of the OpenGL view will match the pixel
|
||||||
screen rather than the dimensions in points.
|
dimensions of the screen rather than the dimensions in points.
|
||||||
*/
|
*/
|
||||||
scale = uiwindow.screen.scale;
|
#ifdef __IPHONE_8_0
|
||||||
|
if ([uiwindow.screen respondsToSelector:@selector(nativeScale)]) {
|
||||||
|
scale = uiwindow.screen.nativeScale;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
scale = uiwindow.screen.scale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_this->gl_config.share_with_current_context) {
|
if (_this->gl_config.share_with_current_context) {
|
||||||
|
|
Loading…
Reference in New Issue