mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 14:21:04 +08:00
Fix how macOS fullscreen video modes are detected
Co-authored-by: Lorenzooone <lollo.lollo.rbiz@gmail.com>
This commit is contained in:
parent
50ced215d0
commit
c6e0f1ad2b
@ -181,7 +181,6 @@
|
||||
{
|
||||
// Create a screen-sized window on the main display
|
||||
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
|
||||
sf::priv::scaleInWidthHeight(desktop, nil);
|
||||
NSRect windowRect = NSMakeRect(0, 0, desktop.width, desktop.height);
|
||||
m_window = [[SFWindow alloc] initWithContentRect:windowRect
|
||||
styleMask:NSBorderlessWindowMask
|
||||
@ -448,7 +447,6 @@
|
||||
// Special case when fullscreen: only resize the opengl view
|
||||
// and make sure the requested size is not bigger than the window.
|
||||
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
|
||||
sf::priv::scaleInWidthHeight(desktop, nil);
|
||||
|
||||
width = std::min(width, desktop.width);
|
||||
height = std::min(height, desktop.height);
|
||||
|
@ -57,13 +57,6 @@ void scaleIn(T& in, id<WindowImplDelegateProtocol> delegate)
|
||||
in /= static_cast<T>(delegate ? [delegate displayScaleFactor] : getDefaultScaleFactor());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void scaleInWidthHeight(T& in, id<WindowImplDelegateProtocol> delegate)
|
||||
{
|
||||
scaleIn(in.width, delegate);
|
||||
scaleIn(in.height, delegate);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void scaleInXY(T& in, id<WindowImplDelegateProtocol> delegate)
|
||||
{
|
||||
|
@ -28,6 +28,7 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/OSX/cg_sf_conversion.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
|
||||
#import <SFML/Window/OSX/Scaling.h>
|
||||
|
||||
@ -95,11 +96,10 @@ VideoMode convertCGModeToSFMode(CGDisplayModeRef cgmode)
|
||||
//
|
||||
// [1]: "APIs for Supporting High Resolution" > "Additions and Changes for OS X v10.8"
|
||||
// https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/APIs/APIs.html#//apple_ref/doc/uid/TP40012302-CH5-SW27
|
||||
VideoMode mode(static_cast<unsigned int>(CGDisplayModeGetWidth(cgmode)), static_cast<unsigned int>(CGDisplayModeGetHeight(cgmode)), static_cast<unsigned int>(modeBitsPerPixel(cgmode)));
|
||||
scaleOutWidthHeight(mode, nil);
|
||||
return mode;
|
||||
Vector2u size = Vector2u(Vector2<size_t>(CGDisplayModeGetPixelWidth(cgmode), CGDisplayModeGetPixelHeight(cgmode)));
|
||||
scaleInXY(size, nil);
|
||||
return VideoMode(size.x, size.y, static_cast<unsigned int>(modeBitsPerPixel(cgmode)));
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
} // namespace sf
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user