From 72acc211539803f1ef57d4331938afb48600398e Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Sun, 22 Jan 2006 03:38:03 +0000 Subject: Fixed Issue 173: Adjust gamma, brightness and contrast Added com.sun.opengl.util.Gamma supporting adjusting of gamma, brightness, and contrast. API and implementation derived from code in the LWJGL project. Added demos.gamma.TestGamma demo illustrating how to use the APIs. Tested on Linux, Mac OS X and Windows. No Solaris support at this time, although future Solaris releases, being based on the Xorg server, will probably have support for the required XF86VidMode extension. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@557 232f8b59-042b-4e1e-8c03-345bb8c30851 --- make/build.xml | 4 +- make/glx-CustomCCode.c | 62 ++++++++++++++++++++++++ make/glx-x11.cfg | 26 +--------- make/stub_includes/opengl/macosx-window-system.h | 4 ++ make/stub_includes/win32/wingdi.h | 4 ++ make/stub_includes/x11/window-system.c | 23 +++++++++ 6 files changed, 97 insertions(+), 26 deletions(-) create mode 100755 make/glx-CustomCCode.c (limited to 'make') diff --git a/make/build.xml b/make/build.xml index ef458a537..71aeabd37 100644 --- a/make/build.xml +++ b/make/build.xml @@ -702,11 +702,13 @@ + - + + diff --git a/make/glx-CustomCCode.c b/make/glx-CustomCCode.c new file mode 100755 index 000000000..2d92b2dde --- /dev/null +++ b/make/glx-CustomCCode.c @@ -0,0 +1,62 @@ +#include +#include +#include +#include +/* Linux headers don't work properly */ +#define __USE_GNU +#include +#undef __USE_GNU + +/* Current versions of Solaris don't expose the XF86 extensions, + although with the recent transition to Xorg this will probably + happen in an upcoming release */ +#ifndef __sun +#include +#else +/* Need to provide stubs for these */ +Bool XF86VidModeGetGammaRampSize( + Display *display, + int screen, + int* size) +{ + return False; +} + +Bool XF86VidModeGetGammaRamp( + Display *display, + int screen, + int size, + unsigned short *red array, + unsigned short *green array, + unsigned short *blue array) { + return False; +} +Bool XF86VidModeSetGammaRamp( + Display *display, + int screen, + int size, + unsigned short *red array, + unsigned short *green array, + unsigned short *blue array) { + return False; +} +#endif + +/* Need to expose DefaultScreen and RootWindow macros to Java */ +JNIEXPORT jlong JNICALL +Java_com_sun_opengl_impl_x11_GLX_DefaultScreen(JNIEnv *env, jclass _unused, jlong display) { + return DefaultScreen((Display*) (intptr_t) display); +} +JNIEXPORT jlong JNICALL +Java_com_sun_opengl_impl_x11_GLX_RootWindow(JNIEnv *env, jclass _unused, jlong display, jint screen) { + return RootWindow((Display*) (intptr_t) display, screen); +} +JNIEXPORT jlong JNICALL +Java_com_sun_opengl_impl_x11_GLX_dlsym(JNIEnv *env, jclass _unused, jstring name) { + const jbyte* chars; + void* res; + chars = (*env)->GetStringUTFChars(env, name, NULL); + res = dlsym(RTLD_DEFAULT, chars); + (*env)->ReleaseStringUTFChars(env, name, chars); + return (jlong) ((intptr_t) res); +} diff --git a/make/glx-x11.cfg b/make/glx-x11.cfg index fd381760e..801c035ee 100644 --- a/make/glx-x11.cfg +++ b/make/glx-x11.cfg @@ -15,37 +15,13 @@ CustomJavaCode GLX private static GLXProcAddressTable glxProcAddressTable = new CustomJavaCode GLX public static GLXProcAddressTable getGLXProcAddressTable() { return glxProcAddressTable; } CustomJavaCode GLX public static native long dlsym(String name); -CustomCCode #include -CustomCCode #include -CustomCCode #include -CustomCCode #include -CustomCCode /* Linux headers don't work properly */ -CustomCCode #define __USE_GNU -CustomCCode #include -CustomCCode #undef __USE_GNU +IncludeAs CustomCCode glx-CustomCCode.c ArgumentIsString XOpenDisplay 0 # Need to expose DefaultScreen and RootWindow macros to Java CustomJavaCode GLX public static native int DefaultScreen(long display); CustomJavaCode GLX public static native long RootWindow(long display, int screen); -CustomCCode JNIEXPORT jlong JNICALL -CustomCCode Java_com_sun_opengl_impl_x11_GLX_DefaultScreen(JNIEnv *env, jclass _unused, jlong display) { -CustomCCode return DefaultScreen((Display*) (intptr_t) display); -CustomCCode } -CustomCCode JNIEXPORT jlong JNICALL -CustomCCode Java_com_sun_opengl_impl_x11_GLX_RootWindow(JNIEnv *env, jclass _unused, jlong display, jint screen) { -CustomCCode return RootWindow((Display*) (intptr_t) display, screen); -CustomCCode } -CustomCCode JNIEXPORT jlong JNICALL -CustomCCode Java_com_sun_opengl_impl_x11_GLX_dlsym(JNIEnv *env, jclass _unused, jstring name) { -CustomCCode const jbyte* chars; -CustomCCode void* res; -CustomCCode chars = (*env)->GetStringUTFChars(env, name, NULL); -CustomCCode res = dlsym(RTLD_DEFAULT, chars); -CustomCCode (*env)->ReleaseStringUTFChars(env, name, chars); -CustomCCode return (jlong) ((intptr_t) res); -CustomCCode } # Get returned array's capacity from XGetVisualInfo to be correct TemporaryCVariableDeclaration XGetVisualInfo int count; diff --git a/make/stub_includes/opengl/macosx-window-system.h b/make/stub_includes/opengl/macosx-window-system.h index 46ee1c45d..3eb6ce514 100644 --- a/make/stub_includes/opengl/macosx-window-system.h +++ b/make/stub_includes/opengl/macosx-window-system.h @@ -44,3 +44,7 @@ void setContextTextureImageToPBuffer(void* nsContext, void* pBuffer, int colorBu void* getProcAddress(const char *procName); void setSwapInterval(void* nsContext, int interval); + +/* Gamma-related functionality */ +Bool setGammaRamp(int tableSize, float* redRamp, float* greenRamp, float* blueRamp); +void resetGammaRamp(); diff --git a/make/stub_includes/win32/wingdi.h b/make/stub_includes/win32/wingdi.h index 35f754178..4d980755b 100644 --- a/make/stub_includes/win32/wingdi.h +++ b/make/stub_includes/win32/wingdi.h @@ -210,3 +210,7 @@ WINUSERAPI BOOL WINAPI ShowWindow(HWND hWnd, int nCmdShow); WINUSERAPI HDC WINAPI GetDC(HWND); WINUSERAPI int WINAPI ReleaseDC(HWND hWnd, HDC hDC); WINUSERAPI BOOL WINAPI DestroyWindow(HWND hWnd); + +// Routines for changing gamma ramp of display device +WINGDIAPI BOOL WINAPI GetDeviceGammaRamp(HDC,LPVOID); +WINGDIAPI BOOL WINAPI SetDeviceGammaRamp(HDC,LPVOID); diff --git a/make/stub_includes/x11/window-system.c b/make/stub_includes/x11/window-system.c index 6af85eeb9..00b474899 100644 --- a/make/stub_includes/x11/window-system.c +++ b/make/stub_includes/x11/window-system.c @@ -35,3 +35,26 @@ extern int XFreePixmap( Display* /* display */, Pixmap /* pixmap */ ); + +// Routines for changing gamma settings. +// Note that these are not currently supported on Solaris. +Bool XF86VidModeGetGammaRampSize( + Display *display, + int screen, + int* size); + +Bool XF86VidModeGetGammaRamp( + Display *display, + int screen, + int size, + unsigned short *red_array, + unsigned short *green_array, + unsigned short *blue_array); + +Bool XF86VidModeSetGammaRamp( + Display *display, + int screen, + int size, + unsigned short *red_array, + unsigned short *green_array, + unsigned short *blue_array); -- cgit v1.2.3