diff --git a/src/native/macosx/org_lwjgl_opengl_Display.m b/src/native/macosx/org_lwjgl_opengl_Display.m index 779888cf..8d76e87e 100644 --- a/src/native/macosx/org_lwjgl_opengl_Display.m +++ b/src/native/macosx/org_lwjgl_opengl_Display.m @@ -431,6 +431,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIE [[NSApplication sharedApplication] setDelegate:window_info->view]; + window_info->display_rect = NSMakeRect(x, y, width, height); if (!fullscreen) { @@ -444,8 +445,6 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIE default_window_mask |= NSResizableWindowMask; } - window_info->display_rect = NSMakeRect(x, y, width, height); - window_info->window = (MacOSXKeyableWindow*)[[NSApplication sharedApplication] mainWindow]; if (window_info->window == nil) { window_info->window = [[MacOSXKeyableWindow alloc] initWithContentRect:window_info->display_rect styleMask:default_window_mask backing:NSBackingStoreBuffered defer:YES]; @@ -464,7 +463,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nCreateWindow(JNIE } else { // set a fixed backbuffer size for fullscreen - CGLContextObj cgcontext = (CGLContextObj)[[window_info->view openGLContext] CGLContextObj]; + CGLContextObj cgcontext = (CGLContextObj)[window_info->context CGLContextObj]; GLint dim[2] = {width, height}; CGLSetParameter(cgcontext, kCGLCPSurfaceBackingSize, dim); CGLEnable(cgcontext, kCGLCESurfaceBackingSize); diff --git a/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m b/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m index 528b42ec..e135e193 100644 --- a/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m +++ b/src/native/macosx/org_lwjgl_opengl_MacOSXContextImplementation.m @@ -75,6 +75,21 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXContextImplementation_nCre throwException(env, "Could not create context"); return NULL; } + + if (peer_info->window_info->fullscreen) { + // set a fixed backbuffer size for fullscreen + CGLContextObj cgcontext = (CGLContextObj)[context CGLContextObj]; + NSSize displaySize = peer_info->window_info->display_rect.size; + GLint dim[2] = {displaySize.width, displaySize.height}; + CGLSetParameter(cgcontext, kCGLCPSurfaceBackingSize, dim); + CGLEnable(cgcontext, kCGLCESurfaceBackingSize); + } + else { + // disable any fixed backbuffer size to allow resizing + CGLContextObj cgcontext = (CGLContextObj)[context CGLContextObj]; + CGLDisable(cgcontext, kCGLCESurfaceBackingSize); + } + [peer_info->window_info->view setOpenGLContext:context]; peer_info->window_info->context = context; context_info = (MacOSXContext *)(*env)->GetDirectBufferAddress(env, context_handle);