Implement initial support for High DPI mode on OS X
This commit is contained in:
parent
ed95cd0f27
commit
225bd176cb
|
@ -96,7 +96,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private native ByteBuffer nCreateWindow(int x, int y, int width, int height, boolean fullscreen, boolean undecorated, boolean resizable, boolean parented, boolean enableFullscreenModeAPI, ByteBuffer peer_info_handle, ByteBuffer window_handle) throws LWJGLException;
|
private native ByteBuffer nCreateWindow(int x, int y, int width, int height, boolean fullscreen, boolean undecorated, boolean resizable, boolean parented, boolean enableFullscreenModeAPI, boolean enableHighDPI, ByteBuffer peer_info_handle, ByteBuffer window_handle) throws LWJGLException;
|
||||||
|
|
||||||
private native Object nGetCurrentDisplayMode();
|
private native Object nGetCurrentDisplayMode();
|
||||||
|
|
||||||
|
@ -135,6 +135,10 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
boolean enableFullscreenModeAPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null &&
|
boolean enableFullscreenModeAPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null &&
|
||||||
!Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.disableOSXFullscreenModeAPI");
|
!Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.disableOSXFullscreenModeAPI");
|
||||||
|
|
||||||
|
// OS X high DPI mode is only available on OS X 10.7+
|
||||||
|
boolean enableHighDPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null &&
|
||||||
|
Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.enableHighDPI");
|
||||||
|
|
||||||
if (parented) this.canvas = parent;
|
if (parented) this.canvas = parent;
|
||||||
else this.canvas = null;
|
else this.canvas = null;
|
||||||
|
|
||||||
|
@ -149,7 +153,7 @@ final class MacOSXDisplay implements DisplayImplementation {
|
||||||
|
|
||||||
window = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(),
|
window = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(),
|
||||||
fullscreen, isUndecorated(), resizable,
|
fullscreen, isUndecorated(), resizable,
|
||||||
parented, enableFullscreenModeAPI, peer_handle, window_handle);
|
parented, enableFullscreenModeAPI, enableHighDPI, peer_handle, window_handle);
|
||||||
|
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
// when going to fullscreen viewport is set to screen size by Cocoa, ignore this value
|
// when going to fullscreen viewport is set to screen size by Cocoa, ignore this value
|
||||||
|
|
|
@ -64,36 +64,38 @@ enum {
|
||||||
@class NSOpenGLContext, NSOpenGLPixelFormat, MacOSXOpenGLView, MacOSXKeyableWindow;
|
@class NSOpenGLContext, NSOpenGLPixelFormat, MacOSXOpenGLView, MacOSXKeyableWindow;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MacOSXKeyableWindow *window;
|
MacOSXKeyableWindow *window;
|
||||||
|
|
||||||
NSRect display_rect;
|
NSRect display_rect;
|
||||||
|
|
||||||
MacOSXOpenGLView *view;
|
MacOSXOpenGLView *view;
|
||||||
NSOpenGLContext *context;
|
NSOpenGLContext *context;
|
||||||
|
|
||||||
// Native objects for Java callbacks
|
// Native objects for Java callbacks
|
||||||
jobject jdisplay;
|
jobject jdisplay;
|
||||||
jobject jmouse;
|
jobject jmouse;
|
||||||
jobject jkeyboard;
|
jobject jkeyboard;
|
||||||
|
|
||||||
jboolean fullscreen;
|
jboolean fullscreen;
|
||||||
jboolean undecorated;
|
jboolean undecorated;
|
||||||
jboolean resizable;
|
jboolean resizable;
|
||||||
jboolean parented;
|
jboolean parented;
|
||||||
jboolean enableFullscreenModeAPI;
|
|
||||||
|
jboolean enableFullscreenModeAPI;
|
||||||
|
jboolean enableHighDPI;
|
||||||
|
|
||||||
jboolean resized;
|
jboolean resized;
|
||||||
|
|
||||||
} MacOSXWindowInfo;
|
} MacOSXWindowInfo;
|
||||||
|
|
||||||
@interface MacOSXOpenGLView : NSView
|
@interface MacOSXOpenGLView : NSView
|
||||||
{
|
{
|
||||||
@public
|
@public
|
||||||
MacOSXWindowInfo* _parent;
|
MacOSXWindowInfo* _parent;
|
||||||
|
|
||||||
@private
|
@private
|
||||||
NSOpenGLContext* _openGLContext;
|
NSOpenGLContext* _openGLContext;
|
||||||
NSOpenGLPixelFormat* _pixelFormat;
|
NSOpenGLPixelFormat* _pixelFormat;
|
||||||
NSTrackingArea * _trackingArea;
|
NSTrackingArea * _trackingArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,9 +143,9 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool isCALayer;
|
bool isCALayer;
|
||||||
bool isWindowed;
|
bool isWindowed;
|
||||||
MacOSXWindowInfo *window_info;
|
MacOSXWindowInfo *window_info;
|
||||||
NSOpenGLPixelFormat *pixel_format;
|
NSOpenGLPixelFormat *pixel_format;
|
||||||
NSOpenGLPixelBuffer *pbuffer;
|
NSOpenGLPixelBuffer *pbuffer;
|
||||||
NSView *parent;
|
NSView *parent;
|
||||||
GLLayer *glLayer;
|
GLLayer *glLayer;
|
||||||
} MacOSXPeerInfo;
|
} MacOSXPeerInfo;
|
||||||
|
|
|
@ -73,6 +73,11 @@ static NSUInteger lastModifierFlags = 0;
|
||||||
NSRect view_rect = NSMakeRect(0.0, 0.0, width, height);
|
NSRect view_rect = NSMakeRect(0.0, 0.0, width, height);
|
||||||
window_info->view = [[MacOSXOpenGLView alloc] initWithFrame:view_rect pixelFormat:peer_info->pixel_format];
|
window_info->view = [[MacOSXOpenGLView alloc] initWithFrame:view_rect pixelFormat:peer_info->pixel_format];
|
||||||
[window_info->view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
[window_info->view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
|
|
||||||
|
if (window_info->enableHighDPI) {
|
||||||
|
// call method using runtime selector as its a 10.7+ api and allows compiling on older SDK's
|
||||||
|
[window_info->view performSelector:NSSelectorFromString(@"setWantsBestResolutionOpenGLSurface:") withObject:YES];
|
||||||
|
}
|
||||||
|
|
||||||
// set nsapp delegate for catching app quit events
|
// set nsapp delegate for catching app quit events
|
||||||
[NSApp setDelegate:window_info->view];
|
[NSApp setDelegate:window_info->view];
|
||||||
|
@ -640,7 +645,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nSetTitle(JNIEnv *env
|
||||||
[window_info->window performSelectorOnMainThread:@selector(setTitle:) withObject:title waitUntilDone:NO];
|
[window_info->window performSelectorOnMainThread:@selector(setTitle:) withObject:title waitUntilDone:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIEnv *env, jobject this, jint x, jint y, jint width, jint height, jboolean fullscreen, jboolean undecorated, jboolean resizable, jboolean parented, jboolean enableFullscreenModeAPI, jobject peer_info_handle, jobject window_handle) {
|
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIEnv *env, jobject this, jint x, jint y, jint width, jint height, jboolean fullscreen, jboolean undecorated, jboolean resizable, jboolean parented, jboolean enableFullscreenModeAPI, jboolean enableHighDPI, jobject peer_info_handle, jobject window_handle) {
|
||||||
|
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
@ -670,7 +675,8 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIE
|
||||||
window_info->undecorated = undecorated;
|
window_info->undecorated = undecorated;
|
||||||
window_info->resizable = resizable;
|
window_info->resizable = resizable;
|
||||||
window_info->parented = parented;
|
window_info->parented = parented;
|
||||||
window_info->enableFullscreenModeAPI = enableFullscreenModeAPI;
|
window_info->enableFullscreenModeAPI = enableFullscreenModeAPI;
|
||||||
|
window_info->enableHighDPI = enableHighDPI;
|
||||||
|
|
||||||
peer_info->window_info = window_info;
|
peer_info->window_info = window_info;
|
||||||
peer_info->isWindowed = true;
|
peer_info->isWindowed = true;
|
||||||
|
|
Loading…
Reference in New Issue