mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Removed support for OS X 10.6 and below
This commit is contained in:
parent
0d6ddde07f
commit
ac28902b57
@ -23,7 +23,7 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
# detect OS X version. (use '/usr/bin/sw_vers -productVersion' to extract V from '10.V.x'.)
|
||||
EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW)
|
||||
STRING(REGEX REPLACE "10\\.([0-9]).*" "\\1" MACOSX_VERSION "${MACOSX_VERSION_RAW}")
|
||||
if(${MACOSX_VERSION} LESS 5)
|
||||
if(${MACOSX_VERSION} LESS 7)
|
||||
message(FATAL_ERROR "Unsupported version of OS X : ${MACOSX_VERSION_RAW}")
|
||||
return()
|
||||
endif()
|
||||
|
@ -36,11 +36,7 @@
|
||||
|
||||
struct SFMLmainWindow;
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
@interface CocoaAppDelegate : NSObject <NSApplicationDelegate> {
|
||||
#else
|
||||
@interface CocoaAppDelegate : NSObject {
|
||||
#endif
|
||||
@private
|
||||
NSWindow *m_window;
|
||||
NSView *m_sfmlView;
|
||||
|
@ -129,11 +129,6 @@ void SFContext::display()
|
||||
////////////////////////////////////////////////////////////
|
||||
void SFContext::setVerticalSyncEnabled(bool enabled)
|
||||
{
|
||||
// Make compiler happy
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
|
||||
typedef int GLint;
|
||||
#endif
|
||||
|
||||
GLint swapInterval = enabled ? 1 : 0;
|
||||
|
||||
[m_context setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
|
||||
|
@ -53,12 +53,7 @@ namespace sf {
|
||||
/// m_fullscreenMode is bind to default video mode if we don't need to change screen size.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 // NSWindowDelegate is only define since 10.6
|
||||
@interface SFWindowController : NSResponder <WindowImplDelegateProtocol>
|
||||
#else
|
||||
@interface SFWindowController : NSResponder <WindowImplDelegateProtocol, NSWindowDelegate>
|
||||
#endif
|
||||
{
|
||||
NSWindow* m_window; ///< Underlying Cocoa window to be controlled
|
||||
SFOpenGLView* m_oglView; ///< OpenGL view for rendering
|
||||
|
@ -431,9 +431,6 @@
|
||||
bitsPerPixel:0]; // 0 == determine automatically
|
||||
|
||||
// Load data pixels.
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 // We may need to define NSUInteger.
|
||||
#define NSUInteger unsigned int
|
||||
#endif
|
||||
for (unsigned int y = 0; y < height; ++y)
|
||||
{
|
||||
for (unsigned int x = 0; x < width; ++x, pixels+=4)
|
||||
|
@ -35,44 +35,10 @@ namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Note :
|
||||
/// Starting with 10.6, CGDisplayModeRef and CGDisplayCopyAllDisplayModes
|
||||
/// should be used instead of CFDictionaryRef and CGDisplayAvailableModes.
|
||||
///
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
|
||||
|
||||
std::vector<VideoMode> modes;
|
||||
|
||||
// Retrieve array of dictionaries representing display modes.
|
||||
CFArrayRef displayModes = CGDisplayAvailableModes(CGMainDisplayID());
|
||||
|
||||
if (displayModes == NULL)
|
||||
{
|
||||
sf::err() << "Couldn't get VideoMode for main display." << std::endl;
|
||||
return modes;
|
||||
}
|
||||
|
||||
// Loop on each mode and convert it into a sf::VideoMode object.
|
||||
const CFIndex modesCount = CFArrayGetCount(displayModes);
|
||||
for (CFIndex i = 0; i < modesCount; i++)
|
||||
{
|
||||
CFDictionaryRef dictionary = (CFDictionaryRef)CFArrayGetValueAtIndex(displayModes, i);
|
||||
|
||||
VideoMode mode = convertCGModeToSFMode(dictionary);
|
||||
|
||||
// If not yet listed we add it to our modes array.
|
||||
if (std::find(modes.begin(), modes.end(), mode) == modes.end())
|
||||
modes.push_back(mode);
|
||||
}
|
||||
|
||||
return modes;
|
||||
|
||||
#else // MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
|
||||
std::vector<VideoMode> modes;
|
||||
|
||||
// Retrieve all modes available for main screen only.
|
||||
@ -101,8 +67,6 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
|
||||
CFRelease(cgmodes);
|
||||
|
||||
return modes;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,7 +35,6 @@ namespace priv
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
size_t modeBitsPerPixel(CGDisplayModeRef mode)
|
||||
{
|
||||
size_t bpp = 0; // no match
|
||||
@ -54,19 +53,11 @@ size_t modeBitsPerPixel(CGDisplayModeRef mode)
|
||||
|
||||
return bpp;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
size_t displayBitsPerPixel(CGDirectDisplayID displayId)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
|
||||
|
||||
return CGDisplayBitsPerPixel(displayId);
|
||||
|
||||
#else // MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
|
||||
// Get the display mode.
|
||||
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displayId);
|
||||
|
||||
@ -77,32 +68,10 @@ size_t displayBitsPerPixel(CGDirectDisplayID displayId)
|
||||
CGDisplayModeRelease(mode);
|
||||
|
||||
return bpp;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
|
||||
|
||||
VideoMode convertCGModeToSFMode(CFDictionaryRef dictionary)
|
||||
{
|
||||
VideoMode sfmode;
|
||||
|
||||
CFNumberRef cfnumber = (CFNumberRef)CFDictionaryGetValue(dictionary, kCGDisplayWidth);
|
||||
CFNumberGetValue(cfnumber, kCFNumberIntType, &(sfmode.width));
|
||||
|
||||
cfnumber = (CFNumberRef)CFDictionaryGetValue(dictionary, kCGDisplayHeight);
|
||||
CFNumberGetValue(cfnumber, kCFNumberIntType, &(sfmode.height));
|
||||
|
||||
cfnumber = (CFNumberRef)CFDictionaryGetValue(dictionary, kCGDisplayBitsPerPixel);
|
||||
CFNumberGetValue(cfnumber, kCFNumberIntType, &(sfmode.bitsPerPixel));
|
||||
|
||||
return sfmode;
|
||||
}
|
||||
|
||||
#else // MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
|
||||
VideoMode convertCGModeToSFMode(CGDisplayModeRef cgmode)
|
||||
{
|
||||
return VideoMode(CGDisplayModeGetWidth(cgmode),
|
||||
@ -110,24 +79,8 @@ VideoMode convertCGModeToSFMode(CGDisplayModeRef cgmode)
|
||||
modeBitsPerPixel(cgmode));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
|
||||
|
||||
CFDictionaryRef convertSFModeToCGMode(VideoMode sfmode)
|
||||
{
|
||||
// If sfmode is in VideoMode::GetFullscreenModes
|
||||
// then this should be an exact match (see NULL parameter doc).
|
||||
return CGDisplayBestModeForParameters(CGMainDisplayID(),
|
||||
sfmode.bitsPerPixel,
|
||||
sfmode.width,
|
||||
sfmode.height,
|
||||
NULL);
|
||||
}
|
||||
|
||||
#else // MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
|
||||
CGDisplayModeRef convertSFModeToCGMode(VideoMode sfmode)
|
||||
{
|
||||
// Starting with 10.6 we should query the display all the modes and
|
||||
@ -167,7 +120,5 @@ CGDisplayModeRef convertSFModeToCGMode(VideoMode sfmode)
|
||||
return cgbestMode;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace priv
|
||||
} // namespace sf
|
||||
|
@ -39,13 +39,11 @@ namespace priv
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get bpp of a video mode for OS 10.6 or later
|
||||
///
|
||||
/// With OS 10.6 and later, Quartz doesn't use anymore dictionaries
|
||||
/// With OS 10.6 and later, Quartz doesn't use dictionaries any more
|
||||
/// to represent video mode. Instead it uses a CGDisplayMode opaque type.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
size_t modeBitsPerPixel(CGDisplayModeRef mode);
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get bpp for all OS X version
|
||||
@ -60,21 +58,13 @@ size_t displayBitsPerPixel(CGDirectDisplayID displayId);
|
||||
/// \brief Convert a Quartz video mode into a sf::VideoMode object
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
|
||||
VideoMode convertCGModeToSFMode(CFDictionaryRef dictionary);
|
||||
#else // MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
VideoMode convertCGModeToSFMode(CGDisplayModeRef cgmode);
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a sf::VideoMode object into a Quartz video mode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
|
||||
CFDictionaryRef convertSFModeToCGMode(VideoMode sfmode);
|
||||
#else // MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||
CGDisplayModeRef convertSFModeToCGMode(VideoMode sfmode);
|
||||
#endif
|
||||
|
||||
} // namespace priv
|
||||
} // namespace sf
|
||||
|
Loading…
Reference in New Issue
Block a user