From: <eli...@us...> - 2006-10-23 14:16:51
|
Revision: 2593 http://svn.sourceforge.net/java-game-lib/?rev=2593&view=rev Author: elias_naur Date: 2006-10-23 07:16:40 -0700 (Mon, 23 Oct 2006) Log Message: ----------- Linux: Moved another Display instance to java Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/native/linux/display.c trunk/LWJGL/src/native/linux/display.h Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 14:05:40 UTC (rev 2592) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 14:16:40 UTC (rev 2593) @@ -485,14 +485,23 @@ private void doSetGamma(ByteBuffer native_gamma) throws LWJGLException { lockAWT(); try { - nSetGammaRamp(getScreen(), native_gamma); + setGammaRampOnTmpDisplay(native_gamma); current_gamma = native_gamma; } finally { unlockAWT(); } } - private static native void nSetGammaRamp(int screen, ByteBuffer gammaRamp) throws LWJGLException; + private void setGammaRampOnTmpDisplay(ByteBuffer native_gamma) throws LWJGLException { + long tmp_display = openDisplay(); + try { + nSetGammaRamp(tmp_display, getScreen(), native_gamma); + } finally { + closeDisplay(tmp_display); + } + } + private static native void nSetGammaRamp(long display, int screen, ByteBuffer gammaRamp) throws LWJGLException; + private static ByteBuffer convertToNativeRamp(FloatBuffer ramp) throws LWJGLException { return nConvertToNativeRamp(ramp, ramp.position(), ramp.remaining()); } @@ -696,7 +705,7 @@ nIconifyWindow(getDisplay(), getWindow(), getScreen()); try { nSwitchDisplayMode(getScreen(), current_displaymode_extension, saved_mode); - nSetGammaRamp(getScreen(), saved_gamma); + setGammaRampOnTmpDisplay(saved_gamma); } catch (LWJGLException e) { LWJGLUtil.log("Failed to restore saved mode: " + e.getMessage()); } @@ -713,7 +722,7 @@ if (current_window_mode == FULLSCREEN_NETWM) { try { nSwitchDisplayMode(getScreen(), current_displaymode_extension, current_mode); - nSetGammaRamp(getScreen(), current_gamma); + setGammaRampOnTmpDisplay(current_gamma); } catch (LWJGLException e) { LWJGLUtil.log("Failed to restore mode: " + e.getMessage()); } Modified: trunk/LWJGL/src/native/linux/display.c =================================================================== --- trunk/LWJGL/src/native/linux/display.c 2006-10-23 14:05:40 UTC (rev 2592) +++ trunk/LWJGL/src/native/linux/display.c 2006-10-23 14:16:40 UTC (rev 2593) @@ -319,16 +319,6 @@ } } -void setGammaRamp(JNIEnv *env, int screen, jobject gamma_ramp_buffer) { - Display * disp = XOpenDisplay(NULL); - if (disp == NULL) { - throwException(env, "Could not open display"); - return; - } - setGamma(env, disp, screen, gamma_ramp_buffer); - XCloseDisplay(disp); -} - bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode) { if (mode == NULL) { throwException(env, "mode must be non-null"); @@ -422,7 +412,8 @@ return (jint)getGammaRampLengthOfDisplay(env, disp, screen); } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jint screen, jobject gamma_buffer) { - setGammaRamp(env, screen, gamma_buffer); +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject gamma_buffer) { + Display *disp = (Display *)(intptr_t)display; + setGamma(env, disp, screen, gamma_buffer); } Modified: trunk/LWJGL/src/native/linux/display.h =================================================================== --- trunk/LWJGL/src/native/linux/display.h 2006-10-23 14:05:40 UTC (rev 2592) +++ trunk/LWJGL/src/native/linux/display.h 2006-10-23 14:16:40 UTC (rev 2593) @@ -46,6 +46,5 @@ #include "common_tools.h" extern bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode); -extern void setGammaRamp(JNIEnv *env, int screen, jobject gamma_ramp_buffer); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |