diff --git a/src/java/org/lwjgl/opengl/MacOSXDisplay.java b/src/java/org/lwjgl/opengl/MacOSXDisplay.java index 697521ec..18f3b316 100644 --- a/src/java/org/lwjgl/opengl/MacOSXDisplay.java +++ b/src/java/org/lwjgl/opengl/MacOSXDisplay.java @@ -64,6 +64,8 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; final class MacOSXDisplay implements DisplayImplementation { + private final static int GAMMA_LENGTH = 256; + private MacOSXFrame frame; private MouseEventQueue mouse_queue; private KeyboardEventQueue keyboard_queue; @@ -103,12 +105,10 @@ final class MacOSXDisplay implements DisplayImplementation { } public int getGammaRampLength() { - return 0; + return GAMMA_LENGTH; } - public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException { - throw new LWJGLException("Gamma not supported"); - } + public native void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException; public String getAdapter() { return null; @@ -137,7 +137,10 @@ final class MacOSXDisplay implements DisplayImplementation { if (MacOSXFrame.getDevice().getFullScreenWindow() != null) MacOSXFrame.getDevice().setFullScreenWindow(null); requested_mode = null; + restoreGamma(); } + + private native void restoreGamma(); private DisplayMode createLWJGLDisplayMode(java.awt.DisplayMode awt_mode) { int bit_depth; diff --git a/src/native/macosx/org_lwjgl_opengl_Display.m b/src/native/macosx/org_lwjgl_opengl_Display.m index 435e4104..1de0ddeb 100644 --- a/src/native/macosx/org_lwjgl_opengl_Display.m +++ b/src/native/macosx/org_lwjgl_opengl_Display.m @@ -162,6 +162,16 @@ static void setView(JNIEnv *env, jobject canvas) { awt.FreeDrawingSurface(ds); } +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_restoreGamma(JNIEnv *env, jobject this) { + CGDisplayRestoreColorSyncSettings(); +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_setGammaRamp(JNIEnv *env, jobject this, jobject gamma_buffer) { + const CGGammaValue *values = (*env)->GetDirectBufferAddress(env, gamma_buffer); + CGTableCount table_size = (*env)->GetDirectBufferCapacity(env, gamma_buffer); + CGSetDisplayTransferByTable(kCGDirectMainDisplay, table_size, values, values, values); +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_hideUI(JNIEnv *env, jobject this, jboolean hide) { if (hide == JNI_TRUE) { SetSystemUIMode(kUIModeContentSuppressed, 0);