JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
Gamma.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * - Redistribution of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistribution in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * Neither the name of Sun Microsystems, Inc. or the names of
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * This software is provided "AS IS," without a warranty of any kind. ALL
20 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
21 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
22 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
23 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
24 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
25 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
26 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
27 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
28 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
29 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
30 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
31 *
32 * You acknowledge that this software is not designed or intended for use
33 * in the design, construction, operation or maintenance of any nuclear
34 * facility.
35 *
36 * Sun gratefully acknowledges that this software was originally authored
37 * and developed by Kenneth Bradley Russell and Christopher John Kline.
38 */
39
40package com.jogamp.opengl.util;
41
42import com.jogamp.opengl.GLAutoDrawable;
43import com.jogamp.opengl.GLDrawable;
44import com.jogamp.opengl.GLDrawableFactory;
45
46import com.jogamp.common.util.locks.RecursiveLock;
47
48/**
49 * Provides convenient wrapper for {@link GLDrawableFactory} control over
50 * individual display's gamma, brightness and contrast values
51 * via the hardware gamma ramp tables.
52 * <p>
53 * Not supported on all platforms or graphics hardware.
54 * </p>
55 * <p>
56 * Thanks to the LWJGL project for illustrating how to access gamma
57 * control on the various platforms.
58 * </p>
59 */
60public class Gamma {
61 private Gamma() {}
62
63 /**
64 * Convenient wrapper for {@link GLDrawableFactory#setDisplayGamma(com.jogamp.nativewindow.NativeSurface, float, float, float)}.
65 * <p>
66 * Use {@link #setDisplayGamma(GLAutoDrawable, float, float, float)} in case of using an {#link GLAutoDrawable}.
67 * </p>
68 */
69 public static boolean setDisplayGamma(final GLDrawable drawable, final float gamma, final float brightness, final float contrast) throws IllegalArgumentException {
70 return GLDrawableFactory.getFactory(drawable.getGLProfile()).setDisplayGamma(drawable.getNativeSurface(), gamma, brightness, contrast);
71 }
72
73 /**
74 * Convenient wrapper for {@link GLDrawableFactory#setDisplayGamma(com.jogamp.nativewindow.NativeSurface, float, float, float)}
75 * locking {@link GLAutoDrawable#getUpstreamLock()} to ensure proper atomic operation.
76 */
77 public static boolean setDisplayGamma(final GLAutoDrawable drawable, final float gamma, final float brightness, final float contrast) throws IllegalArgumentException {
78 final RecursiveLock lock = drawable.getUpstreamLock();
79 lock.lock();
80 try {
81 return GLDrawableFactory.getFactory(drawable.getGLProfile()).setDisplayGamma(drawable.getNativeSurface(), gamma, brightness, contrast);
82 } finally {
83 lock.unlock();
84 }
85 }
86
87 /**
88 * Convenient wrapper for {@link GLDrawableFactory#resetDisplayGamma(com.jogamp.nativewindow.NativeSurface)}.
89 * <p>
90 * Use {@link #resetDisplayGamma(GLAutoDrawable)} in case of using an {#link GLAutoDrawable}.
91 * </p>
92 */
93 public static void resetDisplayGamma(final GLDrawable drawable) {
95 }
96
97 /**
98 * Convenient wrapper for {@link GLDrawableFactory#resetDisplayGamma(com.jogamp.nativewindow.NativeSurface)}
99 * locking {@link GLAutoDrawable#getUpstreamLock()} to ensure proper atomic operation.
100 */
101 public static void resetDisplayGamma(final GLAutoDrawable drawable) {
102 final RecursiveLock lock = drawable.getUpstreamLock();
103 lock.lock();
104 try {
106 } finally {
107 lock.unlock();
108 }
109 }
110
111 /**
112 * Convenient wrapper for {@link GLDrawableFactory#resetAllDisplayGamma()}.
113 */
114 public static void resetAllDisplayGamma(final GLDrawable drawable) {
116 }
117}
abstract void resetDisplayGamma(final NativeSurface surface)
Resets the gamma, brightness and contrast values of the display associated with the given surface to ...
abstract void resetAllDisplayGamma()
Resets the gamma, brightness and contrast values of all modified displays to their original values be...
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
abstract boolean setDisplayGamma(final NativeSurface surface, final float gamma, final float brightness, final float contrast)
Sets the gamma, brightness, and contrast of the display associated with the given surface.
Provides convenient wrapper for GLDrawableFactory control over individual display's gamma,...
Definition: Gamma.java:60
static boolean setDisplayGamma(final GLAutoDrawable drawable, final float gamma, final float brightness, final float contrast)
Convenient wrapper for GLDrawableFactory#setDisplayGamma(com.jogamp.nativewindow.NativeSurface,...
Definition: Gamma.java:77
static boolean setDisplayGamma(final GLDrawable drawable, final float gamma, final float brightness, final float contrast)
Convenient wrapper for GLDrawableFactory#setDisplayGamma(com.jogamp.nativewindow.NativeSurface,...
Definition: Gamma.java:69
static void resetAllDisplayGamma(final GLDrawable drawable)
Convenient wrapper for GLDrawableFactory#resetAllDisplayGamma().
Definition: Gamma.java:114
static void resetDisplayGamma(final GLAutoDrawable drawable)
Convenient wrapper for GLDrawableFactory#resetDisplayGamma(com.jogamp.nativewindow....
Definition: Gamma.java:101
static void resetDisplayGamma(final GLDrawable drawable)
Convenient wrapper for GLDrawableFactory#resetDisplayGamma(com.jogamp.nativewindow....
Definition: Gamma.java:93
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
RecursiveLock getUpstreamLock()
Returns the recursive lock object of the upstream widget to synchronize multithreaded access on top o...
An abstraction for an OpenGL rendering target.
Definition: GLDrawable.java:51
NativeSurface getNativeSurface()
Returns the associated NativeSurface of this NativeSurfaceHolder.
GLProfile getGLProfile()
Fetches the GLProfile for this drawable.