src/video/cocoa/SDL_cocoaopengl.m
changeset 7746 6a05d7352575
parent 7743 360acf8c1526
child 7894 bb624b1348da
     1.1 --- a/src/video/cocoa/SDL_cocoaopengl.m	Fri Sep 27 22:09:51 2013 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoaopengl.m	Fri Sep 20 13:43:00 2013 -0400
     1.3 @@ -35,6 +35,18 @@
     1.4  
     1.5  #define DEFAULT_OPENGL  "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
     1.6  
     1.7 +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
     1.8 +/* New methods for converting to and from backing store pixels, taken from
     1.9 + * AppKite/NSView.h in 10.8 SDK. */
    1.10 +@interface NSView (Backing)
    1.11 +- (NSPoint)convertPointToBacking:(NSPoint)aPoint;
    1.12 +- (NSPoint)convertPointFromBacking:(NSPoint)aPoint;
    1.13 +- (NSSize)convertSizeToBacking:(NSSize)aSize;
    1.14 +- (NSSize)convertSizeFromBacking:(NSSize)aSize;
    1.15 +- (NSRect)convertRectToBacking:(NSRect)aRect;
    1.16 +- (NSRect)convertRectFromBacking:(NSRect)aRect;
    1.17 +@end
    1.18 +#endif
    1.19  
    1.20  #ifndef kCGLPFAOpenGLProfile
    1.21  #define kCGLPFAOpenGLProfile 99
    1.22 @@ -294,6 +306,28 @@
    1.23      return 0;
    1.24  }
    1.25  
    1.26 +void
    1.27 +Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
    1.28 +{
    1.29 +    SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
    1.30 +    NSView *contentView = [windata->nswindow contentView];
    1.31 +    NSRect viewport = [contentView bounds];
    1.32 +
    1.33 +    /* This gives us the correct viewport for a Retina-enabled view, only
    1.34 +     * supported on 10.7+. */
    1.35 +    if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
    1.36 +        viewport = [contentView convertRectToBacking:viewport];
    1.37 +    }
    1.38 +
    1.39 +    if (w) {
    1.40 +        *w = viewport.size.width;
    1.41 +    }
    1.42 +
    1.43 +    if (h) {
    1.44 +        *h = viewport.size.height;
    1.45 +    }
    1.46 +}
    1.47 +
    1.48  int
    1.49  Cocoa_GL_SetSwapInterval(_THIS, int interval)
    1.50  {