From aa13639386fa0722a7ae00ad695674e9e4c9fd77 Mon Sep 17 00:00:00 2001 From: Gregory Pierce Date: Sat, 10 May 2003 19:19:12 +0000 Subject: [PATCH] Changed the location of the CGDisplayCapture from the GL code to the Display code. A side effect of this is that calling resetDisplayMode() is required - not optional. Not calling resetDisplayMode() may result in a non-responsive machine. --- src/native/macosx/org_lwjgl_Display.cpp | 10 ++++++++++ src/native/macosx/org_lwjgl_opengl_BaseGL.cpp | 10 +--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/native/macosx/org_lwjgl_Display.cpp b/src/native/macosx/org_lwjgl_Display.cpp index dc9b99be..dae2457c 100644 --- a/src/native/macosx/org_lwjgl_Display.cpp +++ b/src/native/macosx/org_lwjgl_Display.cpp @@ -142,6 +142,12 @@ jobjectArray GetAvailableDisplayModesOSX(JNIEnv * env) JNIEXPORT void JNICALL Java_org_lwjgl_Display_init (JNIEnv * env, jclass clazz) { + if ( CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess ) + { + printf("Unable to capture the display. Without capturing the display - this application cannot run"); + return; + } + //Get the current display mode from the system // int width = CGDisplayPixelsWide( kCGDirectMainDisplay ); @@ -207,6 +213,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Display_resetDisplayMode // the purpose of this method is to return the display mode to whatever it was before // the application takes over. OSX is smart enough to not require any of this // foolishness :) + + //release the display that we captured so other applications will still work + // + CGReleaseAllDisplays(); } /* diff --git a/src/native/macosx/org_lwjgl_opengl_BaseGL.cpp b/src/native/macosx/org_lwjgl_opengl_BaseGL.cpp index 12a66e73..f4342051 100644 --- a/src/native/macosx/org_lwjgl_opengl_BaseGL.cpp +++ b/src/native/macosx/org_lwjgl_opengl_BaseGL.cpp @@ -55,11 +55,6 @@ static CGDirectDisplayID displayID = kCGDirectMainDisplay; JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nCreate (JNIEnv * env, jobject obj, jstring title, jint x, jint y, jint width, jint height, jint bpp, jint alpha, jint depth, jint stencil, jboolean fullscreen) { - if ( CGDisplayCapture( displayID ) != kCGErrorSuccess ) - { - return; - } - CGLPixelFormatObj pixelFormatObj; long numPixelFormats; @@ -102,10 +97,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nDestroyGL CGLDestroyContext( contextObj ); contextObj = NULL; - } - - - CGReleaseAllDisplays(); + } } /*