summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/windows/wgl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-07-27 23:23:15 +0200
committerSven Gothel <[email protected]>2014-07-27 23:23:15 +0200
commit15b9e36e80d6f62f7dfb5c45d00cd04de2007ee5 (patch)
treeee7b7e78e47ed9d2ea504b7232825b1d13a71071 /src/jogl/classes/jogamp/opengl/windows/wgl
parent007f120cd8d33e4231ef4d207b85ed156d1e0c82 (diff)
Bug 1035 - Allow Gamma [Brightness, Contrast] settings to be performed on display/screen of a NativeSurface
Currently GLDrawableFactoryImpl's gamma settings are performed only on the main screen. Allow passing a NativeSurface, so it's display/screen gamma values will be changed. Further, promote low-level gamma settings to GLDrawableFactory for direct usage. Change com.jogamp.opengl.util.Gamma to use a GLDrawable instead of a GL object to clarify that we use the drawable. Also add a GLAutoDrawable variant, allowing proper locking of its 'upstream-lock' to guarantee atomicity. +++ Tested manually w/ TestGearsES2NEWT on X11 and Windows using the 'g' and 'G' to modify gamma. Value is properly reset on exit.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/windows/wgl')
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java44
1 files changed, 34 insertions, 10 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index 42e802a95..3daf6e1a8 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -559,12 +559,12 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
private static final int GAMMA_RAMP_LENGTH = 256;
@Override
- protected final int getGammaRampLength() {
+ protected final int getGammaRampLength(final NativeSurface surface) {
return GAMMA_RAMP_LENGTH;
}
@Override
- protected final boolean setGammaRamp(final float[] ramp) {
+ protected final boolean setGammaRamp(final NativeSurface surface, final float[] ramp) {
final short[] rampData = new short[3 * GAMMA_RAMP_LENGTH];
for (int i = 0; i < GAMMA_RAMP_LENGTH; i++) {
final short scaledValue = (short) (ramp[i] * 65535);
@@ -573,18 +573,26 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
rampData[i + 2 * GAMMA_RAMP_LENGTH] = scaledValue;
}
- final long screenDC = GDI.GetDC(0);
- final boolean res = GDI.SetDeviceGammaRamp(screenDC, ShortBuffer.wrap(rampData));
- GDI.ReleaseDC(0, screenDC);
+ final long hDC = surface.getSurfaceHandle();
+ if( 0 == hDC ) {
+ return false;
+ }
+ // final long screenDC = GDI.GetDC(0);
+ final boolean res = GDI.SetDeviceGammaRamp(hDC, ShortBuffer.wrap(rampData));
+ // GDI.ReleaseDC(0, screenDC);
return res;
}
@Override
- protected final Buffer getGammaRamp() {
+ protected final Buffer getGammaRamp(final NativeSurface surface) {
final ShortBuffer rampData = ShortBuffer.wrap(new short[3 * GAMMA_RAMP_LENGTH]);
- final long screenDC = GDI.GetDC(0);
- final boolean res = GDI.GetDeviceGammaRamp(screenDC, rampData);
- GDI.ReleaseDC(0, screenDC);
+ final long hDC = surface.getSurfaceHandle();
+ if( 0 == hDC ) {
+ return null;
+ }
+ // final long screenDC = GDI.GetDC(0);
+ final boolean res = GDI.GetDeviceGammaRamp(hDC, rampData);
+ // GDI.ReleaseDC(0, screenDC);
if (!res) {
return null;
}
@@ -592,7 +600,22 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
}
@Override
- protected final void resetGammaRamp(final Buffer originalGammaRamp) {
+ protected final void resetGammaRamp(final NativeSurface surface, final Buffer originalGammaRamp) {
+ if (originalGammaRamp == null) {
+ // getGammaRamp failed earlier
+ return;
+ }
+ final long hDC = surface.getSurfaceHandle();
+ if( 0 == hDC ) {
+ return;
+ }
+ // final long screenDC = GDI.GetDC(0);
+ GDI.SetDeviceGammaRamp(hDC, originalGammaRamp);
+ // GDI.ReleaseDC(0, hDC);
+ }
+
+ @Override
+ protected final void resetGammaRamp(final DeviceScreenID deviceScreenID, final Buffer originalGammaRamp) {
if (originalGammaRamp == null) {
// getGammaRamp failed earlier
return;
@@ -602,6 +625,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
GDI.ReleaseDC(0, screenDC);
}
+
static interface CPUAffinity {
boolean set(final int newAffinity);
boolean reset();