[Mac] Support for Retina display high-resolution gameplay.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@5017 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
5232a456ba
commit
41cd72d2dd
@ -54,7 +54,7 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
@end
|
||||
|
||||
|
||||
#if !OOLITE_SNOW_LEOPARD
|
||||
#if !OOLITE_MAC_OS_X_10_6
|
||||
@interface NSResponder (SnowLeopard)
|
||||
|
||||
- (void) setAcceptsTouchEvents:(BOOL)value;
|
||||
@ -63,6 +63,23 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
#endif
|
||||
|
||||
|
||||
#if !OOLITE_MAC_OS_X_10_7
|
||||
@interface NSView (Lion)
|
||||
|
||||
- (BOOL) wantsBestResolutionOpenGLSurface;
|
||||
- (void) setWantsBestResolutionOpenGLSurface:(BOOL)flag;
|
||||
|
||||
- (NSPoint) convertPointToBacking:(NSPoint)aPoint;
|
||||
- (NSPoint) convertPointFromBacking:(NSPoint)aPoint;
|
||||
- (NSSize) convertSizeToBacking:(NSSize)aSize;
|
||||
- (NSSize) convertSizeFromBacking:(NSSize)aSize;
|
||||
- (NSRect) convertRectToBacking:(NSRect)aRect;
|
||||
- (NSRect) convertRectFromBacking:(NSRect)aRect;
|
||||
|
||||
@end
|
||||
#endif
|
||||
|
||||
|
||||
@implementation MyOpenGLView
|
||||
|
||||
- (id) initWithFrame:(NSRect)frameRect
|
||||
@ -76,6 +93,12 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
|
||||
if (!(self = [super initWithFrame:frameRect])) return nil;
|
||||
|
||||
if ([self respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)])
|
||||
{
|
||||
// Enable high resolution on Retina displays.
|
||||
[self setWantsBestResolutionOpenGLSurface:YES];
|
||||
}
|
||||
|
||||
// Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext
|
||||
NSOpenGLPixelFormatAttribute attrs[] =
|
||||
{
|
||||
@ -111,7 +134,7 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
_pixelFormatAttributes = [[NSData alloc] initWithBytes:attrs length:sizeof attrs];
|
||||
|
||||
// Create our non-FullScreen pixel format.
|
||||
NSOpenGLPixelFormat* pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease];
|
||||
NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease];
|
||||
|
||||
self = [super initWithFrame:frameRect pixelFormat:pixelFormat];
|
||||
|
||||
@ -142,21 +165,25 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
}
|
||||
|
||||
|
||||
- (void) setStringInput: (enum StringInput) value
|
||||
- (void) setStringInput:(enum StringInput)value
|
||||
{
|
||||
allowingStringInput = value;
|
||||
}
|
||||
|
||||
|
||||
- (void) allowStringInput: (BOOL) value
|
||||
- (void) allowStringInput:(BOOL)value
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
allowingStringInput = gvStringInputAlpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
allowingStringInput = gvStringInputNo;
|
||||
}
|
||||
}
|
||||
|
||||
-(enum StringInput) allowingStringInput
|
||||
- (enum StringInput) allowingStringInput
|
||||
{
|
||||
return allowingStringInput;
|
||||
}
|
||||
@ -174,7 +201,7 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
}
|
||||
|
||||
|
||||
- (void) setTypedString:(NSString*) value
|
||||
- (void) setTypedString:(NSString *)value
|
||||
{
|
||||
[typedString setString:value];
|
||||
}
|
||||
@ -204,7 +231,7 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
}
|
||||
|
||||
|
||||
- (GameController *)gameController
|
||||
- (GameController *) gameController
|
||||
{
|
||||
return gameController;
|
||||
}
|
||||
@ -226,6 +253,7 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
{
|
||||
if ((viewSize.width != [self frame].size.width)||(viewSize.height != [self frame].size.height)) // resized
|
||||
{
|
||||
OOLog(@"temp", @"Changing view size from %@ to %@.", NSStringFromSize(viewSize), NSStringFromSize([self frame].size));
|
||||
m_glContextInitialized = NO;
|
||||
viewSize = [self frame].size;
|
||||
}
|
||||
@ -287,7 +315,7 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
}
|
||||
|
||||
|
||||
- (void) initialiseGLWithSize:(NSSize) v_size
|
||||
- (void) initialiseGLWithSize:(NSSize)v_size
|
||||
{
|
||||
viewSize = v_size;
|
||||
if (viewSize.width/viewSize.height > 4.0/3.0) {
|
||||
@ -300,8 +328,14 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
||||
y_offset = 320.0 * viewSize.height/viewSize.width;
|
||||
}
|
||||
|
||||
[self openGLContext];
|
||||
[[self gameController] setUpBasicOpenGLStateWithSize:viewSize];
|
||||
if (![[self gameController] inFullScreenMode] && [self respondsToSelector:@selector(convertSizeToBacking:)])
|
||||
{
|
||||
// High resolution mode support.
|
||||
v_size = [self convertSizeToBacking:v_size];
|
||||
}
|
||||
|
||||
[self openGLContext]; // Force lazy setup if needed.
|
||||
[[self gameController] setUpBasicOpenGLStateWithSize:v_size];
|
||||
[[self openGLContext] flushBuffer];
|
||||
|
||||
m_glContextInitialized = YES;
|
||||
|
@ -651,7 +651,9 @@ static NSComparisonResult CompareDisplayModes(id arg1, id arg2, void *context)
|
||||
CGLGetParameter(cglContext, kCGLCPSwapInterval, &oldSwapInterval);
|
||||
newSwapInterval = 1;
|
||||
CGLSetParameter(cglContext, kCGLCPSwapInterval, &newSwapInterval);
|
||||
|
||||
|
||||
fullscreen = YES;
|
||||
|
||||
// Tell the scene the dimensions of the area it's going to render to, so it can set up an appropriate viewport and viewing transformation.
|
||||
[gameView initialiseGLWithSize:NSMakeSize(width,height)];
|
||||
|
||||
@ -659,7 +661,6 @@ static NSComparisonResult CompareDisplayModes(id arg1, id arg2, void *context)
|
||||
// The shift here is from a model in which we passively receive events handed to us by the AppKit to one in which we are actively driving event processing.
|
||||
stayInFullScreenMode = YES;
|
||||
|
||||
fullscreen = YES;
|
||||
[gameView clearCommandF]; // Avoid immediately switching back to windowed mode.
|
||||
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"fullscreen"];
|
||||
|
||||
|
@ -64,7 +64,11 @@ MA 02110-1301, USA.
|
||||
#endif
|
||||
|
||||
#if defined MAC_OS_X_VERSION_10_6 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
|
||||
#define OOLITE_SNOW_LEOPARD 1
|
||||
#define OOLITE_MAC_OS_X_10_6 1
|
||||
#endif
|
||||
|
||||
#if defined MAC_OS_X_VERSION_10_7 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
|
||||
#define OOLITE_MAC_OS_X_10_7 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -73,8 +77,12 @@ MA 02110-1301, USA.
|
||||
#define OOLITE_GNUSTEP_1_20 0
|
||||
#endif
|
||||
|
||||
#ifndef OOLITE_SNOW_LEOPARD
|
||||
#define OOLITE_SNOW_LEOPARD 0
|
||||
#ifndef OOLITE_MAC_OS_X_10_6
|
||||
#define OOLITE_MAC_OS_X_10_6 0
|
||||
#endif
|
||||
|
||||
#ifndef OOLITE_MAC_OS_X_10_7
|
||||
#define OOLITE_MAC_OS_X_10_7 0
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user