+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing error checking after each OpenGL method call. If an error occurs,
+ * causes a {@link GLException} to be thrown at exactly the point of failure.
+ *
+ *
+ * Sample code which installs this pipeline, manual:
+ *
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing error checking after each OpenGL method call. If an error occurs,
+ * causes a {@link GLException} to be thrown at exactly the point of failure.
+ *
+ *
+ * Sample code which installs this pipeline, manual:
+ *
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ *
+ */
+public class DebugGL3 extends DebugGL4bc {
+ public DebugGL3(final GL3 downstream) {
+ super((GL4bc)downstream);
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/DebugGL3bc.java b/src/jogl/classes/com/jogamp/opengl/DebugGL3bc.java
new file mode 100644
index 000000000..d92f6043f
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/DebugGL3bc.java
@@ -0,0 +1,21 @@
+package com.jogamp.opengl;
+
+/**
+ *
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing error checking after each OpenGL method call. If an error occurs,
+ * causes a {@link GLException} to be thrown at exactly the point of failure.
+ *
+ *
+ * Sample code which installs this pipeline, manual:
+ *
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ *
+ */
+public class DebugGL3bc extends DebugGL4bc {
+ public DebugGL3bc(final GL3bc downstream) {
+ super((GL4bc)downstream);
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/DebugGL4.java b/src/jogl/classes/com/jogamp/opengl/DebugGL4.java
new file mode 100644
index 000000000..76f5a4ac3
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/DebugGL4.java
@@ -0,0 +1,21 @@
+package com.jogamp.opengl;
+
+/**
+ *
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing error checking after each OpenGL method call. If an error occurs,
+ * causes a {@link GLException} to be thrown at exactly the point of failure.
+ *
+ *
+ * Sample code which installs this pipeline, manual:
+ *
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ *
+ */
+public class DebugGL4 extends DebugGL4bc {
+ public DebugGL4(final GL4 downstream) {
+ super((GL4bc)downstream);
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/DebugGLES2.java b/src/jogl/classes/com/jogamp/opengl/DebugGLES2.java
new file mode 100644
index 000000000..e2b280515
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/DebugGLES2.java
@@ -0,0 +1,21 @@
+package com.jogamp.opengl;
+
+/**
+ *
+ * Composable pipeline which wraps an underlying {@link GL} implementation,
+ * providing error checking after each OpenGL method call. If an error occurs,
+ * causes a {@link GLException} to be thrown at exactly the point of failure.
+ *
+ *
+ * Sample code which installs this pipeline, manual:
+ *
+ * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
+ *
+ */
+public class DebugGLES2 extends DebugGLES3 {
+ public DebugGLES2(final GLES2 downstream) {
+ super((GLES3)downstream);
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/com/jogamp/opengl/DefaultGLCapabilitiesChooser.java
new file mode 100644
index 000000000..88a88087f
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/DefaultGLCapabilitiesChooser.java
@@ -0,0 +1,304 @@
+/*
+ * Copyright (c) 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.opengl;
+
+import com.jogamp.nativewindow.NativeWindowException;
+
+import java.util.List;
+
+import com.jogamp.nativewindow.CapabilitiesImmutable;
+
+import com.jogamp.common.ExceptionUtils;
+import com.jogamp.common.util.PropertyAccess;
+
+import jogamp.opengl.Debug;
+
+/**
The default implementation of the {@link
+ GLCapabilitiesChooser} interface, which provides consistent visual
+ selection behavior across platforms. The precise algorithm is
+ deliberately left loosely specified. Some properties are:
+
+
+
+
As long as there is at least one available non-null
+ GLCapabilities which matches the "stereo" option, will return a
+ valid index.
+
+
Attempts to match as closely as possible the given
+ GLCapabilities, but will select one with fewer capabilities (i.e.,
+ lower color depth) if necessary.
+
+
Prefers hardware-accelerated visuals to
+ non-hardware-accelerated.
+
+
If there is no exact match, prefers a more-capable visual to
+ a less-capable one.
+
+
If there is more than one exact match, chooses an arbitrary
+ one.
+
+
May select the opposite of a double- or single-buffered
+ visual (based on the user's request) in dire situations.
+
+
Color depth (including alpha) mismatches are weighted higher
+ than depth buffer mismatches, which are in turn weighted higher
+ than accumulation buffer (including alpha) and stencil buffer
+ depth mismatches.
+
+
If a valid windowSystemRecommendedChoice parameter is
+ supplied, chooses that instead of using the cross-platform code.
+
+
+*/
+
+public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
+ private static final boolean DEBUG;
+
+ static {
+ Debug.initSingleton();
+ DEBUG = PropertyAccess.isPropertyDefined("jogl.debug.CapabilitiesChooser", true);
+ }
+
+ private final static int NO_SCORE = -9999999;
+ private final static int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000;
+ private final static int OPAQUE_MISMATCH_PENALTY = 750;
+ private final static int STENCIL_MISMATCH_PENALTY = 500;
+ private final static int MULTISAMPLE_MISMATCH_PENALTY = 500;
+ private final static int MULTISAMPLE_EXTENSION_MISMATCH_PENALTY = 250; // just a little drop, no scale
+ // Pseudo attempt to keep equal rank penalties scale-equivalent
+ // (e.g., stencil mismatch is 3 * accum because there are 3 accum
+ // components)
+ private final static int COLOR_MISMATCH_PENALTY_SCALE = 36;
+ private final static int DEPTH_MISMATCH_PENALTY_SCALE = 6;
+ private final static int ACCUM_MISMATCH_PENALTY_SCALE = 1;
+ private final static int STENCIL_MISMATCH_PENALTY_SCALE = 3;
+ private final static int MULTISAMPLE_MISMATCH_PENALTY_SCALE = 3;
+
+ @Override
+ public int chooseCapabilities(final CapabilitiesImmutable desired,
+ final List extends CapabilitiesImmutable> available,
+ final int windowSystemRecommendedChoice) {
+ if ( null == desired ) {
+ throw new NativeWindowException("Null desired capabilities");
+ }
+ if ( 0 == available.size() ) {
+ throw new NativeWindowException("Empty available capabilities");
+ }
+
+ final GLCapabilitiesImmutable gldes = (GLCapabilitiesImmutable) desired;
+ final int availnum = available.size();
+
+ if (DEBUG) {
+ ExceptionUtils.dumpStack(System.err);
+ System.err.println("Desired: " + gldes);
+ System.err.println("Available: " + availnum);
+ for (int i = 0; i < available.size(); i++) {
+ System.err.println(i + ": " + available.get(i));
+ }
+ System.err.println("Window system's recommended choice: " + windowSystemRecommendedChoice);
+ }
+
+ if (windowSystemRecommendedChoice >= 0 &&
+ windowSystemRecommendedChoice < availnum &&
+ null != available.get(windowSystemRecommendedChoice)) {
+ if (DEBUG) {
+ System.err.println("Choosing window system's recommended choice of " + windowSystemRecommendedChoice);
+ System.err.println(available.get(windowSystemRecommendedChoice));
+ }
+ return windowSystemRecommendedChoice;
+ }
+
+ // Create score array
+ final int[] scores = new int[availnum];
+
+ for (int i = 0; i < scores.length; i++) {
+ scores[i] = NO_SCORE;
+ }
+ final int gldes_samples = gldes.getNumSamples();
+
+ // Compute score for each
+ for (int i = 0; i < availnum; i++) {
+ final GLCapabilitiesImmutable cur = (GLCapabilitiesImmutable) available.get(i);
+ if (cur == null) {
+ continue;
+ }
+ if (gldes.isOnscreen() && !cur.isOnscreen()) {
+ continue; // requested onscreen, but n/a
+ }
+ if (!gldes.isOnscreen()) {
+ /** FBO is generic ..
+ if (gldes.isFBO() && !cur.isFBO()) {
+ continue; // requested FBO, but n/a
+ } */
+ if (gldes.isPBuffer() && !cur.isPBuffer()) {
+ continue; // requested pBuffer, but n/a
+ }
+ if (gldes.isBitmap() && !cur.isBitmap()) {
+ continue; // requested pBuffer, but n/a
+ }
+ }
+ if (gldes.getStereo() != cur.getStereo()) {
+ continue;
+ }
+ final int cur_samples = cur.getNumSamples() ;
+ int score = 0;
+
+ // Compute difference in color depth
+ // (Note that this decides the direction of all other penalties)
+ score += (COLOR_MISMATCH_PENALTY_SCALE *
+ ((cur.getRedBits() + cur.getGreenBits() + cur.getBlueBits() + cur.getAlphaBits()) -
+ (gldes.getRedBits() + gldes.getGreenBits() + gldes.getBlueBits() + gldes.getAlphaBits())));
+ // Compute difference in depth buffer depth
+ score += (DEPTH_MISMATCH_PENALTY_SCALE * sign(score) *
+ Math.abs(cur.getDepthBits() - gldes.getDepthBits()));
+ // Compute difference in accumulation buffer depth
+ score += (ACCUM_MISMATCH_PENALTY_SCALE * sign(score) *
+ Math.abs((cur.getAccumRedBits() + cur.getAccumGreenBits() + cur.getAccumBlueBits() + cur.getAccumAlphaBits()) -
+ (gldes.getAccumRedBits() + gldes.getAccumGreenBits() + gldes.getAccumBlueBits() + gldes.getAccumAlphaBits())));
+ // Compute difference in stencil bits
+ score += STENCIL_MISMATCH_PENALTY_SCALE * sign(score) * (cur.getStencilBits() - gldes.getStencilBits());
+ // Compute difference in multisampling bits
+ score += MULTISAMPLE_MISMATCH_PENALTY_SCALE * sign(score) * (cur_samples - gldes_samples);
+ // double buffer
+ if (cur.getDoubleBuffered() != gldes.getDoubleBuffered()) {
+ score += sign(score) * DOUBLE_BUFFER_MISMATCH_PENALTY;
+ }
+ // opaque
+ if (cur.isBackgroundOpaque() != gldes.isBackgroundOpaque()) {
+ score += sign(score) * OPAQUE_MISMATCH_PENALTY;
+ }
+ if ((gldes.getStencilBits() > 0) && (cur.getStencilBits() == 0)) {
+ score += sign(score) * STENCIL_MISMATCH_PENALTY;
+ }
+ if (gldes_samples > 0) {
+ if (cur_samples == 0) {
+ score += sign(score) * MULTISAMPLE_MISMATCH_PENALTY;
+ }
+ if (!gldes.getSampleExtension().equals(cur.getSampleExtension())) {
+ score += sign(score) * MULTISAMPLE_EXTENSION_MISMATCH_PENALTY;
+ }
+ }
+ scores[i] = score;
+ }
+ // Now prefer hardware-accelerated visuals by pushing scores of
+ // non-hardware-accelerated visuals out
+ boolean gotHW = false;
+ int maxAbsoluteHWScore = 0;
+ for (int i = 0; i < availnum; i++) {
+ final int score = scores[i];
+ if (score == NO_SCORE) {
+ continue;
+ }
+ final GLCapabilitiesImmutable cur = (GLCapabilitiesImmutable) available.get(i);
+ if (cur.getHardwareAccelerated()) {
+ final int absScore = Math.abs(score);
+ if (!gotHW ||
+ (absScore > maxAbsoluteHWScore)) {
+ gotHW = true;
+ maxAbsoluteHWScore = absScore;
+ }
+ }
+ }
+ if (gotHW) {
+ for (int i = 0; i < availnum; i++) {
+ int score = scores[i];
+ if (score == NO_SCORE) {
+ continue;
+ }
+ final GLCapabilitiesImmutable cur = (GLCapabilitiesImmutable) available.get(i);
+ if (!cur.getHardwareAccelerated()) {
+ if (score <= 0) {
+ score -= maxAbsoluteHWScore;
+ } else if (score > 0) {
+ score += maxAbsoluteHWScore;
+ }
+ scores[i] = score;
+ }
+ }
+ }
+
+ if (DEBUG) {
+ System.err.print("Scores: [");
+ for (int i = 0; i < availnum; i++) {
+ if (i > 0) {
+ System.err.print(",");
+ }
+ System.err.print(" " + i +": " + scores[i]);
+ }
+ System.err.println(" ]");
+ }
+
+ // Ready to select. Choose score closest to 0.
+ int scoreClosestToZero = NO_SCORE;
+ int chosenIndex = -1;
+ for (int i = 0; i < availnum; i++) {
+ final int score = scores[i];
+ if (score == NO_SCORE) {
+ continue;
+ }
+ // Don't substitute a positive score for a smaller negative score
+ if ((scoreClosestToZero == NO_SCORE) ||
+ (Math.abs(score) < Math.abs(scoreClosestToZero) &&
+ ((sign(scoreClosestToZero) < 0) || (sign(score) > 0)))) {
+ scoreClosestToZero = score;
+ chosenIndex = i;
+ }
+ }
+ if (chosenIndex < 0) {
+ throw new NativeWindowException("Unable to select one of the provided GLCapabilities");
+ }
+ if (DEBUG) {
+ System.err.println("Chosen index: " + chosenIndex);
+ System.err.println("Chosen capabilities:");
+ System.err.println(available.get(chosenIndex));
+ }
+
+ return chosenIndex;
+ }
+
+ private static int sign(final int score) {
+ if (score < 0) {
+ return -1;
+ }
+ return 1;
+ }
+
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/FPSCounter.java b/src/jogl/classes/com/jogamp/opengl/FPSCounter.java
new file mode 100644
index 000000000..a3b7ccb70
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/FPSCounter.java
@@ -0,0 +1,117 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl;
+
+import java.io.PrintStream;
+
+/**
+ * FPSCounter feature.
+ * An implementation initially has the FPSCounter feature disabled.
+ * Use {@link #setUpdateFPSFrames(int, PrintStream)} to enable and disable the FPSCounter feature.
+ */
+public interface FPSCounter {
+ public static final int DEFAULT_FRAMES_PER_INTERVAL = 5*60;
+
+ /**
+ * @param frames Update interval in frames. At every rendered frames interval the currentTime and fps values are updated.
+ * If the frames interval is <= 0, no update will be issued, ie the FPSCounter feature is turned off. You may choose {@link #DEFAULT_FRAMES_PER_INTERVAL}.
+ * @param out optional print stream where the fps values gets printed if not null at every frames interval
+ */
+ void setUpdateFPSFrames(int frames, PrintStream out);
+
+ /**
+ * Reset all performance counter (startTime, currentTime, frame number)
+ */
+ void resetFPSCounter();
+
+ /**
+ * @return update interval in frames
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ */
+ int getUpdateFPSFrames();
+
+ /**
+ * Returns the time of the first display call in milliseconds after enabling this feature via {@link #setUpdateFPSFrames(int, PrintStream)}.
+ * This value is reset via {@link #resetFPSCounter()}.
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ long getFPSStartTime();
+
+ /**
+ * Returns the time of the last update interval in milliseconds, if this feature is enabled via {@link #setUpdateFPSFrames(int, PrintStream)}.
+ * This value is reset via {@link #resetFPSCounter()}.
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ long getLastFPSUpdateTime();
+
+ /**
+ * @return Duration of the last update interval in milliseconds.
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ long getLastFPSPeriod();
+
+ /**
+ * @return Last update interval's frames per seconds, {@link #getUpdateFPSFrames()} / {@link #getLastFPSPeriod()}
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ float getLastFPS();
+
+ /**
+ * @return Number of frame rendered since {@link #getFPSStartTime()} up to {@link #getLastFPSUpdateTime()}
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ int getTotalFPSFrames();
+
+ /**
+ * @return Total duration in milliseconds, {@link #getLastFPSUpdateTime()} - {@link #getFPSStartTime()}
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ long getTotalFPSDuration();
+
+
+ /**
+ * @return Total frames per seconds, {@link #getTotalFPSFrames()} / {@link #getTotalFPSDuration()}
+ *
+ * @see #setUpdateFPSFrames(int, PrintStream)
+ * @see #resetFPSCounter()
+ */
+ float getTotalFPS();
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLAnimatorControl.java b/src/jogl/classes/com/jogamp/opengl/GLAnimatorControl.java
new file mode 100644
index 000000000..549efd569
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLAnimatorControl.java
@@ -0,0 +1,236 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl;
+
+/**
+ * An animator control interface,
+ * which implementation may drive a {@link com.jogamp.opengl.GLAutoDrawable} animation.
+ */
+public interface GLAnimatorControl extends FPSCounter {
+ /**
+ * A {@link GLAnimatorControl#setUncaughtExceptionHandler(UncaughtExceptionHandler) registered}
+ * {@link UncaughtExceptionHandler} instance is invoked when an {@link GLAnimatorControl animator} abruptly {@link #stop() stops}
+ * due to an uncaught exception from one of its {@link GLAutoDrawable}s.
+ * @see #uncaughtException(GLAnimatorControl, GLAutoDrawable, Throwable)
+ * @see GLAnimatorControl#setUncaughtExceptionHandler(UncaughtExceptionHandler)
+ * @since 2.2
+ */
+ public static interface UncaughtExceptionHandler {
+ /**
+ * Method invoked when the given {@link GLAnimatorControl} is {@link GLAnimatorControl#stop() stopped} due to the
+ * given uncaught exception happened on the given {@link GLAutoDrawable}.
+ *
+ * The animator thread can still be retrieved via {@link GLAnimatorControl#getThread()}.
+ *
+ *
+ * All {@link GLAnimatorControl} states already reflect its stopped state.
+ *
+ *
+ * After this handler method is called, the {@link GLAnimatorControl} is stopped.
+ *
+ *
+ * Any exception thrown by this method will be ignored.
+ *
+ * @param animator the {@link GLAnimatorControl}
+ * @param drawable the causing {@link GLAutoDrawable}
+ * @param cause the uncaught exception
+ * @see GLAnimatorControl#setUncaughtExceptionHandler(UncaughtExceptionHandler)
+ * @since 2.2
+ */
+ void uncaughtException(final GLAnimatorControl animator, final GLAutoDrawable drawable, final Throwable cause);
+ }
+
+ /**
+ * Indicates whether this animator has been {@link #start() started}.
+ *
+ * @see #start()
+ * @see #stop()
+ * @see #isPaused()
+ * @see #pause()
+ * @see #resume()
+ */
+ boolean isStarted();
+
+ /**
+ * Indicates whether this animator {@link #isStarted() is started} and {@link #isPaused() is not paused}.
+ *
+ * @see #start()
+ * @see #stop()
+ * @see #pause()
+ * @see #resume()
+ */
+ boolean isAnimating();
+
+ /**
+ * Indicates whether this animator {@link #isStarted() is started}
+ * and either {@link #pause() manually paused} or paused
+ * automatically due to no {@link #add(GLAutoDrawable) added} {@link GLAutoDrawable}s.
+ *
+ * @see #start()
+ * @see #stop()
+ * @see #pause()
+ * @see #resume()
+ */
+ boolean isPaused();
+
+ /**
+ * @return The animation thread if running, otherwise null.
+ *
+ * @see #start()
+ * @see #stop()
+ */
+ Thread getThread();
+
+ /**
+ * Starts this animator, if not running.
+ *
+ * In most situations this method blocks until
+ * completion, except when called from the animation thread itself
+ * or in some cases from an implementation-internal thread like the
+ * AWT event queue thread.
+ *
+ *
+ * Note that an animator w/o {@link #add(GLAutoDrawable) added drawables}
+ * will be paused automatically.
+ *
+ *
+ * If started, all counters (time, frames, ..) are reset to zero.
+ *
+ *
+ * @return true is started due to this call,
+ * otherwise false, ie started already or unable to start.
+ *
+ * @see #stop()
+ * @see #isAnimating()
+ * @see #isPaused()
+ * @see #getThread()
+ */
+ boolean start();
+
+ /**
+ * Stops this animator.
+ *
+ * In most situations this method blocks until
+ * completion, except when called from the animation thread itself
+ * or in some cases from an implementation-internal thread like the
+ * AWT event queue thread.
+ *
+ *
+ * @return true is stopped due to this call,
+ * otherwise false, ie not started or unable to stop.
+ *
+ * @see #start()
+ * @see #isAnimating()
+ * @see #getThread()
+ */
+ boolean stop();
+
+ /**
+ * Pauses this animator.
+ *
+ * In most situations this method blocks until
+ * completion, except when called from the animation thread itself
+ * or in some cases from an implementation-internal thread like the
+ * AWT event queue thread.
+ *
+ *
+ * @return false if not started, already paused or failed to pause, otherwise true
+ *
+ * @see #resume()
+ * @see #isAnimating()
+ */
+ boolean pause();
+
+ /**
+ * Resumes animation if paused.
+ *
+ * In most situations this method blocks until
+ * completion, except when called from the animation thread itself
+ * or in some cases from an implementation-internal thread like the
+ * AWT event queue thread.
+ *
+ *
+ * If resumed, all counters (time, frames, ..) are reset to zero.
+ *
+ *
+ * @return false if not started, not paused or unable to resume, otherwise true
+ *
+ * @see #pause()
+ * @see #isAnimating()
+ */
+ boolean resume();
+
+ /**
+ * Adds a drawable to this animator's list of rendering drawables.
+ *
+ * This allows the animator thread to become {@link #isAnimating() animating},
+ * in case the first drawable is added and the animator {@link #isStarted() is started}.
+ *
+ *
+ * @param drawable the drawable to be added
+ * @throws IllegalArgumentException if drawable was already added to this animator
+ */
+ void add(GLAutoDrawable drawable);
+
+ /**
+ * Removes a drawable from the animator's list of rendering drawables.
+ *
+ * This method should get called in case a drawable becomes invalid,
+ * and will not be recovered.
+ *
+ *
+ * This allows the animator thread to become {@link #isAnimating() not animating},
+ * in case the last drawable has been removed.
+ *
+ *
+ * @param drawable the drawable to be removed
+ * @throws IllegalArgumentException if drawable was not added to this animator
+ */
+ void remove(GLAutoDrawable drawable);
+
+ /**
+ * Returns the {@link UncaughtExceptionHandler} invoked when this {@link GLAnimatorControl animator} abruptly {@link #stop() stops}
+ * due to an uncaught exception from one of its {@link GLAutoDrawable}s.
+ *
+ * Default is null.
+ *
+ * @since 2.2
+ */
+ UncaughtExceptionHandler getUncaughtExceptionHandler();
+
+ /**
+ * Set the handler invoked when this {@link GLAnimatorControl animator} abruptly {@link #stop() stops}
+ * due to an uncaught exception from one of its {@link GLAutoDrawable}s.
+ * @param handler the {@link UncaughtExceptionHandler} to use as this {@link GLAnimatorControl animator}'s uncaught exception
+ * handler. Pass null to unset the handler.
+ * @see UncaughtExceptionHandler#uncaughtException(GLAnimatorControl, GLAutoDrawable, Throwable)
+ * @since 2.2
+ */
+ void setUncaughtExceptionHandler(final UncaughtExceptionHandler handler);
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLArrayData.java b/src/jogl/classes/com/jogamp/opengl/GLArrayData.java
new file mode 100644
index 000000000..ea2dfb0f3
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLArrayData.java
@@ -0,0 +1,210 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl;
+
+import java.nio.Buffer;
+
+import com.jogamp.opengl.fixedfunc.GLPointerFunc;
+
+/**
+ *
+ * The total number of bytes hold by the referenced buffer is:
+ * getComponentSize()* getComponentNumber() * getElementNumber()
+ *
+ */
+public interface GLArrayData {
+ /**
+ * Implementation and type dependent object association.
+ *
+ * One currently known use case is to associate a {@link com.jogamp.opengl.util.glsl.ShaderState ShaderState}
+ * to an GLSL aware vertex attribute object, allowing to use the ShaderState to handle it's
+ * data persistence, location and state change.
+ * This is implicitly done via {@link com.jogamp.opengl.util.glsl.ShaderState#ownAttribute(GLArrayData, boolean) shaderState.ownAttribute(GLArrayData, boolean)}.
+ *
+ * @param obj implementation and type dependent association
+ * @param enable pass true to enable the association and false to disable it.
+ */
+ public void associate(Object obj, boolean enable);
+
+ /**
+ * Returns true if this data set is intended for a GLSL vertex shader attribute,
+ * otherwise false, ie intended for fixed function vertex pointer
+ */
+ public boolean isVertexAttribute();
+
+ /**
+ * The index of the predefined array index, see list below,
+ * or -1 in case of a shader attribute array.
+ *
+ * @see GLPointerFunc#GL_VERTEX_ARRAY
+ * @see GLPointerFunc#GL_NORMAL_ARRAY
+ * @see GLPointerFunc#GL_COLOR_ARRAY
+ * @see GLPointerFunc#GL_TEXTURE_COORD_ARRAY
+ */
+ public int getIndex();
+
+ /**
+ * The name of the reflecting shader array attribute.
+ */
+ public String getName();
+
+ /**
+ * Set a new name for this array.
+ *
+ * This clears the location, i.e. sets it to -1.
+ *
+ * @see #setLocation(int)
+ * @see #setLocation(GL2ES2, int)
+ */
+ public void setName(String newName);
+
+
+ /**
+ * Returns the shader attribute location for this name,
+ * -1 if not yet determined
+ */
+ public int getLocation();
+
+ /**
+ * Sets the given location of the shader attribute
+ *
+ * @return the given location
+ * @see com.jogamp.opengl.util.glsl.ShaderState#vertexAttribPointer(GL2ES2, GLArrayData)
+ */
+ public int setLocation(int v);
+
+ /**
+ * Retrieves the location of the shader attribute from the linked shader program.
+ *
+ * No validation is performed within the implementation.
+ *
+ * @param gl
+ * @param program
+ * @return ≥0 denotes a valid attribute location as found and used in the given shader program.
+ * <0 denotes an invalid location, i.e. not found or used in the given shader program.
+ */
+ public int setLocation(GL2ES2 gl, int program);
+
+ /**
+ * Binds the location of the shader attribute to the given location for the unlinked shader program.
+ *
+ * No validation is performed within the implementation.
+ *
+ * @param gl
+ * @param program
+ * @return the given location
+ */
+ public int setLocation(GL2ES2 gl, int program, int location);
+
+ /**
+ * Determines whether the data is server side (VBO) and enabled,
+ * or a client side array (false).
+ */
+ public boolean isVBO();
+
+ /**
+ * The VBO buffer offset or 0 if not a VBO
+ */
+ public long getVBOOffset();
+
+ /**
+ * The VBO name or 0 if not a VBO
+ */
+ public int getVBOName();
+
+ /**
+ * The VBO usage or 0 if not a VBO
+ * @return 0 if not a GPU buffer, otherwise {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
+ */
+ public int getVBOUsage();
+
+ /**
+ * The VBO target or 0 if not a VBO
+ * @return 0 if not a GPU buffer, otherwise {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
+ */
+ public int getVBOTarget();
+
+
+ /**
+ * The Buffer holding the data, may be null if a GPU buffer without client bound data
+ */
+ public Buffer getBuffer();
+
+ /**
+ * The number of components per element
+ */
+ public int getComponentCount();
+
+ /**
+ * The component's GL data type, ie. GL_FLOAT
+ */
+ public int getComponentType();
+
+ /**
+ * The component's size in bytes
+ */
+ public int getComponentSizeInBytes();
+
+ /**
+ * The current number of used elements.
+ *
+ * On element consist out of {@link #getComponentCount()} components.
+ *
+ * In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
+ */
+ public int getElementCount();
+
+ /**
+ * The currently used size in bytes.
+ * In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
+ */
+ public int getSizeInBytes();
+
+ /**
+ * True, if GL shall normalize fixed point data while converting
+ * them into float.
+ *
+ * Default behavior (of the fixed function pipeline) is true
+ * for fixed point data type and false for floating point data types.
+ *
+ */
+ public boolean getNormalized();
+
+ /**
+ * @return the byte offset between consecutive components
+ */
+ public int getStride();
+
+ @Override
+ public String toString();
+
+ public void destroy(GL gl);
+
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawable.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawable.java
new file mode 100644
index 000000000..385acf082
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawable.java
@@ -0,0 +1,636 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.opengl;
+
+import java.util.List;
+
+import com.jogamp.nativewindow.NativeSurface;
+
+import com.jogamp.common.util.locks.RecursiveLock;
+
+import jogamp.opengl.Debug;
+
+/** A higher-level abstraction than {@link GLDrawable} which supplies
+ an event based mechanism ({@link GLEventListener}) for performing
+ OpenGL rendering. A GLAutoDrawable automatically creates a primary
+ rendering context which is associated with the GLAutoDrawable for
+ the lifetime of the object.
+
+ Since the {@link GLContext} {@link GLContext#makeCurrent makeCurrent}
+ implementation is synchronized, i.e. blocks if the context
+ is current on another thread, the internal
+ {@link GLContext} for the GLAutoDrawable can be used for the event
+ based rendering mechanism and by end users directly.
+
+ The implementation shall initialize itself as soon as possible,
+ which is only possible after the attached {@link com.jogamp.nativewindow.NativeSurface NativeSurface} becomes visible and and is realized.
+ The following initialization sequence should be implemented:
+
+
Create the {@link GLDrawable} with the requested {@link GLCapabilities}
+
Notify {@link GLDrawable} to validate the {@link GLCapabilities} by calling {@link GLDrawable#setRealized setRealized(true)}.
+
Create the new {@link GLContext}.
+
Initialize all OpenGL resources by calling {@link GLEventListener#init init(..)} for all
+ registered {@link GLEventListener}s. This can be done immediately, or with the followup {@link #display display(..)} call.
+
Send a reshape event by calling {@link GLEventListener#reshape reshape(..)} for all
+ registered {@link GLEventListener}s. This shall be done after the {@link GLEventListener#init init(..)} calls.
+
+ Note: The last to {@link GLEventListener} actions shall be also performed, when {@link #addGLEventListener(GLEventListener) adding}
+ a new one to an already initialized {@link GLAutoDrawable}.
+
+
+ Another implementation detail is the {@link GLDrawable} reconfiguration. One use case is where a window is being
+ dragged to another screen with a different pixel configuration, ie {@link GLCapabilities}. The implementation
+ shall be able to detect such cases in conjunction with the associated {@link com.jogamp.nativewindow.NativeSurface NativeSurface}.
+ For example, AWT's {@link java.awt.Canvas} 's {@link java.awt.Canvas#getGraphicsConfiguration getGraphicsConfiguration()}
+ is capable to determine a display device change. This is demonstrated within {@link com.jogamp.opengl.awt.GLCanvas}'s
+ and NEWT's AWTCanvas {@link com.jogamp.opengl.awt.GLCanvas#getGraphicsConfiguration getGraphicsConfiguration()}
+ specialization. Another demonstration is NEWT's {@link com.jogamp.nativewindow.NativeWindow NativeWindow}
+ implementation on the Windows platform, which utilizes the native platform's MonitorFromWindow(HWND) function.
+ All OpenGL resources shall be regenerated, while the drawable's {@link GLCapabilities} has
+ to be chosen again. The following protocol shall be satisfied.
+
+
Controlled disposal:
+
+
Dispose all OpenGL resources by calling {@link GLEventListener#dispose dispose(..)} for all
+ registered {@link GLEventListener}s.
+
Destroy the {@link GLContext}.
+
Notify {@link GLDrawable} of the invalid state by calling {@link GLDrawable#setRealized setRealized(false)}.
+
+
Controlled regeneration:
+
+
Create the new {@link GLDrawable} with the requested {@link GLCapabilities}
+
Notify {@link GLDrawable} to revalidate the {@link GLCapabilities} by calling {@link GLDrawable#setRealized setRealized(true)}.
+
Create the new {@link GLContext}.
+
Initialize all OpenGL resources by calling {@link GLEventListener#init init(..)} for all
+ registered {@link GLEventListener}s. This can be done immediatly, or with the followup {@link #display display(..)} call.
+
Send a reshape event by calling {@link GLEventListener#reshape reshape(..)} for all
+ registered {@link GLEventListener}s. This shall be done after the {@link GLEventListener#init init(..)} calls.
+
+
+ Note: Current graphics driver keep the surface configuration for a given window, even if the window is moved to
+ a monitor with a different pixel configuration, ie 32bpp to 16bpp. However, it is best to not assume such behavior
+ and make your application comply with the above protocol.
+
+ Avoiding breakage with older applications and because of the situation
+ mentioned above, the boolean system property jogl.screenchange.action will control the
+ screen change action as follows:
+
+ -Djogl.screenchange.action=false Disable the {@link GLDrawable} reconfiguration (the default)
+ -Djogl.screenchange.action=true Enable the {@link GLDrawable} reconfiguration
+
+
+ Above locking order is mandatory to guarantee
+ atomicity of operation and to avoid race-conditions.
+ A custom implementation or user applications requiring exclusive access
+ shall follow the locking order.
+ See:
+
+
{@link #getUpstreamLock()}
+
{@link #invoke(boolean, GLRunnable)}
+
{@link #invoke(boolean, List)}
+
+
+ */
+public interface GLAutoDrawable extends GLDrawable {
+ /** Flag reflecting whether the {@link GLDrawable} reconfiguration will be issued in
+ * case a screen device change occurred, e.g. in a multihead environment,
+ * where you drag the window to another monitor. */
+ public static final boolean SCREEN_CHANGE_ACTION_ENABLED = Debug.getBooleanProperty("jogl.screenchange.action", true);
+
+ /**
+ * If the implementation uses delegation, return the delegated {@link GLDrawable} instance,
+ * otherwise return this instance.
+ */
+ public GLDrawable getDelegatedDrawable();
+
+ /**
+ * Returns the context associated with this drawable. The returned
+ * context will be synchronized.
+ * Don't rely on it's identity, the context may change.
+ */
+ public GLContext getContext();
+
+ /**
+ * Associate the new context, newtCtx, to this auto-drawable.
+ *
+ * Remarks:
+ *
+ *
The currently associated context will be destroyed if destroyPrevCtx is true,
+ * otherwise it will be disassociated from this auto-drawable
+ * via {@link GLContext#setGLDrawable(GLDrawable, boolean) setGLDrawable(null, true);} including {@link GL#glFinish() glFinish()}.
+ *
The new context will be associated with this auto-drawable
+ * via {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}.
+ *
If the old context was current on this thread, it is being released after disassociating this auto-drawable.
+ *
If the new context was current on this thread, it is being released before associating this auto-drawable
+ * and made current afterwards.
+ *
Implementation may issue {@link #makeCurrent()} and {@link #release()} while drawable reassociation.
+ *
The user shall take extra care of thread synchronization,
+ * i.e. lock the involved {@link GLAutoDrawable auto-drawable's}
+ * {@link GLAutoDrawable#getUpstreamLock() upstream-locks} and {@link GLAutoDrawable#getNativeSurface() surfaces}
+ * to avoid a race condition. See GLAutoDrawable Locking.
+ *
+ *
+ *
+ * @param newCtx the new context, maybe null for dis-association.
+ * @param destroyPrevCtx if true, destroy the previous context if exists
+ * @return the previous GLContext, maybe null
+ *
+ * @see GLContext#setGLDrawable(GLDrawable, boolean)
+ * @see GLContext#setGLReadDrawable(GLDrawable)
+ * @see jogamp.opengl.GLDrawableHelper#switchContext(GLDrawable, GLContext, boolean, GLContext, int)
+ */
+ public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx);
+
+ /**
+ * Adds the given {@link GLEventListener listener} to the end of this drawable queue.
+ * The {@link GLEventListener listeners} are notified of events in the order of the queue.
+ *
+ * The newly added listener's {@link GLEventListener#init(GLAutoDrawable) init(..)}
+ * method will be called once before any other of it's callback methods.
+ * See {@link #getGLEventListenerInitState(GLEventListener)} for details.
+ *
+ * @param listener The GLEventListener object to be inserted
+ */
+ public void addGLEventListener(GLEventListener listener);
+
+ /**
+ * Adds the given {@link GLEventListener listener} at the given index of this drawable queue.
+ * The {@link GLEventListener listeners} are notified of events in the order of the queue.
+ *
+ * The newly added listener's {@link GLEventListener#init(GLAutoDrawable) init(..)}
+ * method will be called once before any other of it's callback methods.
+ * See {@link #getGLEventListenerInitState(GLEventListener)} for details.
+ *
+ * @param index Position where the listener will be inserted.
+ * Should be within (0 <= index && index <= size()).
+ * An index value of -1 is interpreted as the end of the list, size().
+ * @param listener The GLEventListener object to be inserted
+ * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index <= size()), or -1
+ */
+ public void addGLEventListener(int index, GLEventListener listener) throws IndexOutOfBoundsException;
+
+ /**
+ * Returns the number of {@link GLEventListener} of this drawable queue.
+ * @return The number of GLEventListener objects of this drawable queue.
+ */
+ public int getGLEventListenerCount();
+
+ /**
+ * Returns true if all added {@link GLEventListener} are initialized, otherwise false.
+ * @since 2.2
+ */
+ boolean areAllGLEventListenerInitialized();
+
+ /**
+ * Returns the {@link GLEventListener} at the given index of this drawable queue.
+ * @param index Position of the listener to be returned.
+ * Should be within (0 <= index && index < size()).
+ * An index value of -1 is interpreted as last listener, size()-1.
+ * @return The GLEventListener object at the given index.
+ * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index < size()), or -1
+ */
+ public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException;
+
+ /**
+ * Retrieves whether the given {@link GLEventListener listener} is initialized or not.
+ *
+ * After {@link #addGLEventListener(GLEventListener) adding} a {@link GLEventListener} it is
+ * marked uninitialized and added to a list of to be initialized {@link GLEventListener}.
+ * If such uninitialized {@link GLEventListener}'s handler methods (reshape, display)
+ * are about to be invoked, it's {@link GLEventListener#init(GLAutoDrawable) init(..)} method is invoked first.
+ * Afterwards the {@link GLEventListener} is marked initialized
+ * and removed from the list of to be initialized {@link GLEventListener}.
+ *
+ *
+ * This methods returns the {@link GLEventListener} initialized state,
+ * i.e. returns false if it is included in the list of to be initialized {@link GLEventListener},
+ * otherwise true.
+ *
+ * @param listener the GLEventListener object to query it's initialized state.
+ */
+ public boolean getGLEventListenerInitState(GLEventListener listener);
+
+ /**
+ * Sets the given {@link GLEventListener listener's} initialized state.
+ *
+ * This methods allows manually setting the {@link GLEventListener} initialized state,
+ * i.e. adding it to, or removing it from the list of to be initialized {@link GLEventListener}.
+ * See {@link #getGLEventListenerInitState(GLEventListener)} for details.
+ *
+ *
+ * Warning: This method does not validate whether the given {@link GLEventListener listener's}
+ * is member of this drawable queue, i.e. {@link #addGLEventListener(GLEventListener) added}.
+ *
+ *
+ * This method is only exposed to allow users full control over the {@link GLEventListener}'s state
+ * and is usually not recommended to change.
+ *
+ *
+ * One use case is moving a {@link GLContext} and their initialized {@link GLEventListener}
+ * from one {@link GLAutoDrawable} to another,
+ * where a subsequent {@link GLEventListener#init(GLAutoDrawable) init(..)} call after adding it
+ * to the new owner is neither required nor desired.
+ * See {@link com.jogamp.opengl.util.GLDrawableUtil#swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable) swapGLContextAndAllGLEventListener(..)}.
+ *
+ * @param listener the GLEventListener object to perform a state change.
+ * @param initialized if true, mark the listener initialized, otherwise uninitialized.
+ */
+ public void setGLEventListenerInitState(GLEventListener listener, boolean initialized);
+
+ /**
+ * Disposes the given {@link GLEventListener listener} via {@link GLEventListener#dispose(GLAutoDrawable) dispose(..)}
+ * if it has been initialized and added to this queue.
+ *
+ * If remove is true, the {@link GLEventListener} is removed from this drawable queue before disposal,
+ * otherwise marked uninitialized.
+ *
+ *
+ * If an {@link GLAnimatorControl} is being attached and the current thread is different
+ * than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation.
+ *
+ *
+ * Note that this is an expensive operation, since {@link GLEventListener#dispose(GLAutoDrawable) dispose(..)}
+ * is decorated by {@link GLContext#makeCurrent()} and {@link GLContext#release()}.
+ *
+ *
+ * Use {@link #removeGLEventListener(GLEventListener) removeGLEventListener(listener)} instead
+ * if you just want to remove the {@link GLEventListener listener} and don't care about the disposal of the it's (OpenGL) resources.
+ *
+ *
+ * Also note that this is done from within a particular drawable's
+ * {@link GLEventListener} handler (reshape, display, etc.), that it is not
+ * guaranteed that all other listeners will be evaluated properly
+ * during this update cycle.
+ *
+ * @param listener The GLEventListener object to be disposed and removed if remove is true
+ * @param remove pass true to have the listener removed from this drawable queue, otherwise pass false
+ * @return the disposed and/or removed GLEventListener, or null if no action was performed, i.e. listener was not added
+ */
+ public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove);
+
+ /**
+ * Removes the given {@link GLEventListener listener} from this drawable queue.
+ *
+ * This is an inexpensive operation, since the removed listener's
+ * {@link GLEventListener#dispose(GLAutoDrawable) dispose(..)} method will not be called.
+ *
+ *
+ * Use {@link #disposeGLEventListener(GLEventListener, boolean) disposeGLEventListener(listener, true)}
+ * instead to ensure disposal of the {@link GLEventListener listener}'s (OpenGL) resources.
+ *
+ *
+ * Note that if this is done from within a particular drawable's
+ * {@link GLEventListener} handler (reshape, display, etc.), that it is not
+ * guaranteed that all other listeners will be evaluated properly
+ * during this update cycle.
+ *
+ * @param listener The GLEventListener object to be removed
+ * @return the removed GLEventListener, or null if listener was not added
+ */
+ public GLEventListener removeGLEventListener(GLEventListener listener);
+
+ /**
+ * Registers the usage of an animator, an {@link com.jogamp.opengl.GLAnimatorControl} implementation.
+ * The animator will be queried whether it's animating, ie periodically issuing {@link #display()} calls or not.
+ *
+ * This method shall be called by an animator implementation only,
+ * e.g. {@link com.jogamp.opengl.util.Animator#add(com.jogamp.opengl.GLAutoDrawable)}, passing it's control implementation,
+ * and {@link com.jogamp.opengl.util.Animator#remove(com.jogamp.opengl.GLAutoDrawable)}, passing null.
+ *
+ *
+ * Impacts {@link #display()} and {@link #invoke(boolean, GLRunnable)} semantics.
+ *
+ * @param animatorControl null reference indicates no animator is using
+ * this GLAutoDrawable,
+ * a valid reference indicates an animator is using this GLAutoDrawable.
+ *
+ * @throws GLException if an animator is already registered.
+ * @see #display()
+ * @see #invoke(boolean, GLRunnable)
+ * @see com.jogamp.opengl.GLAnimatorControl
+ */
+ public abstract void setAnimator(GLAnimatorControl animatorControl) throws GLException;
+
+ /**
+ * @return the registered {@link com.jogamp.opengl.GLAnimatorControl} implementation, using this GLAutoDrawable.
+ *
+ * @see #setAnimator(com.jogamp.opengl.GLAnimatorControl)
+ * @see com.jogamp.opengl.GLAnimatorControl
+ */
+ public GLAnimatorControl getAnimator();
+
+ /**
+ * Dedicates this instance's {@link GLContext} to the given thread.
+ * The thread will exclusively claim the {@link GLContext} via {@link #display()} and not release it
+ * until {@link #destroy()} or setExclusiveContextThread(null) has been called.
+ *
+ * Default non-exclusive behavior is requested via setExclusiveContextThread(null),
+ * which will cause the next call of {@link #display()} on the exclusive thread to
+ * release the {@link GLContext}. Only after it's async release, {@link #getExclusiveContextThread()}
+ * will return null.
+ *
+ *
+ * To release a previous made exclusive thread, a user issues setExclusiveContextThread(null)
+ * and may poll {@link #getExclusiveContextThread()} until it returns null,
+ * while the exclusive thread is still running.
+ *
+ *
+ * Note: Setting a new exclusive thread without properly releasing a previous one
+ * will throw an GLException.
+ *
+ *
+ * Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation.
+ * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas.
+ *
+ *
+ * One scenario could be to dedicate the context to the {@link GLAnimatorControl#getThread() animator thread}
+ * and spare redundant context switches, see {@link com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean)}.
+ *
+ * @param t the exclusive thread to claim the context, or null for default operation.
+ * @return previous exclusive context thread
+ * @throws GLException If an exclusive thread is still active but a new one is attempted to be set
+ * @see com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean)
+ */
+ public Thread setExclusiveContextThread(Thread t) throws GLException;
+
+ /**
+ * @see #setExclusiveContextThread(Thread)
+ */
+ public Thread getExclusiveContextThread();
+
+ /**
+ * Enqueues a one-shot {@link GLRunnable},
+ * which will be executed within the next {@link #display()} call
+ * after all registered {@link GLEventListener}s
+ * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)}
+ * methods have been called.
+ *
+ * If no {@link GLAnimatorControl} is animating (default),
+ * or if the current thread is the animator thread,
+ * a {@link #display()} call is issued after enqueue the GLRunnable,
+ * hence the {@link GLRunnable} will be executed right away.
+ *
+ *
+ * If an {@link GLAnimatorControl animator} is running,
+ * no explicit {@link #display()} call is issued, allowing the {@link GLAnimatorControl animator} to perform at due time.
+ *
+ *
+ * If wait is true the call blocks until the glRunnable
+ * has been executed by the {@link GLAnimatorControl animator}, otherwise the method returns immediately.
+ *
+ *
+ * If wait is trueand
+ * {@link #isRealized()} returns falseor {@link #getContext()} returns null,
+ * the call is ignored and returns false.
+ * This helps avoiding deadlocking the caller.
+ *
+ *
+ * The internal queue of {@link GLRunnable}'s is being flushed with {@link #destroy()}
+ * where all blocked callers are being notified.
+ *
+ *
+ * To avoid a deadlock situation which causes an {@link IllegalStateException} one should
+ * avoid issuing {@link #invoke(boolean, GLRunnable) invoke} while this GLAutoDrawable is being locked.
+ * Detected deadlock situations throwing an {@link IllegalStateException} are:
+ *
+ *
{@link #getAnimator() Animator} is running on another thread and waiting and is locked on current thread, but is not {@link #isThreadGLCapable() GL-Thread}
+ *
No {@link #getAnimator() Animator} is running on another thread and is locked on current thread, but is not {@link #isThreadGLCapable() GL-Thread}
+ *
+ *
+ *
+ * @param wait if true block until execution of glRunnable is finished, otherwise return immediately w/o waiting
+ * @param glRunnable the {@link GLRunnable} to execute within {@link #display()}
+ * @return true if the {@link GLRunnable} has been processed or queued, otherwise false.
+ * @throws IllegalStateException in case of a detected deadlock situation ahead, see above.
+ *
+ * @see #setAnimator(GLAnimatorControl)
+ * @see #display()
+ * @see GLRunnable
+ * @see #invoke(boolean, List)
+ * @see #flushGLRunnables()
+ */
+ public boolean invoke(boolean wait, GLRunnable glRunnable) throws IllegalStateException ;
+
+ /**
+ * Extends {@link #invoke(boolean, GLRunnable)} functionality
+ * allowing to inject a list of {@link GLRunnable}s.
+ * @param wait if true block until execution of the last glRunnable is finished, otherwise return immediately w/o waiting
+ * @param glRunnables the {@link GLRunnable}s to execute within {@link #display()}
+ * @return true if the {@link GLRunnable}s has been processed or queued, otherwise false.
+ * @throws IllegalStateException in case of a detected deadlock situation ahead, see {@link #invoke(boolean, GLRunnable)}.
+ * @see #invoke(boolean, GLRunnable)
+ * @see #flushGLRunnables()
+ */
+ public boolean invoke(boolean wait, List glRunnables) throws IllegalStateException;
+
+ /**
+ * Flushes all {@link #invoke(boolean, GLRunnable) enqueued} {@link GLRunnable} of this {@link GLAutoDrawable}
+ * including notifying waiting executor.
+ *
+ * The executor which might have been blocked until notified
+ * will be unblocked and all tasks removed from the queue.
+ *
+ * @see #invoke(boolean, GLRunnable)
+ * @since 2.2
+ */
+ public void flushGLRunnables();
+
+ /** Destroys all resources associated with this GLAutoDrawable,
+ inclusive the GLContext.
+ If a window is attached to it's implementation, it shall be closed.
+ Causes disposing of all OpenGL resources
+ by calling {@link GLEventListener#dispose dispose(..)} for all
+ registered {@link GLEventListener}s. Called automatically by the
+ window system toolkit upon receiving a destroy notification. This
+ routine may be called manually. */
+ public void destroy();
+
+ /**
+ *
+ * Causes OpenGL rendering to be performed for this GLAutoDrawable
+ * in the following order:
+ *
+ *
Calling {@link GLEventListener#display display(..)} for all
+ * registered {@link GLEventListener}s.
+ *
Executes all one-shot {@link com.jogamp.opengl.GLRunnable GLRunnable},
+ * enqueued via {@link #invoke(boolean, GLRunnable)}.
+ *
+ *
+ * May be called periodically by a running {@link com.jogamp.opengl.GLAnimatorControl} implementation,
+ * which must register itself with {@link #setAnimator(com.jogamp.opengl.GLAnimatorControl)}.
+ *
+ * Called automatically by the window system toolkit upon receiving a repaint() request,
+ * except an {@link com.jogamp.opengl.GLAnimatorControl} implementation {@link com.jogamp.opengl.GLAnimatorControl#isAnimating()}.
+ *
+ * This routine may also be called manually for better control over the
+ * rendering process. It is legal to call another GLAutoDrawable's
+ * display method from within the {@link GLEventListener#display
+ * display(..)} callback.
+ *
+ * In case of a new generated OpenGL context,
+ * the implementation shall call {@link GLEventListener#init init(..)} for all
+ * registered {@link GLEventListener}s before making the
+ * actual {@link GLEventListener#display display(..)} calls,
+ * in case this has not been done yet.
+ *
+ * @see #setAnimator(com.jogamp.opengl.GLAnimatorControl)
+ */
+ public void display();
+
+ /** Enables or disables automatic buffer swapping for this drawable.
+ By default this property is set to true; when true, after all
+ GLEventListeners have been called for a display() event, the
+ front and back buffers are swapped, displaying the results of
+ the render. When disabled, the user is responsible for calling
+ {@link #swapBuffers(..)} manually. */
+ public void setAutoSwapBufferMode(boolean enable);
+
+ /** Indicates whether automatic buffer swapping is enabled for this
+ drawable. See {@link #setAutoSwapBufferMode}. */
+ public boolean getAutoSwapBufferMode();
+
+ /**
+ * @param flags Additional context creation flags.
+ *
+ * @see GLContext#setContextCreationFlags(int)
+ * @see GLContext#enableGLDebugMessage(boolean)
+ */
+ public void setContextCreationFlags(int flags);
+
+ /**
+ * @return Additional context creation flags
+ */
+ public int getContextCreationFlags();
+
+ /**
+ * {@inheritDoc}
+ *
+ * This GLAutoDrawable implementation holds it's own GLContext reference,
+ * thus created a GLContext using this methods won't replace it implicitly.
+ * To replace or set this GLAutoDrawable's GLContext you need to call {@link #setContext(GLContext, boolean)}.
+ *
+ *
+ * The GLAutoDrawable implementation shall also set the
+ * context creation flags as customized w/ {@link #setContextCreationFlags(int)}.
+ *
+ */
+ @Override
+ public GLContext createContext(GLContext shareWith);
+
+ /** Returns the {@link GL} pipeline object this GLAutoDrawable uses.
+ If this method is called outside of the {@link
+ GLEventListener}'s callback methods (init, display, etc.) it may
+ return null. Users should not rely on the identity of the
+ returned GL object; for example, users should not maintain a
+ hash table with the GL object as the key. Additionally, the GL
+ object should not be cached in client code, but should be
+ re-fetched from the GLAutoDrawable at the beginning of each call
+ to init, display, etc. */
+ public GL getGL();
+
+ /** Sets the {@link GL} pipeline object this GLAutoDrawable uses.
+ This should only be called from within the GLEventListener's
+ callback methods, and usually only from within the init()
+ method, in order to install a composable pipeline. See the JOGL
+ demos for examples.
+ @return the set GL pipeline or null if not successful */
+ public GL setGL(GL gl);
+
+ /**
+ * Method may return the upstream UI toolkit object
+ * holding this {@link GLAutoDrawable} instance, if exist.
+ *
+ * Currently known Java UI toolkits and it's known return types are:
+ *
+ *
+ *
Toolkit
GLAutoDrawable Implementation
~
Return Type of getUpstreamWidget()
+ *
NEWT
{@link com.jogamp.newt.opengl.GLWindow}
has a
{@link com.jogamp.newt.Window}
+ *
SWT
{@link com.jogamp.opengl.swt.GLCanvas}
is a
{@link org.eclipse.swt.widgets.Canvas}
+ *
AWT
{@link com.jogamp.opengl.awt.GLCanvas}
is a
{@link java.awt.Canvas}
+ *
AWT
{@link com.jogamp.opengl.awt.GLJPanel}
is a
{@link javax.swing.JPanel}
+ *
+ * However, the result may be other object types than the listed above
+ * due to new supported toolkits.
+ *
+ *
+ * This method may also return null if no UI toolkit is being used,
+ * as common for offscreen rendering.
+ *
+ */
+ public Object getUpstreamWidget();
+
+ /**
+ * Returns the recursive lock object of the {@link #getUpstreamWidget() upstream widget}
+ * to synchronize multithreaded access on top of {@link NativeSurface#lockSurface()}.
+ *
+ * @since 2.2
+ */
+ public RecursiveLock getUpstreamLock();
+
+ /**
+ * Indicates whether the current thread is capable of
+ * performing OpenGL-related work.
+ *
+ * Implementation utilizes this knowledge to determine
+ * whether {@link #display()} performs the OpenGL commands on the current thread directly
+ * or spawns them on the dedicated OpenGL thread.
+ *
+ * @since 2.2
+ */
+ public boolean isThreadGLCapable();
+
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLBase.java b/src/jogl/classes/com/jogamp/opengl/GLBase.java
new file mode 100644
index 000000000..19b7808fc
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLBase.java
@@ -0,0 +1,646 @@
+/**
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl;
+
+/**
+ *
The base interface from which all GL profiles derive, providing
+ * checked conversion down to concrete profiles, access to the
+ * OpenGL context associated with the GL and extension/function
+ * availability queries as described below.
+ *
+ *
While the APIs for vendor extensions are unconditionally
+ * exposed, the underlying functions may not be present. The method
+ * {@link #isFunctionAvailable} should be used to query the
+ * availability of any non-core function before it is used for the
+ * first time; for example,
+ * gl.isFunctionAvailable("glProgramStringARB"). On
+ * certain platforms (Windows in particular), the most "core"
+ * functionality is only OpenGL 1.1, so in theory any routines first
+ * exposed in OpenGL 1.2, 1.3, and 1.4, 1.5, or 2.0 as well as vendor
+ * extensions should all be queried. Calling an unavailable function
+ * will cause a {@link GLException} to be raised.
+ *
+ * {@link #isExtensionAvailable} may also be used to determine whether
+ * a specific extension is available before calling the routines or
+ * using the functionality it exposes: for example,
+ * gl.isExtensionAvailable("GL_ARB_vertex_program");.
+ * However, in this case it is up to the end user to know which
+ * routines or functionality are associated with which OpenGL
+ * extensions. It may also be used to test for the availability of a
+ * particular version of OpenGL: for example,
+ * gl.isExtensionAvailable("GL_VERSION_1_5");.
+ *
+ *
Exceptions to the window system extension naming rules:
+ *
+ *
+ *
+ *
The memory allocators for the NVidia vertex_array_range (VAR)
+ * extension, in particular wglAllocateMemoryNV /
+ * glXAllocateMemoryNV and associated routines. {@link
+ * #glAllocateMemoryNV} has been provided for window system-independent
+ * access to VAR. {@link #isFunctionAvailable} will translate an argument
+ * of "glAllocateMemoryNV" or "glFreeMemoryNV" into the appropriate
+ * window system-specific name.
+ *
+ *
WGL_ARB_pbuffer, WGL_ARB_pixel_format, and other
+ * platform-specific pbuffer functionality; the availability of
+ * pbuffers can be queried on Windows, X11 and Mac OS X platforms by
+ * querying {@link #isExtensionAvailable} with an argument of
+ * "GL_ARB_pbuffer" or "GL_ARB_pixel_format".
+ *
+ *
+ *
+ */
+public interface GLBase {
+
+ /**
+ * Indicates whether this GL object conforms to any of the OpenGL profiles.
+ */
+ public boolean isGL();
+
+ /**
+ * Indicates whether this GL object conforms to the OpenGL ≥ 4.0 compatibility profile.
+ * The GL4 compatibility profile includes the GL2, GL2ES1, GL2ES2, GL3, GL3bc and GL4 profile.
+ * @see GLContext#isGL4bc()
+ */
+ public boolean isGL4bc();
+
+ /**
+ * Indicates whether this GL object conforms to the OpenGL ≥ 4.0 core profile.
+ * The GL4 core profile includes the GL2ES2, and GL3 profile.
+ * @see GLContext#isGL4()
+ */
+ public boolean isGL4();
+
+ /**
+ * Indicates whether this GL object conforms to the OpenGL ≥ 3.1 compatibility profile.
+ * The GL3 compatibility profile includes the GL2, GL2ES1, GL2ES2 and GL3 profile.
+ * @see GLContext#isGL3bc()
+ */
+ public boolean isGL3bc();
+
+ /**
+ * Indicates whether this GL object conforms to the OpenGL ≥ 3.1 core profile.
+ * The GL3 core profile includes the GL2ES2 profile.
+ * @see GLContext#isGL3()
+ */
+ public boolean isGL3();
+
+ /**
+ * Indicates whether this GL object conforms to the OpenGL ≤ 3.0 profile.
+ * The GL2 profile includes the GL2ES1 and GL2ES2 profile.
+ * @see GLContext#isGL2()
+ */
+ public boolean isGL2();
+
+ /**
+ * Indicates whether this GL object conforms to the OpenGL ES ≥ 1.0 profile.
+ * @see GLContext#isGLES1()
+ */
+ public boolean isGLES1();
+
+ /**
+ * Indicates whether this GL object conforms to the OpenGL ES ≥ 2.0 profile.
+ *
+ * Remark: ES2 compatible desktop profiles are not included.
+ * To query whether core ES2 functionality is provided, use {@link #isGLES2Compatible()}.
+ *
+ * @see #isGLES2Compatible()
+ * @see GLContext#isGLES2()
+ */
+ public boolean isGLES2();
+
+ /**
+ * Indicates whether this GL object conforms to the OpenGL ES ≥ 3.0 profile.
+ *
+ * Remark: ES3 compatible desktop profiles are not included.
+ * To query whether core ES3 functionality is provided, use {@link #isGLES3Compatible()}.
+ *
+ * @see #isGLES3Compatible()
+ * @see GLContext#isGLES3()
+ */
+ public boolean isGLES3();
+
+ /**
+ * Indicates whether this GL object conforms to one of the OpenGL ES profiles,
+ * see {@link #isGLES1()}, {@link #isGLES2()} and {@link #isGLES3()}.
+ * @see GLContext#isGLES()
+ */
+ public boolean isGLES();
+
+ /**
+ * Indicates whether this GL object conforms to a GL2ES1 compatible profile.
+ * @see GLContext#isGL2ES1()
+ */
+ public boolean isGL2ES1();
+
+ /**
+ * Indicates whether this GL object conforms to a GL2ES2 compatible profile.
+ * @see GLContext#isGL2ES2()
+ */
+ public boolean isGL2ES2();
+
+ /**
+ * Indicates whether this GL object conforms to a either a GL2GL3 or GL3ES3 compatible profile.
+ * @see GLContext#isGL2ES3()
+ */
+ public boolean isGL2ES3();
+
+ /**
+ * Indicates whether this GL object conforms to a GL3ES3 compatible profile.
+ * @see GLContext#isGL3ES3()
+ */
+ public boolean isGL3ES3();
+
+ /**
+ * Returns true if this GL object conforms to a GL4ES3 compatible profile, i.e. if {@link #isGLES3Compatible()} returns true.
+ *
Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
+ * @see GLContext#isGL4ES3()
+ */
+ public boolean isGL4ES3();
+
+ /**
+ * Indicates whether this GL object conforms to a GL2GL3 compatible profile.
+ * @see GLContext#isGL2GL3()
+ */
+ public boolean isGL2GL3();
+
+ /**
+ * Indicates whether this GL object uses a GL4 core profile.
Includes [ GL4 ].
+ * @see GLContext#isGL4core()
+ */
+ public boolean isGL4core();
+
+ /**
+ * Indicates whether this GL object uses a GL3 core profile.
Includes [ GL4, GL3 ].
+ * @see GLContext#isGL3core()
+ */
+ public boolean isGL3core();
+
+ /**
+ * Indicates whether this GL object uses a GL core profile.
Includes [ GL4, GL3, GLES3, GL2ES2 ].
+ * @see GLContext#isGLcore()
+ */
+ public boolean isGLcore();
+
+ /**
+ * Indicates whether this GL object is compatible with the core OpenGL ES2 functionality.
+ * @return true if this context is an ES2 context or implements
+ * the extension GL_ARB_ES2_compatibility, otherwise false
+ * @see GLContext#isGLES2Compatible()
+ */
+ public boolean isGLES2Compatible();
+
+ /**
+ * Indicates whether this GL object is compatible with the core OpenGL ES3 functionality.
+ *
+ * Return true if the underlying context is an ES3 context or implements
+ * the extension GL_ARB_ES3_compatibility, otherwise false.
+ *
+ *
+ * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
+ *
+ * @see GLContext#isGLES3Compatible()
+ */
+ public boolean isGLES3Compatible();
+
+ /**
+ * Indicates whether this GL object supports GLSL.
+ * @see GLContext#hasGLSL()
+ */
+ public boolean hasGLSL();
+
+ /**
+ * Returns the downstream GL instance in case this is a wrapping pipeline, otherwise null.
+ *
+ * See {@link #getRootGL()} for retrieving the implementing root instance.
+ *
+ * @throws GLException if the downstream instance is not null and not a GL implementation
+ * @see #getRootGL()
+ */
+ public GL getDownstreamGL() throws GLException;
+
+ /**
+ * Returns the implementing root instance, considering a wrapped pipelined hierarchy, see {@link #getDownstreamGL()}.
+ *
+ * If this instance is not a wrapping pipeline, i.e. has no downstream instance,
+ * this instance is returned.
+ *
+ * @throws GLException if the root instance is not a GL implementation
+ */
+ public GL getRootGL() throws GLException;
+
+ /**
+ * Casts this object to the GL interface.
+ * @throws GLException if this object is not a GL implementation
+ */
+ public GL getGL() throws GLException;
+
+ /**
+ * Casts this object to the GL4bc interface.
+ * @throws GLException if this object is not a GL4bc implementation
+ */
+ public GL4bc getGL4bc() throws GLException;
+
+ /**
+ * Casts this object to the GL4 interface.
+ * @throws GLException if this object is not a GL4 implementation
+ */
+ public GL4 getGL4() throws GLException;
+
+ /**
+ * Casts this object to the GL3bc interface.
+ * @throws GLException if this object is not a GL3bc implementation
+ */
+ public GL3bc getGL3bc() throws GLException;
+
+ /**
+ * Casts this object to the GL3 interface.
+ * @throws GLException if this object is not a GL3 implementation
+ */
+ public GL3 getGL3() throws GLException;
+
+ /**
+ * Casts this object to the GL2 interface.
+ * @throws GLException if this object is not a GL2 implementation
+ */
+ public GL2 getGL2() throws GLException;
+
+ /**
+ * Casts this object to the GLES1 interface.
+ * @throws GLException if this object is not a GLES1 implementation
+ */
+ public GLES1 getGLES1() throws GLException;
+
+ /**
+ * Casts this object to the GLES2 interface.
+ * @throws GLException if this object is not a GLES2 implementation
+ */
+ public GLES2 getGLES2() throws GLException;
+
+ /**
+ * Casts this object to the GLES3 interface.
+ * @throws GLException if this object is not a GLES3 implementation
+ */
+ public GLES3 getGLES3() throws GLException;
+
+ /**
+ * Casts this object to the GL2ES1 interface.
+ * @throws GLException if this object is not a GL2ES1 implementation
+ */
+ public GL2ES1 getGL2ES1() throws GLException;
+
+ /**
+ * Casts this object to the GL2ES2 interface.
+ * @throws GLException if this object is not a GL2ES2 implementation
+ */
+ public GL2ES2 getGL2ES2() throws GLException;
+
+ /**
+ * Casts this object to the GL2ES3 interface.
+ * @throws GLException if this object is not a GL2ES3 implementation
+ */
+ public GL2ES3 getGL2ES3() throws GLException;
+
+ /**
+ * Casts this object to the GL3ES3 interface.
+ * @throws GLException if this object is not a GL3ES3 implementation
+ */
+ public GL3ES3 getGL3ES3() throws GLException;
+
+ /**
+ * Casts this object to the GL4ES3 interface.
+ * @throws GLException if this object is not a GL4ES3 implementation
+ */
+ public GL4ES3 getGL4ES3() throws GLException;
+
+ /**
+ * Casts this object to the GL2GL3 interface.
+ * @throws GLException if this object is not a GL2GL3 implementation
+ */
+ public GL2GL3 getGL2GL3() throws GLException;
+
+ /**
+ * Returns the GLProfile associated with this GL object.
+ */
+ public GLProfile getGLProfile();
+
+ /**
+ * Returns the GLContext associated which this GL object.
+ */
+ public GLContext getContext();
+
+ /**
+ * Returns true if the specified OpenGL core- or extension-function can be
+ * used successfully through this GL instance given the current host (OpenGL
+ * client) and display (OpenGL server) configuration.
+ * By "successfully" we mean that the function is both callable
+ * on the machine running the program and available on the current
+ * display.
+ *
+ * In order to call a function successfully, the function must be both
+ * callable on the machine running the program and available on
+ * the display device that is rendering the output (note: on non-networked,
+ * single-display machines these two conditions are identical; on networked and/or
+ * multi-display machines this becomes more complicated). These conditions are
+ * met if the function is either part of the core OpenGL version supported by
+ * both the host and display, or it is an OpenGL extension function that both
+ * the host and display support.
+ *
+ * A GL function is callable if it is successfully linked at runtime,
+ * hence the GLContext must be made current at least once.
+ *
+ * @param glFunctionName the name of the OpenGL function (e.g., use
+ * "glBindRenderbufferEXT" or "glBindRenderbuffer" to check if {@link
+ * GL#glBindRenderbuffer(int,int)} is available).
+ */
+ public boolean isFunctionAvailable(String glFunctionName);
+
+ /**
+ * Returns true if the specified OpenGL extension can be
+ * used successfully through this GL instance given the current host (OpenGL
+ * client) and display (OpenGL server) configuration.
+ *
+ * @param glExtensionName the name of the OpenGL extension (e.g.,
+ * "GL_ARB_vertex_program").
+ */
+ public boolean isExtensionAvailable(String glExtensionName);
+
+ /**
+ * Returns true if basic FBO support is available, otherwise false.
+ *
+ * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= 3.0 [core, compat] or implements the extensions
+ * GL_ARB_ES2_compatibility, GL_ARB_framebuffer_object, GL_EXT_framebuffer_object or GL_OES_framebuffer_object.
+ *
+ *
+ * Basic FBO support may only include one color attachment and no multisampling,
+ * as well as limited internal formats for renderbuffer.
+ *
+ * @see GLContext#hasBasicFBOSupport()
+ */
+ public boolean hasBasicFBOSupport();
+
+ /**
+ * Returns true if full FBO support is available, otherwise false.
+ *
+ * Full FBO is supported if the context is either GL >= core 3.0 [ES, core, compat] or implements the extensions
+ * ARB_framebuffer_object, or all of
+ * EXT_framebuffer_object, EXT_framebuffer_multisample,
+ * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil.
+ *
+ *
+ * Full FBO support includes multiple color attachments and multisampling.
+ *
+ * @see GLContext#hasFullFBOSupport()
+ */
+ public boolean hasFullFBOSupport();
+
+ /**
+ * Returns the maximum number of FBO RENDERBUFFER samples
+ * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false.
+ * @see GLContext#getMaxRenderbufferSamples()
+ */
+ public int getMaxRenderbufferSamples();
+
+ /**
+ * Returns true if the GL context supports non power of two (NPOT) textures,
+ * otherwise false.
+ *
+ * NPOT textures are supported in OpenGL >= 3, GLES2 or if the
+ * 'GL_ARB_texture_non_power_of_two' extension is available.
+ *
+ */
+ public boolean isNPOTTextureAvailable();
+
+ public boolean isTextureFormatBGRA8888Available();
+
+ /** Provides a platform-independent way to specify the minimum swap
+ interval for buffer swaps. An argument of 0 disables
+ sync-to-vertical-refresh completely, while an argument of 1
+ causes the application to wait until the next vertical refresh
+ until swapping buffers. The default, which is platform-specific,
+ is usually either 0 or 1. This function is not guaranteed to
+ have an effect, and in particular only affects heavyweight
+ onscreen components.
+
+ @see #getSwapInterval
+ @throws GLException if this context is not the current
+ */
+ public void setSwapInterval(int interval);
+
+ /** Provides a platform-independent way to get the swap
+ interval set by {@link #setSwapInterval}.
+
+ If the interval is not set by {@link #setSwapInterval} yet,
+ -1 is returned, indicating that the platforms default
+ is being used.
+
+ @see #setSwapInterval
+ */
+ public int getSwapInterval();
+
+ /**
+ * Returns an object through which platform-specific OpenGL extensions
+ * (EGL, GLX, WGL, etc.) may be accessed. The data type of the returned
+ * object and its associated capabilities are undefined. Most
+ * applications will never need to call this method. It is highly
+ * recommended that any applications which do call this method perform
+ * all accesses on the returned object reflectively to guard
+ * themselves against changes to the implementation.
+ */
+ public Object getPlatformGLExtensions();
+
+ /**
+ * Returns an object providing access to the specified OpenGL
+ * extension. This is intended to provide a mechanism for vendors who
+ * wish to provide access to new OpenGL extensions without changing
+ * the public API of the core package. For example, a user may request
+ * access to extension "GL_VENDOR_foo" and receive back an object
+ * which implements a vendor-specified interface which can call the
+ * OpenGL extension functions corresponding to that extension. It is
+ * up to the vendor to specify both the extension name and Java API
+ * for accessing it, including which class or interface contains the
+ * functions.
+ *
+ *
+ *
+ * Note: it is the intent to add new extensions as quickly as possible
+ * to the core GL API. Therefore it is unlikely that most vendors will
+ * use this extension mechanism, but it is being provided for
+ * completeness.
+ */
+ public Object getExtension(String extensionName);
+
+ /** Aliased entrypoint of void {@native glClearDepth}(GLclampd depth); and void {@native glClearDepthf}(GLclampf depth); . */
+ public void glClearDepth( double depth );
+
+ /** Aliased entrypoint of void {@native glDepthRange}(GLclampd depth); and void {@native glDepthRangef}(GLclampf depth); . */
+ public void glDepthRange(double zNear, double zFar);
+
+ /**
+ * @param target a GL buffer (VBO) target as used in {@link GL#glBindBuffer(int, int)}, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}, {@link GL#GL_ARRAY_BUFFER}, ..
+ * @return the GL buffer name bound to a target via {@link GL#glBindBuffer(int, int)} or 0 if unbound.
+ * @see #getBufferStorage(int)
+ */
+ public int getBoundBuffer(int target);
+
+ /**
+ * @param bufferName a GL buffer name, generated with e.g. {@link GL#glGenBuffers(int, int[], int)} and used in {@link GL#glBindBuffer(int, int)}, {@link GL#glBufferData(int, long, java.nio.Buffer, int)} or {@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)}.
+ * @return the size of the given GL buffer storage, see {@link GLBufferStorage}
+ * @see #getBoundBuffer(int)
+ */
+ public GLBufferStorage getBufferStorage(int bufferName);
+
+ /**
+ * Returns the {@link GLBufferStorage} instance as mapped via OpenGL's native {@link GL#glMapBuffer(int, int) glMapBuffer(..)} implementation.
+ *
+ * Throws a {@link GLException} if GL-function constraints are not met.
+ *
+ *
+ * {@link GL#glMapBuffer(int, int)} wrapper calls this method and returns {@link GLBufferStorage#getMappedBuffer()}.
+ *
+ *
+ * A zero {@link GLBufferStorage#getSize()} will avoid a native call and returns the unmapped {@link GLBufferStorage}.
+ *
+ *
+ * A null native mapping result indicating an error will
+ * not cause a GLException but returns the unmapped {@link GLBufferStorage}.
+ * This allows the user to handle this case.
+ *
+ * @param target denotes the buffer via it's bound target
+ * @param access the mapping access mode
+ * @throws GLException if buffer is not bound to target
+ * @throws GLException if buffer is not tracked
+ * @throws GLException if buffer is already mapped
+ * @throws GLException if buffer has invalid store size, i.e. less-than zero
+ */
+ public GLBufferStorage mapBuffer(int target, int access) throws GLException;
+
+ /**
+ * Returns the {@link GLBufferStorage} instance as mapped via OpenGL's native {@link GL#glMapBufferRange(int, long, long, int) glMapBufferRange(..)} implementation.
+ *
+ * Throws a {@link GLException} if GL-function constraints are not met.
+ *
+ *
+ * {@link GL#glMapBufferRange(int, long, long, int)} wrapper calls this method and returns {@link GLBufferStorage#getMappedBuffer()}.
+ *
+ *
+ * A zero {@link GLBufferStorage#getSize()} will avoid a native call and returns the unmapped {@link GLBufferStorage}.
+ *
+ *
+ * A null native mapping result indicating an error will
+ * not cause a GLException but returns the unmapped {@link GLBufferStorage}.
+ * This allows the user to handle this case.
+ *
+ * @param target denotes the buffer via it's bound target
+ * @param offset offset of the mapped buffer's storage
+ * @param length length of the mapped buffer's storage
+ * @param access the mapping access mode
+ * @throws GLException if buffer is not bound to target
+ * @throws GLException if buffer is not tracked
+ * @throws GLException if buffer is already mapped
+ * @throws GLException if buffer has invalid store size, i.e. less-than zero
+ * @throws GLException if buffer mapping range does not fit, incl. offset
+ */
+ public GLBufferStorage mapBufferRange(final int target, final long offset, final long length, final int access) throws GLException;
+
+ /**
+ * @return true if a VBO is bound to {@link GL#GL_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false
+ */
+ public boolean isVBOArrayBound();
+
+ /**
+ * @return true if a VBO is bound to {@link GL#GL_ELEMENT_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false
+ */
+ public boolean isVBOElementArrayBound();
+
+ /**
+ * Return the framebuffer name bound to this context,
+ * see {@link GL#glBindFramebuffer(int, int)}.
+ *
+ */
+ public int getDefaultReadFramebuffer();
+
+ /**
+ * Returns the default color buffer within the current bound
+ * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER,
+ * which will be used as the source for pixel reading commands,
+ * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels} etc.
+ *
+ * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0},
+ * otherwise this is {@link GL#GL_FRONT} for single buffer configurations
+ * and {@link GL#GL_BACK} for double buffer configurations.
+ *
+ *
+ * Note-1: Neither ES1 nor ES2 supports selecting the read buffer via glReadBuffer
+ * and {@link GL#GL_BACK} is the default.
+ *
+ *
+ * Note-2: ES3 only supports {@link GL#GL_BACK}, {@link GL#GL_NONE} or {@link GL#GL_COLOR_ATTACHMENT0}+i
+ *
+ *
+ * Note-3: See {@link com.jogamp.opengl.util.GLDrawableUtil#swapBuffersBeforeRead(GLCapabilitiesImmutable) swapBuffersBeforeRead}
+ * for read-pixels and swap-buffers implications.
+ *
+ */
+ public int getDefaultReadBuffer();
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/GLBufferStorage.java b/src/jogl/classes/com/jogamp/opengl/GLBufferStorage.java
new file mode 100644
index 000000000..5db97d42f
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLBufferStorage.java
@@ -0,0 +1,160 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl;
+
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+
+/**
+ * OpenGL buffer storage object reflecting it's
+ *
+ *
storage size
+ *
storage memory if mapped
+ *
mutable usage or immutable flags
+ *
+ *
+ * Buffer storage is created via:
+ *
+ *
glBufferStorage - storage creation with target
+ *
{@link GL#glBufferData(int, long, java.nio.Buffer, int)} - storage recreation with target
+ *
{@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)} - storage recreation, direct
+ *
+ * Note that storage recreation as mentioned above also invalidate a previous storage instance,
+ * i.e. disposed the buffer's current storage if exist and attaches a new storage instance.
+ *
+ *
+ * Buffer storage is disposed via:
+ *
+ *
{@link GL#glDeleteBuffers(int, IntBuffer)} - explicit, direct, via {@link #notifyBuffersDeleted(int, IntBuffer)} or {@link #notifyBuffersDeleted(int, int[], int)}
+ *
{@link GL#glBufferData(int, long, java.nio.Buffer, int)} - storage recreation via target
+ *
{@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)} - storage recreation, direct
+ *
+ */
+public abstract class GLBufferStorage {
+ private final int name;
+ private /* final */ long size;
+ private /* final */ int mutableUsage;
+ private /* final */ int immutableFlags;
+ private ByteBuffer mappedBuffer;
+
+ protected GLBufferStorage(final int name, final long size, final int mutableUsage, final int immutableFlags) {
+ this.name = name;
+ this.size = size;
+ this.mutableUsage = mutableUsage;
+ this.immutableFlags = immutableFlags;
+ this.mappedBuffer = null;
+ }
+
+ protected void reset(final long size, final int mutableUsage, final int immutableFlags) {
+ this.size = size;
+ this.mutableUsage = mutableUsage;
+ this.immutableFlags = immutableFlags;
+ this.mappedBuffer = null;
+ }
+ protected void setMappedBuffer(final ByteBuffer buffer) {
+ this.mappedBuffer = buffer;
+ }
+
+ /** Return the buffer name */
+ public final int getName() { return name; }
+
+ /** Return the buffer's storage size. */
+ public final long getSize() { return size; }
+
+ /**
+ * Returns true if buffer's storage is mutable, i.e.
+ * created via {@link GL#glBufferData(int, long, java.nio.Buffer, int)}.
+ *
+ * Returns false if buffer's storage is immutable, i.e.
+ * created via glBufferStorage. FIXME: Add GL 4.4 support!
+ *
+ * @return
+ */
+ public final boolean isMutableStorage() { return 0 != mutableUsage; }
+
+ /**
+ * Returns the mutable storage usage or 0 if storage is not {@link #isMutableStorage() mutable}.
+ */
+ public final int getMutableUsage() { return mutableUsage; }
+
+ /**
+ * Returns the immutable storage flags, invalid if storage is {@link #isMutableStorage() mutable}.
+ */
+ public final int getImmutableFlags() { return immutableFlags; }
+
+ /**
+ * Returns the mapped ByteBuffer, or null if not mapped.
+ * Mapping may occur via:
+ *
+ * If enabled this method also invokes {@link #setOnscreen(boolean) setOnscreen(false)}.
+ *
+ *
+ * Defaults to false.
+ *
+ *
+ * Requesting offscreen FBO mode disables the offscreen auto selection.
+ *
+ */
+ public void setFBO(final boolean enable) {
+ if(enable) {
+ setOnscreen(false);
+ }
+ isFBO = enable;
+ }
+
+ @Override
+ public final boolean getDoubleBuffered() {
+ return doubleBuffered;
+ }
+
+ /** Enables or disables double buffering. */
+ public void setDoubleBuffered(final boolean enable) {
+ doubleBuffered = enable;
+ }
+
+ @Override
+ public final boolean getStereo() {
+ return stereo;
+ }
+
+ /** Enables or disables stereo viewing. */
+ public void setStereo(final boolean enable) {
+ stereo = enable;
+ }
+
+ @Override
+ public final boolean getHardwareAccelerated() {
+ return hardwareAccelerated;
+ }
+
+ /** Enables or disables hardware acceleration. */
+ public void setHardwareAccelerated(final boolean enable) {
+ hardwareAccelerated = enable;
+ }
+
+ @Override
+ public final int getDepthBits() {
+ return depthBits;
+ }
+
+ /** Sets the number of bits requested for the depth buffer. */
+ public void setDepthBits(final int depthBits) {
+ this.depthBits = depthBits;
+ }
+
+ @Override
+ public final int getStencilBits() {
+ return stencilBits;
+ }
+
+ /** Sets the number of bits requested for the stencil buffer. */
+ public void setStencilBits(final int stencilBits) {
+ this.stencilBits = stencilBits;
+ }
+
+ @Override
+ public final int getAccumRedBits() {
+ return accumRedBits;
+ }
+
+ /** Sets the number of bits requested for the accumulation buffer's
+ red component. On some systems only the accumulation buffer
+ depth, which is the sum of the red, green, and blue bits, is
+ considered. */
+ public void setAccumRedBits(final int accumRedBits) {
+ this.accumRedBits = accumRedBits;
+ }
+
+ @Override
+ public final int getAccumGreenBits() {
+ return accumGreenBits;
+ }
+
+ /** Sets the number of bits requested for the accumulation buffer's
+ green component. On some systems only the accumulation buffer
+ depth, which is the sum of the red, green, and blue bits, is
+ considered. */
+ public void setAccumGreenBits(final int accumGreenBits) {
+ this.accumGreenBits = accumGreenBits;
+ }
+
+ @Override
+ public final int getAccumBlueBits() {
+ return accumBlueBits;
+ }
+
+ /** Sets the number of bits requested for the accumulation buffer's
+ blue component. On some systems only the accumulation buffer
+ depth, which is the sum of the red, green, and blue bits, is
+ considered. */
+ public void setAccumBlueBits(final int accumBlueBits) {
+ this.accumBlueBits = accumBlueBits;
+ }
+
+ @Override
+ public final int getAccumAlphaBits() {
+ return accumAlphaBits;
+ }
+
+ /** Sets number of bits requested for accumulation buffer's alpha
+ component. On some systems only the accumulation buffer depth,
+ which is the sum of the red, green, and blue bits, is
+ considered. */
+ public void setAccumAlphaBits(final int accumAlphaBits) {
+ this.accumAlphaBits = accumAlphaBits;
+ }
+
+ /**
+ * Sets the desired extension for full-scene antialiasing
+ * (FSAA), default is {@link #DEFAULT_SAMPLE_EXTENSION}.
+ */
+ public void setSampleExtension(final String se) {
+ sampleExtension = se;
+ }
+
+ @Override
+ public final String getSampleExtension() {
+ return sampleExtension;
+ }
+
+ /**
+ * Defaults to false.
+ * Indicates whether sample buffers for full-scene antialiasing
+ * (FSAA) should be allocated for this drawable.
+ * Mind that this requires the alpha component.
+ * If enabled this method also invokes {@link #setAlphaBits(int) setAlphaBits(1)}
+ * if {@link #getAlphaBits()} == 0.
+ */
+ public void setSampleBuffers(final boolean enable) {
+ sampleBuffers = enable;
+ if(sampleBuffers && getAlphaBits()==0) {
+ setAlphaBits(1);
+ }
+ }
+
+ @Override
+ public final boolean getSampleBuffers() {
+ return sampleBuffers;
+ }
+
+ /**
+ * If sample buffers are enabled, indicates the number of buffers
+ * to be allocated. Defaults to 2.
+ * @see #getNumSamples()
+ */
+ public void setNumSamples(final int numSamples) {
+ this.numSamples = numSamples;
+ }
+
+ @Override
+ public final int getNumSamples() {
+ return sampleBuffers ? numSamples : 0;
+ }
+
+ @Override
+ public StringBuilder toString(StringBuilder sink) {
+ if(null == sink) {
+ sink = new StringBuilder();
+ }
+
+ final int samples = sampleBuffers ? numSamples : 0 ;
+
+ super.toString(sink, false);
+
+ sink.append(", accum-rgba ").append(accumRedBits).append(ESEP).append(accumGreenBits).append(ESEP).append(accumBlueBits).append(ESEP).append(accumAlphaBits);
+ sink.append(", dp/st/ms ").append(depthBits).append(ESEP).append(stencilBits).append(ESEP).append(samples);
+ if(samples>0) {
+ sink.append(", sample-ext ").append(sampleExtension);
+ }
+ if(doubleBuffered) {
+ sink.append(", dbl");
+ } else {
+ sink.append(", one");
+ }
+ if(stereo) {
+ sink.append(", stereo");
+ } else {
+ sink.append(", mono ");
+ }
+ if(hardwareAccelerated) {
+ sink.append(", hw, ");
+ } else {
+ sink.append(", sw, ");
+ }
+ sink.append(glProfile);
+ if(isOnscreen()) {
+ sink.append(", on-scr[");
+ } else {
+ sink.append(", offscr[");
+ }
+ boolean ns=false;
+ if(isFBO()) {
+ sink.append("fbo");
+ ns = true;
+ }
+ if(isPBuffer()) {
+ if(ns) { sink.append(CSEP); }
+ sink.append("pbuffer");
+ ns = true;
+ }
+ if(isBitmap()) {
+ if(ns) { sink.append(CSEP); }
+ sink.append("bitmap");
+ ns = true;
+ }
+ if(!ns) { // !FBO !PBuffer !Bitmap
+ if(isOnscreen()) {
+ sink.append("."); // no additional off-screen modes besides on-screen
+ } else {
+ sink.append("auto-cfg"); // auto-config off-screen mode
+ }
+ }
+ sink.append("]");
+
+ return sink;
+ }
+
+ /** Returns a textual representation of this GLCapabilities
+ object. */
+ @Override
+ public String toString() {
+ final StringBuilder msg = new StringBuilder();
+ msg.append("GLCaps[");
+ toString(msg);
+ msg.append("]");
+ return msg.toString();
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLCapabilitiesChooser.java b/src/jogl/classes/com/jogamp/opengl/GLCapabilitiesChooser.java
new file mode 100644
index 000000000..9911d1314
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLCapabilitiesChooser.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.opengl;
+
+import java.util.List;
+
+import com.jogamp.nativewindow.CapabilitiesImmutable;
+import com.jogamp.nativewindow.CapabilitiesChooser;
+
+import com.jogamp.opengl.GLCapabilitiesImmutable;
+
+/** Provides a mechanism by which applications can customize the
+ window type selection for a given {@link GLCapabilities}.
+ Developers can implement this interface and pass an instance into
+ the appropriate method of {@link GLDrawableFactory}; the chooser
+ will be called during the OpenGL context creation process. Note
+ that this is only a marker interface; its signature is the same as
+ {@link CapabilitiesChooser} and the {@link List} of
+ objects extending {@link CapabilitiesImmutable}
+ passed to {@link #chooseCapabilities chooseCapabilities}
+ is actually a {@link List} of type {@link GLCapabilitiesImmutable}. */
+
+public interface GLCapabilitiesChooser extends CapabilitiesChooser {
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/com/jogamp/opengl/GLCapabilitiesImmutable.java
new file mode 100644
index 000000000..25081a521
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLCapabilitiesImmutable.java
@@ -0,0 +1,178 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl;
+
+import com.jogamp.nativewindow.CapabilitiesImmutable;
+
+/**
+ * Specifies an immutable set of OpenGL capabilities.
+ *
+ * @see com.jogamp.opengl.GLCapabilities
+ * @see com.jogamp.nativewindow.CapabilitiesImmutable
+ */
+public interface GLCapabilitiesImmutable extends CapabilitiesImmutable {
+ /**
+ * One of the platform's default sample extension
+ * EGL.EGL_SAMPLES, GLX.GLX_SAMPLES, WGLExt.WGL_SAMPLES_ARB
+ * if available, or any other known fallback one, ie EGLExt.EGL_COVERAGE_SAMPLES_NV
+ */
+ public static final String DEFAULT_SAMPLE_EXTENSION = "default" ;
+
+ /**
+ * Returns the GL profile you desire or used by the drawable.
+ */
+ GLProfile getGLProfile();
+
+ /**
+ * Returns the number of bits for the accumulation
+ * buffer's alpha component. On some systems only the accumulation
+ * buffer depth, which is the sum of the red, green, and blue bits,
+ * is considered.
+ */
+ int getAccumAlphaBits();
+
+ /**
+ * Returns the number of bits for the accumulation
+ * buffer's blue component. On some systems only the accumulation
+ * buffer depth, which is the sum of the red, green, and blue bits,
+ * is considered.
+ */
+ int getAccumBlueBits();
+
+ /**
+ * Returns the number of bits for the accumulation
+ * buffer's green component. On some systems only the accumulation
+ * buffer depth, which is the sum of the red, green, and blue bits,
+ * is considered.
+ */
+ int getAccumGreenBits();
+
+ /**
+ * Returns the number of bits for the accumulation
+ * buffer's red component. On some systems only the accumulation
+ * buffer depth, which is the sum of the red, green, and blue bits,
+ * is considered.
+ */
+ int getAccumRedBits();
+
+ /**
+ * Returns the number of depth buffer bits.
+ */
+ int getDepthBits();
+
+ /**
+ * Returns whether double-buffering is requested, available or chosen.
+ *
+ * Default is true.
+ *
+ */
+ boolean getDoubleBuffered();
+
+ /**
+ * Returns whether hardware acceleration is requested, available or chosen.
+ *
+ * Default is {@link #DEFAULT_SAMPLE_EXTENSION}.
+ *
+ */
+ String getSampleExtension();
+
+ /**
+ * Returns whether sample buffers for full-scene antialiasing
+ * (FSAA) should be allocated for this drawable.
+ *
+ * Default is false.
+ *
+ */
+ boolean getSampleBuffers();
+
+ /**
+ * Returns the number of sample buffers to be allocated if sample
+ * buffers are enabled, otherwise returns 0.
+ *
+ * Default is 0 due to disable sample buffers per default.
+ *
+ */
+ int getNumSamples();
+
+ /**
+ * Returns the number of stencil buffer bits.
+ *
+ * Default is 0.
+ *
+ */
+ int getStencilBits();
+
+ /**
+ * Returns whether stereo is requested, available or chosen.
+ *
+ * Default is false.
+ *
+ */
+ boolean getStereo();
+
+ /**
+ * Returns whether pbuffer offscreen mode is requested, available or chosen.
+ *
+ * Default is false.
+ *
+ *
+ * For chosen capabilities, only the selected offscreen surface is set to true.
+ *
+ */
+ boolean isPBuffer();
+
+ /**
+ * Returns whether FBO offscreen mode is requested, available or chosen.
+ *
+ * Default is false.
+ *
+ *
+ * For chosen capabilities, only the selected offscreen surface is set to true.
+ *
+ */
+ boolean isFBO();
+
+ @Override
+ boolean equals(Object obj);
+
+ @Override
+ int hashCode();
+
+ @Override
+ String toString();
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLContext.java b/src/jogl/classes/com/jogamp/opengl/GLContext.java
new file mode 100644
index 000000000..6366c4e37
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLContext.java
@@ -0,0 +1,2038 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.opengl;
+
+import java.nio.IntBuffer;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import com.jogamp.nativewindow.AbstractGraphicsDevice;
+import com.jogamp.nativewindow.NativeSurface;
+
+import jogamp.opengl.Debug;
+import jogamp.opengl.GLContextImpl;
+import jogamp.opengl.GLContextShareSet;
+
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.VersionNumber;
+import com.jogamp.common.util.VersionNumberString;
+import com.jogamp.common.util.locks.LockFactory;
+import com.jogamp.common.util.locks.RecursiveLock;
+import com.jogamp.opengl.GLExtensions;
+import com.jogamp.opengl.GLRendererQuirks;
+
+/** Abstraction for an OpenGL rendering context. In order to perform
+ OpenGL rendering, a context must be "made current" on the current
+ thread. OpenGL rendering semantics specify that only one context
+ may be current on the current thread at any given time, and also
+ that a given context may be current on only one thread at any
+ given time. Because components can be added to and removed from
+ the component hierarchy at any time, it is possible that the
+ underlying OpenGL context may need to be destroyed and recreated
+ multiple times over the lifetime of a given component. This
+ process is handled by the implementation, and the GLContext
+ abstraction provides a stable object which clients can use to
+ refer to a given context. */
+public abstract class GLContext {
+
+ public static final boolean DEBUG = Debug.debug("GLContext");
+ public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true);
+ public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH;
+
+ /**
+ * If true (default), bootstrapping the available GL profiles
+ * will use the highest compatible GL context for each profile,
+ * hence skipping querying lower profiles if a compatible higher one is found:
+ *
+ *
4.2-core -> 4.2-core, 3.3-core
+ *
4.2-comp -> 4.2-comp, 3.3-comp, 2
+ *
+ * Otherwise the dedicated GL context would be queried and used:
+ *
+ *
4.2-core -> 4.2-core
+ *
3.3-core -> 3.3-core
+ *
4.2-comp -> 4.2-comp
+ *
3.3-comp -> 3.3-comp
+ *
3.0-comp -> 2
+ *
+ * Using aliasing speeds up initialization about:
+ *
+ *
Linux x86_64 - Nvidia: 28%, 700ms down to 500ms
+ *
Linux x86_64 - AMD : 40%, 1500ms down to 900ms
+ *
+ * Can be turned off with property jogl.debug.GLContext.NoProfileAliasing.
+ *
+ */
+ public static final boolean PROFILE_ALIASING = !Debug.isPropertyDefined("jogl.debug.GLContext.NoProfileAliasing", true);
+
+ protected static final boolean FORCE_NO_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.none", true);
+ protected static final boolean FORCE_MIN_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.min", true);
+ protected static final boolean FORCE_NO_COLOR_RENDERBUFFER = Debug.isPropertyDefined("jogl.fbo.force.nocolorrenderbuffer", true);
+
+ /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */
+ public static final boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true);
+ /** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */
+ public static final boolean TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true);
+
+ /** Indicates that the context was not made current during the last call to {@link #makeCurrent makeCurrent}, value {@value}. */
+ public static final int CONTEXT_NOT_CURRENT = 0;
+ /** Indicates that the context was made current during the last call to {@link #makeCurrent makeCurrent}, value {@value}. */
+ public static final int CONTEXT_CURRENT = 1;
+ /** Indicates that a newly-created context was made current during the last call to {@link #makeCurrent makeCurrent}, value {@value}. */
+ public static final int CONTEXT_CURRENT_NEW = 2;
+
+ /** Version 1.00, i.e. GLSL 1.00 for ES 2.0. */
+ public static final VersionNumber Version1_0 = new VersionNumber(1, 0, 0);
+ /** Version 1.10, i.e. GLSL 1.10 for GL 2.0. */
+ public static final VersionNumber Version1_10 = new VersionNumber(1, 10, 0);
+ /** Version 1.20, i.e. GLSL 1.20 for GL 2.1. */
+ public static final VersionNumber Version1_20 = new VersionNumber(1, 20, 0);
+ /** Version 1.30, i.e. GLSL 1.30 for GL 3.0. */
+ public static final VersionNumber Version1_30 = new VersionNumber(1, 30, 0);
+ /** Version 1.40, i.e. GLSL 1.40 for GL 3.1. */
+ public static final VersionNumber Version1_40 = new VersionNumber(1, 40, 0);
+ /** Version 1.50, i.e. GLSL 1.50 for GL 3.2. */
+ public static final VersionNumber Version1_50 = new VersionNumber(1, 50, 0);
+
+ /** Version 1.1, i.e. GL 1.1 */
+ public static final VersionNumber Version1_1 = new VersionNumber(1, 1, 0);
+
+ /** Version 1.2, i.e. GL 1.2 */
+ public static final VersionNumber Version1_2 = new VersionNumber(1, 2, 0);
+
+ /** Version 1.4, i.e. GL 1.4 */
+ public static final VersionNumber Version1_4 = new VersionNumber(1, 4, 0);
+
+ /** Version 1.5, i.e. GL 1.5 */
+ public static final VersionNumber Version1_5 = new VersionNumber(1, 5, 0);
+
+ /** Version 3.0. As an OpenGL version, it qualifies for desktop {@link #isGL2()} only, or ES 3.0. Or GLSL 3.00 for ES 3.0. */
+ public static final VersionNumber Version3_0 = new VersionNumber(3, 0, 0);
+
+ /** Version 3.1. As an OpenGL version, it qualifies for {@link #isGL3core()}, {@link #isGL3bc()} and {@link #isGL3()} */
+ public static final VersionNumber Version3_1 = new VersionNumber(3, 1, 0);
+
+ /** Version 3.2. As an OpenGL version, it qualifies for geometry shader */
+ public static final VersionNumber Version3_2 = new VersionNumber(3, 2, 0);
+
+ /** Version 4.3. As an OpenGL version, it qualifies for GL_ARB_ES3_compatibility */
+ public static final VersionNumber Version4_3 = new VersionNumber(4, 3, 0);
+
+ protected static final VersionNumber Version8_0 = new VersionNumber(8, 0, 0);
+
+ private static final String S_EMPTY = "";
+
+ //
+ // Cached keys, bits [0..15]
+ //
+
+ /** Context option bits, full bit mask covering 16 bits [0..15], i.e. 0x0000FFFF, {@value}. */
+ protected static final int CTX_IMPL_FULL_MASK = 0x0000FFFF;
+
+ /** Context option bits, cached bit mask covering 10 bits [0..9], i.e. 0x000003FF, {@value}. Leaving 6 bits for non cached options, i.e. 10:6. */
+ protected static final int CTX_IMPL_CACHE_MASK = 0x000003FF;
+
+ /** ARB_create_context related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
+ protected static final int CTX_IS_ARB_CREATED = 1 << 0;
+ /** ARB_create_context related: desktop compatibility profile. Cache key value. See {@link #isGLCompatibilityProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
+ protected static final int CTX_PROFILE_COMPAT = 1 << 1;
+ /** ARB_create_context related: desktop core profile. Cache key value. See {@link #isGLCoreProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
+ protected static final int CTX_PROFILE_CORE = 1 << 2;
+ /** ARB_create_context related: ES profile. Cache key value. See {@link #isGLES()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
+ protected static final int CTX_PROFILE_ES = 1 << 3;
+ /** ARB_create_context related: flag forward compatible. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
+ protected static final int CTX_OPTION_FORWARD = 1 << 4;
+ /** ARB_create_context related: flag debug. Cache key value. See {@link #setContextCreationFlags(int)}, {@link GLAutoDrawable#setContextCreationFlags(int)}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
+ public static final int CTX_OPTION_DEBUG = 1 << 5;
+ /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. See {@link #isHardwareRasterizer()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
+ protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 6;
+
+ //
+ // Non cached keys, 6 bits [10..15]
+ //
+
+ /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
+ protected static final int CTX_IMPL_ES2_COMPAT = 1 << 10;
+
+ /** GL_ARB_ES3_compatibility implementation related: Context is compatible w/ ES3. Not a cache key. See {@link #isGLES3Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
+ protected static final int CTX_IMPL_ES3_COMPAT = 1 << 11;
+
+ /**
+ * Context supports basic FBO, details see {@link #hasBasicFBOSupport()}.
+ * Not a cache key.
+ * @see #hasBasicFBOSupport()
+ * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)
+ */
+ protected static final int CTX_IMPL_FBO = 1 << 12;
+
+ /**
+ * Context supports OES_single_precision, fp32, fixed function point (FFP) compatibility entry points,
+ * see {@link #hasFP32CompatAPI()}.
+ * Not a cache key.
+ * @see #hasFP32CompatAPI()
+ * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)
+ */
+ protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 13;
+
+ private static final ThreadLocal currentContext = new ThreadLocal();
+
+ private final HashMap attachedObjects = new HashMap();
+
+ // RecursiveLock maintains a queue of waiting Threads, ensuring the longest waiting thread will be notified at unlock.
+ protected final RecursiveLock lock = LockFactory.createRecursiveLock(); // FIXME: Move to GLContextImpl when incr. minor version (incompatible change)
+
+ /** The underlying native OpenGL context */
+ protected volatile long contextHandle; // volatile: avoid locking for read-only access
+
+ protected GLContext() {
+ resetStates(true);
+ }
+
+ protected VersionNumber ctxVersion;
+ protected int ctxOptions;
+ protected String ctxVersionString;
+ protected VersionNumberString ctxVendorVersion;
+ protected VersionNumber ctxGLSLVersion;
+ private int currentSwapInterval;
+ protected GLRendererQuirks glRendererQuirks;
+
+ /** Did the drawable association changed ? see {@link GLRendererQuirks#NoSetSwapIntervalPostRetarget} */
+ protected boolean drawableRetargeted;
+
+ /**
+ * @param isInit true if called for class initialization, otherwise false (re-init or destruction).
+ */
+ protected void resetStates(final boolean isInit) {
+ if (DEBUG) {
+ System.err.println(getThreadName() + ": GLContext.resetStates(isInit "+isInit+")");
+ // Thread.dumpStack();
+ }
+ ctxVersion = VersionNumberString.zeroVersion;
+ ctxVendorVersion = VersionNumberString.zeroVersion;
+ ctxOptions=0;
+ ctxVersionString=null;
+ ctxGLSLVersion = VersionNumber.zeroVersion;
+ attachedObjects.clear();
+ contextHandle=0;
+ currentSwapInterval = -1;
+ glRendererQuirks = null;
+ drawableRetargeted = false;
+ }
+
+ /** Returns true if this GLContext is shared, otherwise false. */
+ public final boolean isShared() {
+ return GLContextShareSet.isShared(this);
+ }
+
+ /**
+ * Returns the shared master GLContext of this GLContext if shared, otherwise return null.
+ *
+ * Returns this GLContext, if it is a shared master.
+ *
+ * @since 2.2.1
+ */
+ public final GLContext getSharedMaster() {
+ return GLContextShareSet.getSharedMaster(this);
+ }
+
+ /** Returns a new list of created GLContext shared with this GLContext. */
+ public final List getCreatedShares() {
+ return GLContextShareSet.getCreatedShares(this);
+ }
+
+ /** Returns a new list of destroyed GLContext shared with this GLContext. */
+ public final List getDestroyedShares() {
+ return GLContextShareSet.getDestroyedShares(this);
+ }
+
+ /**
+ * Returns the instance of {@link GLRendererQuirks}, allowing one to determine workarounds.
+ * @return instance of {@link GLRendererQuirks} if context was made current once, otherwise null.
+ */
+ public final GLRendererQuirks getRendererQuirks() { return glRendererQuirks; }
+
+ /**
+ * Returns true if the quirk exist in {@link #getRendererQuirks()}, otherwise false.
+ *
+ *
+ * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}.
+ * @throws IllegalArgumentException if the quirk is out of range
+ */
+ public final boolean hasRendererQuirk(final int quirk) throws IllegalArgumentException {
+ return null != glRendererQuirks ? glRendererQuirks.exist(quirk) : false ;
+ }
+
+ /**
+ * Sets the read/write drawable for framebuffer operations, i.e. reassociation of the context's drawable.
+ *
+ * If the arguments reflect the current state of this context
+ * this method is a no-operation and returns the old and current {@link GLDrawable}.
+ *
+ *
+ * Remarks:
+ *
+ *
{@link GL#glFinish() glFinish()} is issued if context {@link #isCreated()} and a {@link #getGLDrawable() previous drawable} was bound before disassociation.
+ *
If the context was current on this thread, it is being released before drawable reassociation
+ * and made current afterwards.
+ *
Implementation may issue {@link #makeCurrent()} and {@link #release()} while drawable reassociation.
+ *
The user shall take extra care of thread synchronization,
+ * i.e. lock the involved {@link GLDrawable#getNativeSurface() drawable's} {@link NativeSurface}s
+ * to avoid a race condition. In case {@link GLAutoDrawable auto-drawable's} are used,
+ * their {@link GLAutoDrawable#getUpstreamLock() upstream-lock} must be locked beforehand
+ * see GLAutoDrawable Locking.
+ *
+ *
+ * @param readWrite The read/write drawable for framebuffer operations, maybe null to remove association.
+ * @param setWriteOnly Only change the write-drawable, if setWriteOnly is true and
+ * if the {@link #getGLReadDrawable() read-drawable} differs
+ * from the {@link #getGLDrawable() write-drawable}.
+ * Otherwise set both drawables, read and write.
+ * @return The previous read/write drawable if operation succeeds
+ *
+ * @throws GLException in case null is being passed,
+ * this context is made current on another thread
+ * or operation fails.
+ *
+ * @see #isGLReadDrawableAvailable()
+ * @see #setGLReadDrawable(GLDrawable)
+ * @see #getGLReadDrawable()
+ * @see #setGLDrawable(GLDrawable, boolean)
+ * @see #getGLDrawable()
+ */
+ public abstract GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly);
+
+ /**
+ * Returns the write-drawable this context uses for framebuffer operations.
+ *
+ * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)},
+ * it equals to the write-drawable (default).
+ *
+ *
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ *
+ * @see #setGLDrawable(GLDrawable, boolean)
+ * @see #setGLReadDrawable(GLDrawable)
+ */
+ public abstract GLDrawable getGLDrawable();
+
+ /**
+ * Query whether using a distinguished read-drawable is supported.
+ * @return true if using a read-drawable is supported with your driver/OS, otherwise false.
+ */
+ public abstract boolean isGLReadDrawableAvailable();
+
+ /**
+ * Set the read-Drawable for read framebuffer operations.
+ * The caller should query if this feature is supported via {@link #isGLReadDrawableAvailable()}.
+ *
+ * If the context was current on this thread, it is being released before switching the drawable
+ * and made current afterwards. However the user shall take extra care that not other thread
+ * attempts to make this context current. Otherwise a race condition may happen.
+ *
+ *
+ * @param read the read-drawable for read framebuffer operations.
+ * If null is passed, the default write drawable will be set.
+ * @return the previous read-drawable
+ *
+ * @throws GLException in case a read drawable is not supported or
+ * this context is made current on another thread.
+ *
+ * @see #isGLReadDrawableAvailable()
+ * @see #getGLReadDrawable()
+ */
+ public abstract GLDrawable setGLReadDrawable(GLDrawable read);
+
+ /**
+ * Returns the read-Drawable this context uses for read framebuffer operations.
+ *
+ * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)},
+ * it equals to the write-drawable (default).
+ *
+ *
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ *
+ * @see #isGLReadDrawableAvailable()
+ * @see #setGLReadDrawable(GLDrawable)
+ * @see #getGLReadDrawable()
+ */
+ public abstract GLDrawable getGLReadDrawable();
+
+ /**
+ * Makes this GLContext current on the calling thread.
+ *
+ * Recursive call to {@link #makeCurrent()} and hence {@link #release()} are supported.
+ *
+ *
+ * There are two return values that indicate success and one that
+ * indicates failure.
+ *
+ *
+ * A return value of {@link #CONTEXT_CURRENT_NEW}
+ * indicates that that context has been made current for the 1st time,
+ * or that the state of the underlying context or drawable has
+ * changed since the last time this context was current.
+ * In this case, the application may wish to initialize the render state.
+ *
+ *
+ * A return value of {@link #CONTEXT_CURRENT} indicates that the context has
+ * been made current, with its previous state restored.
+ *
+ *
+ * If the context could not be made current (for example, because
+ * the underlying drawable has not ben realized on the display) ,
+ * a value of {@link #CONTEXT_NOT_CURRENT} is returned.
+ *
+ *
+ * This method is blocking, i.e. waits until another thread has
+ * released the context.
+ *
+ *
+ * The drawable's surface is being locked at entry
+ * and unlocked at {@link #release()}
+ *
+ *
+ * @return
+ *
{@link #CONTEXT_CURRENT_NEW} if the context was successfully made current the 1st time,
+ *
{@link #CONTEXT_CURRENT} if the context was successfully made current,
+ *
{@link #CONTEXT_NOT_CURRENT} if the context could not be made current.
+ *
+ *
+ * @throws GLException if the context could not be created
+ * or made current due to non-recoverable, system-specific errors.
+ */
+ public abstract int makeCurrent() throws GLException;
+
+ /**
+ * Releases control of this GLContext from the current thread.
+ *
+ * Recursive call to {@link #release()} and hence {@link #makeCurrent()} are supported.
+ *
+ *
+ * The drawable's surface is being unlocked at exit,
+ * assumed to be locked by {@link #makeCurrent()}.
+ *
+ *
+ * @throws GLException if the context had not previously been made
+ * current on the current thread
+ */
+ public abstract void release() throws GLException;
+
+ /**
+ * Copies selected groups of OpenGL state variables from the
+ * supplied source context into this one. The mask
+ * parameter indicates which groups of state variables are to be
+ * copied. mask contains the bitwise OR of the same
+ * symbolic names that are passed to the GL command {@link
+ * GL2#glPushAttrib glPushAttrib}. The single symbolic constant
+ * {@link GL2#GL_ALL_ATTRIB_BITS GL_ALL_ATTRIB_BITS} can be used to
+ * copy the maximum possible portion of rendering state.
+ *
+ * Not all values for GL state can be copied. For example, pixel
+ * pack and unpack state, render mode state, and select and feedback
+ * state are not copied. The state that can be copied is exactly the
+ * state that is manipulated by the GL command {@link
+ * GL2#glPushAttrib glPushAttrib}.
+ *
+ * On most platforms, this context may not be current to any thread,
+ * including the calling thread, when this method is called. Some
+ * platforms have additional requirements such as whether this
+ * context or the source context must occasionally be made current
+ * in order for the results of the copy to be seen; these
+ * requirements are beyond the scope of this specification.
+ *
+ * @param source the source OpenGL context from which to copy state
+ * @param mask a mask of symbolic names indicating which groups of state to copy
+
+ * @throws GLException if an OpenGL-related error occurred
+ */
+ public abstract void copy(GLContext source, int mask) throws GLException;
+
+ /**
+ * Returns the GL object bound to this thread current context.
+ * If no context is current, throw an GLException
+ *
+ * @return the current context's GL object on this thread
+ * @throws GLException if no context is current
+ */
+ public static GL getCurrentGL() throws GLException {
+ final GLContext glc = getCurrent();
+ if(null==glc) {
+ throw new GLException(getThreadName()+": No OpenGL context current on this thread");
+ }
+ return glc.getGL();
+ }
+
+ /**
+ * Returns this thread current context.
+ * If no context is current, returns null.
+ *
+ * @return the context current on this thread, or null if no context
+ * is current.
+ */
+ public static GLContext getCurrent() {
+ return currentContext.get();
+ }
+
+ /**
+ * @return true if this GLContext is current on this thread
+ */
+ public final boolean isCurrent() {
+ return getCurrent() == this ;
+ }
+
+ /**
+ * @throws GLException if this GLContext is not current on this thread
+ */
+ public final void validateCurrent() throws GLException {
+ if(getCurrent() != this) {
+ throw new GLException(getThreadName()+": This context is not current. Current context: "+getCurrent()+", this context "+this);
+ }
+ }
+
+ /** Returns a String representation of the {@link #makeCurrent()} result. */
+ public static final String makeCurrentResultToString(final int res) {
+ switch(res) {
+ case CONTEXT_NOT_CURRENT: return "CONTEXT_NOT_CURRENT";
+ case CONTEXT_CURRENT: return "CONTEXT_CURRENT";
+ case CONTEXT_CURRENT_NEW: return "CONTEXT_CURRENT_NEW";
+ default: return "INVALID_VALUE";
+ }
+ }
+
+ /**
+ * Sets the thread-local variable returned by {@link #getCurrent}
+ * and has no other side-effects. For use by third parties adding
+ * new GLContext implementations; not for use by end users.
+ */
+ protected static void setCurrent(final GLContext cur) {
+ if( TRACE_SWITCH ) {
+ if(null == cur) {
+ System.err.println(getThreadName()+": GLContext.ContextSwitch: - setCurrent() - NULL");
+ } else {
+ System.err.println(getThreadName()+": GLContext.ContextSwitch: - setCurrent() - obj " + toHexString(cur.hashCode()) + ", ctx " + toHexString(cur.getHandle()));
+ }
+ }
+ currentContext.set(cur);
+ }
+
+ /**
+ * Destroys this OpenGL context and frees its associated
+ * resources.
+ *
+ * The context may be current w/o recursion when calling destroy(),
+ * in which case this method destroys the context and releases the lock.
+ *
+ */
+ public abstract void destroy();
+
+ /**
+ * Returns the implementing root GL instance of this GLContext's GL object,
+ * considering a wrapped pipelined hierarchy, see {@link GLBase#getDownstreamGL()}.
+ * @throws GLException if the root instance is not a GL implementation
+ * @see GLBase#getRootGL()
+ * @see GLBase#getDownstreamGL()
+ * @see #getGL()
+ * @see #setGL(GL)
+ */
+ public abstract GL getRootGL();
+
+ /**
+ * Returns the GL pipeline object for this GLContext.
+ *
+ * @return the aggregated GL instance, or null if this context was not yet made current.
+ */
+ public abstract GL getGL();
+
+ /**
+ * Sets the GL pipeline object for this GLContext.
+ *
+ * @return the set GL pipeline or null if not successful
+ */
+ public abstract GL setGL(GL gl);
+
+ /**
+ * Returns the underlying native OpenGL context handle
+ */
+ public final long getHandle() { return contextHandle; }
+
+ /**
+ * Indicates whether the underlying native OpenGL context has been created.
+ */
+ public final boolean isCreated() {
+ return 0 != contextHandle;
+ }
+
+ /**
+ * Returns the attached user object for the given name to this GLContext.
+ */
+ public final Object getAttachedObject(final String name) {
+ return attachedObjects.get(name);
+ }
+
+ /**
+ * Sets the attached user object for the given name to this GLContext.
+ * Returns the previously set object or null.
+ */
+ public final Object attachObject(final String name, final Object obj) {
+ return attachedObjects.put(name, obj);
+ }
+
+ public final Object detachObject(final String name) {
+ return attachedObjects.remove(name);
+ }
+
+ /**
+ * Classname, GL, GLDrawable
+ */
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(getClass().getSimpleName());
+ sb.append(" [");
+ this.append(sb);
+ sb.append("] ");
+ return sb.toString();
+ }
+
+ public final StringBuilder append(final StringBuilder sb) {
+ sb.append("Version ").append(getGLVersion()).append(" [GL ").append(getGLVersionNumber()).append(", vendor ").append(getGLVendorVersionNumber());
+ sb.append("], options 0x");
+ sb.append(Integer.toHexString(ctxOptions));
+ sb.append(", this ");
+ sb.append(toHexString(hashCode()));
+ sb.append(", handle ");
+ sb.append(toHexString(contextHandle));
+ sb.append(", isShared "+isShared()+", ");
+ sb.append(getGL());
+ sb.append(",\n\t quirks: ");
+ if(null != glRendererQuirks) {
+ glRendererQuirks.toString(sb);
+ } else {
+ sb.append("n/a");
+ }
+ if(getGLDrawable()!=getGLReadDrawable()) {
+ sb.append(",\n\tRead Drawable : ");
+ sb.append(getGLReadDrawable());
+ sb.append(",\n\tWrite Drawable: ");
+ sb.append(getGLDrawable());
+ } else {
+ sb.append(",\n\tDrawable: ");
+ sb.append(getGLDrawable());
+ }
+ return sb;
+ }
+
+ /**
+ * Returns true if the specified OpenGL core- or extension-function can be
+ * successfully called using this GL context given the current host (OpenGL
+ * client) and display (OpenGL server) configuration.
+ *
+ * See {@link GL#isFunctionAvailable(String)} for more details.
+ *
+ * @param glFunctionName the name of the OpenGL function (e.g., use
+ * "glPolygonOffsetEXT" or "glPolygonOffset" to check if the {@link
+ * com.jogamp.opengl.GL#glPolygonOffset(float,float)} is available).
+ */
+ public abstract boolean isFunctionAvailable(String glFunctionName);
+
+ /**
+ * Returns true if the specified OpenGL extension can be
+ * successfully called using this GL context given the current host (OpenGL
+ * client) and display (OpenGL server) configuration.
+ *
+ * See {@link GL#isExtensionAvailable(String)} for more details.
+ *
+ * @param glExtensionName the name of the OpenGL extension (e.g.,
+ * "GL_VERTEX_PROGRAM_ARB").
+ */
+ public abstract boolean isExtensionAvailable(String glExtensionName);
+
+ /** Returns the number of platform extensions */
+ public abstract int getPlatformExtensionCount();
+
+ /** Returns a non-null (but possibly empty) string containing the
+ space-separated list of available platform-dependent (e.g., WGL,
+ GLX) extensions. Can only be called while this context is
+ current. */
+ public abstract String getPlatformExtensionsString();
+
+ /** Returns the number of OpenGL extensions */
+ public abstract int getGLExtensionCount();
+
+ /** Returns a non-null (but possibly empty) string containing the
+ space-separated list of available extensions.
+ Can only be called while this context is current.
+ This is equivalent to
+ {@link com.jogamp.opengl.GL#glGetString(int) glGetString}({@link com.jogamp.opengl.GL#GL_EXTENSIONS GL_EXTENSIONS})
+ */
+ public abstract String getGLExtensionsString();
+
+ /**
+ * @return Additional context creation flags, supported: {@link GLContext#CTX_OPTION_DEBUG}.
+ */
+ public abstract int getContextCreationFlags();
+
+ /**
+ * @param flags Additional context creation flags, supported: {@link GLContext#CTX_OPTION_DEBUG}.
+ * Unsupported flags are masked out.
+ * Only affects this context state if not created yet via {@link #makeCurrent()}.
+ * @see #enableGLDebugMessage(boolean)
+ * @see GLAutoDrawable#setContextCreationFlags(int)
+ */
+ public abstract void setContextCreationFlags(int flags);
+
+ /**
+ * Returns a valid OpenGL version string, ie
+ *
+ */
+ public final String getGLVersion() {
+ return ctxVersionString;
+ }
+
+ /**
+ * Returns this context OpenGL version.
+ * @see #getGLSLVersionNumber()
+ **/
+ public final VersionNumber getGLVersionNumber() { return ctxVersion; }
+ /**
+ * Returns the vendor's version, i.e. version number at the end of GL_VERSION not being the GL version.
+ *
+ * In case no such version exists within GL_VERSION,
+ * the {@link VersionNumberString#zeroVersion zero version} instance is returned.
+ *
+ *
+ * The vendor's version is usually the vendor's OpenGL driver version.
+ *
+ */
+ public final VersionNumberString getGLVendorVersionNumber() { return ctxVendorVersion; }
+ public final boolean isGLCompatibilityProfile() { return ( 0 != ( CTX_PROFILE_COMPAT & ctxOptions ) ); }
+ public final boolean isGLCoreProfile() { return ( 0 != ( CTX_PROFILE_CORE & ctxOptions ) ); }
+ public final boolean isGLESProfile() { return ( 0 != ( CTX_PROFILE_ES & ctxOptions ) ); }
+ public final boolean isGLForwardCompatible() { return ( 0 != ( CTX_OPTION_FORWARD & ctxOptions ) ); }
+ public final boolean isGLDebugEnabled() { return ( 0 != ( CTX_OPTION_DEBUG & ctxOptions ) ); }
+ public final boolean isCreatedWithARBMethod() { return ( 0 != ( CTX_IS_ARB_CREATED & ctxOptions ) ); }
+
+ /**
+ * Returns the matching GLSL version number, queried by this context GL
+ * via {@link GL2ES2#GL_SHADING_LANGUAGE_VERSION} if ≥ ES2.0 or GL2.0,
+ * otherwise a static match is being utilized.
+ *
+ * The context must have been current once,
+ * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned.
+ *
+ * Matching could also refer to the maximum GLSL version usable by this context
+ * since normal GL implementations are capable of using a lower GLSL version as well.
+ * The latter is not true on OSX w/ a GL3 context.
+ *
+ *
+ * @return GLSL version number if context has been made current at least once,
+ * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned.
+ *
+ * @see #getGLVersionNumber()
+ */
+ public final VersionNumber getGLSLVersionNumber() {
+ return ctxGLSLVersion;
+ }
+
+ /**
+ * Returns the GLSL version string as to be used in a shader program, including a terminating newline '\n',
+ * i.e. for desktop
+ *
+ * If context has not been made current yet, a string of zero length is returned.
+ *
+ * @see #getGLSLVersionNumber()
+ */
+ public final String getGLSLVersionString() {
+ if( ctxGLSLVersion.isZero() ) {
+ return S_EMPTY;
+ }
+ final int minor = ctxGLSLVersion.getMinor();
+ final String profileOpt;
+ if( isGLES() ) {
+ profileOpt = ctxGLSLVersion.compareTo(Version3_0) >= 0 ? " es" : S_EMPTY;
+ } else if( isGLCoreProfile() ) {
+ profileOpt = ctxGLSLVersion.compareTo(Version1_50) >= 0 ? " core" : S_EMPTY;
+ } else if( isGLCompatibilityProfile() ) {
+ profileOpt = ctxGLSLVersion.compareTo(Version1_50) >= 0 ? " compatibility" : S_EMPTY;
+ } else {
+ throw new InternalError("Neither ES, Core nor Compat: "+this); // see validateProfileBits(..)
+ }
+ return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + profileOpt + "\n" ;
+ }
+
+ protected static final VersionNumber getStaticGLSLVersionNumber(final int glMajorVersion, final int glMinorVersion, final int ctxOptions) {
+ if( 0 != ( CTX_PROFILE_ES & ctxOptions ) ) {
+ if( 3 == glMajorVersion ) {
+ return Version3_0; // ES 3.0 -> GLSL 3.00
+ } else if( 2 == glMajorVersion ) {
+ return Version1_0; // ES 2.0 -> GLSL 1.00
+ }
+ } else if( 1 == glMajorVersion ) {
+ return Version1_10; // GL 1.x -> GLSL 1.10
+ } else if( 2 == glMajorVersion ) {
+ switch ( glMinorVersion ) {
+ case 0: return Version1_10; // GL 2.0 -> GLSL 1.10
+ default: return Version1_20; // GL 2.1 -> GLSL 1.20
+ }
+ } else if( 3 == glMajorVersion && 2 >= glMinorVersion ) {
+ switch ( glMinorVersion ) {
+ case 0: return Version1_30; // GL 3.0 -> GLSL 1.30
+ case 1: return Version1_40; // GL 3.1 -> GLSL 1.40
+ default: return Version1_50; // GL 3.2 -> GLSL 1.50
+ }
+ }
+ // The new default: GL >= 3.3, ES >= 3.0
+ return new VersionNumber(glMajorVersion, glMinorVersion * 10, 0); // GL M.N -> GLSL M.N
+ }
+
+ /**
+ * @return true if this context is an ES2 context or implements
+ * the extension GL_ARB_ES3_compatibility or GL_ARB_ES2_compatibility, otherwise false
+ */
+ public final boolean isGLES2Compatible() {
+ return 0 != ( ctxOptions & ( CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ) ) ;
+ }
+
+ /**
+ * Return true if this context is an ES3 context or implements
+ * the extension GL_ARB_ES3_compatibility, otherwise false.
+ *
+ * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
+ *
+ */
+ public final boolean isGLES3Compatible() {
+ return 0 != ( ctxOptions & CTX_IMPL_ES3_COMPAT ) ;
+ }
+
+ /**
+ * @return true if impl. is a hardware rasterizer, otherwise false.
+ * @see #isHardwareRasterizer(AbstractGraphicsDevice, GLProfile)
+ * @see GLProfile#isHardwareRasterizer()
+ */
+ public final boolean isHardwareRasterizer() {
+ return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ;
+ }
+
+ /**
+ * @return true if context supports GLSL, i.e. is either {@link #isGLES3()}, {@link #isGLES2()}, {@link #isGL3()} or {@link #isGL2()} and major-version > 1.
+ * @see GLProfile#hasGLSL()
+ */
+ public final boolean hasGLSL() {
+ return isGLES3() ||
+ isGLES2() ||
+ isGL3() ||
+ isGL2() && ctxVersion.getMajor()>1 ;
+ }
+
+ /**
+ * Returns true if basic FBO support is available, otherwise false.
+ *
+ * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= 3.0 [core, compat] or implements the extensions
+ * GL_ARB_ES2_compatibility, GL_ARB_framebuffer_object, GL_EXT_framebuffer_object or GL_OES_framebuffer_object.
+ *
+ *
+ * Basic FBO support may only include one color attachment and no multisampling,
+ * as well as limited internal formats for renderbuffer.
+ *
+ * @see #CTX_IMPL_FBO
+ */
+ public final boolean hasBasicFBOSupport() {
+ return 0 != ( ctxOptions & CTX_IMPL_FBO ) ;
+ }
+
+ /**
+ * Returns true if full FBO support is available, otherwise false.
+ *
+ * Full FBO is supported if the context is either GL >= 3.0 [ES, core, compat] or implements the extensions
+ * ARB_framebuffer_object, or all of
+ * EXT_framebuffer_object, EXT_framebuffer_multisample,
+ * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil.
+ *
+ *
+ * Full FBO support includes multiple color attachments and multisampling.
+ *
+ */
+ public final boolean hasFullFBOSupport() {
+ return hasBasicFBOSupport() && !hasRendererQuirk(GLRendererQuirks.NoFullFBOSupport) &&
+ ( isGL3ES3() || // GL >= 3.0 [ES, core, compat]
+ isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object
+ ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object*
+ isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) &&
+ isExtensionAvailable(GLExtensions.EXT_framebuffer_blit) &&
+ isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil)
+ )
+ ) ;
+ }
+
+ /**
+ * Returns true if OES_single_precision, fp32, fixed function point (FFP) compatibility entry points available,
+ * otherwise false.
+ * @see #CTX_IMPL_FP32_COMPAT_API
+ */
+ public final boolean hasFP32CompatAPI() {
+ return 0 != ( ctxOptions & CTX_IMPL_FP32_COMPAT_API ) ;
+ }
+
+ /**
+ * Returns the maximum number of FBO RENDERBUFFER samples
+ * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false.
+ */
+ public final int getMaxRenderbufferSamples() {
+ if( hasFullFBOSupport() ) {
+ final GL gl = getGL();
+ final int[] val = new int[] { 0 } ;
+ try {
+ gl.glGetIntegerv(GL2ES3.GL_MAX_SAMPLES, val, 0);
+ final int glerr = gl.glGetError();
+ if(GL.GL_NO_ERROR == glerr) {
+ return val[0];
+ } else if(DEBUG) {
+ System.err.println("GLContext.getMaxRenderbufferSamples: GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr));
+ }
+ } catch (final GLException gle) { gle.printStackTrace(); }
+ }
+ return 0;
+ }
+
+ /** Note: The GL impl. may return a const value, ie {@link GLES2#isNPOTTextureAvailable()} always returns true. */
+ public boolean isNPOTTextureAvailable() {
+ return isGL3() || isGLES2Compatible() || isExtensionAvailable(GLExtensions.ARB_texture_non_power_of_two);
+ }
+
+ public boolean isTextureFormatBGRA8888Available() {
+ return isGL2GL3() ||
+ isExtensionAvailable(GLExtensions.EXT_texture_format_BGRA8888) ||
+ isExtensionAvailable(GLExtensions.IMG_texture_format_BGRA8888) ;
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GL4bc.
Includes [ GL4bc ].
+ * @see GLProfile#isGL4bc()
+ */
+ public final boolean isGL4bc() {
+ return 0 != (ctxOptions & CTX_PROFILE_COMPAT) &&
+ ctxVersion.getMajor() >= 4;
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GL4.
Includes [ GL4bc, GL4 ].
+ * @see GLProfile#isGL4()
+ */
+ public final boolean isGL4() {
+ return 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)) &&
+ ctxVersion.getMajor() >= 4;
+ }
+
+ /**
+ * Indicates whether this GLContext uses a GL4 core profile.
Includes [ GL4 ].
+ */
+ public final boolean isGL4core() {
+ return 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
+ ctxVersion.getMajor() >= 4;
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GL3bc.
Includes [ GL4bc, GL3bc ].
+ * @see GLProfile#isGL3bc()
+ */
+ public final boolean isGL3bc() {
+ return 0 != (ctxOptions & CTX_PROFILE_COMPAT) &&
+ ctxVersion.compareTo(Version3_1) >= 0 ;
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GL3.
See Bug 852 - https://jogamp.org/bugzilla/show_bug.cgi?id=852
+ */
+ public final boolean isCPUDataSourcingAvail() {
+ return isGL2ES1() || isGLES2();
+ }
+
+ /**
+ * Indicates whether this GLContext's native profile does not implement a default vertex array object (VAO),
+ * starting w/ OpenGL 3.1 core.
+ *
Includes [ GL4, GL3 ].
+ *
+ Due to GL 3.1 core spec: E.1. DEPRECATED AND REMOVED FEATURES (p 296),
+ GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331)
+ there is no more default VAO buffer 0 bound, hence generating and binding one
+ to avoid INVALID_OPERATION at VertexAttribPointer.
+ More clear is GL 4.3 core spec: 10.4 (p 307).
+ *
+ *
+ ES 3.x is not included here.
+ Due to it's ES 2.0 backward compatibility it still supports the following features:
+ client side vertex arrays
+ default vertex array object
+
+ Binding a custom VAO with ES 3.0 would cause client side vertex arrays via {@link GL2ES1#glVertexPointer(int, int, int, java.nio.Buffer) glVertexPointer}
+ to produce GL_INVALID_OPERATION.
+
+ However, they are marked deprecated:
+ GL ES 3.0 spec F.1. Legacy Features (p 322).
+ GL ES 3.1 spec F.1. Legacy Features (p 454).
+ *
+ *
+ * If no default VAO is implemented in the native OpenGL profile,
+ * an own default VAO is being used, see {@link #getDefaultVAO()}.
+ *
+ * @see #getDefaultVAO()
+ */
+ public final boolean hasNoDefaultVAO() {
+ return // ES 3.x not included, see above. ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ) ||
+ ( 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) &&
+ 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
+ ctxVersion.compareTo(Version3_1) >= 0
+ ) ;
+ }
+
+ /**
+ * If this GLContext does not implement a default VAO, see {@link #hasNoDefaultVAO()},
+ * an own default VAO will be created and bound at context creation.
+ *
+ * If this GLContext does implement a default VAO, i.e. {@link #hasNoDefaultVAO()}
+ * returns false, this method returns 0.
+ *
+ *
+ * Otherwise this method returns the VAO object name
+ * representing this GLContext's own default VAO.
+ *
+ * @see #hasNoDefaultVAO()
+ */
+ public abstract int getDefaultVAO();
+
+ /**
+ * Indicates whether this GLContext is capable of GL2.
Includes [ GL4bc, GL3bc, GL2 ].
+ * @see GLProfile#isGL2()
+ */
+ public final boolean isGL2() {
+ return 0 != ( ctxOptions & CTX_PROFILE_COMPAT ) && ctxVersion.getMajor()>=1 ;
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GL2GL3.
Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].
+ * @see GLProfile#isGL2GL3()
+ */
+ public final boolean isGL2GL3() {
+ return isGL2() || isGL3();
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GLES1.
Includes [ GLES1 ].
+ * @see GLProfile#isGLES1()
+ */
+ public final boolean isGLES1() {
+ return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 1 ;
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GLES2.
Includes [ GLES2, GLES3 ].
+ * @see GLProfile#isGLES2()
+ */
+ public final boolean isGLES2() {
+ if( 0 != ( ctxOptions & CTX_PROFILE_ES ) ) {
+ final int major = ctxVersion.getMajor();
+ return 2 == major || 3 == major;
+ }
+ return false;
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GLES3.
Includes [ GLES3 ].
+ * @see GLProfile#isGLES3()
+ */
+ public final boolean isGLES3() {
+ return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 3 ;
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GLES.
Includes [ GLES3, GLES1, GLES2 ].
+ * @see GLProfile#isGLES()
+ */
+ public final boolean isGLES() {
+ return 0 != ( CTX_PROFILE_ES & ctxOptions ) ;
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GL2ES1.
Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].
+ * @see GLProfile#isGL2ES1()
+ */
+ public final boolean isGL2ES1() {
+ return isGLES1() || isGL2();
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GL2ES2.
+ * @see GLProfile#isGL2ES3()
+ * @see #isGL3ES3()
+ * @see #isGL2GL3()
+ */
+ public final boolean isGL2ES3() {
+ return isGL3ES3() || isGL2GL3();
+ }
+
+ /**
+ * Indicates whether this GLContext is capable of GL3ES3.
Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].
+ * @see GLProfile#isGL3ES3()
+ */
+ public final boolean isGL3ES3() {
+ return isGL4ES3() || isGL3();
+ }
+
+ /**
+ * Returns true if this profile is capable of GL4ES3, i.e. if {@link #isGLES3Compatible()} returns true.
+ *
Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
+ * @see GLProfile#isGL4ES3()
+ */
+ public final boolean isGL4ES3() {
+ return isGLES3Compatible() ;
+ }
+
+ /**
+ * Set the swap interval of the current context and attached drawable.
+ * @param interval Should be ≥ 0. 0 disables the vertical synchronization,
+ * where ≥ 1 is the number of vertical refreshes before a swap buffer occurs.
+ * A value < 0 is ignored.
+ * @return true if the operation was successful, otherwise false
+ *
+ * @throws GLException if the context is not current.
+ */
+ public final boolean setSwapInterval(final int interval) throws GLException {
+ validateCurrent();
+ if(0<=interval) {
+ if( !drawableRetargeted || !hasRendererQuirk(GLRendererQuirks.NoSetSwapIntervalPostRetarget) ) {
+ if( setSwapIntervalImpl(interval) ) {
+ currentSwapInterval = interval;
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ protected boolean setSwapIntervalImpl(final int interval) {
+ return false;
+ }
+ /** Return the current swap interval.
+ *
+ * If the context has not been made current at all,
+ * the default value -1 is returned.
+ *
+ *
+ * For a valid context the default value is 1
+ * in case of an EGL based profile (ES1 or ES2) and -1
+ * (undefined) for desktop.
+ *
+ */
+ public final int getSwapInterval() {
+ return currentSwapInterval;
+ }
+ protected final void setDefaultSwapInterval() {
+ if(this.isGLES()) {
+ currentSwapInterval = 1;
+ } else {
+ currentSwapInterval = -1;
+ }
+ }
+
+ public final boolean queryMaxSwapGroups(final int[] maxGroups, final int maxGroups_offset,
+ final int[] maxBarriers, final int maxBarriers_offset) {
+ validateCurrent();
+ return queryMaxSwapGroupsImpl(maxGroups, maxGroups_offset, maxBarriers, maxBarriers_offset);
+ }
+ protected boolean queryMaxSwapGroupsImpl(final int[] maxGroups, final int maxGroups_offset,
+ final int[] maxBarriers, final int maxBarriers_offset) { return false; }
+ public final boolean joinSwapGroup(final int group) {
+ validateCurrent();
+ return joinSwapGroupImpl(group);
+ }
+ protected boolean joinSwapGroupImpl(final int group) { /** nop per default .. **/ return false; }
+ protected int currentSwapGroup = -1; // default: not set yet ..
+ public int getSwapGroup() {
+ return currentSwapGroup;
+ }
+ public final boolean bindSwapBarrier(final int group, final int barrier) {
+ validateCurrent();
+ return bindSwapBarrierImpl(group, barrier);
+ }
+ protected boolean bindSwapBarrierImpl(final int group, final int barrier) { /** nop per default .. **/ return false; }
+
+ /**
+ * Return the framebuffer name bound to this context,
+ * see {@link GL#glBindFramebuffer(int, int)}.
+ *
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ *
+ */
+ public abstract int getBoundFramebuffer(int target);
+
+ /**
+ * Return the default draw framebuffer name.
+ *
+ * May differ from it's default zero
+ * in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
+ * is being used.
+ *
+ *
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ *
+ */
+ public abstract int getDefaultDrawFramebuffer();
+
+ /**
+ * Return the default read framebuffer name.
+ *
+ * May differ from it's default zero
+ * in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
+ * is being used.
+ *
+ *
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ *
+ */
+ public abstract int getDefaultReadFramebuffer();
+
+ /**
+ * Returns the default color buffer within the current bound
+ * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​,
+ * which will be used as the source for pixel reading commands,
+ * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels} etc.
+ *
+ * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0},
+ * otherwise this is {@link GL#GL_FRONT} for single buffer configurations
+ * and {@link GL#GL_BACK} for double buffer configurations.
+ *
+ *
+ * Note-1: Neither ES1 nor ES2 supports selecting the read buffer via glReadBuffer
+ * and {@link GL#GL_BACK} is the default.
+ *
+ *
+ * Note-2: ES3 only supports {@link GL#GL_BACK}, {@link GL#GL_NONE} or {@link GL#GL_COLOR_ATTACHMENT0}+i
+ *
+ *
+ * Note-3: See {@link com.jogamp.opengl.util.GLDrawableUtil#swapBuffersBeforeRead(GLCapabilitiesImmutable) swapBuffersBeforeRead}
+ * for read-pixels and swap-buffers implications.
+ *
+ *
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ *
+ */
+ public abstract int getDefaultReadBuffer();
+
+ /**
+ * Get the default pixel data type, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}.
+ *
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ *
+ */
+ public abstract int getDefaultPixelDataType();
+
+ /**
+ * Get the default pixel data format, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}.
+ *
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ *
+ */
+ public abstract int getDefaultPixelDataFormat();
+
+ /**
+ * @return The extension implementing the GLDebugOutput feature,
+ * either {@link GLExtensions#ARB_debug_output} or {@link GLExtensions#AMD_debug_output}.
+ * If unavailable or called before initialized via {@link #makeCurrent()}, null is returned.
+ */
+ public abstract String getGLDebugMessageExtension();
+
+ /**
+ * @return the current synchronous debug behavior, set via {@link #setGLDebugSynchronous(boolean)}.
+ */
+ public abstract boolean isGLDebugSynchronous();
+
+ /**
+ * Enables or disables the synchronous debug behavior via
+ * {@link GL2GL3#GL_DEBUG_OUTPUT_SYNCHRONOUS glEnable/glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS)},
+ * if extension is {@link GLExtensions#ARB_debug_output}.
+ * There is no equivalent for {@link GLExtensions#AMD_debug_output}.
+ *
The default is true, ie {@link GL2GL3#GL_DEBUG_OUTPUT_SYNCHRONOUS}.
+ * @link {@link #isGLDebugSynchronous()}
+ */
+ public abstract void setGLDebugSynchronous(boolean synchronous);
+
+ /**
+ * @return true if the GLDebugOutput feature is enabled or not.
+ */
+ public abstract boolean isGLDebugMessageEnabled();
+
+ /**
+ * Enables or disables the GLDebugOutput feature of extension {@link GLExtensions#ARB_debug_output}
+ * or {@link GLExtensions#AMD_debug_output}, if available.
+ *
+ *
To enable the GLDebugOutput feature {@link #enableGLDebugMessage(boolean) enableGLDebugMessage(true)}
+ * or {@link #setContextCreationFlags(int) setContextCreationFlags}({@link GLContext#CTX_OPTION_DEBUG})
+ * shall be called before context creation via {@link #makeCurrent()}!
+ *
+ *
In case {@link GLAutoDrawable} are being used,
+ * {@link GLAutoDrawable#setContextCreationFlags(int) glAutoDrawable.setContextCreationFlags}({@link GLContext#CTX_OPTION_DEBUG})
+ * shall be issued before context creation via {@link #makeCurrent()}!
+ *
+ *
After context creation, the GLDebugOutput feature may be enabled or disabled at any time using this method.
+ *
+ * @param enable If true enables, otherwise disables the GLDebugOutput feature.
+ *
+ * @throws GLException if this context is not current or GLDebugOutput registration failed (enable)
+ *
+ * @see #setContextCreationFlags(int)
+ * @see #addGLDebugListener(GLDebugListener)
+ * @see GLAutoDrawable#setContextCreationFlags(int)
+ */
+ public abstract void enableGLDebugMessage(boolean enable) throws GLException;
+
+ /**
+ * Add {@link GLDebugListener}.
+ *
+ * @param listener {@link GLDebugListener} handling {@link GLDebugMessage}s
+ * @see #enableGLDebugMessage(boolean)
+ * @see #removeGLDebugListener(GLDebugListener)
+ */
+ public abstract void addGLDebugListener(GLDebugListener listener);
+
+ /**
+ * Remove {@link GLDebugListener}.
+ *
+ * @param listener {@link GLDebugListener} handling {@link GLDebugMessage}s
+ * @see #enableGLDebugMessage(boolean)
+ * @see #addGLDebugListener(GLDebugListener)
+ */
+ public abstract void removeGLDebugListener(GLDebugListener listener);
+
+ /**
+ * Generic entry for {@link GL2GL3#glDebugMessageControl(int, int, int, int, IntBuffer, boolean)}
+ * and {@link GL2GL3#glDebugMessageEnableAMD(int, int, int, IntBuffer, boolean)} of the GLDebugOutput feature.
+ * @see #enableGLDebugMessage(boolean)
+ */
+ public abstract void glDebugMessageControl(int source, int type, int severity, int count, IntBuffer ids, boolean enabled);
+
+ /**
+ * Generic entry for {@link GL2GL3#glDebugMessageControl(int, int, int, int, int[], int, boolean)}
+ * and {@link GL2GL3#glDebugMessageEnableAMD(int, int, int, int[], int, boolean)} of the GLDebugOutput feature.
+ * @see #enableGLDebugMessage(boolean)
+ */
+ public abstract void glDebugMessageControl(int source, int type, int severity, int count, int[] ids, int ids_offset, boolean enabled);
+
+ /**
+ * Generic entry for {@link GL2GL3#glDebugMessageInsert(int, int, int, int, int, String)}
+ * and {@link GL2GL3#glDebugMessageInsertAMD(int, int, int, int, String)} of the GLDebugOutput feature.
+ * @see #enableGLDebugMessage(boolean)
+ */
+ public abstract void glDebugMessageInsert(int source, int type, int id, int severity, String buf);
+
+ public static final int GL_VERSIONS[][] = {
+ /* 0.*/ { -1 },
+ /* 1.*/ { 0, 1, 2, 3, 4, 5 },
+ /* 2.*/ { 0, 1 },
+ /* 3.*/ { 0, 1, 2, 3 },
+ /* 4.*/ { 0, 1, 2, 3, 4, 5 } };
+
+ public static final int ES_VERSIONS[][] = {
+ /* 0.*/ { -1 },
+ /* 1.*/ { 0, 1 },
+ /* 2.*/ { 0 },
+ /* 3.*/ { 0, 1 } };
+
+ public static final int getMaxMajor(final int ctxProfile) {
+ return ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ? ES_VERSIONS.length-1 : GL_VERSIONS.length-1;
+ }
+
+ public static final int getMaxMinor(final int ctxProfile, final int major) {
+ if( 1>major ) {
+ return -1;
+ }
+ if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) {
+ if( major>=ES_VERSIONS.length ) return -1;
+ return ES_VERSIONS[major].length-1;
+ } else {
+ if( major>=GL_VERSIONS.length ) return -1;
+ return GL_VERSIONS[major].length-1;
+ }
+ }
+
+ /**
+ * Returns true, if the major.minor is not inferior to the lowest
+ * valid version and does not exceed the highest known major number by more than one.
+ *
+ * The minor version number is ignored by the upper limit validation
+ * and the major version number may exceed by one.
+ *
+ *
+ * The upper limit check is relaxed since we don't want to cut-off
+ * unforseen new GL version since the release of JOGL.
+ *
+ *
+ * Hence it is important to iterate through GL version from the upper limit
+ * and {@link #decrementGLVersion(int, int[], int[])} until invalid.
+ *
+ */
+ public static final boolean isValidGLVersion(final int ctxProfile, final int major, final int minor) {
+ if( 1>major || 0>minor ) {
+ return false;
+ }
+ if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) {
+ if( major >= ES_VERSIONS.length + 1 ) return false;
+ } else {
+ if( major>=GL_VERSIONS.length + 1 ) return false;
+ }
+ return true;
+ }
+
+ /**
+ * Clip the given GL version to the maximum known valid version if exceeding.
+ * @return true if clipped, i.e. given value exceeds maximum, otherwise false.
+ */
+ public static final boolean clipGLVersion(final int ctxProfile, final int major[], final int minor[]) {
+ final int m = major[0];
+ final int n = minor[0];
+
+ if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) {
+ if( m >= ES_VERSIONS.length ) {
+ major[0] = ES_VERSIONS.length - 1;
+ minor[0] = ES_VERSIONS[major[0]].length - 1;
+ return true;
+ }
+ if( n >= ES_VERSIONS[m].length ) {
+ minor[0] = ES_VERSIONS[m].length - 1;
+ return true;
+ }
+ } else if( m >= GL_VERSIONS.length ) { // !isES
+ major[0] = GL_VERSIONS.length - 1;
+ minor[0] = GL_VERSIONS[major[0]].length - 1;
+ return true;
+ } else if( n >= GL_VERSIONS[m].length ) { // !isES
+ minor[0] = GL_VERSIONS[m].length - 1;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Decrement the given GL version by one
+ * and return true if still valid, otherwise false.
+ *
+ * If the given version exceeds the maximum known valid version,
+ * it is {@link #clipGLVersion(int, int[], int[]) clipped} and
+ * true is returned.
+ *
+ *
+ * @param ctxProfile
+ * @param major
+ * @param minor
+ * @return
+ */
+ public static final boolean decrementGLVersion(final int ctxProfile, final int major[], final int minor[]) {
+ if( !clipGLVersion(ctxProfile, major, minor) ) {
+ int m = major[0];
+ int n = minor[0] - 1;
+ if(n < 0) {
+ if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) {
+ if( m >= 3 ) {
+ m -= 1;
+ } else {
+ m = 0; // major decr [1,2] -> 0
+ }
+ n = ES_VERSIONS[m].length-1;
+ } else {
+ m -= 1;
+ n = GL_VERSIONS[m].length-1;
+ }
+ }
+ if( !isValidGLVersion(ctxProfile, m, n) ) {
+ return false;
+ }
+ major[0]=m;
+ minor[0]=n;
+ }
+ return true;
+ }
+
+ protected static int composeBits(final int a8, final int b8, final int c16) {
+ return ( ( a8 & 0x000000FF ) << 24 ) |
+ ( ( b8 & 0x000000FF ) << 16 ) |
+ ( ( c16 & 0x0000FFFF ) ) ;
+ }
+
+ private static void validateProfileBits(final int bits, final String argName) {
+ int num = 0;
+ if( 0 != ( CTX_PROFILE_COMPAT & bits ) ) { num++; }
+ if( 0 != ( CTX_PROFILE_CORE & bits ) ) { num++; }
+ if( 0 != ( CTX_PROFILE_ES & bits ) ) { num++; }
+ if(1!=num) {
+ throw new GLException("Internal Error: "+argName+": 1 != num-profiles: "+num);
+ }
+ }
+
+ //
+ // version mapping
+ //
+
+ /**
+ * @see #getDeviceVersionAvailableKey(com.jogamp.nativewindow.AbstractGraphicsDevice, int, int)
+ */
+ protected static final IdentityHashMap deviceVersionAvailable = new IdentityHashMap();
+
+ /**
+ * @see #getUniqueDeviceString(com.jogamp.nativewindow.AbstractGraphicsDevice)
+ */
+ private static final IdentityHashMap deviceVersionsAvailableSet = new IdentityHashMap();
+
+ /** clears the device/context mappings as well as the GL/GLX proc address tables. */
+ protected static void shutdown() {
+ deviceVersionAvailable.clear();
+ deviceVersionsAvailableSet.clear();
+ GLContextImpl.shutdownImpl(); // well ..
+ }
+
+ protected static boolean getAvailableGLVersionsSet(final AbstractGraphicsDevice device) {
+ synchronized ( deviceVersionsAvailableSet ) {
+ return deviceVersionsAvailableSet.containsKey(device.getUniqueID());
+ }
+ }
+
+ protected static void setAvailableGLVersionsSet(final AbstractGraphicsDevice device, final boolean set) {
+ synchronized ( deviceVersionsAvailableSet ) {
+ final String devKey = device.getUniqueID();
+ if( set ) {
+ deviceVersionsAvailableSet.put(devKey, devKey);
+ } else {
+ deviceVersionsAvailableSet.remove(devKey);
+ }
+ if (DEBUG) {
+ System.err.println(getThreadName() + ": createContextARB: SET mappedVersionsAvailableSet "+devKey);
+ System.err.println(GLContext.dumpAvailableGLVersions(null).toString());
+ }
+ }
+ }
+
+ /**
+ * Returns a unique String object using {@link String#intern()} for the given arguments,
+ * which object reference itself can be used as a key.
+ */
+ protected static String getDeviceVersionAvailableKey(final AbstractGraphicsDevice device, final int major, final int profile) {
+ final String r = device.getUniqueID() + "-" + toHexString(composeBits(major, profile, 0));
+ return r.intern();
+ }
+
+ /**
+ * Called by {@link jogamp.opengl.GLContextImpl#createContextARBMapVersionsAvailable(int,int)} not intended to be used by
+ * implementations. However, if {@link jogamp.opengl.GLContextImpl#createContextARB(long, boolean)} is not being used within
+ * {@link com.jogamp.opengl.GLDrawableFactory#getOrCreateSharedContext(com.jogamp.nativewindow.AbstractGraphicsDevice)},
+ * GLProfile has to map the available versions.
+ *
+ * @param reqMajor Key Value either 1, 2, 3 or 4
+ * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ * @return the old mapped value
+ *
+ * @see #createContextARBMapVersionsAvailable
+ */
+ protected static Integer mapAvailableGLVersion(final AbstractGraphicsDevice device,
+ final int reqMajor, final int profile, final int resMajor, final int resMinor, int resCtp)
+ {
+ validateProfileBits(profile, "profile");
+ validateProfileBits(resCtp, "resCtp");
+
+ if(FORCE_NO_FBO_SUPPORT) {
+ resCtp &= ~CTX_IMPL_FBO ;
+ }
+ if(DEBUG) {
+ System.err.println("GLContext.mapAvailableGLVersion: "+device+": "+getGLVersion(reqMajor, 0, profile, null)+" -> "+getGLVersion(resMajor, resMinor, resCtp, null));
+ // Thread.dumpStack();
+ }
+ final String objectKey = getDeviceVersionAvailableKey(device, reqMajor, profile);
+ final Integer val = Integer.valueOf(composeBits(resMajor, resMinor, resCtp));
+ synchronized(deviceVersionAvailable) {
+ return deviceVersionAvailable.put( objectKey, val );
+ }
+ }
+
+ protected static StringBuilder dumpAvailableGLVersions(StringBuilder sb) {
+ if(null == sb) {
+ sb = new StringBuilder();
+ }
+ synchronized(deviceVersionAvailable) {
+ final Set keys = deviceVersionAvailable.keySet();
+ boolean needsSeparator = false;
+ for(final Iterator i = keys.iterator(); i.hasNext(); ) {
+ if(needsSeparator) {
+ sb.append(Platform.getNewline());
+ }
+ final String key = i.next();
+ sb.append(key).append(": ");
+ final Integer valI = deviceVersionAvailable.get(key);
+ if(null != valI) {
+ final int bits32 = valI.intValue();
+ final int major = ( bits32 & 0xFF000000 ) >>> 24 ;
+ final int minor = ( bits32 & 0x00FF0000 ) >>> 16 ;
+ final int ctp = ( bits32 & 0x0000FFFF ) ;
+ sb.append(GLContext.getGLVersion(major, minor, ctp, null));
+ } else {
+ sb.append("n/a");
+ }
+ needsSeparator = true;
+ }
+ }
+ return sb;
+ }
+
+ /**
+ * @param device the device to request whether the profile is available for
+ * @param reqMajor Key Value either 1, 2, 3 or 4
+ * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ * @return the available GL version as encoded with {@link #composeBits(int, int, int), otherwise null
+ */
+ protected static Integer getAvailableGLVersion(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile) {
+ final String objectKey = getDeviceVersionAvailableKey(device, reqMajor, reqProfile);
+ Integer val;
+ synchronized(deviceVersionAvailable) {
+ val = deviceVersionAvailable.get( objectKey );
+ }
+ return val;
+ }
+
+ /**
+ * @param reqMajor Key Value either 1, 2, 3 or 4
+ * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ * @param major if not null, returns the used major version
+ * @param minor if not null, returns the used minor version
+ * @param ctp if not null, returns the used context profile
+ */
+ protected static boolean getAvailableGLVersion(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile,
+ final int[] major, final int minor[], final int ctp[]) {
+
+ final Integer valI = getAvailableGLVersion(device, reqMajor, reqProfile);
+ if(null==valI) {
+ return false;
+ }
+
+ final int bits32 = valI.intValue();
+
+ if(null!=major) {
+ major[0] = ( bits32 & 0xFF000000 ) >>> 24 ;
+ }
+ if(null!=minor) {
+ minor[0] = ( bits32 & 0x00FF0000 ) >>> 16 ;
+ }
+ if(null!=ctp) {
+ ctp[0] = ( bits32 & 0x0000FFFF ) ;
+ }
+ return true;
+ }
+
+ /**
+ * returns the highest GLProfile string regarding the implementation version and context profile bits.
+ * @throws GLException if version and context profile bits could not be mapped to a GLProfile
+ */
+ protected static String getGLProfile(final int major, final int minor, final int ctp)
+ throws GLException {
+ if(0 != ( CTX_PROFILE_COMPAT & ctp )) {
+ if(major >= 4) { return GLProfile.GL4bc; }
+ else if(major == 3 && minor >= 1) { return GLProfile.GL3bc; }
+ else { return GLProfile.GL2; }
+ } else if(0 != ( CTX_PROFILE_CORE & ctp )) {
+ if(major >= 4) { return GLProfile.GL4; }
+ else if(major == 3 && minor >= 1) { return GLProfile.GL3; }
+ } else if(0 != ( CTX_PROFILE_ES & ctp )) {
+ if(major == 3) { return GLProfile.GLES3; }
+ else if(major == 2) { return GLProfile.GLES2; }
+ else if(major == 1) { return GLProfile.GLES1; }
+ }
+ throw new GLException("Unhandled OpenGL version/profile: "+GLContext.getGLVersion(major, minor, ctp, null));
+ }
+
+ /**
+ * Returns the GLProfile's major version number at reqMajorCTP[0] and it's context property (CTP) at reqMajorCTP[1] for availability mapping request.
+ */
+ protected static final void getRequestMajorAndCompat(final GLProfile glp, final int[/*2*/] reqMajorCTP) {
+ final GLProfile glpImpl = glp.getImpl();
+ if( glpImpl.isGL4() ) {
+ reqMajorCTP[0]=4;
+ } else if ( glpImpl.isGL3() || glpImpl.isGLES3() ) {
+ reqMajorCTP[0]=3;
+ } else if (glpImpl.isGLES1()) {
+ reqMajorCTP[0]=1;
+ } else /* if (glpImpl.isGL2() || glpImpl.isGLES2()) */ {
+ reqMajorCTP[0]=2;
+ }
+ if( glpImpl.isGLES() ) {
+ reqMajorCTP[1]=CTX_PROFILE_ES;
+ } else if( glpImpl.isGL2() ) { // incl GL3bc and GL4bc
+ reqMajorCTP[1]=CTX_PROFILE_COMPAT;
+ } else {
+ reqMajorCTP[1]=CTX_PROFILE_CORE;
+ }
+ }
+
+ /**
+ * @param device the device the context profile is being requested for
+ * @param GLProfile the GLProfile the context profile is being requested for
+ * @return the GLProfile's context property (CTP) if available, otherwise 0
+ */
+ protected static final int getAvailableContextProperties(final AbstractGraphicsDevice device, final GLProfile glp) {
+ final int[] reqMajorCTP = new int[] { 0, 0 };
+ getRequestMajorAndCompat(glp, reqMajorCTP);
+
+ final int _major[] = { 0 };
+ final int _minor[] = { 0 };
+ final int _ctp[] = { 0 };
+ if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], _major, _minor, _ctp)) {
+ return _ctp[0];
+ }
+ return 0; // n/a
+ }
+
+ /**
+ * @param device the device the profile is being requested
+ * @param major Key Value either 1, 2, 3 or 4
+ * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ * @return the highest GLProfile for the device regarding availability, version and profile bits.
+ */
+ protected static GLProfile getAvailableGLProfile(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile)
+ throws GLException {
+ final String glpName = getAvailableGLProfileName(device, reqMajor, reqProfile);
+ return null != glpName ? GLProfile.get(device, glpName) : null;
+ }
+
+ /**
+ * @param device the device the profile is being requested
+ * @param major Key Value either 1, 2, 3 or 4
+ * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ * @return the highest GLProfile name for the device regarding availability, version and profile bits.
+ */
+ /* package */ static String getAvailableGLProfileName(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile)
+ throws GLException {
+ final int major[] = { 0 };
+ final int minor[] = { 0 };
+ final int ctp[] = { 0 };
+ if(GLContext.getAvailableGLVersion(device, reqMajor, reqProfile, major, minor, ctp)) {
+ return GLContext.getGLProfile(major[0], minor[0], ctp[0]);
+ }
+ return null;
+ }
+
+ /**
+ * @param device the device the profile is being requested
+ * @param major Key Value either 1, 2, 3 or 4
+ * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ */
+ protected static String getAvailableGLVersionAsString(final AbstractGraphicsDevice device, final int major, final int profile) {
+ final int _major[] = { 0 };
+ final int _minor[] = { 0 };
+ final int _ctp[] = { 0 };
+ if(getAvailableGLVersion(device, major, profile, _major, _minor, _ctp)) {
+ return getGLVersion(_major[0], _minor[0], _ctp[0], null);
+ }
+ return null;
+ }
+
+ /**
+ * Returns true if it is possible to create an framebuffer object (FBO).
+ *
+ * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent.
+ *
+ *
+ * FBO support is queried as described in {@link #hasBasicFBOSupport()}.
+ *
+ *
+ * @param device the device to request whether FBO is available for
+ * @param glp {@link GLProfile} to check for FBO capabilities
+ * @see GLContext#hasBasicFBOSupport()
+ */
+ public static final boolean isFBOAvailable(final AbstractGraphicsDevice device, final GLProfile glp) {
+ return 0 != ( CTX_IMPL_FBO & getAvailableContextProperties(device, glp) );
+ }
+
+ /**
+ * @return 1 if using a hardware rasterizer, 0 if using a software rasterizer and -1 if not determined yet.
+ * @see GLContext#isHardwareRasterizer()
+ * @see GLProfile#isHardwareRasterizer()
+ */
+ public static final int isHardwareRasterizer(final AbstractGraphicsDevice device, final GLProfile glp) {
+ final int r;
+ final int ctp = getAvailableContextProperties(device, glp);
+ if(0 == ctp) {
+ r = -1;
+ } else if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctp ) ) {
+ r = 1;
+ } else {
+ r = 0;
+ }
+ return r;
+ }
+
+ /**
+ * @param device the device to request whether the profile is available for
+ * @param reqMajor Key Value either 1, 2, 3 or 4
+ * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ * @param isHardware return value of one boolean, whether the profile is a hardware rasterizer or not
+ * @return true if the requested GL version is available regardless of a software or hardware rasterizer, otherwise false.
+ */
+ protected static boolean isGLVersionAvailable(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile, final boolean isHardware[]) {
+ final Integer valI = getAvailableGLVersion(device, reqMajor, reqProfile);
+ if(null==valI) {
+ return false;
+ }
+ isHardware[0] = 0 == ( valI.intValue() & GLContext.CTX_IMPL_ACCEL_SOFT ) ;
+ return true;
+ }
+
+ public static boolean isGLES1Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
+ return isGLVersionAvailable(device, 1, GLContext.CTX_PROFILE_ES, isHardware);
+ }
+
+ public static boolean isGLES2Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
+ return isGLVersionAvailable(device, 2, GLContext.CTX_PROFILE_ES, isHardware);
+ }
+
+ public static boolean isGLES3Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
+ return isGLVersionAvailable(device, 3, GLContext.CTX_PROFILE_ES, isHardware);
+ }
+
+ /**
+ * Returns true if a ES3 compatible profile is available,
+ * i.e. either a ≥ 4.3 context or a ≥ 3.1 context supporting GL_ARB_ES3_compatibility,
+ * otherwise false.
+ *
+ * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
+ *
+ */
+ public static final boolean isGLES3CompatibleAvailable(final AbstractGraphicsDevice device) {
+ final int major[] = { 0 };
+ final int minor[] = { 0 };
+ final int ctp[] = { 0 };
+ boolean ok;
+
+ ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_ES, major, minor, ctp);
+ if( !ok ) {
+ ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_CORE, major, minor, ctp);
+ }
+ if( !ok ) {
+ GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_COMPAT, major, minor, ctp);
+ }
+ return 0 != ( ctp[0] & CTX_IMPL_ES3_COMPAT );
+ }
+
+ public static boolean isGL4bcAvailable(final AbstractGraphicsDevice device, final boolean isHardware[]) {
+ return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT, isHardware);
+ }
+
+ public static boolean isGL4Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
+ return isGLVersionAvailable(device, 4, CTX_PROFILE_CORE, isHardware);
+ }
+
+ public static boolean isGL3bcAvailable(final AbstractGraphicsDevice device, final boolean isHardware[]) {
+ return isGLVersionAvailable(device, 3, CTX_PROFILE_COMPAT, isHardware);
+ }
+
+ public static boolean isGL3Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
+ return isGLVersionAvailable(device, 3, CTX_PROFILE_CORE, isHardware);
+ }
+
+ public static boolean isGL2Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
+ return isGLVersionAvailable(device, 2, CTX_PROFILE_COMPAT, isHardware);
+ }
+
+ protected static String getGLVersion(final int major, final int minor, final int ctp, final String gl_version) {
+ boolean needColon = false;
+ final StringBuilder sb = new StringBuilder();
+ sb.append(major);
+ sb.append(".");
+ sb.append(minor);
+ sb.append(" (");
+ needColon = appendString(sb, "ES profile", needColon, 0 != ( CTX_PROFILE_ES & ctp ));
+ needColon = appendString(sb, "Compat profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp ));
+ needColon = appendString(sb, "Core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp ));
+ needColon = appendString(sb, "forward", needColon, 0 != ( CTX_OPTION_FORWARD & ctp ));
+ needColon = appendString(sb, "arb", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp ));
+ needColon = appendString(sb, "debug", needColon, 0 != ( CTX_OPTION_DEBUG & ctp ));
+ needColon = appendString(sb, "ES2 compat", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp ));
+ needColon = appendString(sb, "ES3 compat", needColon, 0 != ( CTX_IMPL_ES3_COMPAT & ctp ));
+ needColon = appendString(sb, "FBO", needColon, 0 != ( CTX_IMPL_FBO & ctp ));
+ needColon = appendString(sb, "FP32 compat", needColon, 0 != ( CTX_IMPL_FP32_COMPAT_API & ctp ));
+ if( 0 != ( CTX_IMPL_ACCEL_SOFT & ctp ) ) {
+ needColon = appendString(sb, "software", needColon, true);
+ } else {
+ needColon = appendString(sb, "hardware", needColon, true);
+ }
+ sb.append(")");
+ if(null!=gl_version) {
+ sb.append(" - ");
+ sb.append(gl_version);
+ }
+ return sb.toString();
+ }
+
+ //
+ // internal string utils
+ //
+
+ protected static String toHexString(final int hex) {
+ return "0x" + Integer.toHexString(hex);
+ }
+
+ protected static String toHexString(final long hex) {
+ return "0x" + Long.toHexString(hex);
+ }
+
+ private static boolean appendString(final StringBuilder sb, final String string, boolean needColon, final boolean condition) {
+ if(condition) {
+ if(needColon) {
+ sb.append(", ");
+ }
+ sb.append(string);
+ needColon=true;
+ }
+ return needColon;
+ }
+
+ protected static String getThreadName() { return Thread.currentThread().getName(); }
+
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/GLDebugListener.java b/src/jogl/classes/com/jogamp/opengl/GLDebugListener.java
new file mode 100644
index 000000000..30e1a49c2
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLDebugListener.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl;
+
+/**
+ * Listener for {@link GLDebugMessage}s.
+ *
+ *
One can enable GLDebugOutput via {@link GLContext#enableGLDebugMessage(boolean)}
+ * and add listeners via {@link GLContext#addGLDebugListener(GLDebugListener)}.
+ */
+public interface GLDebugListener {
+ /**
+ * Handle {@link GLDebugMessage} message sent from native GL implementation.
+ *
+ *
Since this method is invoked directly by the GL implementation, it shall
+ * return as fast as possible.
+ */
+ void messageSent(GLDebugMessage event);
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLDebugMessage.java b/src/jogl/classes/com/jogamp/opengl/GLDebugMessage.java
new file mode 100644
index 000000000..a8868026b
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLDebugMessage.java
@@ -0,0 +1,253 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl;
+
+import com.jogamp.common.os.Platform;
+
+/**
+ * OpenGL debug message generated by the driver
+ * and delivered via {@link GLDebugListener}.
+ */
+public class GLDebugMessage {
+ final GLContext source;
+ final long when;
+ final int dbgSource;
+ final int dbgType;
+ final int dbgId;
+ final int dbgSeverity;
+ final String dbgMsg;
+
+ /**
+ * @param source The source of the event
+ * @param when The time of the event
+ * @param dbgSource The ARB source
+ * @param dbgType The ARB type
+ * @param dbgId The ARB id
+ * @param dbgSeverity The ARB severity level
+ * @param dbgMsg The debug message
+ */
+ public GLDebugMessage(final GLContext source, final long when, final int dbgSource, final int dbgType, final int dbgId, final int dbgSeverity, final String dbgMsg) {
+ this.source = source;
+ this.when = when;
+ this.dbgSource = dbgSource;
+ this.dbgType = dbgType;
+ this.dbgId = dbgId;
+ this.dbgSeverity = dbgSeverity;
+ this.dbgMsg = dbgMsg;
+ }
+
+ /**
+ *
+ * @param source
+ * @param when
+ * @param dbgId
+ * @param amdDbgCategory
+ * @param dbgSeverity AMD severity level equals ARB severity level (value and semantic)
+ * @param dbgMsg
+ * @return
+ */
+ public static GLDebugMessage translateAMDEvent(final GLContext source, final long when, final int dbgId, final int amdDbgCategory, final int dbgSeverity, final String dbgMsg) {
+ int dbgSource, dbgType;
+
+ // AMD category == ARB source/type
+ switch(amdDbgCategory) {
+ case GL2GL3.GL_DEBUG_CATEGORY_API_ERROR_AMD:
+ dbgSource = GL2ES2.GL_DEBUG_SOURCE_API;
+ dbgType = GL2ES2.GL_DEBUG_TYPE_ERROR;
+ break;
+
+ //
+ // def source / other type
+ //
+
+ case GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD:
+ dbgSource = GL2ES2.GL_DEBUG_SOURCE_WINDOW_SYSTEM;
+ dbgType = GL2ES2.GL_DEBUG_TYPE_OTHER;
+ break;
+
+ case GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD:
+ dbgSource = GL2ES2.GL_DEBUG_SOURCE_SHADER_COMPILER;
+ dbgType = GL2ES2.GL_DEBUG_TYPE_OTHER;
+ break;
+
+ case GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD:
+ dbgSource = GL2ES2.GL_DEBUG_SOURCE_APPLICATION;
+ dbgType = GL2ES2.GL_DEBUG_TYPE_OTHER;
+ break;
+
+
+ //
+ // other source / def type
+ //
+
+ case GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD:
+ dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
+ dbgType = GL2ES2.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR;
+ break;
+
+ case GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD:
+ dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
+ dbgType = GL2ES2.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR;
+ break;
+
+ case GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD:
+ dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
+ dbgType = GL2ES2.GL_DEBUG_TYPE_PERFORMANCE;
+ break;
+
+ case GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD:
+ default:
+ dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
+ dbgType = GL2ES2.GL_DEBUG_TYPE_OTHER;
+ }
+
+ return new GLDebugMessage(source, when, dbgSource, dbgType, dbgId, dbgSeverity, dbgMsg);
+ }
+
+ public static int translateARB2AMDCategory(final int dbgSource, final int dbgType) {
+ switch (dbgSource) {
+ case GL2ES2.GL_DEBUG_SOURCE_WINDOW_SYSTEM:
+ return GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD;
+
+ case GL2ES2.GL_DEBUG_SOURCE_SHADER_COMPILER:
+ return GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD;
+
+ case GL2ES2.GL_DEBUG_SOURCE_APPLICATION:
+ return GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD;
+ }
+
+ switch(dbgType) {
+ case GL2ES2.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
+ return GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD;
+
+ case GL2ES2.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
+ return GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD;
+
+ case GL2ES2.GL_DEBUG_TYPE_PERFORMANCE:
+ return GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD;
+ }
+
+ return GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD;
+ }
+
+ public GLContext getSource() {
+ return source;
+ }
+
+ public long getWhen() {
+ return when;
+ }
+
+ public int getDbgSource() {
+ return dbgSource;
+ }
+
+ public int getDbgType() {
+ return dbgType;
+ }
+
+ public int getDbgId() {
+ return dbgId;
+ }
+
+ public int getDbgSeverity() {
+ return dbgSeverity;
+ }
+
+ public String getDbgMsg() {
+ return dbgMsg;
+ }
+
+ public StringBuilder toString(StringBuilder sb) {
+ final String crtab = Platform.getNewline()+"\t";
+ if(null==sb) {
+ sb = new StringBuilder();
+ }
+ sb.append("GLDebugEvent[ id ");
+ toHexString(sb, dbgId)
+ .append(crtab).append("type ").append(getDbgTypeString(dbgType))
+ .append(crtab).append("severity ").append(getDbgSeverityString(dbgSeverity))
+ .append(crtab).append("source ").append(getDbgSourceString(dbgSource))
+ .append(crtab).append("msg ").append(dbgMsg)
+ .append(crtab).append("when ").append(when);
+ if(null != source) {
+ sb.append(crtab).append("source ").append(source.getGLVersion()).append(" - hash 0x").append(Integer.toHexString(source.hashCode()));
+ }
+ sb.append("]");
+ return sb;
+ }
+
+ @Override
+ public String toString() {
+ return toString(null).toString();
+ }
+
+ public static String getDbgSourceString(final int dbgSource) {
+ switch(dbgSource) {
+ case GL2ES2.GL_DEBUG_SOURCE_API: return "GL API";
+ case GL2ES2.GL_DEBUG_SOURCE_SHADER_COMPILER: return "GLSL or extension compiler";
+ case GL2ES2.GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "Native Windowing binding";
+ case GL2ES2.GL_DEBUG_SOURCE_THIRD_PARTY: return "Third party";
+ case GL2ES2.GL_DEBUG_SOURCE_APPLICATION: return "Application";
+ case GL2ES2.GL_DEBUG_SOURCE_OTHER: return "generic";
+ default: return "Unknown (" + toHexString(dbgSource) + ")";
+ }
+ }
+
+ public static String getDbgTypeString(final int dbgType) {
+ switch(dbgType) {
+ case GL2ES2.GL_DEBUG_TYPE_ERROR: return "Error";
+ case GL2ES2.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "Warning: marked for deprecation";
+ case GL2ES2.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "Warning: undefined behavior";
+ case GL2ES2.GL_DEBUG_TYPE_PERFORMANCE: return "Warning: implementation dependent performance";
+ case GL2ES2.GL_DEBUG_TYPE_PORTABILITY: return "Warning: vendor-specific extension use";
+ case GL2ES2.GL_DEBUG_TYPE_OTHER: return "Warning: generic";
+ default: return "Unknown (" + toHexString(dbgType) + ")";
+ }
+ }
+
+ public static String getDbgSeverityString(final int dbgSeverity) {
+ switch(dbgSeverity) {
+ case GL2ES2.GL_DEBUG_SEVERITY_HIGH: return "High: dangerous undefined behavior";
+ case GL2ES2.GL_DEBUG_SEVERITY_MEDIUM: return "Medium: Severe performance/deprecation/other warnings";
+ case GL2ES2.GL_DEBUG_SEVERITY_LOW: return "Low: Performance warnings (redundancy/undefined)";
+ default: return "Unknown (" + toHexString(dbgSeverity) + ")";
+ }
+ }
+
+ public static StringBuilder toHexString(StringBuilder sb, final int i) {
+ if(null==sb) {
+ sb = new StringBuilder();
+ }
+ return sb.append("0x").append(Integer.toHexString(i));
+ }
+ public static String toHexString(final int i) {
+ return "0x"+Integer.toHexString(i);
+ }
+
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLDrawable.java b/src/jogl/classes/com/jogamp/opengl/GLDrawable.java
new file mode 100644
index 000000000..c801ba463
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLDrawable.java
@@ -0,0 +1,251 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.opengl;
+
+import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
+import com.jogamp.nativewindow.NativeSurface;
+import com.jogamp.nativewindow.NativeSurfaceHolder;
+
+
+/** An abstraction for an OpenGL rendering target. A GLDrawable's
+ primary functionality is to create OpenGL contexts which can be
+ used to perform rendering. A GLDrawable does not automatically
+ create an OpenGL context, but all implementations of {@link
+ GLAutoDrawable} do so upon creation. */
+
+public interface GLDrawable extends NativeSurfaceHolder {
+ /**
+ * Creates a new context for drawing to this drawable that will
+ * optionally share buffer objects, textures and other server-side OpenGL
+ * objects with the specified GLContext.
+ *
+ * The GLContext share need not be associated with this
+ * GLDrawable and may be null if sharing of display lists and other
+ * objects is not desired. See the note in the overview
+ * documentation
+ * context sharing
+ * as well as {@link GLSharedContextSetter}.
+ *
+ */
+ public GLContext createContext(GLContext shareWith);
+
+ /**
+ * Indicates to GLDrawable implementations whether the
+ * underlying {@link NativeSurface surface} has been created and can be drawn into.
+ *
+ * If realized, the {@link #getHandle() drawable handle} may become
+ * valid while it's {@link NativeSurface surface} is being {@link NativeSurface#lockSurface() locked}.
+ *
+ *
+ * End users do not need to call this method; it is not necessary to
+ * call setRealized on a {@link GLAutoDrawable}
+ * as these perform the appropriate calls on their underlying GLDrawables internally.
+ *
+ *
+ * Developers implementing new OpenGL components for various window
+ * toolkits need to call this method against GLDrawables obtained
+ * from the GLDrawableFactory via the
+ * {@link GLDrawableFactory#createGLDrawable(NativeSurface)} method.
+ * It must typically be
+ * called with an argument of true when the component
+ * associated with the GLDrawable is realized and with an argument
+ * of false just before the component is unrealized.
+ * For the AWT, this means calling setRealized(true) in
+ * the addNotify method and with an argument of
+ * false in the removeNotify method.
+ *
+ *
+ * GLDrawable implementations should handle multiple
+ * cycles of setRealized(true) /
+ * setRealized(false) calls. Most, if not all, Java
+ * window toolkits have a persistent object associated with a given
+ * component, regardless of whether that component is currently
+ * realized. The GLDrawable object associated with a
+ * particular component is intended to be similarly persistent. A
+ * GLDrawable is intended to be created for a given
+ * component when it is constructed and live as long as that
+ * component. setRealized allows the
+ * GLDrawable to re-initialize and destroy any
+ * associated resources as the component becomes realized and
+ * unrealized, respectively.
+ *
+ *
+ * With an argument of true,
+ * the minimum implementation shall call
+ * {@link NativeSurface#lockSurface() NativeSurface's lockSurface()} and if successful:
+ *
+ *
Update the {@link GLCapabilities}, which are associated with
+ * the attached {@link NativeSurface}'s {@link AbstractGraphicsConfiguration}.
+ *
Release the lock with {@link NativeSurface#unlockSurface() NativeSurface's unlockSurface()}.
+ *
+ * This is important since {@link NativeSurface#lockSurface() NativeSurface's lockSurface()}
+ * ensures resolving the window/surface handles, and the drawable's {@link GLCapabilities}
+ * might have changed.
+ *
+ *
+ * Calling this method has no other effects. For example, if
+ * removeNotify is called on a Canvas implementation
+ * for which a GLDrawable has been created, it is also necessary to
+ * destroy all OpenGL contexts associated with that GLDrawable. This
+ * is not done automatically by the implementation.
+ *
+ * @see #isRealized()
+ * @see #getHandle()
+ * @see NativeSurface#lockSurface()
+ */
+ public void setRealized(boolean realized);
+
+ /**
+ * Returns true if this drawable is realized, otherwise true.
+ *
+ * A drawable can be realized and unrealized via {@link #setRealized(boolean)}.
+ *
+ * @see #setRealized(boolean)
+ */
+ public boolean isRealized();
+
+ /**
+ * Returns the width of this {@link GLDrawable}'s {@link #getNativeSurface() surface} client area in pixel units.
+ * @see NativeSurface#getSurfaceWidth()
+ */
+ public int getSurfaceWidth();
+
+ /**
+ * Returns the height of this {@link GLDrawable}'s {@link #getNativeSurface() surface} client area in pixel units.
+ * @see NativeSurface#getSurfaceHeight()
+ */
+ public int getSurfaceHeight();
+
+ /**
+ * Returns true if the drawable is rendered in
+ * OpenGL's coordinate system, origin at bottom left.
+ * Otherwise returns false, i.e. origin at top left.
+ *
+ * Default impl. is true, i.e. OpenGL coordinate system.
+ *
+ *
+ * Currently only MS-Windows bitmap offscreen drawable uses a non OpenGL orientation and hence returns false.
+ * This removes the need of a vertical flip when used in AWT or Windows applications.
+ *
+ */
+ public boolean isGLOriented();
+
+ /** Swaps the front and back buffers of this drawable. For {@link
+ GLAutoDrawable} implementations, when automatic buffer swapping
+ is enabled (as is the default), this method is called
+ automatically and should not be called by the end user. */
+ public void swapBuffers() throws GLException;
+
+ /** Fetches the {@link GLCapabilitiesImmutable} corresponding to the chosen
+ OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
+
+ This query only returns the chosen capabilities if {@link #isRealized()}.
+
+
+ On some platforms, the pixel format is not directly associated
+ with the drawable; a best attempt is made to return a reasonable
+ value in this case.
+
+
+ This object shall be directly associated to the attached {@link NativeSurface}'s
+ {@link AbstractGraphicsConfiguration}, and if changes are necessary,
+ they should reflect those as well.
+
+ @return The immutable queried instance.
+ @see #getRequestedGLCapabilities()
+ */
+ public GLCapabilitiesImmutable getChosenGLCapabilities();
+
+ /** Fetches the {@link GLCapabilitiesImmutable} corresponding to the user requested
+ OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
+
+ If {@link #isRealized() realized}, {@link #getChosenGLCapabilities() the chosen capabilities}
+ reflect the actual selected OpenGL capabilities.
+
+ @return The immutable queried instance.
+ @see #getChosenGLCapabilities()
+ @since 2.2
+ */
+ public GLCapabilitiesImmutable getRequestedGLCapabilities();
+
+ /** Fetches the {@link GLProfile} for this drawable.
+ Returns the GLProfile object, no copy.
+ */
+ public GLProfile getGLProfile();
+
+ /**
+ * {@inheritDoc}
+ *
+ * Returns the underlying {@link NativeSurface} which {@link NativeSurface#getSurfaceHandle() native handle}
+ * represents this OpenGL drawable's native resource.
+ *
+ *
+ * @see #getHandle()
+ */
+ @Override
+ public NativeSurface getNativeSurface();
+
+ /**
+ * Returns the GL drawable handle,
+ * guaranteed to be valid after {@link #setRealized(boolean) realization}
+ * and while it's {@link NativeSurface surface} is being {@link NativeSurface#lockSurface() locked}.
+ *
+ * It is usually identical to the underlying windowing toolkit {@link NativeSurface surface}'s
+ * {@link com.jogamp.nativewindow.NativeSurface#getSurfaceHandle() handle}
+ * or an intermediate layer to suite GL, e.g. an EGL surface.
+ *
+ *
+ * On EGL it is represented by the EGLSurface.
+ * On X11/GLX it is represented by either the Window XID, GLXPixmap, or GLXPbuffer.
+ * On Windows it is represented by the HDC, which may change with each {@link NativeSurface#lockSurface()}.
+ *
+ * @see #setRealized(boolean)
+ * @see NativeSurface#lockSurface()
+ * @see NativeSurface#unlockSurface()
+ */
+ public long getHandle();
+
+ /** Return the {@link GLDrawableFactory} being used to create this instance. */
+ public GLDrawableFactory getFactory();
+
+ @Override
+ public String toString();
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/GLDrawableFactory.java
new file mode 100644
index 000000000..07c3e77e0
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLDrawableFactory.java
@@ -0,0 +1,798 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.opengl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.jogamp.common.util.PropertyAccess;
+import com.jogamp.common.util.ReflectionUtil;
+import com.jogamp.opengl.GLAutoDrawableDelegate;
+import com.jogamp.opengl.GLRendererQuirks;
+
+import com.jogamp.nativewindow.AbstractGraphicsDevice;
+import com.jogamp.nativewindow.AbstractGraphicsScreen;
+import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
+import com.jogamp.nativewindow.CapabilitiesImmutable;
+import com.jogamp.nativewindow.NativeSurface;
+import com.jogamp.nativewindow.NativeWindowFactory;
+import com.jogamp.nativewindow.ProxySurface;
+import com.jogamp.nativewindow.UpstreamSurfaceHook;
+
+import jogamp.opengl.Debug;
+
+/**
Provides a virtual machine- and operating system-independent
+ mechanism for creating {@link GLDrawable}s.
+
+
The {@link com.jogamp.opengl.GLCapabilities} objects passed
+ in to the various factory methods are used as a hint for the
+ properties of the returned drawable. The default capabilities
+ selection algorithm (equivalent to passing in a null {@link
+ GLCapabilitiesChooser}) is described in {@link
+ DefaultGLCapabilitiesChooser}. Sophisticated applications needing
+ to change the selection algorithm may pass in their own {@link
+ GLCapabilitiesChooser} which can select from the available pixel
+ formats. The GLCapabilitiesChooser mechanism may not be supported
+ by all implementations or on all platforms, in which case any
+ passed GLCapabilitiesChooser will be ignored.
+
+
+
Because of the multithreaded nature of the Java platform's
+ Abstract Window Toolkit, it is typically not possible to immediately
+ reject a given {@link GLCapabilities} as being unsupportable by
+ either returning null from the creation routines or
+ raising a {@link GLException}. The semantics of the rejection
+ process are (unfortunately) left unspecified for now. The current
+ implementation will cause a {@link GLException} to be raised
+ during the first repaint of the {@link com.jogamp.opengl.awt.GLCanvas} or {@link
+ com.jogamp.opengl.awt.GLJPanel} if the capabilities can not be met.
+ {@link GLOffscreenAutoDrawable} are created lazily,
+ see {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) createOffscreenAutoDrawable(..)}.
+
+
+
The concrete GLDrawableFactory subclass instantiated by {@link
+ #getFactory getFactory} can be changed by setting the system
+ property opengl.factory.class.name to the
+ fully-qualified name of the desired class.
+
+*/
+public abstract class GLDrawableFactory {
+
+ protected static final boolean DEBUG = Debug.debug("GLDrawable");
+
+ private static volatile boolean isInit = false;
+ private static GLDrawableFactory eglFactory;
+ private static GLDrawableFactory nativeOSFactory;
+
+ private static ArrayList glDrawableFactories = new ArrayList();
+
+ /**
+ * Instantiate singleton factories if available, EGLES1, EGLES2 and the OS native ones.
+ */
+ public static final void initSingleton() {
+ if (!isInit) { // volatile: ok
+ synchronized (GLDrawableFactory.class) {
+ if (!isInit) {
+ isInit=true;
+ initSingletonImpl();
+ }
+ }
+ }
+ }
+ private static final void initSingletonImpl() {
+ NativeWindowFactory.initSingleton();
+ NativeWindowFactory.addCustomShutdownHook(false /* head */, new Runnable() {
+ @Override
+ public void run() {
+ shutdown0();
+ }
+ });
+
+ final String nwt = NativeWindowFactory.getNativeWindowType(true);
+ GLDrawableFactory tmp = null;
+ String factoryClassName = PropertyAccess.getProperty("jogl.gldrawablefactory.class.name", true);
+ final ClassLoader cl = GLDrawableFactory.class.getClassLoader();
+ if (null == factoryClassName) {
+ if ( nwt == NativeWindowFactory.TYPE_X11 ) {
+ factoryClassName = "jogamp.opengl.x11.glx.X11GLXDrawableFactory";
+ } else if ( nwt == NativeWindowFactory.TYPE_WINDOWS ) {
+ factoryClassName = "jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory";
+ } else if ( nwt == NativeWindowFactory.TYPE_MACOSX ) {
+ factoryClassName = "jogamp.opengl.macosx.cgl.MacOSXCGLDrawableFactory";
+ } else {
+ // may use egl*Factory ..
+ if (DEBUG || GLProfile.DEBUG) {
+ System.err.println("GLDrawableFactory.static - No native Windowing Factory for: "+nwt+"; May use EGLDrawableFactory, if available." );
+ }
+ }
+ }
+ if (null != factoryClassName && !GLProfile.disableOpenGLDesktop) {
+ if (DEBUG || GLProfile.DEBUG) {
+ System.err.println("GLDrawableFactory.static - Native OS Factory for: "+nwt+": "+factoryClassName);
+ }
+ try {
+ tmp = (GLDrawableFactory) ReflectionUtil.createInstance(factoryClassName, cl);
+ } catch (final Exception jre) {
+ if (DEBUG || GLProfile.DEBUG) {
+ System.err.println("Info: GLDrawableFactory.static - Native Platform: "+nwt+" - not available: "+factoryClassName);
+ jre.printStackTrace();
+ }
+ }
+ }
+ if(null != tmp && tmp.isComplete()) {
+ nativeOSFactory = tmp;
+ }
+ tmp = null;
+
+ if(!GLProfile.disableOpenGLES) {
+ try {
+ tmp = (GLDrawableFactory) ReflectionUtil.createInstance("jogamp.opengl.egl.EGLDrawableFactory", cl);
+ } catch (final Exception jre) {
+ if (DEBUG || GLProfile.DEBUG) {
+ System.err.println("Info: GLDrawableFactory.static - EGLDrawableFactory - not available");
+ jre.printStackTrace();
+ }
+ }
+ if(null != tmp && tmp.isComplete()) {
+ eglFactory = tmp;
+ }
+ } else if( DEBUG || GLProfile.DEBUG ) {
+ System.err.println("Info: GLDrawableFactory.static - EGLDrawableFactory - disabled!");
+ }
+ }
+
+ protected static void shutdown() {
+ if (isInit) { // volatile: ok
+ synchronized (GLDrawableFactory.class) {
+ if (isInit) {
+ isInit=false;
+ shutdown0();
+ }
+ }
+ }
+ }
+
+ private static void shutdown0() {
+ // Following code will _always_ remain in shutdown hook
+ // due to special semantics of native utils, i.e. X11Utils.
+ // The latter requires shutdown at JVM-Shutdown only.
+ synchronized(glDrawableFactories) {
+ final int gldfCount = glDrawableFactories.size();
+ if( DEBUG ) {
+ System.err.println("GLDrawableFactory.shutdownAll "+gldfCount+" instances, on thread "+getThreadName());
+ }
+ for(int i=0; isurface.
+ *
+ * This functionality is not available on all platforms and
+ * graphics hardware. Returns true if the settings were successfully
+ * changed, false if not. This method may return false for some
+ * values of the incoming arguments even on hardware which does
+ * support the underlying functionality.
+ *
+ * If this method returns true, the display settings will
+ * automatically be reset to their original values upon JVM exit
+ * (assuming the JVM does not crash); if the user wishes to change
+ * the display settings back to normal ahead of time,
+ * use {@link #resetDisplayGamma(NativeSurface)} or {@link #resetAllDisplayGamma()}.
+ *
+ *
+ * It is recommended to call {@link #resetDisplayGamma(NativeSurface)} or {@link #resetAllDisplayGamma()}
+ * before calling e.g. System.exit() from the application rather than
+ * rely on the shutdown hook functionality due to inevitable race
+ * conditions and unspecified behavior during JVM teardown.
+ *
+ *
+ * This method may be called multiple times during the application's
+ * execution, but calling {@link #resetDisplayGamma(NativeSurface)}
+ * will only reset the settings to the values
+ * before the first call to this method.
+ *
+ * @param surface denominates the display device
+ * @param gamma The gamma value, typically > 1.0 (default values vary, but typically roughly 1.0)
+ * @param brightness The brightness value between -1.0 and 1.0, inclusive (default values vary, but typically 0)
+ * @param contrast The contrast, greater than 0.0 (default values vary, but typically 1)
+ *
+ * @return true if gamma settings were successfully changed, false if not
+ * @throws IllegalArgumentException if any of the parameters were out-of-bounds
+ * @see #resetDisplayGamma(NativeSurface)
+ * @see #resetAllDisplayGamma()
+ */
+ public abstract boolean setDisplayGamma(final NativeSurface surface, final float gamma, final float brightness, final float contrast) throws IllegalArgumentException;
+
+ /**
+ * Resets the gamma, brightness and contrast values of the display associated with the given surface
+ * to its original values before {@link #setDisplayGamma(NativeSurface, float, float, float) setDisplayGamma}
+ * was called the first time.
+ *
+ * While it is not explicitly required that this method be called before
+ * exiting manually, calling it is recommended because of the inevitable
+ * unspecified behavior during JVM teardown.
+ *
+ */
+ public abstract void resetDisplayGamma(final NativeSurface surface);
+
+ /**
+ * Resets the gamma, brightness and contrast values of all modified
+ * displays to their original values before {@link #setDisplayGamma(NativeSurface, float, float, float) setDisplayGamma}
+ * was called the first time.
+ *
+ * While it is not explicitly required that this method be called before
+ * exiting manually, calling it is recommended because of the inevitable
+ * unspecified behavior during JVM teardown.
+ *
+ */
+ public abstract void resetAllDisplayGamma();
+
+ protected abstract void resetAllDisplayGammaNoSync();
+
+ /**
+ * Retrieve the default device {@link AbstractGraphicsDevice#getConnection() connection},
+ * {@link AbstractGraphicsDevice#getUnitID() unit ID} and {@link AbstractGraphicsDevice#getUniqueID() unique ID name}. for this factory
+ * The implementation must return a non null default device, which must not be opened, ie. it's native handle is null.
+ *
+ * This method shall return the default device if available
+ * even if the GLDrawableFactory is not functional and hence not compatible.
+ * The latter situation may happen because no native OpenGL implementation is available for the specific implementation.
+ *
+ * @return the default shared device for this factory, eg. :0.0 on X11 desktop.
+ * @see #getIsDeviceCompatible(AbstractGraphicsDevice)
+ */
+ public abstract AbstractGraphicsDevice getDefaultDevice();
+
+ /**
+ * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
+ * @return true if the device is compatible with this factory, ie. if it can be used for GLDrawable creation. Otherwise false.
+ * This implies validation whether the implementation is functional.
+ *
+ * @see #getDefaultDevice()
+ */
+ public abstract boolean getIsDeviceCompatible(AbstractGraphicsDevice device);
+
+ protected final AbstractGraphicsDevice validateDevice(AbstractGraphicsDevice device) {
+ if(null==device) {
+ device = getDefaultDevice();
+ if(null==device) {
+ throw new InternalError("no default device available");
+ }
+ if (GLProfile.DEBUG) {
+ System.err.println("Info: "+getClass().getSimpleName()+".validateDevice: using default device : "+device);
+ }
+ }
+
+ // Always validate the device,
+ // since even the default device may not be used by this factory.
+ if( !getIsDeviceCompatible(device) ) {
+ if (GLProfile.DEBUG) {
+ System.err.println("Info: "+getClass().getSimpleName()+".validateDevice: device not compatible : "+device);
+ }
+ return null;
+ }
+ return device;
+ }
+
+ /**
+ * Validate and start the shared resource runner thread if necessary and
+ * if the implementation uses it.
+ *
+ * @return the shared resource runner thread, if implementation uses it.
+ */
+ protected abstract Thread getSharedResourceThread();
+
+ /**
+ * Create the shared resource used internally as a reference for capabilities etc.
+ *
+ * Returns true if a shared resource could be created
+ * for the device {@link AbstractGraphicsDevice#getConnection()}.
+ * This does not imply a shared resource is mapped (ie. made persistent), but is available in general .
+ *
+ *
+ * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
+ * @return true if a shared resource could been created, otherwise false.
+ */
+ protected final boolean createSharedResource(final AbstractGraphicsDevice device) {
+ return createSharedResourceImpl(device);
+ }
+ protected abstract boolean createSharedResourceImpl(AbstractGraphicsDevice device);
+
+ /**
+ * Returns true if the quirk exist in the shared resource's context {@link GLRendererQuirks}.
+ *
+ *
+ *
+ * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
+ * @param glp {@link GLProfile} to identify the device's {@link GLRendererQuirks}, maybe {@code null}
+ * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}.
+ * @throws IllegalArgumentException if the quirk is out of range
+ * @see #getRendererQuirks(AbstractGraphicsDevice, GLProfile)
+ * @see GLRendererQuirks
+ */
+ public final boolean hasRendererQuirk(final AbstractGraphicsDevice device, final GLProfile glp, final int quirk) {
+ final GLRendererQuirks glrq = getRendererQuirks(device, glp);
+ return null != glrq ? glrq.exist(quirk) : false;
+ }
+
+ /**
+ * Returns the shared resource's context {@link GLRendererQuirks}.
+ *
+ * Implementation calls {@link GLContext#getRendererQuirks()} on the shared resource context.
+ *
+ *
+ * In case no shared device exist yet or the implementation doesn't support tracking quirks,
+ * the result is always null.
+ *
+ * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
+ * @param glp {@link GLProfile} to identify the device's {@link GLRendererQuirks}, maybe {@code null}
+ * @see GLContext#getRendererQuirks()
+ * @see GLRendererQuirks
+ */
+ public abstract GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device, final GLProfile glp);
+
+ /**
+ * Returns the sole GLDrawableFactory instance for the desktop (X11, WGL, ..) if exist or null
+ */
+ public static GLDrawableFactory getDesktopFactory() {
+ GLProfile.initSingleton();
+ return nativeOSFactory;
+ }
+
+ /**
+ * Returns the sole GLDrawableFactory instance for EGL if exist or null
+ */
+ public static GLDrawableFactory getEGLFactory() {
+ GLProfile.initSingleton();
+ return eglFactory;
+ }
+
+ /**
+ * Returns the sole GLDrawableFactory instance.
+ *
+ * @param glProfile GLProfile to determine the factory type, ie EGLDrawableFactory,
+ * or one of the native GLDrawableFactory's, ie X11/GLX, Windows/WGL or MacOSX/CGL.
+ */
+ public static GLDrawableFactory getFactory(final GLProfile glProfile) throws GLException {
+ return getFactoryImpl(glProfile.getImplName());
+ }
+
+ protected static GLDrawableFactory getFactoryImpl(final String glProfileImplName) throws GLException {
+ if ( GLProfile.usesNativeGLES(glProfileImplName) ) {
+ if(null!=eglFactory) {
+ return eglFactory;
+ }
+ } else if(null!=nativeOSFactory) {
+ return nativeOSFactory;
+ }
+ throw new GLException("No GLDrawableFactory available for profile: "+glProfileImplName);
+ }
+
+ protected static GLDrawableFactory getFactoryImpl(final AbstractGraphicsDevice device) throws GLException {
+ if(null != nativeOSFactory && nativeOSFactory.getIsDeviceCompatible(device)) {
+ return nativeOSFactory;
+ }
+ if(null != eglFactory && eglFactory.getIsDeviceCompatible(device)) {
+ return eglFactory;
+ }
+ throw new GLException("No native platform GLDrawableFactory, nor EGLDrawableFactory available: "+device);
+ }
+
+ /**
+ * Returns an array of available GLCapabilities for the device.
+ * The list is sorted by the native ID, ascending.
+ * The chosen GLProfile statement in the result may not refer to the maximum available profile
+ * due to implementation constraints, ie using the shared resource.
+ *
+ * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
+ * @return A list of {@link com.jogamp.opengl.GLCapabilitiesImmutable}'s, maybe empty if none is available.
+ */
+ public final List getAvailableCapabilities(AbstractGraphicsDevice device) {
+ device = validateDevice(device);
+ if(null!=device) {
+ return getAvailableCapabilitiesImpl(device);
+ }
+ return null;
+ }
+ protected abstract List getAvailableCapabilitiesImpl(AbstractGraphicsDevice device);
+
+ //----------------------------------------------------------------------
+ // Methods to create high-level objects
+
+ /**
+ * Returns an {@link GLDrawable#isRealized() unrealized} GLDrawable according to it's chosen {@link GLCapabilitiesImmutable},
+ * which determines pixel format, on- and offscreen incl. PBuffer type.
+ *
+ * The chosen {@link GLCapabilitiesImmutable} are referenced within the target
+ * {@link NativeSurface}'s {@link AbstractGraphicsConfiguration}.
+ *
+ *
+ * An onscreen GLDrawable is created if {@link CapabilitiesImmutable#isOnscreen() caps.isOnscreen()} is true.
+ *
+ *
+ * A FBO drawable is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()}
+ * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true.
+ *
+ *
+ * A Pbuffer drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()}
+ * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true.
+ *
+ *
+ * If not onscreen and neither FBO nor Pbuffer is available,
+ * a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated.
+ *
+ *
+ * @throws IllegalArgumentException if the passed target is null
+ * @throws GLException if any window system-specific errors caused
+ * the creation of the GLDrawable to fail.
+ *
+ * @see #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile)
+ * @see GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile)
+ * @see com.jogamp.opengl.GLCapabilities#isOnscreen()
+ * @see com.jogamp.opengl.GLCapabilities#isFBO()
+ * @see com.jogamp.opengl.GLCapabilities#isPBuffer()
+ * @see GraphicsConfigurationFactory#chooseGraphicsConfiguration(CapabilitiesImmutable, CapabilitiesImmutable, CapabilitiesChooser, AbstractGraphicsScreen, int)
+ */
+ public abstract GLDrawable createGLDrawable(NativeSurface target)
+ throws IllegalArgumentException, GLException;
+
+ /**
+ * Creates a {@link GLDrawable#isRealized() realized} {@link GLOffscreenAutoDrawable}
+ * incl it's offscreen {@link NativeSurface} with the given capabilites and dimensions.
+ *
+ * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized}
+ * without an assigned {@link GLContext}, hence not initialized completely.
+ *
+ * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)}
+ * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
+ *
+ * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account
+ * which has been set {@link GLOffscreenAutoDrawable#setSharedContext(GLContext) directly}
+ * or {@link GLOffscreenAutoDrawable#setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}.
+ *
+ *
+ * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e.
+ * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true,
+ * it is auto-configured. Auto configuration will set {@link GLCapabilitiesImmutable caps} to offscreen
+ * and FBO or Pbuffer, whichever is available in that order.
+ *
+ *
+ * A FBO based auto drawable, {@link GLOffscreenAutoDrawable.FBO}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()}
+ * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true.
+ *
+ *
+ * A Pbuffer based auto drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()}
+ * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true.
+ *
+ *
+ * If neither FBO nor Pbuffer is available,
+ * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated.
+ *
+ *
+ * The resulting {@link GLOffscreenAutoDrawable} has it's own independent device instance using device details.
+ *
+ *
+ * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device.
+ * @param caps the requested GLCapabilties
+ * @param chooser the custom chooser, may be null for default
+ * @param width the requested offscreen width
+ * @param height the requested offscreen height
+ * @return the created and realized offscreen {@link GLOffscreenAutoDrawable} instance
+ *
+ * @throws GLException if any window system-specific errors caused
+ * the creation of the Offscreen to fail.
+ *
+ * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int)
+ */
+ public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device,
+ GLCapabilitiesImmutable caps,
+ GLCapabilitiesChooser chooser,
+ int width, int height) throws GLException;
+
+ /**
+ * Creates a {@link GLDrawable#isRealized() realized} dummy {@link GLAutoDrawable}
+ * incl it's dummy, invisible {@link NativeSurface}
+ * as created with {@link #createDummyDrawable(AbstractGraphicsDevice, boolean, GLCapabilitiesImmutable, GLCapabilitiesChooser)}.
+ *
+ * The dummy {@link GLAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized}
+ * without an assigned {@link GLContext}, hence not initialized completely.
+ * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)}
+ * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
+ * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account
+ * which has been set {@link GLOffscreenAutoDrawable#setSharedContext(GLContext) directly}
+ * or {@link GLOffscreenAutoDrawable#setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}.
+ *
+ *
+ * @param deviceReq which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device.
+ * @param createNewDevice if true a new independent device instance is created from the deviceReq, otherwise deviceReq is used as-is and must be valid!
+ * @param capsRequested the desired {@link GLCapabilitiesImmutable}, incl. it's {@link GLProfile}.
+ * For shared context, same {@link GLCapabilitiesImmutable#getVisualID(com.jogamp.nativewindow.VisualIDHolder.VIDType)}
+ * across shared drawables will yield best compatibility.
+ * @param chooser the custom chooser, may be null for default
+ * @return the created and realized dummy {@link GLAutoDrawable} instance
+ *
+ * @see #createDummyDrawable(AbstractGraphicsDevice, boolean, GLCapabilitiesImmutable, GLCapabilitiesChooser)
+ */
+ public abstract GLAutoDrawable createDummyAutoDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser);
+
+ /**
+ * Creates an {@link GLDrawable#isRealized() unrealized} offscreen {@link GLDrawable}
+ * incl it's offscreen {@link NativeSurface} with the given capabilites and dimensions.
+ *
+ * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e.
+ * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true,
+ * it is auto-configured. The latter will set offscreen and also FBO or Pbuffer, whichever is available in that order.
+ *
+ *
+ * A resizeable FBO drawable, {@link GLFBODrawable.Resizeable}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()}
+ * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true.
+ *
+ *
+ * A Pbuffer drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()}
+ * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true.
+ *
+ *
+ * If neither FBO nor Pbuffer is available,
+ * a simple pixmap/bitmap drawable is created, which is unlikely to be hardware accelerated.
+ *
+ *
+ * The resulting {@link GLDrawable} has it's own independent device instance using device details.
+ *
+ *
+ * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device.
+ * @param caps the requested GLCapabilties
+ * @param chooser the custom chooser, may be null for default
+ * @param width the requested offscreen width
+ * @param height the requested offscreen height
+ *
+ * @return the created unrealized offscreen {@link GLDrawable}
+ *
+ * @throws GLException if any window system-specific errors caused
+ * the creation of the Offscreen to fail.
+ *
+ * @see #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext)
+ */
+ public abstract GLDrawable createOffscreenDrawable(AbstractGraphicsDevice device,
+ GLCapabilitiesImmutable caps,
+ GLCapabilitiesChooser chooser,
+ int width, int height) throws GLException;
+
+ /**
+ * Creates an {@link GLDrawable#isRealized() unrealized} dummy {@link GLDrawable}.
+ * A dummy drawable is not visible on screen and will not be used to render directly to, it maybe on- or offscreen.
+ *
+ * It is used to allow the creation of a {@link GLContext} to query information.
+ * It also allows creation of framebuffer objects which are used for rendering or creating a shared GLContext w/o actually rendering to this dummy drawable's framebuffer.
+ *
+ * @param deviceReq which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device.
+ * @param createNewDevice if true a new independent device instance is created from the deviceReq, otherwise deviceReq is used as-is and must be valid!
+ * @param capsRequested the desired {@link GLCapabilitiesImmutable}, incl. it's {@link GLProfile}.
+ * For shared context, same {@link GLCapabilitiesImmutable#getVisualID(com.jogamp.nativewindow.VisualIDHolder.VIDType) visual ID}
+ * or {@link GLCapabilitiesImmutable caps}
+ * across shared drawables will yield best compatibility.
+ * @param chooser the custom chooser, may be null for default
+ * @return the created unrealized dummy {@link GLDrawable}
+ */
+ public abstract GLDrawable createDummyDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser);
+
+ /**
+ * Creates a proxy {@link NativeSurface} w/ defined surface handle,
+ * i.e. a {@link jogamp.nativewindow.WrappedSurface} or {@link jogamp.nativewindow.windows.GDISurface} instance.
+ *
+ * It's {@link AbstractGraphicsConfiguration} is properly set according to the given
+ * windowHandle's native visualID if set or the given {@link GLCapabilitiesImmutable}.
+ *
+ *
+ * Lifecycle (creation and destruction) of the given surface handle shall be handled by the caller
+ * via {@link ProxySurface#createNotify()} and {@link ProxySurface#destroyNotify()}.
+ *
+ *
+ * Such surface can be used to instantiate a GLDrawable. With the help of {@link GLAutoDrawableDelegate}
+ * you will be able to implement a new native windowing system binding almost on-the-fly,
+ * see {@link com.jogamp.opengl.swt.GLCanvas}.
+ *
+ *
+ * The resulting {@link GLOffscreenAutoDrawable} has it's own independent device instance using device details
+ * which may be blocking depending on platform and windowing-toolkit requirements.
+ *
+ *
+ * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
+ * Caller has to ensure it is compatible w/ the given windowHandle
+ * @param screenIdx matching screen index of given windowHandle
+ * @param windowHandle the native window handle
+ * @param caps the requested GLCapabilties
+ * @param chooser the custom chooser, may be null for default
+ * @param upstream optional {@link UpstreamSurfaceHook} allowing control of the {@link ProxySurface}'s lifecycle and data it presents.
+ * @return the created {@link ProxySurface} instance w/ defined surface handle.
+ */
+ public abstract ProxySurface createProxySurface(AbstractGraphicsDevice device,
+ int screenIdx,
+ long windowHandle,
+ GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream);
+
+ /**
+ * Returns true if it is possible to create an framebuffer object (FBO).
+ *
+ * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent.
+ *
+ *
+ * FBO support is queried as described in {@link GLContext#hasBasicFBOSupport()}.
+ *
+ *
+ * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
+ * @param glp {@link GLProfile} to check for FBO capabilities
+ * @see GLContext#hasBasicFBOSupport()
+ */
+ public abstract boolean canCreateFBO(AbstractGraphicsDevice device, GLProfile glp);
+
+ /**
+ * Returns true if it is possible to create an pbuffer surface.
+ *
+ * Some older graphics cards do not have this capability,
+ * as well as some new GL implementation, i.e. OpenGL 3 core on OSX.
+ *
+ *
+ * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
+ * @param glp {@link GLProfile} to check for FBO capabilities
+ */
+ public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device, GLProfile glp);
+
+ //----------------------------------------------------------------------
+ // Methods for interacting with third-party OpenGL libraries
+
+ /**
+ *
Creates a GLContext object representing an existing OpenGL
+ * context in an external (third-party) OpenGL-based library. This
+ * GLContext object may be used to draw into this preexisting
+ * context using its {@link GL} and {@link
+ * com.jogamp.opengl.glu.GLU} objects. New contexts created through
+ * {@link GLDrawable}s may share textures and display lists with
+ * this external context.
+ *
+ *
The underlying OpenGL context must be current on the current
+ * thread at the time this method is called. The user is responsible
+ * for the maintenance of the underlying OpenGL context; calls to
+ * makeCurrent and release on the returned
+ * GLContext object have no effect. If the underlying OpenGL context
+ * is destroyed, the destroy method should be called on
+ * the GLContext. A new GLContext object
+ * should be created for each newly-created underlying OpenGL
+ * context.
+ *
+ * @throws GLException if any window system-specific errors caused
+ * the creation of the external GLContext to fail.
+ */
+ public abstract GLContext createExternalGLContext()
+ throws GLException;
+
+ /**
+ * Returns true if it is possible to create an external GLDrawable
+ * object via {@link #createExternalGLDrawable}.
+ *
+ * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
+ */
+ public abstract boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device);
+
+ /**
+ *
Creates a {@link GLDrawable} object representing an existing
+ * OpenGL drawable in an external (third-party) OpenGL-based
+ * library. This GLDrawable object may be used to create new,
+ * fully-functional {@link GLContext}s on the OpenGL drawable. This
+ * is useful when interoperating with a third-party OpenGL-based
+ * library and it is essential to not perturb the state of the
+ * library's existing context, even to the point of not sharing
+ * textures or display lists with that context.
+ *
+ *
An underlying OpenGL context must be current on the desired
+ * drawable and the current thread at the time this method is
+ * called. The user is responsible for the maintenance of the
+ * underlying drawable. If one or more contexts are created on the
+ * drawable using {@link GLDrawable#createContext}, and the drawable
+ * is deleted by the third-party library, the user is responsible
+ * for calling {@link GLContext#destroy} on these contexts.
+ *
+ *
Calls to setSize, getWidth and
+ * getHeight are illegal on the returned GLDrawable. If
+ * these operations are required by the user, they must be performed
+ * by the third-party library.
+ *
+ *
It is legal to create both an external GLContext and
+ * GLDrawable representing the same third-party OpenGL entities.
+ * This can be used, for example, to query current state information
+ * using the external GLContext and then create and set up new
+ * GLContexts using the external GLDrawable.
+ *
+ *
This functionality may not be available on all platforms and
+ * {@link #canCreateExternalGLDrawable} should be called first to
+ * see if it is present. For example, on X11 platforms, this API
+ * requires the presence of GLX 1.3 or later.
+ *
+ * @throws GLException if any window system-specific errors caused
+ * the creation of the external GLDrawable to fail.
+ */
+ public abstract GLDrawable createExternalGLDrawable()
+ throws GLException;
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLEventListener.java b/src/jogl/classes/com/jogamp/opengl/GLEventListener.java
new file mode 100644
index 000000000..8c5dfd3b3
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLEventListener.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.opengl;
+
+import java.util.EventListener;
+
+/** Declares events which client code can use to manage OpenGL
+ rendering into a {@link GLAutoDrawable}. At the time any of these
+ methods is called, the drawable has made its associated OpenGL
+ context current, so it is valid to make OpenGL calls. */
+
+public interface GLEventListener extends EventListener {
+ /** Called by the drawable immediately after the OpenGL context is
+ initialized. Can be used to perform one-time OpenGL
+ initialization per GLContext, such as setup of lights and display lists.
+
+ Note that this method may be called more than once if the underlying
+ OpenGL context for the GLAutoDrawable is destroyed and
+ recreated, for example if a GLCanvas is removed from the widget
+ hierarchy and later added again.
+ */
+ public void init(GLAutoDrawable drawable);
+
+ /** Notifies the listener to perform the release of all OpenGL
+ resources per GLContext, such as memory buffers and GLSL programs.
+
+ Called by the drawable before the OpenGL context is
+ destroyed by an external event, like a reconfiguration of the
+ {@link GLAutoDrawable} closing an attached window,
+ but also manually by calling {@link GLAutoDrawable#destroy destroy}.
+
+ Note that this event does not imply the end of life of the application.
+ It could be produced with a followup call to {@link #init(GLAutoDrawable)}
+ in case the GLContext has been recreated,
+ e.g. due to a pixel configuration change in a multihead environment.
+ */
+ public void dispose(GLAutoDrawable drawable);
+
+ /** Called by the drawable to initiate OpenGL rendering by the
+ client. After all GLEventListeners have been notified of a
+ display event, the drawable will swap its buffers if {@link
+ GLAutoDrawable#setAutoSwapBufferMode setAutoSwapBufferMode} is
+ enabled. */
+ public void display(GLAutoDrawable drawable);
+
+ /**
+ * Called by the drawable during the first repaint after the
+ * component has been resized.
+ *
+ * The client can update it's viewport associated data
+ * and view volume of the window appropriately.
+ *
+ *
+ * For efficiency the GL viewport has already been updated
+ * via glViewport(x, y, width, height) when this method is called.
+ *
+ *
+ * @param drawable the triggering {@link GLAutoDrawable}
+ * @param x viewport x-coord in pixel units
+ * @param y viewport y-coord in pixel units
+ * @param width viewport width in pixel units
+ * @param height viewport height in pixel units
+ */
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height);
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLException.java b/src/jogl/classes/com/jogamp/opengl/GLException.java
new file mode 100644
index 000000000..843934ab2
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLException.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.opengl;
+
+/** A generic exception for OpenGL errors used throughout the binding
+ as a substitute for {@link RuntimeException}. */
+@SuppressWarnings("serial")
+public class GLException extends RuntimeException {
+ /** Constructs a GLException object. */
+ public GLException() {
+ super();
+ }
+
+ /** Constructs a GLException object with the specified detail
+ message. */
+ public GLException(final String message) {
+ super(message);
+ }
+
+ /** Constructs a GLException object with the specified detail
+ message and root cause. */
+ public GLException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ /** Constructs a GLException object with the specified root
+ cause. */
+ public GLException(final Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Constructs a GLException object with the specified root
+ * cause with a decorating message including the current thread name.
+ * @since 2.2
+ */
+ public static GLException newGLException(final Throwable t) {
+ return new GLException("Caught "+t.getClass().getSimpleName()+": "+t.getMessage()+" on thread "+Thread.currentThread().getName(), t);
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLFBODrawable.java b/src/jogl/classes/com/jogamp/opengl/GLFBODrawable.java
new file mode 100644
index 000000000..69358743e
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLFBODrawable.java
@@ -0,0 +1,227 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl;
+
+import com.jogamp.nativewindow.NativeWindowException;
+
+import com.jogamp.opengl.FBObject;
+import com.jogamp.opengl.FBObject.Colorbuffer;
+import com.jogamp.opengl.FBObject.ColorAttachment;
+import com.jogamp.opengl.FBObject.TextureAttachment;
+import com.jogamp.opengl.GLRendererQuirks;
+
+/**
+ * Platform-independent {@link GLDrawable} specialization,
+ * exposing {@link FBObject} functionality.
+ *
+ *
+ * A {@link GLFBODrawable} is uninitialized until a {@link GLContext} is bound
+ * and made current the first time, hence only then it's capabilities fully reflect expectations,
+ * i.e. color, depth, stencil and MSAA bits will be valid only after the first {@link GLContext#makeCurrent() makeCurrent()} call.
+ * On-/offscreen bits are valid after {@link #setRealized(boolean) setRealized(true)}.
+ *
+ *
+ *
+ * MSAA is used if {@link GLCapabilitiesImmutable#getNumSamples() requested}.
+ *
+ *
+ * Double buffering is used if {@link GLCapabilitiesImmutable#getDoubleBuffered() requested}.
+ *
+ *
+ * In MSAA mode, it always uses the implicit 2nd {@link FBObject framebuffer} {@link FBObject#getSamplingSinkFBO() sink}.
+ * Hence double buffering is always the case w/ MSAA.
+ *
+ *
+ * In non MSAA a second explicit {@link FBObject framebuffer} is being used.
+ * This method allows compliance w/ the spec, i.e. read and draw framebuffer selection
+ * and double buffer usage for e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)}.
+ * This method also allows usage of both textures seperately.
+ *
+ *
+ * It would be possible to implement double buffering simply using
+ * {@link Colorbuffer}s with one {@link FBObject framebuffer}.
+ * This would require mode selection and hence complicate the API. Besides, it would
+ * not support differentiation of read and write framebuffer and hence not be spec compliant.
+ *
+ *
+ * Actual swapping of the {@link Colorbuffer}s and/or {@link FBObject framebuffer}
+ * is performed either in the {@link jogamp.opengl.GLContextImpl#contextMadeCurrent(boolean) context current hook}
+ * or when {@link jogamp.opengl.GLDrawableImpl#swapBuffersImpl(boolean) swapping buffers}, whatever comes first.
+ *
+ */
+public interface GLFBODrawable extends GLDrawable {
+ // public enum DoubleBufferMode { NONE, TEXTURE, FBO }; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support
+
+ /** FBO Mode Bit: Use a {@link TextureAttachment} for the {@link #getColorbuffer(int) render colorbuffer}, see {@link #setFBOMode(int)}. */
+ public static final int FBOMODE_USE_TEXTURE = 1 << 0;
+
+ /**
+ * @return true if initialized, i.e. a {@link GLContext} is bound and made current once, otherwise false.
+ */
+ public boolean isInitialized();
+
+ /**
+ * Set the FBO mode bits used for FBO creation.
+ *
+ * Default value is: {@link #FBOMODE_USE_TEXTURE}.
+ *
+ *
+ * If {@link GLRendererQuirks#BuggyColorRenderbuffer} is set,
+ * {@link #FBOMODE_USE_TEXTURE} is always added at initialization.
+ *
+ *
+ * @param modeBits custom FBO mode bits like {@link #FBOMODE_USE_TEXTURE}.
+ * @throws IllegalStateException if already initialized, see {@link #isInitialized()}.
+ */
+ void setFBOMode(final int modeBits) throws IllegalStateException;
+
+ /**
+ * @return the used FBO mode bits, mutable via {@link #setFBOMode(int)}
+ */
+ int getFBOMode();
+
+ /**
+ * Notify this instance about upstream size change
+ * to reconfigure the {@link FBObject}.
+ * @param gl GL context object bound to this drawable, will be made current during operation.
+ * A prev. current context will be make current after operation.
+ * @throws GLException if resize operation failed
+ */
+ void resetSize(final GL gl) throws GLException;
+
+ /**
+ * @return the used texture unit
+ */
+ int getTextureUnit();
+
+ /**
+ *
+ * @param unit the texture unit to be used
+ */
+ void setTextureUnit(final int unit);
+
+ /**
+ * Set the number of sample buffers if using MSAA
+ *
+ * @param gl GL context object bound to this drawable, will be made current during operation.
+ * A prev. current context will be make current after operation.
+ * @param newSamples new sample size
+ * @throws GLException if resetting the FBO failed
+ */
+ void setNumSamples(final GL gl, final int newSamples) throws GLException;
+
+ /**
+ * @return the number of sample buffers if using MSAA, otherwise 0
+ */
+ int getNumSamples();
+
+ /**
+ * Sets the number of buffers (FBO) being used if using {@link GLCapabilities#getDoubleBuffered() double buffering}.
+ *
+ * If {@link GLCapabilities#getDoubleBuffered() double buffering} is not chosen, this is a NOP.
+ *
+ *
+ * Must be called before {@link #isInitialized() initialization}, otherwise an exception is thrown.
+ *
+ * @return the new number of buffers (FBO) used, maybe different than the requested bufferCount (see above)
+ * @throws IllegalStateException if already initialized, see {@link #isInitialized()}.
+ */
+ int setNumBuffers(final int bufferCount) throws IllegalStateException, GLException;
+
+ /**
+ * @return the number of buffers (FBO) being used. 1 if not using {@link GLCapabilities#getDoubleBuffered() double buffering},
+ * otherwise ≥ 2, depending on {@link #setNumBuffers(int)}.
+ */
+ int getNumBuffers();
+
+ /**
+ * @return the used {@link DoubleBufferMode}
+ */
+ // DoubleBufferMode getDoubleBufferMode(); // TODO: Add or remove TEXTURE (only) DoubleBufferMode support
+
+ /**
+ * Sets the {@link DoubleBufferMode}. Must be called before {@link #isInitialized() initialization},
+ * otherwise an exception is thrown.
+ *
+ * This call has no effect is MSAA is selected, since MSAA always forces the mode to {@link DoubleBufferMode#FBO FBO}.
+ * Also setting the mode to {@link DoubleBufferMode#NONE NONE} where double buffering is {@link GLCapabilitiesImmutable#getDoubleBuffered() requested}
+ * or setting a double buffering mode w/o {@link GLCapabilitiesImmutable#getDoubleBuffered() request} will be ignored.
+ *
+ *
+ * Since {@link DoubleBufferMode#TEXTURE TEXTURE} mode is currently not implemented, this method has no effect.
+ *
+ * @throws GLException if already initialized, see {@link #isInitialized()}.
+ */
+ // void setDoubleBufferMode(DoubleBufferMode mode) throws GLException; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support
+
+ /**
+ * If MSAA is being used and {@link GL#GL_FRONT} is requested,
+ * the internal {@link FBObject} {@link FBObject#getSamplingSinkFBO() sample sink} is being returned.
+ *
+ * @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names
+ * @return the named {@link FBObject}
+ * @throws IllegalArgumentException if an illegal buffer name is being used
+ */
+ FBObject getFBObject(final int bufferName) throws IllegalArgumentException;
+
+ /**
+ * Returns the named {@link Colorbuffer} instance.
+ *
+ * If MSAA is being used, only the {@link GL#GL_FRONT} buffer is accessible
+ * and an exception is being thrown if {@link GL#GL_BACK} is being requested.
+ *
+ *
+ * Depending on the {@link #setFBOMode(int) fbo mode} the resulting {@link Colorbuffer}
+ * is either a {@link TextureAttachment} if {@link #FBOMODE_USE_TEXTURE} is set,
+ * otherwise a {@link ColorAttachment}.
+ * See {@link Colorbuffer#isTextureAttachment()}.
+ *
+ * @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names
+ * @return the named {@link Colorbuffer}
+ * @throws IllegalArgumentException if using MSAA and {@link GL#GL_BACK} is requested or an illegal buffer name is being used
+ */
+ Colorbuffer getColorbuffer(final int bufferName) throws IllegalArgumentException;
+
+ /** Resizeable {@link GLFBODrawable} specialization */
+ public interface Resizeable extends GLFBODrawable {
+ /**
+ * Resize this {@link GLFBODrawable}'s surface.
+ *
+ * This drawable is being locked during operation.
+ *
+ * @param context the {@link GLContext} bound to this drawable, will be made current during operation
+ * A prev. current context will be make current after operation.
+ * @param newWidth new width in pixel units
+ * @param newHeight new width in pixel units
+ * @throws NativeWindowException in case the surface could no be locked
+ * @throws GLException in case an error during the resize operation occurred
+ */
+ void setSurfaceSize(GLContext context, int newWidth, int newHeight) throws NativeWindowException, GLException;
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLOffscreenAutoDrawable.java b/src/jogl/classes/com/jogamp/opengl/GLOffscreenAutoDrawable.java
new file mode 100644
index 000000000..a2d0f5fdb
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLOffscreenAutoDrawable.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl;
+
+import com.jogamp.nativewindow.NativeWindowException;
+
+import com.jogamp.opengl.FBObject;
+
+/**
+ * Platform-independent {@link GLAutoDrawable} specialization,
+ * exposing offscreen functionality.
+ *
+ * This class distinguishes itself from {@link GLAutoDrawable}
+ * with it's {@link #setSurfaceSize(int, int)} functionality.
+ *
+ * To share a {@link GLContext} see the following note in the documentation overview:
+ * context sharing
+ * as well as {@link GLSharedContextSetter}.
+ *
+ */
+public interface GLOffscreenAutoDrawable extends GLAutoDrawable, GLSharedContextSetter {
+
+ /**
+ * Resize this {@link GLAutoDrawable}'s surface
+ * @param newWidth new width in pixel units
+ * @param newHeight new height in pixel units
+ * @throws NativeWindowException in case the surface could no be locked
+ * @throws GLException in case of an error during the resize operation
+ */
+ void setSurfaceSize(int newWidth, int newHeight) throws NativeWindowException, GLException;
+
+ /**
+ * Set the upstream UI toolkit object.
+ * @see #getUpstreamWidget()
+ */
+ void setUpstreamWidget(Object newUpstreamWidget);
+
+ /** {@link FBObject} based {@link GLOffscreenAutoDrawable} specialization */
+ public interface FBO extends GLOffscreenAutoDrawable, GLFBODrawable {
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLPipelineFactory.java b/src/jogl/classes/com/jogamp/opengl/GLPipelineFactory.java
new file mode 100644
index 000000000..8d8b0428b
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLPipelineFactory.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ */
+
+package com.jogamp.opengl;
+
+import java.lang.reflect.*;
+import java.util.StringTokenizer;
+
+import com.jogamp.common.util.ReflectionUtil;
+
+import jogamp.opengl.*;
+
+/**
+ * Factory for pipelining GL instances
+ */
+public class GLPipelineFactory {
+ public static final boolean DEBUG = Debug.debug("GLPipelineFactory");
+
+ /**
+ * Creates a pipelined GL instance using the given downstream downstream
+ * and optional arguments additionalArgs for the constructor.
+ *
+ *
+ * Sample code which installs a Debug and Trace pipeline
+ * automatic w/ user defined interface, here: GL2ES2:
+ *
+ * The upstream GL instance is determined as follows:
+ *
+ *
Use pipelineClazzBaseName as the class name's full basename, incl. package name
+ *
For the downstream class and it's superclasses, do:
+ *
+ *
For all downstream class and superclass interfaces, do:
+ *
+ *
If reqInterface is not null and the interface is unequal, continue loop.
+ *
If downstream is not instance of interface, continue loop.
+ *
If upstream class is available use it, end loop.
+ *
+ *
+ *
+ *
+ *
+ * @param pipelineClazzBaseName the basename of the pipline class name
+ * @param reqInterface optional requested interface to be used, may be null, in which case the first matching one is used
+ * @param downstream is always the 1st argument for the upstream constructor
+ * @param additionalArgs additional arguments for the upstream constructor
+ */
+ public static final GL create(final String pipelineClazzBaseName, final Class> reqInterface, final GL downstream, final Object[] additionalArgs) {
+ Class> downstreamClazz = downstream.getClass();
+ Class> upstreamClazz = null;
+ Class> interfaceClazz = null;
+
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: Start "+downstreamClazz.getName()+", req. Interface: "+reqInterface+" -> "+pipelineClazzBaseName);
+ }
+
+ // For all classes: child -> parent
+ do {
+ // For all interfaces: right -> left == child -> parent
+ // It is important that this matches with the gluegen cfg file's 'Implements' clause !
+ final Class>[] clazzes = downstreamClazz.getInterfaces();
+ for(int i=clazzes.length-1; null==upstreamClazz && i>=0; i--) {
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: Try "+downstreamClazz.getName()+" Interface["+i+"]: "+clazzes[i].getName());
+ }
+ if( reqInterface != null && !reqInterface.getName().equals(clazzes[i].getName()) ) {
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: requested Interface "+reqInterface+" is _not_ "+ clazzes[i].getName());
+ }
+ continue; // not the requested one ..
+ }
+ if( ! clazzes[i].isInstance(downstream) ) {
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: "+downstream.getClass().getName() + " is _not_ instance of "+ clazzes[i].getName());
+ }
+ continue; // not a compatible one
+ } else {
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: "+downstream.getClass().getName() + " _is_ instance of "+ clazzes[i].getName());
+ }
+ }
+ upstreamClazz = getUpstreamClazz(clazzes[i], pipelineClazzBaseName);
+ if( null != upstreamClazz ) {
+ interfaceClazz = clazzes[i];
+ }
+ }
+
+ if(null==upstreamClazz) {
+ downstreamClazz = downstreamClazz.getSuperclass();
+ }
+ } while (null!=downstreamClazz && null==upstreamClazz);
+
+
+ if(null==upstreamClazz) {
+ throw new GLException("No pipeline ("+pipelineClazzBaseName+"*) available for :"+downstream.getClass().getName());
+ }
+
+ if(DEBUG) {
+ System.out.println("GLPipelineFactory: Got : "+ upstreamClazz.getName()+", base interface: "+interfaceClazz.getName());
+ }
+
+ final Class>[] cstrArgTypes = new Class>[ 1 + ( ( null==additionalArgs ) ? 0 : additionalArgs.length ) ] ;
+ {
+ int i = 0;
+ cstrArgTypes[i++] = interfaceClazz;
+ for(int j=0; null!=additionalArgs && j cstr = ReflectionUtil.getConstructor(upstreamClazz, cstrArgTypes);
+ Object instance = null;
+ try {
+ final Object[] cstrArgs = new Object[ 1 + ( ( null==additionalArgs ) ? 0 : additionalArgs.length ) ] ;
+ {
+ int i = 0;
+ cstrArgs[i++] = downstream;
+ for(int j=0; null!=additionalArgs && j arg0, final Object[] args) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(arg0.getName());
+ if(args!=null) {
+ for(int j=0; j getUpstreamClazz(final Class> downstreamClazz, final String pipelineClazzBaseName) {
+ final String downstreamClazzName = downstreamClazz.getName();
+
+ final StringTokenizer st = new StringTokenizer(downstreamClazzName, ".");
+ String downstreamClazzBaseName = downstreamClazzName;
+ while(st.hasMoreTokens()) {
+ downstreamClazzBaseName = st.nextToken();
+ }
+ final String upstreamClazzName = pipelineClazzBaseName+downstreamClazzBaseName;
+
+ Class> upstreamClazz = null;
+ try {
+ upstreamClazz = Class.forName(upstreamClazzName, true, GLPipelineFactory.class.getClassLoader());
+ } catch (final Throwable e) { e.printStackTrace(); }
+
+ return upstreamClazz;
+ }
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/GLProfile.java b/src/jogl/classes/com/jogamp/opengl/GLProfile.java
new file mode 100644
index 000000000..a36a21ad5
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLProfile.java
@@ -0,0 +1,2322 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ */
+
+package com.jogamp.opengl;
+
+import jogamp.opengl.Debug;
+import jogamp.opengl.GLDrawableFactoryImpl;
+import jogamp.opengl.DesktopGLDynamicLookupHelper;
+
+import com.jogamp.common.ExceptionUtils;
+import com.jogamp.common.GlueGenVersion;
+import com.jogamp.common.jvm.JNILibLoaderBase;
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.PropertyAccess;
+import com.jogamp.common.util.ReflectionUtil;
+import com.jogamp.common.util.VersionUtil;
+import com.jogamp.common.util.cache.TempJarCache;
+import com.jogamp.common.util.locks.LockFactory;
+import com.jogamp.common.util.locks.RecursiveThreadGroupLock;
+import com.jogamp.gluegen.runtime.FunctionAddressResolver;
+import com.jogamp.nativewindow.NativeWindowVersion;
+import com.jogamp.opengl.GLRendererQuirks;
+import com.jogamp.opengl.JoglVersion;
+
+import com.jogamp.nativewindow.AbstractGraphicsDevice;
+import com.jogamp.nativewindow.NativeWindowFactory;
+import com.jogamp.opengl.fixedfunc.GLPointerFunc;
+
+import java.lang.reflect.Constructor;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Specifies the the OpenGL profile.
+ *
+ * This class static singleton initialization queries the availability of all OpenGL Profiles
+ * and instantiates singleton GLProfile objects for each available profile.
+ *
+ * The platform default profile may be used, using {@link GLProfile#GetProfileDefault()},
+ * or more specialized versions using the other static GetProfile methods.
+ */
+public class GLProfile {
+
+ public static final boolean DEBUG;
+
+ /**
+ * In case no native OpenGL core profiles are required
+ * and if one platform may have a buggy implementation,
+ * setting the property jogl.disable.openglcore disables querying possible existing native OpenGL core profiles.
+ *
+ * This exclusion is disabled for {@link Platform.OSType#MACOS}.
+ *
+ */
+ public static final boolean disableOpenGLCore;
+
+ /**
+ * In case the implementation of the ARB_create_context
+ * context creation extension is buggy on one platform,
+ * setting the property jogl.disable.openglarbcontext disables utilizing it.
+ *
+ * This exclusion also disables {@link #disableOpenGLES OpenGL ES}.
+ *
+ *
+ * This exclusion is disabled for {@link Platform.OSType#MACOS}.
+ *
+ */
+ public static final boolean disableOpenGLARBContext;
+
+ /**
+ * In case no OpenGL ES profiles are required
+ * and if one platform may have a buggy implementation,
+ * setting the property jogl.disable.opengles disables querying possible existing OpenGL ES profiles.
+ */
+ public static final boolean disableOpenGLES;
+
+ /**
+ * In case no OpenGL desktop profiles are required
+ * and if one platform may have a buggy implementation,
+ * setting the property jogl.disable.opengldesktop disables querying possible existing OpenGL desktop profiles.
+ */
+ public static final boolean disableOpenGLDesktop;
+
+ /**
+ * Disable surfaceless OpenGL context capability and its probing
+ * by setting the property jogl.disable.surfacelesscontext.
+ *
+ * By default surfaceless OpenGL context capability is probed,
+ * i.e. whether an OpenGL context can be made current without a default framebuffer.
+ *
+ *
+ * If probing fails or if this property is set, the {@link GLRendererQuirks quirk} {@link GLRendererQuirks#NoSurfacelessCtx}
+ * is being set.
+ *
+ */
+ public static final boolean disableSurfacelessContext;
+
+ /**
+ * We have to disable support for ANGLE, the D3D ES2 emulation on Windows provided w/ Firefox and Chrome.
+ * When run in the mentioned browsers, the eglInitialize(..) implementation crashes.
+ *
+ * This can be overridden by explicitly enabling ANGLE on Windows by setting the property
+ * jogl.enable.ANGLE.
+ *
+ * This method shall not need to be called for other reasons than having a defined initialization sequence.
+ *
+ *
+ *
+ * In case this method is not invoked, GLProfile is initialized implicit by
+ * the first call to {@link #getDefault()}, {@link #get(java.lang.String)}.
+ *
+ *
+ *
+ * To initialize JOGL at startup ASAP, this method may be invoked in the main class's
+ * static initializer block, in the static main() method or in the Applet init() method.
+ *
+ *
+ *
+ * Since JOGL's initialization is complex and involves multi threading, it is not recommended
+ * to be have it invoked on the AWT EDT thread. In case all JOGL usage is performed
+ * on the AWT EDT, invoke this method outside the AWT EDT - see above.
+ *
+ *
+ */
+ public static void initSingleton() {
+ final boolean justInitialized;
+ initLock.lock();
+ try {
+ if(!initialized) {
+ initialized = true;
+ justInitialized = true;
+ if(DEBUG) {
+ System.err.println("GLProfile.initSingleton() - thread "+Thread.currentThread().getName());
+ ExceptionUtils.dumpStack(System.err);
+ }
+
+ if(ReflectionUtil.DEBUG_STATS_FORNAME) {
+ ReflectionUtil.resetForNameCount();
+ }
+
+ // run the whole static initialization privileged to speed up,
+ // since this skips checking further access
+ AccessController.doPrivileged(new PrivilegedAction
+ *
+ * @param coords
+ * Specifics the location of the new vertex.
+ * @param data
+ * Specifics the vertices used to create the new vertex.
+ * @param weight
+ * Specifics the weights used to create the new vertex.
+ * @param outData
+ * Reference user the put the coodinates of the new vertex.
+ *
+ * @see GLU#gluTessCallback gluTessCallback
+ * @see #combineData combineData
+ */
+ public void combine(double[] coords, Object[] data,
+ float[] weight, Object[] outData);
+
+
+ /**
+ * The same as the {@link #combine combine} callback method except
+ * that it takes an additional reference argument. This reference is
+ * identical to the opaque reference provided when {@link
+ * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
+ *
+ * @param coords
+ * Specifics the location of the new vertex.
+ * @param data
+ * Specifics the vertices used to create the new vertex.
+ * @param weight
+ * Specifics the weights used to create the new vertex.
+ * @param outData
+ * Reference user the put the coodinates of the new vertex.
+ * @param polygonData
+ * Specifics a reference to user-defined data.
+ *
+ * @see GLU#gluTessCallback gluTessCallback
+ * @see #combine combine
+ */
+ public void combineData(double[] coords, Object[] data,
+ float[] weight, Object[] outData,
+ Object polygonData);
+
+
+ /**
+ * The error callback method is called when an error is encountered.
+ * The one argument is of type int; it indicates the specific error that
+ * occurred and will be set to one of GLU_TESS_MISSING_BEGIN_POLYGON,
+ * GLU_TESS_MISSING_END_POLYGON, GLU_TESS_MISSING_BEGIN_CONTOUR,
+ * GLU_TESS_MISSING_END_CONTOUR, GLU_TESS_COORD_TOO_LARGE,
+ * GLU_TESS_NEED_COMBINE_CALLBACK or GLU_OUT_OF_MEMORY.
+ * Character strings describing these errors can be retrieved with the
+ * {@link GLU#gluErrorString gluErrorString} call.
+ *
+ * The GLU library will recover from the first four errors by inserting the
+ * missing call(s). GLU_TESS_COORD_TOO_LARGE indicates that some
+ * vertex coordinate exceeded the predefined constant
+ * GLU_TESS_MAX_COORD in absolute value, and that the value has been
+ * clamped. (Coordinate values must be small enough so that two can be
+ * multiplied together without overflow.)
+ * GLU_TESS_NEED_COMBINE_CALLBACK indicates that the tessellation
+ * detected an intersection between two edges in the input data, and the
+ * GLU_TESS_COMBINE or GLU_TESS_COMBINE_DATA callback was not
+ * provided. No output is generated. GLU_OUT_OF_MEMORY indicates that
+ * there is not enough memory so no output is generated.
+ *
+ * @param errnum
+ * Specifics the error number code.
+ *
+ * @see GLU#gluTessCallback gluTessCallback
+ * @see #errorData errorData
+ */
+ public void error(int errnum);
+
+
+ /**
+ * The same as the {@link #error error} callback method except that
+ * it takes an additional reference argument. This reference is
+ * identical to the opaque reference provided when {@link
+ * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
+ *
+ * @param errnum
+ * Specifics the error number code.
+ * @param polygonData
+ * Specifics a reference to user-defined data.
+ *
+ * @see GLU#gluTessCallback gluTessCallback
+ * @see #error error
+ */
+ public void errorData(int errnum, Object polygonData);
+
+ //void mesh(jogamp.opengl.tessellator.GLUmesh mesh);
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/glu/GLUtessellatorCallbackAdapter.java b/src/jogl/classes/com/jogamp/opengl/glu/GLUtessellatorCallbackAdapter.java
new file mode 100644
index 000000000..b9503f12e
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/glu/GLUtessellatorCallbackAdapter.java
@@ -0,0 +1,96 @@
+/*
+* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
+* All rights reserved.
+*/
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 2.0 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** NOTE: The Original Code (as defined below) has been licensed to Sun
+** Microsystems, Inc. ("Sun") under the SGI Free Software License B
+** (Version 1.1), shown above ("SGI License"). Pursuant to Section
+** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
+** you under an alternative license ("Alternative License"). This
+** Alternative License includes all of the provisions of the SGI License
+** except that Section 2.2 and 11 are omitted. Any differences between
+** the Alternative License and the SGI License are offered solely by Sun
+** and not by SGI.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+** Author: Eric Veach, July 1994
+** Java Port: Pepijn Van Eeckhoudt, July 2003
+** Java Port: Nathan Parker Burg, August 2003
+*/
+package com.jogamp.opengl.glu;
+
+/**
+ * The GLUtessellatorCallbackAdapter provides a default implementation of
+ * {@link GLUtessellatorCallback GLUtessellatorCallback}
+ * with empty callback methods. This class can be extended to provide user
+ * defined callback methods.
+ *
+ * @author Eric Veach, July 1994
+ * @author Java Port: Pepijn Van Eechhoudt, July 2003
+ * @author Java Port: Nathan Parker Burg, August 2003
+ */
+
+public class GLUtessellatorCallbackAdapter implements GLUtessellatorCallback {
+ @Override
+ public void begin(final int type) {}
+ @Override
+ public void edgeFlag(final boolean boundaryEdge) {}
+ @Override
+ public void vertex(final Object vertexData) {}
+ @Override
+ public void end() {}
+// public void mesh(jogamp.opengl.tessellator.GLUmesh mesh) {}
+ @Override
+ public void error(final int errnum) {}
+ @Override
+ public void combine(final double[] coords, final Object[] data,
+ final float[] weight, final Object[] outData) {}
+ @Override
+ public void beginData(final int type, final Object polygonData) {}
+ @Override
+ public void edgeFlagData(final boolean boundaryEdge,
+ final Object polygonData) {}
+ @Override
+ public void vertexData(final Object vertexData, final Object polygonData) {}
+ @Override
+ public void endData(final Object polygonData) {}
+ @Override
+ public void errorData(final int errnum, final Object polygonData) {}
+ @Override
+ public void combineData(final double[] coords, final Object[] data,
+ final float[] weight, final Object[] outData,
+ final Object polygonData) {}
+}
diff --git a/src/jogl/classes/javax/media/opengl/DebugGL2.java b/src/jogl/classes/javax/media/opengl/DebugGL2.java
deleted file mode 100644
index dc0f0df50..000000000
--- a/src/jogl/classes/javax/media/opengl/DebugGL2.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.jogamp.opengl;
-
-/**
- *
- * Composable pipeline which wraps an underlying {@link GL} implementation,
- * providing error checking after each OpenGL method call. If an error occurs,
- * causes a {@link GLException} to be thrown at exactly the point of failure.
- *
- *
- * Sample code which installs this pipeline, manual:
- *
- * Composable pipeline which wraps an underlying {@link GL} implementation,
- * providing error checking after each OpenGL method call. If an error occurs,
- * causes a {@link GLException} to be thrown at exactly the point of failure.
- *
- *
- * Sample code which installs this pipeline, manual:
- *
- * Composable pipeline which wraps an underlying {@link GL} implementation,
- * providing error checking after each OpenGL method call. If an error occurs,
- * causes a {@link GLException} to be thrown at exactly the point of failure.
- *
- *
- * Sample code which installs this pipeline, manual:
- *
- * Composable pipeline which wraps an underlying {@link GL} implementation,
- * providing error checking after each OpenGL method call. If an error occurs,
- * causes a {@link GLException} to be thrown at exactly the point of failure.
- *
- *
- * Sample code which installs this pipeline, manual:
- *
- * Composable pipeline which wraps an underlying {@link GL} implementation,
- * providing error checking after each OpenGL method call. If an error occurs,
- * causes a {@link GLException} to be thrown at exactly the point of failure.
- *
- *
- * Sample code which installs this pipeline, manual:
- *
- * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
- *
- */
-public class DebugGLES2 extends DebugGLES3 {
- public DebugGLES2(final GLES2 downstream) {
- super((GLES3)downstream);
- }
-}
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
deleted file mode 100644
index 88a88087f..000000000
--- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright (c) 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl;
-
-import com.jogamp.nativewindow.NativeWindowException;
-
-import java.util.List;
-
-import com.jogamp.nativewindow.CapabilitiesImmutable;
-
-import com.jogamp.common.ExceptionUtils;
-import com.jogamp.common.util.PropertyAccess;
-
-import jogamp.opengl.Debug;
-
-/**
The default implementation of the {@link
- GLCapabilitiesChooser} interface, which provides consistent visual
- selection behavior across platforms. The precise algorithm is
- deliberately left loosely specified. Some properties are:
-
-
-
-
As long as there is at least one available non-null
- GLCapabilities which matches the "stereo" option, will return a
- valid index.
-
-
Attempts to match as closely as possible the given
- GLCapabilities, but will select one with fewer capabilities (i.e.,
- lower color depth) if necessary.
-
-
Prefers hardware-accelerated visuals to
- non-hardware-accelerated.
-
-
If there is no exact match, prefers a more-capable visual to
- a less-capable one.
-
-
If there is more than one exact match, chooses an arbitrary
- one.
-
-
May select the opposite of a double- or single-buffered
- visual (based on the user's request) in dire situations.
-
-
Color depth (including alpha) mismatches are weighted higher
- than depth buffer mismatches, which are in turn weighted higher
- than accumulation buffer (including alpha) and stencil buffer
- depth mismatches.
-
-
If a valid windowSystemRecommendedChoice parameter is
- supplied, chooses that instead of using the cross-platform code.
-
-
-*/
-
-public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
- private static final boolean DEBUG;
-
- static {
- Debug.initSingleton();
- DEBUG = PropertyAccess.isPropertyDefined("jogl.debug.CapabilitiesChooser", true);
- }
-
- private final static int NO_SCORE = -9999999;
- private final static int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000;
- private final static int OPAQUE_MISMATCH_PENALTY = 750;
- private final static int STENCIL_MISMATCH_PENALTY = 500;
- private final static int MULTISAMPLE_MISMATCH_PENALTY = 500;
- private final static int MULTISAMPLE_EXTENSION_MISMATCH_PENALTY = 250; // just a little drop, no scale
- // Pseudo attempt to keep equal rank penalties scale-equivalent
- // (e.g., stencil mismatch is 3 * accum because there are 3 accum
- // components)
- private final static int COLOR_MISMATCH_PENALTY_SCALE = 36;
- private final static int DEPTH_MISMATCH_PENALTY_SCALE = 6;
- private final static int ACCUM_MISMATCH_PENALTY_SCALE = 1;
- private final static int STENCIL_MISMATCH_PENALTY_SCALE = 3;
- private final static int MULTISAMPLE_MISMATCH_PENALTY_SCALE = 3;
-
- @Override
- public int chooseCapabilities(final CapabilitiesImmutable desired,
- final List extends CapabilitiesImmutable> available,
- final int windowSystemRecommendedChoice) {
- if ( null == desired ) {
- throw new NativeWindowException("Null desired capabilities");
- }
- if ( 0 == available.size() ) {
- throw new NativeWindowException("Empty available capabilities");
- }
-
- final GLCapabilitiesImmutable gldes = (GLCapabilitiesImmutable) desired;
- final int availnum = available.size();
-
- if (DEBUG) {
- ExceptionUtils.dumpStack(System.err);
- System.err.println("Desired: " + gldes);
- System.err.println("Available: " + availnum);
- for (int i = 0; i < available.size(); i++) {
- System.err.println(i + ": " + available.get(i));
- }
- System.err.println("Window system's recommended choice: " + windowSystemRecommendedChoice);
- }
-
- if (windowSystemRecommendedChoice >= 0 &&
- windowSystemRecommendedChoice < availnum &&
- null != available.get(windowSystemRecommendedChoice)) {
- if (DEBUG) {
- System.err.println("Choosing window system's recommended choice of " + windowSystemRecommendedChoice);
- System.err.println(available.get(windowSystemRecommendedChoice));
- }
- return windowSystemRecommendedChoice;
- }
-
- // Create score array
- final int[] scores = new int[availnum];
-
- for (int i = 0; i < scores.length; i++) {
- scores[i] = NO_SCORE;
- }
- final int gldes_samples = gldes.getNumSamples();
-
- // Compute score for each
- for (int i = 0; i < availnum; i++) {
- final GLCapabilitiesImmutable cur = (GLCapabilitiesImmutable) available.get(i);
- if (cur == null) {
- continue;
- }
- if (gldes.isOnscreen() && !cur.isOnscreen()) {
- continue; // requested onscreen, but n/a
- }
- if (!gldes.isOnscreen()) {
- /** FBO is generic ..
- if (gldes.isFBO() && !cur.isFBO()) {
- continue; // requested FBO, but n/a
- } */
- if (gldes.isPBuffer() && !cur.isPBuffer()) {
- continue; // requested pBuffer, but n/a
- }
- if (gldes.isBitmap() && !cur.isBitmap()) {
- continue; // requested pBuffer, but n/a
- }
- }
- if (gldes.getStereo() != cur.getStereo()) {
- continue;
- }
- final int cur_samples = cur.getNumSamples() ;
- int score = 0;
-
- // Compute difference in color depth
- // (Note that this decides the direction of all other penalties)
- score += (COLOR_MISMATCH_PENALTY_SCALE *
- ((cur.getRedBits() + cur.getGreenBits() + cur.getBlueBits() + cur.getAlphaBits()) -
- (gldes.getRedBits() + gldes.getGreenBits() + gldes.getBlueBits() + gldes.getAlphaBits())));
- // Compute difference in depth buffer depth
- score += (DEPTH_MISMATCH_PENALTY_SCALE * sign(score) *
- Math.abs(cur.getDepthBits() - gldes.getDepthBits()));
- // Compute difference in accumulation buffer depth
- score += (ACCUM_MISMATCH_PENALTY_SCALE * sign(score) *
- Math.abs((cur.getAccumRedBits() + cur.getAccumGreenBits() + cur.getAccumBlueBits() + cur.getAccumAlphaBits()) -
- (gldes.getAccumRedBits() + gldes.getAccumGreenBits() + gldes.getAccumBlueBits() + gldes.getAccumAlphaBits())));
- // Compute difference in stencil bits
- score += STENCIL_MISMATCH_PENALTY_SCALE * sign(score) * (cur.getStencilBits() - gldes.getStencilBits());
- // Compute difference in multisampling bits
- score += MULTISAMPLE_MISMATCH_PENALTY_SCALE * sign(score) * (cur_samples - gldes_samples);
- // double buffer
- if (cur.getDoubleBuffered() != gldes.getDoubleBuffered()) {
- score += sign(score) * DOUBLE_BUFFER_MISMATCH_PENALTY;
- }
- // opaque
- if (cur.isBackgroundOpaque() != gldes.isBackgroundOpaque()) {
- score += sign(score) * OPAQUE_MISMATCH_PENALTY;
- }
- if ((gldes.getStencilBits() > 0) && (cur.getStencilBits() == 0)) {
- score += sign(score) * STENCIL_MISMATCH_PENALTY;
- }
- if (gldes_samples > 0) {
- if (cur_samples == 0) {
- score += sign(score) * MULTISAMPLE_MISMATCH_PENALTY;
- }
- if (!gldes.getSampleExtension().equals(cur.getSampleExtension())) {
- score += sign(score) * MULTISAMPLE_EXTENSION_MISMATCH_PENALTY;
- }
- }
- scores[i] = score;
- }
- // Now prefer hardware-accelerated visuals by pushing scores of
- // non-hardware-accelerated visuals out
- boolean gotHW = false;
- int maxAbsoluteHWScore = 0;
- for (int i = 0; i < availnum; i++) {
- final int score = scores[i];
- if (score == NO_SCORE) {
- continue;
- }
- final GLCapabilitiesImmutable cur = (GLCapabilitiesImmutable) available.get(i);
- if (cur.getHardwareAccelerated()) {
- final int absScore = Math.abs(score);
- if (!gotHW ||
- (absScore > maxAbsoluteHWScore)) {
- gotHW = true;
- maxAbsoluteHWScore = absScore;
- }
- }
- }
- if (gotHW) {
- for (int i = 0; i < availnum; i++) {
- int score = scores[i];
- if (score == NO_SCORE) {
- continue;
- }
- final GLCapabilitiesImmutable cur = (GLCapabilitiesImmutable) available.get(i);
- if (!cur.getHardwareAccelerated()) {
- if (score <= 0) {
- score -= maxAbsoluteHWScore;
- } else if (score > 0) {
- score += maxAbsoluteHWScore;
- }
- scores[i] = score;
- }
- }
- }
-
- if (DEBUG) {
- System.err.print("Scores: [");
- for (int i = 0; i < availnum; i++) {
- if (i > 0) {
- System.err.print(",");
- }
- System.err.print(" " + i +": " + scores[i]);
- }
- System.err.println(" ]");
- }
-
- // Ready to select. Choose score closest to 0.
- int scoreClosestToZero = NO_SCORE;
- int chosenIndex = -1;
- for (int i = 0; i < availnum; i++) {
- final int score = scores[i];
- if (score == NO_SCORE) {
- continue;
- }
- // Don't substitute a positive score for a smaller negative score
- if ((scoreClosestToZero == NO_SCORE) ||
- (Math.abs(score) < Math.abs(scoreClosestToZero) &&
- ((sign(scoreClosestToZero) < 0) || (sign(score) > 0)))) {
- scoreClosestToZero = score;
- chosenIndex = i;
- }
- }
- if (chosenIndex < 0) {
- throw new NativeWindowException("Unable to select one of the provided GLCapabilities");
- }
- if (DEBUG) {
- System.err.println("Chosen index: " + chosenIndex);
- System.err.println("Chosen capabilities:");
- System.err.println(available.get(chosenIndex));
- }
-
- return chosenIndex;
- }
-
- private static int sign(final int score) {
- if (score < 0) {
- return -1;
- }
- return 1;
- }
-
-}
diff --git a/src/jogl/classes/javax/media/opengl/FPSCounter.java b/src/jogl/classes/javax/media/opengl/FPSCounter.java
deleted file mode 100644
index a3b7ccb70..000000000
--- a/src/jogl/classes/javax/media/opengl/FPSCounter.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package com.jogamp.opengl;
-
-import java.io.PrintStream;
-
-/**
- * FPSCounter feature.
- * An implementation initially has the FPSCounter feature disabled.
- * Use {@link #setUpdateFPSFrames(int, PrintStream)} to enable and disable the FPSCounter feature.
- */
-public interface FPSCounter {
- public static final int DEFAULT_FRAMES_PER_INTERVAL = 5*60;
-
- /**
- * @param frames Update interval in frames. At every rendered frames interval the currentTime and fps values are updated.
- * If the frames interval is <= 0, no update will be issued, ie the FPSCounter feature is turned off. You may choose {@link #DEFAULT_FRAMES_PER_INTERVAL}.
- * @param out optional print stream where the fps values gets printed if not null at every frames interval
- */
- void setUpdateFPSFrames(int frames, PrintStream out);
-
- /**
- * Reset all performance counter (startTime, currentTime, frame number)
- */
- void resetFPSCounter();
-
- /**
- * @return update interval in frames
- *
- * @see #setUpdateFPSFrames(int, PrintStream)
- */
- int getUpdateFPSFrames();
-
- /**
- * Returns the time of the first display call in milliseconds after enabling this feature via {@link #setUpdateFPSFrames(int, PrintStream)}.
- * This value is reset via {@link #resetFPSCounter()}.
- *
- * @see #setUpdateFPSFrames(int, PrintStream)
- * @see #resetFPSCounter()
- */
- long getFPSStartTime();
-
- /**
- * Returns the time of the last update interval in milliseconds, if this feature is enabled via {@link #setUpdateFPSFrames(int, PrintStream)}.
- * This value is reset via {@link #resetFPSCounter()}.
- *
- * @see #setUpdateFPSFrames(int, PrintStream)
- * @see #resetFPSCounter()
- */
- long getLastFPSUpdateTime();
-
- /**
- * @return Duration of the last update interval in milliseconds.
- *
- * @see #setUpdateFPSFrames(int, PrintStream)
- * @see #resetFPSCounter()
- */
- long getLastFPSPeriod();
-
- /**
- * @return Last update interval's frames per seconds, {@link #getUpdateFPSFrames()} / {@link #getLastFPSPeriod()}
- *
- * @see #setUpdateFPSFrames(int, PrintStream)
- * @see #resetFPSCounter()
- */
- float getLastFPS();
-
- /**
- * @return Number of frame rendered since {@link #getFPSStartTime()} up to {@link #getLastFPSUpdateTime()}
- *
- * @see #setUpdateFPSFrames(int, PrintStream)
- * @see #resetFPSCounter()
- */
- int getTotalFPSFrames();
-
- /**
- * @return Total duration in milliseconds, {@link #getLastFPSUpdateTime()} - {@link #getFPSStartTime()}
- *
- * @see #setUpdateFPSFrames(int, PrintStream)
- * @see #resetFPSCounter()
- */
- long getTotalFPSDuration();
-
-
- /**
- * @return Total frames per seconds, {@link #getTotalFPSFrames()} / {@link #getTotalFPSDuration()}
- *
- * @see #setUpdateFPSFrames(int, PrintStream)
- * @see #resetFPSCounter()
- */
- float getTotalFPS();
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java
deleted file mode 100644
index 549efd569..000000000
--- a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl;
-
-/**
- * An animator control interface,
- * which implementation may drive a {@link com.jogamp.opengl.GLAutoDrawable} animation.
- */
-public interface GLAnimatorControl extends FPSCounter {
- /**
- * A {@link GLAnimatorControl#setUncaughtExceptionHandler(UncaughtExceptionHandler) registered}
- * {@link UncaughtExceptionHandler} instance is invoked when an {@link GLAnimatorControl animator} abruptly {@link #stop() stops}
- * due to an uncaught exception from one of its {@link GLAutoDrawable}s.
- * @see #uncaughtException(GLAnimatorControl, GLAutoDrawable, Throwable)
- * @see GLAnimatorControl#setUncaughtExceptionHandler(UncaughtExceptionHandler)
- * @since 2.2
- */
- public static interface UncaughtExceptionHandler {
- /**
- * Method invoked when the given {@link GLAnimatorControl} is {@link GLAnimatorControl#stop() stopped} due to the
- * given uncaught exception happened on the given {@link GLAutoDrawable}.
- *
- * The animator thread can still be retrieved via {@link GLAnimatorControl#getThread()}.
- *
- *
- * All {@link GLAnimatorControl} states already reflect its stopped state.
- *
- *
- * After this handler method is called, the {@link GLAnimatorControl} is stopped.
- *
- *
- * Any exception thrown by this method will be ignored.
- *
- * @param animator the {@link GLAnimatorControl}
- * @param drawable the causing {@link GLAutoDrawable}
- * @param cause the uncaught exception
- * @see GLAnimatorControl#setUncaughtExceptionHandler(UncaughtExceptionHandler)
- * @since 2.2
- */
- void uncaughtException(final GLAnimatorControl animator, final GLAutoDrawable drawable, final Throwable cause);
- }
-
- /**
- * Indicates whether this animator has been {@link #start() started}.
- *
- * @see #start()
- * @see #stop()
- * @see #isPaused()
- * @see #pause()
- * @see #resume()
- */
- boolean isStarted();
-
- /**
- * Indicates whether this animator {@link #isStarted() is started} and {@link #isPaused() is not paused}.
- *
- * @see #start()
- * @see #stop()
- * @see #pause()
- * @see #resume()
- */
- boolean isAnimating();
-
- /**
- * Indicates whether this animator {@link #isStarted() is started}
- * and either {@link #pause() manually paused} or paused
- * automatically due to no {@link #add(GLAutoDrawable) added} {@link GLAutoDrawable}s.
- *
- * @see #start()
- * @see #stop()
- * @see #pause()
- * @see #resume()
- */
- boolean isPaused();
-
- /**
- * @return The animation thread if running, otherwise null.
- *
- * @see #start()
- * @see #stop()
- */
- Thread getThread();
-
- /**
- * Starts this animator, if not running.
- *
- * In most situations this method blocks until
- * completion, except when called from the animation thread itself
- * or in some cases from an implementation-internal thread like the
- * AWT event queue thread.
- *
- *
- * Note that an animator w/o {@link #add(GLAutoDrawable) added drawables}
- * will be paused automatically.
- *
- *
- * If started, all counters (time, frames, ..) are reset to zero.
- *
- *
- * @return true is started due to this call,
- * otherwise false, ie started already or unable to start.
- *
- * @see #stop()
- * @see #isAnimating()
- * @see #isPaused()
- * @see #getThread()
- */
- boolean start();
-
- /**
- * Stops this animator.
- *
- * In most situations this method blocks until
- * completion, except when called from the animation thread itself
- * or in some cases from an implementation-internal thread like the
- * AWT event queue thread.
- *
- *
- * @return true is stopped due to this call,
- * otherwise false, ie not started or unable to stop.
- *
- * @see #start()
- * @see #isAnimating()
- * @see #getThread()
- */
- boolean stop();
-
- /**
- * Pauses this animator.
- *
- * In most situations this method blocks until
- * completion, except when called from the animation thread itself
- * or in some cases from an implementation-internal thread like the
- * AWT event queue thread.
- *
- *
- * @return false if not started, already paused or failed to pause, otherwise true
- *
- * @see #resume()
- * @see #isAnimating()
- */
- boolean pause();
-
- /**
- * Resumes animation if paused.
- *
- * In most situations this method blocks until
- * completion, except when called from the animation thread itself
- * or in some cases from an implementation-internal thread like the
- * AWT event queue thread.
- *
- *
- * If resumed, all counters (time, frames, ..) are reset to zero.
- *
- *
- * @return false if not started, not paused or unable to resume, otherwise true
- *
- * @see #pause()
- * @see #isAnimating()
- */
- boolean resume();
-
- /**
- * Adds a drawable to this animator's list of rendering drawables.
- *
- * This allows the animator thread to become {@link #isAnimating() animating},
- * in case the first drawable is added and the animator {@link #isStarted() is started}.
- *
- *
- * @param drawable the drawable to be added
- * @throws IllegalArgumentException if drawable was already added to this animator
- */
- void add(GLAutoDrawable drawable);
-
- /**
- * Removes a drawable from the animator's list of rendering drawables.
- *
- * This method should get called in case a drawable becomes invalid,
- * and will not be recovered.
- *
- *
- * This allows the animator thread to become {@link #isAnimating() not animating},
- * in case the last drawable has been removed.
- *
- *
- * @param drawable the drawable to be removed
- * @throws IllegalArgumentException if drawable was not added to this animator
- */
- void remove(GLAutoDrawable drawable);
-
- /**
- * Returns the {@link UncaughtExceptionHandler} invoked when this {@link GLAnimatorControl animator} abruptly {@link #stop() stops}
- * due to an uncaught exception from one of its {@link GLAutoDrawable}s.
- *
- * Default is null.
- *
- * @since 2.2
- */
- UncaughtExceptionHandler getUncaughtExceptionHandler();
-
- /**
- * Set the handler invoked when this {@link GLAnimatorControl animator} abruptly {@link #stop() stops}
- * due to an uncaught exception from one of its {@link GLAutoDrawable}s.
- * @param handler the {@link UncaughtExceptionHandler} to use as this {@link GLAnimatorControl animator}'s uncaught exception
- * handler. Pass null to unset the handler.
- * @see UncaughtExceptionHandler#uncaughtException(GLAnimatorControl, GLAutoDrawable, Throwable)
- * @since 2.2
- */
- void setUncaughtExceptionHandler(final UncaughtExceptionHandler handler);
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLArrayData.java b/src/jogl/classes/javax/media/opengl/GLArrayData.java
deleted file mode 100644
index ea2dfb0f3..000000000
--- a/src/jogl/classes/javax/media/opengl/GLArrayData.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl;
-
-import java.nio.Buffer;
-
-import com.jogamp.opengl.fixedfunc.GLPointerFunc;
-
-/**
- *
- * The total number of bytes hold by the referenced buffer is:
- * getComponentSize()* getComponentNumber() * getElementNumber()
- *
- */
-public interface GLArrayData {
- /**
- * Implementation and type dependent object association.
- *
- * One currently known use case is to associate a {@link com.jogamp.opengl.util.glsl.ShaderState ShaderState}
- * to an GLSL aware vertex attribute object, allowing to use the ShaderState to handle it's
- * data persistence, location and state change.
- * This is implicitly done via {@link com.jogamp.opengl.util.glsl.ShaderState#ownAttribute(GLArrayData, boolean) shaderState.ownAttribute(GLArrayData, boolean)}.
- *
- * @param obj implementation and type dependent association
- * @param enable pass true to enable the association and false to disable it.
- */
- public void associate(Object obj, boolean enable);
-
- /**
- * Returns true if this data set is intended for a GLSL vertex shader attribute,
- * otherwise false, ie intended for fixed function vertex pointer
- */
- public boolean isVertexAttribute();
-
- /**
- * The index of the predefined array index, see list below,
- * or -1 in case of a shader attribute array.
- *
- * @see GLPointerFunc#GL_VERTEX_ARRAY
- * @see GLPointerFunc#GL_NORMAL_ARRAY
- * @see GLPointerFunc#GL_COLOR_ARRAY
- * @see GLPointerFunc#GL_TEXTURE_COORD_ARRAY
- */
- public int getIndex();
-
- /**
- * The name of the reflecting shader array attribute.
- */
- public String getName();
-
- /**
- * Set a new name for this array.
- *
- * This clears the location, i.e. sets it to -1.
- *
- * @see #setLocation(int)
- * @see #setLocation(GL2ES2, int)
- */
- public void setName(String newName);
-
-
- /**
- * Returns the shader attribute location for this name,
- * -1 if not yet determined
- */
- public int getLocation();
-
- /**
- * Sets the given location of the shader attribute
- *
- * @return the given location
- * @see com.jogamp.opengl.util.glsl.ShaderState#vertexAttribPointer(GL2ES2, GLArrayData)
- */
- public int setLocation(int v);
-
- /**
- * Retrieves the location of the shader attribute from the linked shader program.
- *
- * No validation is performed within the implementation.
- *
- * @param gl
- * @param program
- * @return ≥0 denotes a valid attribute location as found and used in the given shader program.
- * <0 denotes an invalid location, i.e. not found or used in the given shader program.
- */
- public int setLocation(GL2ES2 gl, int program);
-
- /**
- * Binds the location of the shader attribute to the given location for the unlinked shader program.
- *
- * No validation is performed within the implementation.
- *
- * @param gl
- * @param program
- * @return the given location
- */
- public int setLocation(GL2ES2 gl, int program, int location);
-
- /**
- * Determines whether the data is server side (VBO) and enabled,
- * or a client side array (false).
- */
- public boolean isVBO();
-
- /**
- * The VBO buffer offset or 0 if not a VBO
- */
- public long getVBOOffset();
-
- /**
- * The VBO name or 0 if not a VBO
- */
- public int getVBOName();
-
- /**
- * The VBO usage or 0 if not a VBO
- * @return 0 if not a GPU buffer, otherwise {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW}
- */
- public int getVBOUsage();
-
- /**
- * The VBO target or 0 if not a VBO
- * @return 0 if not a GPU buffer, otherwise {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER}
- */
- public int getVBOTarget();
-
-
- /**
- * The Buffer holding the data, may be null if a GPU buffer without client bound data
- */
- public Buffer getBuffer();
-
- /**
- * The number of components per element
- */
- public int getComponentCount();
-
- /**
- * The component's GL data type, ie. GL_FLOAT
- */
- public int getComponentType();
-
- /**
- * The component's size in bytes
- */
- public int getComponentSizeInBytes();
-
- /**
- * The current number of used elements.
- *
- * On element consist out of {@link #getComponentCount()} components.
- *
- * In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
- */
- public int getElementCount();
-
- /**
- * The currently used size in bytes.
- * In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
- */
- public int getSizeInBytes();
-
- /**
- * True, if GL shall normalize fixed point data while converting
- * them into float.
- *
- * Default behavior (of the fixed function pipeline) is true
- * for fixed point data type and false for floating point data types.
- *
- */
- public boolean getNormalized();
-
- /**
- * @return the byte offset between consecutive components
- */
- public int getStride();
-
- @Override
- public String toString();
-
- public void destroy(GL gl);
-
-}
-
diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
deleted file mode 100644
index 385acf082..000000000
--- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl;
-
-import java.util.List;
-
-import com.jogamp.nativewindow.NativeSurface;
-
-import com.jogamp.common.util.locks.RecursiveLock;
-
-import jogamp.opengl.Debug;
-
-/** A higher-level abstraction than {@link GLDrawable} which supplies
- an event based mechanism ({@link GLEventListener}) for performing
- OpenGL rendering. A GLAutoDrawable automatically creates a primary
- rendering context which is associated with the GLAutoDrawable for
- the lifetime of the object.
-
- Since the {@link GLContext} {@link GLContext#makeCurrent makeCurrent}
- implementation is synchronized, i.e. blocks if the context
- is current on another thread, the internal
- {@link GLContext} for the GLAutoDrawable can be used for the event
- based rendering mechanism and by end users directly.
-
- The implementation shall initialize itself as soon as possible,
- which is only possible after the attached {@link com.jogamp.nativewindow.NativeSurface NativeSurface} becomes visible and and is realized.
- The following initialization sequence should be implemented:
-
-
Create the {@link GLDrawable} with the requested {@link GLCapabilities}
-
Notify {@link GLDrawable} to validate the {@link GLCapabilities} by calling {@link GLDrawable#setRealized setRealized(true)}.
-
Create the new {@link GLContext}.
-
Initialize all OpenGL resources by calling {@link GLEventListener#init init(..)} for all
- registered {@link GLEventListener}s. This can be done immediately, or with the followup {@link #display display(..)} call.
-
Send a reshape event by calling {@link GLEventListener#reshape reshape(..)} for all
- registered {@link GLEventListener}s. This shall be done after the {@link GLEventListener#init init(..)} calls.
-
- Note: The last to {@link GLEventListener} actions shall be also performed, when {@link #addGLEventListener(GLEventListener) adding}
- a new one to an already initialized {@link GLAutoDrawable}.
-
-
- Another implementation detail is the {@link GLDrawable} reconfiguration. One use case is where a window is being
- dragged to another screen with a different pixel configuration, ie {@link GLCapabilities}. The implementation
- shall be able to detect such cases in conjunction with the associated {@link com.jogamp.nativewindow.NativeSurface NativeSurface}.
- For example, AWT's {@link java.awt.Canvas} 's {@link java.awt.Canvas#getGraphicsConfiguration getGraphicsConfiguration()}
- is capable to determine a display device change. This is demonstrated within {@link com.jogamp.opengl.awt.GLCanvas}'s
- and NEWT's AWTCanvas {@link com.jogamp.opengl.awt.GLCanvas#getGraphicsConfiguration getGraphicsConfiguration()}
- specialization. Another demonstration is NEWT's {@link com.jogamp.nativewindow.NativeWindow NativeWindow}
- implementation on the Windows platform, which utilizes the native platform's MonitorFromWindow(HWND) function.
- All OpenGL resources shall be regenerated, while the drawable's {@link GLCapabilities} has
- to be chosen again. The following protocol shall be satisfied.
-
-
Controlled disposal:
-
-
Dispose all OpenGL resources by calling {@link GLEventListener#dispose dispose(..)} for all
- registered {@link GLEventListener}s.
-
Destroy the {@link GLContext}.
-
Notify {@link GLDrawable} of the invalid state by calling {@link GLDrawable#setRealized setRealized(false)}.
-
-
Controlled regeneration:
-
-
Create the new {@link GLDrawable} with the requested {@link GLCapabilities}
-
Notify {@link GLDrawable} to revalidate the {@link GLCapabilities} by calling {@link GLDrawable#setRealized setRealized(true)}.
-
Create the new {@link GLContext}.
-
Initialize all OpenGL resources by calling {@link GLEventListener#init init(..)} for all
- registered {@link GLEventListener}s. This can be done immediatly, or with the followup {@link #display display(..)} call.
-
Send a reshape event by calling {@link GLEventListener#reshape reshape(..)} for all
- registered {@link GLEventListener}s. This shall be done after the {@link GLEventListener#init init(..)} calls.
-
-
- Note: Current graphics driver keep the surface configuration for a given window, even if the window is moved to
- a monitor with a different pixel configuration, ie 32bpp to 16bpp. However, it is best to not assume such behavior
- and make your application comply with the above protocol.
-
- Avoiding breakage with older applications and because of the situation
- mentioned above, the boolean system property jogl.screenchange.action will control the
- screen change action as follows:
-
- -Djogl.screenchange.action=false Disable the {@link GLDrawable} reconfiguration (the default)
- -Djogl.screenchange.action=true Enable the {@link GLDrawable} reconfiguration
-
-
- Above locking order is mandatory to guarantee
- atomicity of operation and to avoid race-conditions.
- A custom implementation or user applications requiring exclusive access
- shall follow the locking order.
- See:
-
-
{@link #getUpstreamLock()}
-
{@link #invoke(boolean, GLRunnable)}
-
{@link #invoke(boolean, List)}
-
-
- */
-public interface GLAutoDrawable extends GLDrawable {
- /** Flag reflecting whether the {@link GLDrawable} reconfiguration will be issued in
- * case a screen device change occurred, e.g. in a multihead environment,
- * where you drag the window to another monitor. */
- public static final boolean SCREEN_CHANGE_ACTION_ENABLED = Debug.getBooleanProperty("jogl.screenchange.action", true);
-
- /**
- * If the implementation uses delegation, return the delegated {@link GLDrawable} instance,
- * otherwise return this instance.
- */
- public GLDrawable getDelegatedDrawable();
-
- /**
- * Returns the context associated with this drawable. The returned
- * context will be synchronized.
- * Don't rely on it's identity, the context may change.
- */
- public GLContext getContext();
-
- /**
- * Associate the new context, newtCtx, to this auto-drawable.
- *
- * Remarks:
- *
- *
The currently associated context will be destroyed if destroyPrevCtx is true,
- * otherwise it will be disassociated from this auto-drawable
- * via {@link GLContext#setGLDrawable(GLDrawable, boolean) setGLDrawable(null, true);} including {@link GL#glFinish() glFinish()}.
- *
The new context will be associated with this auto-drawable
- * via {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}.
- *
If the old context was current on this thread, it is being released after disassociating this auto-drawable.
- *
If the new context was current on this thread, it is being released before associating this auto-drawable
- * and made current afterwards.
- *
Implementation may issue {@link #makeCurrent()} and {@link #release()} while drawable reassociation.
- *
The user shall take extra care of thread synchronization,
- * i.e. lock the involved {@link GLAutoDrawable auto-drawable's}
- * {@link GLAutoDrawable#getUpstreamLock() upstream-locks} and {@link GLAutoDrawable#getNativeSurface() surfaces}
- * to avoid a race condition. See GLAutoDrawable Locking.
- *
- *
- *
- * @param newCtx the new context, maybe null for dis-association.
- * @param destroyPrevCtx if true, destroy the previous context if exists
- * @return the previous GLContext, maybe null
- *
- * @see GLContext#setGLDrawable(GLDrawable, boolean)
- * @see GLContext#setGLReadDrawable(GLDrawable)
- * @see jogamp.opengl.GLDrawableHelper#switchContext(GLDrawable, GLContext, boolean, GLContext, int)
- */
- public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx);
-
- /**
- * Adds the given {@link GLEventListener listener} to the end of this drawable queue.
- * The {@link GLEventListener listeners} are notified of events in the order of the queue.
- *
- * The newly added listener's {@link GLEventListener#init(GLAutoDrawable) init(..)}
- * method will be called once before any other of it's callback methods.
- * See {@link #getGLEventListenerInitState(GLEventListener)} for details.
- *
- * @param listener The GLEventListener object to be inserted
- */
- public void addGLEventListener(GLEventListener listener);
-
- /**
- * Adds the given {@link GLEventListener listener} at the given index of this drawable queue.
- * The {@link GLEventListener listeners} are notified of events in the order of the queue.
- *
- * The newly added listener's {@link GLEventListener#init(GLAutoDrawable) init(..)}
- * method will be called once before any other of it's callback methods.
- * See {@link #getGLEventListenerInitState(GLEventListener)} for details.
- *
- * @param index Position where the listener will be inserted.
- * Should be within (0 <= index && index <= size()).
- * An index value of -1 is interpreted as the end of the list, size().
- * @param listener The GLEventListener object to be inserted
- * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index <= size()), or -1
- */
- public void addGLEventListener(int index, GLEventListener listener) throws IndexOutOfBoundsException;
-
- /**
- * Returns the number of {@link GLEventListener} of this drawable queue.
- * @return The number of GLEventListener objects of this drawable queue.
- */
- public int getGLEventListenerCount();
-
- /**
- * Returns true if all added {@link GLEventListener} are initialized, otherwise false.
- * @since 2.2
- */
- boolean areAllGLEventListenerInitialized();
-
- /**
- * Returns the {@link GLEventListener} at the given index of this drawable queue.
- * @param index Position of the listener to be returned.
- * Should be within (0 <= index && index < size()).
- * An index value of -1 is interpreted as last listener, size()-1.
- * @return The GLEventListener object at the given index.
- * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index < size()), or -1
- */
- public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException;
-
- /**
- * Retrieves whether the given {@link GLEventListener listener} is initialized or not.
- *
- * After {@link #addGLEventListener(GLEventListener) adding} a {@link GLEventListener} it is
- * marked uninitialized and added to a list of to be initialized {@link GLEventListener}.
- * If such uninitialized {@link GLEventListener}'s handler methods (reshape, display)
- * are about to be invoked, it's {@link GLEventListener#init(GLAutoDrawable) init(..)} method is invoked first.
- * Afterwards the {@link GLEventListener} is marked initialized
- * and removed from the list of to be initialized {@link GLEventListener}.
- *
- *
- * This methods returns the {@link GLEventListener} initialized state,
- * i.e. returns false if it is included in the list of to be initialized {@link GLEventListener},
- * otherwise true.
- *
- * @param listener the GLEventListener object to query it's initialized state.
- */
- public boolean getGLEventListenerInitState(GLEventListener listener);
-
- /**
- * Sets the given {@link GLEventListener listener's} initialized state.
- *
- * This methods allows manually setting the {@link GLEventListener} initialized state,
- * i.e. adding it to, or removing it from the list of to be initialized {@link GLEventListener}.
- * See {@link #getGLEventListenerInitState(GLEventListener)} for details.
- *
- *
- * Warning: This method does not validate whether the given {@link GLEventListener listener's}
- * is member of this drawable queue, i.e. {@link #addGLEventListener(GLEventListener) added}.
- *
- *
- * This method is only exposed to allow users full control over the {@link GLEventListener}'s state
- * and is usually not recommended to change.
- *
- *
- * One use case is moving a {@link GLContext} and their initialized {@link GLEventListener}
- * from one {@link GLAutoDrawable} to another,
- * where a subsequent {@link GLEventListener#init(GLAutoDrawable) init(..)} call after adding it
- * to the new owner is neither required nor desired.
- * See {@link com.jogamp.opengl.util.GLDrawableUtil#swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable) swapGLContextAndAllGLEventListener(..)}.
- *
- * @param listener the GLEventListener object to perform a state change.
- * @param initialized if true, mark the listener initialized, otherwise uninitialized.
- */
- public void setGLEventListenerInitState(GLEventListener listener, boolean initialized);
-
- /**
- * Disposes the given {@link GLEventListener listener} via {@link GLEventListener#dispose(GLAutoDrawable) dispose(..)}
- * if it has been initialized and added to this queue.
- *
- * If remove is true, the {@link GLEventListener} is removed from this drawable queue before disposal,
- * otherwise marked uninitialized.
- *
- *
- * If an {@link GLAnimatorControl} is being attached and the current thread is different
- * than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation.
- *
- *
- * Note that this is an expensive operation, since {@link GLEventListener#dispose(GLAutoDrawable) dispose(..)}
- * is decorated by {@link GLContext#makeCurrent()} and {@link GLContext#release()}.
- *
- *
- * Use {@link #removeGLEventListener(GLEventListener) removeGLEventListener(listener)} instead
- * if you just want to remove the {@link GLEventListener listener} and don't care about the disposal of the it's (OpenGL) resources.
- *
- *
- * Also note that this is done from within a particular drawable's
- * {@link GLEventListener} handler (reshape, display, etc.), that it is not
- * guaranteed that all other listeners will be evaluated properly
- * during this update cycle.
- *
- * @param listener The GLEventListener object to be disposed and removed if remove is true
- * @param remove pass true to have the listener removed from this drawable queue, otherwise pass false
- * @return the disposed and/or removed GLEventListener, or null if no action was performed, i.e. listener was not added
- */
- public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove);
-
- /**
- * Removes the given {@link GLEventListener listener} from this drawable queue.
- *
- * This is an inexpensive operation, since the removed listener's
- * {@link GLEventListener#dispose(GLAutoDrawable) dispose(..)} method will not be called.
- *
- *
- * Use {@link #disposeGLEventListener(GLEventListener, boolean) disposeGLEventListener(listener, true)}
- * instead to ensure disposal of the {@link GLEventListener listener}'s (OpenGL) resources.
- *
- *
- * Note that if this is done from within a particular drawable's
- * {@link GLEventListener} handler (reshape, display, etc.), that it is not
- * guaranteed that all other listeners will be evaluated properly
- * during this update cycle.
- *
- * @param listener The GLEventListener object to be removed
- * @return the removed GLEventListener, or null if listener was not added
- */
- public GLEventListener removeGLEventListener(GLEventListener listener);
-
- /**
- * Registers the usage of an animator, an {@link com.jogamp.opengl.GLAnimatorControl} implementation.
- * The animator will be queried whether it's animating, ie periodically issuing {@link #display()} calls or not.
- *
- * This method shall be called by an animator implementation only,
- * e.g. {@link com.jogamp.opengl.util.Animator#add(com.jogamp.opengl.GLAutoDrawable)}, passing it's control implementation,
- * and {@link com.jogamp.opengl.util.Animator#remove(com.jogamp.opengl.GLAutoDrawable)}, passing null.
- *
- *
- * Impacts {@link #display()} and {@link #invoke(boolean, GLRunnable)} semantics.
- *
- * @param animatorControl null reference indicates no animator is using
- * this GLAutoDrawable,
- * a valid reference indicates an animator is using this GLAutoDrawable.
- *
- * @throws GLException if an animator is already registered.
- * @see #display()
- * @see #invoke(boolean, GLRunnable)
- * @see com.jogamp.opengl.GLAnimatorControl
- */
- public abstract void setAnimator(GLAnimatorControl animatorControl) throws GLException;
-
- /**
- * @return the registered {@link com.jogamp.opengl.GLAnimatorControl} implementation, using this GLAutoDrawable.
- *
- * @see #setAnimator(com.jogamp.opengl.GLAnimatorControl)
- * @see com.jogamp.opengl.GLAnimatorControl
- */
- public GLAnimatorControl getAnimator();
-
- /**
- * Dedicates this instance's {@link GLContext} to the given thread.
- * The thread will exclusively claim the {@link GLContext} via {@link #display()} and not release it
- * until {@link #destroy()} or setExclusiveContextThread(null) has been called.
- *
- * Default non-exclusive behavior is requested via setExclusiveContextThread(null),
- * which will cause the next call of {@link #display()} on the exclusive thread to
- * release the {@link GLContext}. Only after it's async release, {@link #getExclusiveContextThread()}
- * will return null.
- *
- *
- * To release a previous made exclusive thread, a user issues setExclusiveContextThread(null)
- * and may poll {@link #getExclusiveContextThread()} until it returns null,
- * while the exclusive thread is still running.
- *
- *
- * Note: Setting a new exclusive thread without properly releasing a previous one
- * will throw an GLException.
- *
- *
- * Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation.
- * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas.
- *
- *
- * One scenario could be to dedicate the context to the {@link GLAnimatorControl#getThread() animator thread}
- * and spare redundant context switches, see {@link com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean)}.
- *
- * @param t the exclusive thread to claim the context, or null for default operation.
- * @return previous exclusive context thread
- * @throws GLException If an exclusive thread is still active but a new one is attempted to be set
- * @see com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean)
- */
- public Thread setExclusiveContextThread(Thread t) throws GLException;
-
- /**
- * @see #setExclusiveContextThread(Thread)
- */
- public Thread getExclusiveContextThread();
-
- /**
- * Enqueues a one-shot {@link GLRunnable},
- * which will be executed within the next {@link #display()} call
- * after all registered {@link GLEventListener}s
- * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)}
- * methods have been called.
- *
- * If no {@link GLAnimatorControl} is animating (default),
- * or if the current thread is the animator thread,
- * a {@link #display()} call is issued after enqueue the GLRunnable,
- * hence the {@link GLRunnable} will be executed right away.
- *
- *
- * If an {@link GLAnimatorControl animator} is running,
- * no explicit {@link #display()} call is issued, allowing the {@link GLAnimatorControl animator} to perform at due time.
- *
- *
- * If wait is true the call blocks until the glRunnable
- * has been executed by the {@link GLAnimatorControl animator}, otherwise the method returns immediately.
- *
- *
- * If wait is trueand
- * {@link #isRealized()} returns falseor {@link #getContext()} returns null,
- * the call is ignored and returns false.
- * This helps avoiding deadlocking the caller.
- *
- *
- * The internal queue of {@link GLRunnable}'s is being flushed with {@link #destroy()}
- * where all blocked callers are being notified.
- *
- *
- * To avoid a deadlock situation which causes an {@link IllegalStateException} one should
- * avoid issuing {@link #invoke(boolean, GLRunnable) invoke} while this GLAutoDrawable is being locked.
- * Detected deadlock situations throwing an {@link IllegalStateException} are:
- *
- *
{@link #getAnimator() Animator} is running on another thread and waiting and is locked on current thread, but is not {@link #isThreadGLCapable() GL-Thread}
- *
No {@link #getAnimator() Animator} is running on another thread and is locked on current thread, but is not {@link #isThreadGLCapable() GL-Thread}
- *
- *
- *
- * @param wait if true block until execution of glRunnable is finished, otherwise return immediately w/o waiting
- * @param glRunnable the {@link GLRunnable} to execute within {@link #display()}
- * @return true if the {@link GLRunnable} has been processed or queued, otherwise false.
- * @throws IllegalStateException in case of a detected deadlock situation ahead, see above.
- *
- * @see #setAnimator(GLAnimatorControl)
- * @see #display()
- * @see GLRunnable
- * @see #invoke(boolean, List)
- * @see #flushGLRunnables()
- */
- public boolean invoke(boolean wait, GLRunnable glRunnable) throws IllegalStateException ;
-
- /**
- * Extends {@link #invoke(boolean, GLRunnable)} functionality
- * allowing to inject a list of {@link GLRunnable}s.
- * @param wait if true block until execution of the last glRunnable is finished, otherwise return immediately w/o waiting
- * @param glRunnables the {@link GLRunnable}s to execute within {@link #display()}
- * @return true if the {@link GLRunnable}s has been processed or queued, otherwise false.
- * @throws IllegalStateException in case of a detected deadlock situation ahead, see {@link #invoke(boolean, GLRunnable)}.
- * @see #invoke(boolean, GLRunnable)
- * @see #flushGLRunnables()
- */
- public boolean invoke(boolean wait, List glRunnables) throws IllegalStateException;
-
- /**
- * Flushes all {@link #invoke(boolean, GLRunnable) enqueued} {@link GLRunnable} of this {@link GLAutoDrawable}
- * including notifying waiting executor.
- *
- * The executor which might have been blocked until notified
- * will be unblocked and all tasks removed from the queue.
- *
- * @see #invoke(boolean, GLRunnable)
- * @since 2.2
- */
- public void flushGLRunnables();
-
- /** Destroys all resources associated with this GLAutoDrawable,
- inclusive the GLContext.
- If a window is attached to it's implementation, it shall be closed.
- Causes disposing of all OpenGL resources
- by calling {@link GLEventListener#dispose dispose(..)} for all
- registered {@link GLEventListener}s. Called automatically by the
- window system toolkit upon receiving a destroy notification. This
- routine may be called manually. */
- public void destroy();
-
- /**
- *
- * Causes OpenGL rendering to be performed for this GLAutoDrawable
- * in the following order:
- *
- *
Calling {@link GLEventListener#display display(..)} for all
- * registered {@link GLEventListener}s.
- *
Executes all one-shot {@link com.jogamp.opengl.GLRunnable GLRunnable},
- * enqueued via {@link #invoke(boolean, GLRunnable)}.
- *
- *
- * May be called periodically by a running {@link com.jogamp.opengl.GLAnimatorControl} implementation,
- * which must register itself with {@link #setAnimator(com.jogamp.opengl.GLAnimatorControl)}.
- *
- * Called automatically by the window system toolkit upon receiving a repaint() request,
- * except an {@link com.jogamp.opengl.GLAnimatorControl} implementation {@link com.jogamp.opengl.GLAnimatorControl#isAnimating()}.
- *
- * This routine may also be called manually for better control over the
- * rendering process. It is legal to call another GLAutoDrawable's
- * display method from within the {@link GLEventListener#display
- * display(..)} callback.
- *
- * In case of a new generated OpenGL context,
- * the implementation shall call {@link GLEventListener#init init(..)} for all
- * registered {@link GLEventListener}s before making the
- * actual {@link GLEventListener#display display(..)} calls,
- * in case this has not been done yet.
- *
- * @see #setAnimator(com.jogamp.opengl.GLAnimatorControl)
- */
- public void display();
-
- /** Enables or disables automatic buffer swapping for this drawable.
- By default this property is set to true; when true, after all
- GLEventListeners have been called for a display() event, the
- front and back buffers are swapped, displaying the results of
- the render. When disabled, the user is responsible for calling
- {@link #swapBuffers(..)} manually. */
- public void setAutoSwapBufferMode(boolean enable);
-
- /** Indicates whether automatic buffer swapping is enabled for this
- drawable. See {@link #setAutoSwapBufferMode}. */
- public boolean getAutoSwapBufferMode();
-
- /**
- * @param flags Additional context creation flags.
- *
- * @see GLContext#setContextCreationFlags(int)
- * @see GLContext#enableGLDebugMessage(boolean)
- */
- public void setContextCreationFlags(int flags);
-
- /**
- * @return Additional context creation flags
- */
- public int getContextCreationFlags();
-
- /**
- * {@inheritDoc}
- *
- * This GLAutoDrawable implementation holds it's own GLContext reference,
- * thus created a GLContext using this methods won't replace it implicitly.
- * To replace or set this GLAutoDrawable's GLContext you need to call {@link #setContext(GLContext, boolean)}.
- *
- *
- * The GLAutoDrawable implementation shall also set the
- * context creation flags as customized w/ {@link #setContextCreationFlags(int)}.
- *
- */
- @Override
- public GLContext createContext(GLContext shareWith);
-
- /** Returns the {@link GL} pipeline object this GLAutoDrawable uses.
- If this method is called outside of the {@link
- GLEventListener}'s callback methods (init, display, etc.) it may
- return null. Users should not rely on the identity of the
- returned GL object; for example, users should not maintain a
- hash table with the GL object as the key. Additionally, the GL
- object should not be cached in client code, but should be
- re-fetched from the GLAutoDrawable at the beginning of each call
- to init, display, etc. */
- public GL getGL();
-
- /** Sets the {@link GL} pipeline object this GLAutoDrawable uses.
- This should only be called from within the GLEventListener's
- callback methods, and usually only from within the init()
- method, in order to install a composable pipeline. See the JOGL
- demos for examples.
- @return the set GL pipeline or null if not successful */
- public GL setGL(GL gl);
-
- /**
- * Method may return the upstream UI toolkit object
- * holding this {@link GLAutoDrawable} instance, if exist.
- *
- * Currently known Java UI toolkits and it's known return types are:
- *
- *
- *
Toolkit
GLAutoDrawable Implementation
~
Return Type of getUpstreamWidget()
- *
NEWT
{@link com.jogamp.newt.opengl.GLWindow}
has a
{@link com.jogamp.newt.Window}
- *
SWT
{@link com.jogamp.opengl.swt.GLCanvas}
is a
{@link org.eclipse.swt.widgets.Canvas}
- *
AWT
{@link com.jogamp.opengl.awt.GLCanvas}
is a
{@link java.awt.Canvas}
- *
AWT
{@link com.jogamp.opengl.awt.GLJPanel}
is a
{@link javax.swing.JPanel}
- *
- * However, the result may be other object types than the listed above
- * due to new supported toolkits.
- *
- *
- * This method may also return null if no UI toolkit is being used,
- * as common for offscreen rendering.
- *
- */
- public Object getUpstreamWidget();
-
- /**
- * Returns the recursive lock object of the {@link #getUpstreamWidget() upstream widget}
- * to synchronize multithreaded access on top of {@link NativeSurface#lockSurface()}.
- *
- * @since 2.2
- */
- public RecursiveLock getUpstreamLock();
-
- /**
- * Indicates whether the current thread is capable of
- * performing OpenGL-related work.
- *
- * Implementation utilizes this knowledge to determine
- * whether {@link #display()} performs the OpenGL commands on the current thread directly
- * or spawns them on the dedicated OpenGL thread.
- *
- * @since 2.2
- */
- public boolean isThreadGLCapable();
-
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java
deleted file mode 100644
index 19b7808fc..000000000
--- a/src/jogl/classes/javax/media/opengl/GLBase.java
+++ /dev/null
@@ -1,646 +0,0 @@
-/**
- * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl;
-
-/**
- *
The base interface from which all GL profiles derive, providing
- * checked conversion down to concrete profiles, access to the
- * OpenGL context associated with the GL and extension/function
- * availability queries as described below.
- *
- *
While the APIs for vendor extensions are unconditionally
- * exposed, the underlying functions may not be present. The method
- * {@link #isFunctionAvailable} should be used to query the
- * availability of any non-core function before it is used for the
- * first time; for example,
- * gl.isFunctionAvailable("glProgramStringARB"). On
- * certain platforms (Windows in particular), the most "core"
- * functionality is only OpenGL 1.1, so in theory any routines first
- * exposed in OpenGL 1.2, 1.3, and 1.4, 1.5, or 2.0 as well as vendor
- * extensions should all be queried. Calling an unavailable function
- * will cause a {@link GLException} to be raised.
- *
- * {@link #isExtensionAvailable} may also be used to determine whether
- * a specific extension is available before calling the routines or
- * using the functionality it exposes: for example,
- * gl.isExtensionAvailable("GL_ARB_vertex_program");.
- * However, in this case it is up to the end user to know which
- * routines or functionality are associated with which OpenGL
- * extensions. It may also be used to test for the availability of a
- * particular version of OpenGL: for example,
- * gl.isExtensionAvailable("GL_VERSION_1_5");.
- *
- *
Exceptions to the window system extension naming rules:
- *
- *
- *
- *
The memory allocators for the NVidia vertex_array_range (VAR)
- * extension, in particular wglAllocateMemoryNV /
- * glXAllocateMemoryNV and associated routines. {@link
- * #glAllocateMemoryNV} has been provided for window system-independent
- * access to VAR. {@link #isFunctionAvailable} will translate an argument
- * of "glAllocateMemoryNV" or "glFreeMemoryNV" into the appropriate
- * window system-specific name.
- *
- *
WGL_ARB_pbuffer, WGL_ARB_pixel_format, and other
- * platform-specific pbuffer functionality; the availability of
- * pbuffers can be queried on Windows, X11 and Mac OS X platforms by
- * querying {@link #isExtensionAvailable} with an argument of
- * "GL_ARB_pbuffer" or "GL_ARB_pixel_format".
- *
- *
- *
- */
-public interface GLBase {
-
- /**
- * Indicates whether this GL object conforms to any of the OpenGL profiles.
- */
- public boolean isGL();
-
- /**
- * Indicates whether this GL object conforms to the OpenGL ≥ 4.0 compatibility profile.
- * The GL4 compatibility profile includes the GL2, GL2ES1, GL2ES2, GL3, GL3bc and GL4 profile.
- * @see GLContext#isGL4bc()
- */
- public boolean isGL4bc();
-
- /**
- * Indicates whether this GL object conforms to the OpenGL ≥ 4.0 core profile.
- * The GL4 core profile includes the GL2ES2, and GL3 profile.
- * @see GLContext#isGL4()
- */
- public boolean isGL4();
-
- /**
- * Indicates whether this GL object conforms to the OpenGL ≥ 3.1 compatibility profile.
- * The GL3 compatibility profile includes the GL2, GL2ES1, GL2ES2 and GL3 profile.
- * @see GLContext#isGL3bc()
- */
- public boolean isGL3bc();
-
- /**
- * Indicates whether this GL object conforms to the OpenGL ≥ 3.1 core profile.
- * The GL3 core profile includes the GL2ES2 profile.
- * @see GLContext#isGL3()
- */
- public boolean isGL3();
-
- /**
- * Indicates whether this GL object conforms to the OpenGL ≤ 3.0 profile.
- * The GL2 profile includes the GL2ES1 and GL2ES2 profile.
- * @see GLContext#isGL2()
- */
- public boolean isGL2();
-
- /**
- * Indicates whether this GL object conforms to the OpenGL ES ≥ 1.0 profile.
- * @see GLContext#isGLES1()
- */
- public boolean isGLES1();
-
- /**
- * Indicates whether this GL object conforms to the OpenGL ES ≥ 2.0 profile.
- *
- * Remark: ES2 compatible desktop profiles are not included.
- * To query whether core ES2 functionality is provided, use {@link #isGLES2Compatible()}.
- *
- * @see #isGLES2Compatible()
- * @see GLContext#isGLES2()
- */
- public boolean isGLES2();
-
- /**
- * Indicates whether this GL object conforms to the OpenGL ES ≥ 3.0 profile.
- *
- * Remark: ES3 compatible desktop profiles are not included.
- * To query whether core ES3 functionality is provided, use {@link #isGLES3Compatible()}.
- *
- * @see #isGLES3Compatible()
- * @see GLContext#isGLES3()
- */
- public boolean isGLES3();
-
- /**
- * Indicates whether this GL object conforms to one of the OpenGL ES profiles,
- * see {@link #isGLES1()}, {@link #isGLES2()} and {@link #isGLES3()}.
- * @see GLContext#isGLES()
- */
- public boolean isGLES();
-
- /**
- * Indicates whether this GL object conforms to a GL2ES1 compatible profile.
- * @see GLContext#isGL2ES1()
- */
- public boolean isGL2ES1();
-
- /**
- * Indicates whether this GL object conforms to a GL2ES2 compatible profile.
- * @see GLContext#isGL2ES2()
- */
- public boolean isGL2ES2();
-
- /**
- * Indicates whether this GL object conforms to a either a GL2GL3 or GL3ES3 compatible profile.
- * @see GLContext#isGL2ES3()
- */
- public boolean isGL2ES3();
-
- /**
- * Indicates whether this GL object conforms to a GL3ES3 compatible profile.
- * @see GLContext#isGL3ES3()
- */
- public boolean isGL3ES3();
-
- /**
- * Returns true if this GL object conforms to a GL4ES3 compatible profile, i.e. if {@link #isGLES3Compatible()} returns true.
- *
Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
- * @see GLContext#isGL4ES3()
- */
- public boolean isGL4ES3();
-
- /**
- * Indicates whether this GL object conforms to a GL2GL3 compatible profile.
- * @see GLContext#isGL2GL3()
- */
- public boolean isGL2GL3();
-
- /**
- * Indicates whether this GL object uses a GL4 core profile.
Includes [ GL4 ].
- * @see GLContext#isGL4core()
- */
- public boolean isGL4core();
-
- /**
- * Indicates whether this GL object uses a GL3 core profile.
Includes [ GL4, GL3 ].
- * @see GLContext#isGL3core()
- */
- public boolean isGL3core();
-
- /**
- * Indicates whether this GL object uses a GL core profile.
Includes [ GL4, GL3, GLES3, GL2ES2 ].
- * @see GLContext#isGLcore()
- */
- public boolean isGLcore();
-
- /**
- * Indicates whether this GL object is compatible with the core OpenGL ES2 functionality.
- * @return true if this context is an ES2 context or implements
- * the extension GL_ARB_ES2_compatibility, otherwise false
- * @see GLContext#isGLES2Compatible()
- */
- public boolean isGLES2Compatible();
-
- /**
- * Indicates whether this GL object is compatible with the core OpenGL ES3 functionality.
- *
- * Return true if the underlying context is an ES3 context or implements
- * the extension GL_ARB_ES3_compatibility, otherwise false.
- *
- *
- * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
- *
- * @see GLContext#isGLES3Compatible()
- */
- public boolean isGLES3Compatible();
-
- /**
- * Indicates whether this GL object supports GLSL.
- * @see GLContext#hasGLSL()
- */
- public boolean hasGLSL();
-
- /**
- * Returns the downstream GL instance in case this is a wrapping pipeline, otherwise null.
- *
- * See {@link #getRootGL()} for retrieving the implementing root instance.
- *
- * @throws GLException if the downstream instance is not null and not a GL implementation
- * @see #getRootGL()
- */
- public GL getDownstreamGL() throws GLException;
-
- /**
- * Returns the implementing root instance, considering a wrapped pipelined hierarchy, see {@link #getDownstreamGL()}.
- *
- * If this instance is not a wrapping pipeline, i.e. has no downstream instance,
- * this instance is returned.
- *
- * @throws GLException if the root instance is not a GL implementation
- */
- public GL getRootGL() throws GLException;
-
- /**
- * Casts this object to the GL interface.
- * @throws GLException if this object is not a GL implementation
- */
- public GL getGL() throws GLException;
-
- /**
- * Casts this object to the GL4bc interface.
- * @throws GLException if this object is not a GL4bc implementation
- */
- public GL4bc getGL4bc() throws GLException;
-
- /**
- * Casts this object to the GL4 interface.
- * @throws GLException if this object is not a GL4 implementation
- */
- public GL4 getGL4() throws GLException;
-
- /**
- * Casts this object to the GL3bc interface.
- * @throws GLException if this object is not a GL3bc implementation
- */
- public GL3bc getGL3bc() throws GLException;
-
- /**
- * Casts this object to the GL3 interface.
- * @throws GLException if this object is not a GL3 implementation
- */
- public GL3 getGL3() throws GLException;
-
- /**
- * Casts this object to the GL2 interface.
- * @throws GLException if this object is not a GL2 implementation
- */
- public GL2 getGL2() throws GLException;
-
- /**
- * Casts this object to the GLES1 interface.
- * @throws GLException if this object is not a GLES1 implementation
- */
- public GLES1 getGLES1() throws GLException;
-
- /**
- * Casts this object to the GLES2 interface.
- * @throws GLException if this object is not a GLES2 implementation
- */
- public GLES2 getGLES2() throws GLException;
-
- /**
- * Casts this object to the GLES3 interface.
- * @throws GLException if this object is not a GLES3 implementation
- */
- public GLES3 getGLES3() throws GLException;
-
- /**
- * Casts this object to the GL2ES1 interface.
- * @throws GLException if this object is not a GL2ES1 implementation
- */
- public GL2ES1 getGL2ES1() throws GLException;
-
- /**
- * Casts this object to the GL2ES2 interface.
- * @throws GLException if this object is not a GL2ES2 implementation
- */
- public GL2ES2 getGL2ES2() throws GLException;
-
- /**
- * Casts this object to the GL2ES3 interface.
- * @throws GLException if this object is not a GL2ES3 implementation
- */
- public GL2ES3 getGL2ES3() throws GLException;
-
- /**
- * Casts this object to the GL3ES3 interface.
- * @throws GLException if this object is not a GL3ES3 implementation
- */
- public GL3ES3 getGL3ES3() throws GLException;
-
- /**
- * Casts this object to the GL4ES3 interface.
- * @throws GLException if this object is not a GL4ES3 implementation
- */
- public GL4ES3 getGL4ES3() throws GLException;
-
- /**
- * Casts this object to the GL2GL3 interface.
- * @throws GLException if this object is not a GL2GL3 implementation
- */
- public GL2GL3 getGL2GL3() throws GLException;
-
- /**
- * Returns the GLProfile associated with this GL object.
- */
- public GLProfile getGLProfile();
-
- /**
- * Returns the GLContext associated which this GL object.
- */
- public GLContext getContext();
-
- /**
- * Returns true if the specified OpenGL core- or extension-function can be
- * used successfully through this GL instance given the current host (OpenGL
- * client) and display (OpenGL server) configuration.
- * By "successfully" we mean that the function is both callable
- * on the machine running the program and available on the current
- * display.
- *
- * In order to call a function successfully, the function must be both
- * callable on the machine running the program and available on
- * the display device that is rendering the output (note: on non-networked,
- * single-display machines these two conditions are identical; on networked and/or
- * multi-display machines this becomes more complicated). These conditions are
- * met if the function is either part of the core OpenGL version supported by
- * both the host and display, or it is an OpenGL extension function that both
- * the host and display support.
- *
- * A GL function is callable if it is successfully linked at runtime,
- * hence the GLContext must be made current at least once.
- *
- * @param glFunctionName the name of the OpenGL function (e.g., use
- * "glBindRenderbufferEXT" or "glBindRenderbuffer" to check if {@link
- * GL#glBindRenderbuffer(int,int)} is available).
- */
- public boolean isFunctionAvailable(String glFunctionName);
-
- /**
- * Returns true if the specified OpenGL extension can be
- * used successfully through this GL instance given the current host (OpenGL
- * client) and display (OpenGL server) configuration.
- *
- * @param glExtensionName the name of the OpenGL extension (e.g.,
- * "GL_ARB_vertex_program").
- */
- public boolean isExtensionAvailable(String glExtensionName);
-
- /**
- * Returns true if basic FBO support is available, otherwise false.
- *
- * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= 3.0 [core, compat] or implements the extensions
- * GL_ARB_ES2_compatibility, GL_ARB_framebuffer_object, GL_EXT_framebuffer_object or GL_OES_framebuffer_object.
- *
- *
- * Basic FBO support may only include one color attachment and no multisampling,
- * as well as limited internal formats for renderbuffer.
- *
- * @see GLContext#hasBasicFBOSupport()
- */
- public boolean hasBasicFBOSupport();
-
- /**
- * Returns true if full FBO support is available, otherwise false.
- *
- * Full FBO is supported if the context is either GL >= core 3.0 [ES, core, compat] or implements the extensions
- * ARB_framebuffer_object, or all of
- * EXT_framebuffer_object, EXT_framebuffer_multisample,
- * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil.
- *
- *
- * Full FBO support includes multiple color attachments and multisampling.
- *
- * @see GLContext#hasFullFBOSupport()
- */
- public boolean hasFullFBOSupport();
-
- /**
- * Returns the maximum number of FBO RENDERBUFFER samples
- * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false.
- * @see GLContext#getMaxRenderbufferSamples()
- */
- public int getMaxRenderbufferSamples();
-
- /**
- * Returns true if the GL context supports non power of two (NPOT) textures,
- * otherwise false.
- *
- * NPOT textures are supported in OpenGL >= 3, GLES2 or if the
- * 'GL_ARB_texture_non_power_of_two' extension is available.
- *
- */
- public boolean isNPOTTextureAvailable();
-
- public boolean isTextureFormatBGRA8888Available();
-
- /** Provides a platform-independent way to specify the minimum swap
- interval for buffer swaps. An argument of 0 disables
- sync-to-vertical-refresh completely, while an argument of 1
- causes the application to wait until the next vertical refresh
- until swapping buffers. The default, which is platform-specific,
- is usually either 0 or 1. This function is not guaranteed to
- have an effect, and in particular only affects heavyweight
- onscreen components.
-
- @see #getSwapInterval
- @throws GLException if this context is not the current
- */
- public void setSwapInterval(int interval);
-
- /** Provides a platform-independent way to get the swap
- interval set by {@link #setSwapInterval}.
-
- If the interval is not set by {@link #setSwapInterval} yet,
- -1 is returned, indicating that the platforms default
- is being used.
-
- @see #setSwapInterval
- */
- public int getSwapInterval();
-
- /**
- * Returns an object through which platform-specific OpenGL extensions
- * (EGL, GLX, WGL, etc.) may be accessed. The data type of the returned
- * object and its associated capabilities are undefined. Most
- * applications will never need to call this method. It is highly
- * recommended that any applications which do call this method perform
- * all accesses on the returned object reflectively to guard
- * themselves against changes to the implementation.
- */
- public Object getPlatformGLExtensions();
-
- /**
- * Returns an object providing access to the specified OpenGL
- * extension. This is intended to provide a mechanism for vendors who
- * wish to provide access to new OpenGL extensions without changing
- * the public API of the core package. For example, a user may request
- * access to extension "GL_VENDOR_foo" and receive back an object
- * which implements a vendor-specified interface which can call the
- * OpenGL extension functions corresponding to that extension. It is
- * up to the vendor to specify both the extension name and Java API
- * for accessing it, including which class or interface contains the
- * functions.
- *
- *
- *
- * Note: it is the intent to add new extensions as quickly as possible
- * to the core GL API. Therefore it is unlikely that most vendors will
- * use this extension mechanism, but it is being provided for
- * completeness.
- */
- public Object getExtension(String extensionName);
-
- /** Aliased entrypoint of void {@native glClearDepth}(GLclampd depth); and void {@native glClearDepthf}(GLclampf depth); . */
- public void glClearDepth( double depth );
-
- /** Aliased entrypoint of void {@native glDepthRange}(GLclampd depth); and void {@native glDepthRangef}(GLclampf depth); . */
- public void glDepthRange(double zNear, double zFar);
-
- /**
- * @param target a GL buffer (VBO) target as used in {@link GL#glBindBuffer(int, int)}, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}, {@link GL#GL_ARRAY_BUFFER}, ..
- * @return the GL buffer name bound to a target via {@link GL#glBindBuffer(int, int)} or 0 if unbound.
- * @see #getBufferStorage(int)
- */
- public int getBoundBuffer(int target);
-
- /**
- * @param bufferName a GL buffer name, generated with e.g. {@link GL#glGenBuffers(int, int[], int)} and used in {@link GL#glBindBuffer(int, int)}, {@link GL#glBufferData(int, long, java.nio.Buffer, int)} or {@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)}.
- * @return the size of the given GL buffer storage, see {@link GLBufferStorage}
- * @see #getBoundBuffer(int)
- */
- public GLBufferStorage getBufferStorage(int bufferName);
-
- /**
- * Returns the {@link GLBufferStorage} instance as mapped via OpenGL's native {@link GL#glMapBuffer(int, int) glMapBuffer(..)} implementation.
- *
- * Throws a {@link GLException} if GL-function constraints are not met.
- *
- *
- * {@link GL#glMapBuffer(int, int)} wrapper calls this method and returns {@link GLBufferStorage#getMappedBuffer()}.
- *
- *
- * A zero {@link GLBufferStorage#getSize()} will avoid a native call and returns the unmapped {@link GLBufferStorage}.
- *
- *
- * A null native mapping result indicating an error will
- * not cause a GLException but returns the unmapped {@link GLBufferStorage}.
- * This allows the user to handle this case.
- *
- * @param target denotes the buffer via it's bound target
- * @param access the mapping access mode
- * @throws GLException if buffer is not bound to target
- * @throws GLException if buffer is not tracked
- * @throws GLException if buffer is already mapped
- * @throws GLException if buffer has invalid store size, i.e. less-than zero
- */
- public GLBufferStorage mapBuffer(int target, int access) throws GLException;
-
- /**
- * Returns the {@link GLBufferStorage} instance as mapped via OpenGL's native {@link GL#glMapBufferRange(int, long, long, int) glMapBufferRange(..)} implementation.
- *
- * Throws a {@link GLException} if GL-function constraints are not met.
- *
- *
- * {@link GL#glMapBufferRange(int, long, long, int)} wrapper calls this method and returns {@link GLBufferStorage#getMappedBuffer()}.
- *
- *
- * A zero {@link GLBufferStorage#getSize()} will avoid a native call and returns the unmapped {@link GLBufferStorage}.
- *
- *
- * A null native mapping result indicating an error will
- * not cause a GLException but returns the unmapped {@link GLBufferStorage}.
- * This allows the user to handle this case.
- *
- * @param target denotes the buffer via it's bound target
- * @param offset offset of the mapped buffer's storage
- * @param length length of the mapped buffer's storage
- * @param access the mapping access mode
- * @throws GLException if buffer is not bound to target
- * @throws GLException if buffer is not tracked
- * @throws GLException if buffer is already mapped
- * @throws GLException if buffer has invalid store size, i.e. less-than zero
- * @throws GLException if buffer mapping range does not fit, incl. offset
- */
- public GLBufferStorage mapBufferRange(final int target, final long offset, final long length, final int access) throws GLException;
-
- /**
- * @return true if a VBO is bound to {@link GL#GL_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false
- */
- public boolean isVBOArrayBound();
-
- /**
- * @return true if a VBO is bound to {@link GL#GL_ELEMENT_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false
- */
- public boolean isVBOElementArrayBound();
-
- /**
- * Return the framebuffer name bound to this context,
- * see {@link GL#glBindFramebuffer(int, int)}.
- *
- */
- public int getDefaultReadFramebuffer();
-
- /**
- * Returns the default color buffer within the current bound
- * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER,
- * which will be used as the source for pixel reading commands,
- * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels} etc.
- *
- * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0},
- * otherwise this is {@link GL#GL_FRONT} for single buffer configurations
- * and {@link GL#GL_BACK} for double buffer configurations.
- *
- *
- * Note-1: Neither ES1 nor ES2 supports selecting the read buffer via glReadBuffer
- * and {@link GL#GL_BACK} is the default.
- *
- *
- * Note-2: ES3 only supports {@link GL#GL_BACK}, {@link GL#GL_NONE} or {@link GL#GL_COLOR_ATTACHMENT0}+i
- *
- *
- * Note-3: See {@link com.jogamp.opengl.util.GLDrawableUtil#swapBuffersBeforeRead(GLCapabilitiesImmutable) swapBuffersBeforeRead}
- * for read-pixels and swap-buffers implications.
- *
- */
- public int getDefaultReadBuffer();
-}
-
diff --git a/src/jogl/classes/javax/media/opengl/GLBufferStorage.java b/src/jogl/classes/javax/media/opengl/GLBufferStorage.java
deleted file mode 100644
index 5db97d42f..000000000
--- a/src/jogl/classes/javax/media/opengl/GLBufferStorage.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * Copyright 2014 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package com.jogamp.opengl;
-
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-
-/**
- * OpenGL buffer storage object reflecting it's
- *
- *
storage size
- *
storage memory if mapped
- *
mutable usage or immutable flags
- *
- *
- * Buffer storage is created via:
- *
- *
glBufferStorage - storage creation with target
- *
{@link GL#glBufferData(int, long, java.nio.Buffer, int)} - storage recreation with target
- *
{@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)} - storage recreation, direct
- *
- * Note that storage recreation as mentioned above also invalidate a previous storage instance,
- * i.e. disposed the buffer's current storage if exist and attaches a new storage instance.
- *
- *
- * Buffer storage is disposed via:
- *
- *
{@link GL#glDeleteBuffers(int, IntBuffer)} - explicit, direct, via {@link #notifyBuffersDeleted(int, IntBuffer)} or {@link #notifyBuffersDeleted(int, int[], int)}
- *
{@link GL#glBufferData(int, long, java.nio.Buffer, int)} - storage recreation via target
- *
{@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)} - storage recreation, direct
- *
- */
-public abstract class GLBufferStorage {
- private final int name;
- private /* final */ long size;
- private /* final */ int mutableUsage;
- private /* final */ int immutableFlags;
- private ByteBuffer mappedBuffer;
-
- protected GLBufferStorage(final int name, final long size, final int mutableUsage, final int immutableFlags) {
- this.name = name;
- this.size = size;
- this.mutableUsage = mutableUsage;
- this.immutableFlags = immutableFlags;
- this.mappedBuffer = null;
- }
-
- protected void reset(final long size, final int mutableUsage, final int immutableFlags) {
- this.size = size;
- this.mutableUsage = mutableUsage;
- this.immutableFlags = immutableFlags;
- this.mappedBuffer = null;
- }
- protected void setMappedBuffer(final ByteBuffer buffer) {
- this.mappedBuffer = buffer;
- }
-
- /** Return the buffer name */
- public final int getName() { return name; }
-
- /** Return the buffer's storage size. */
- public final long getSize() { return size; }
-
- /**
- * Returns true if buffer's storage is mutable, i.e.
- * created via {@link GL#glBufferData(int, long, java.nio.Buffer, int)}.
- *
- * Returns false if buffer's storage is immutable, i.e.
- * created via glBufferStorage. FIXME: Add GL 4.4 support!
- *
- * @return
- */
- public final boolean isMutableStorage() { return 0 != mutableUsage; }
-
- /**
- * Returns the mutable storage usage or 0 if storage is not {@link #isMutableStorage() mutable}.
- */
- public final int getMutableUsage() { return mutableUsage; }
-
- /**
- * Returns the immutable storage flags, invalid if storage is {@link #isMutableStorage() mutable}.
- */
- public final int getImmutableFlags() { return immutableFlags; }
-
- /**
- * Returns the mapped ByteBuffer, or null if not mapped.
- * Mapping may occur via:
- *
- * If enabled this method also invokes {@link #setOnscreen(boolean) setOnscreen(false)}.
- *
- *
- * Defaults to false.
- *
- *
- * Requesting offscreen FBO mode disables the offscreen auto selection.
- *
- */
- public void setFBO(final boolean enable) {
- if(enable) {
- setOnscreen(false);
- }
- isFBO = enable;
- }
-
- @Override
- public final boolean getDoubleBuffered() {
- return doubleBuffered;
- }
-
- /** Enables or disables double buffering. */
- public void setDoubleBuffered(final boolean enable) {
- doubleBuffered = enable;
- }
-
- @Override
- public final boolean getStereo() {
- return stereo;
- }
-
- /** Enables or disables stereo viewing. */
- public void setStereo(final boolean enable) {
- stereo = enable;
- }
-
- @Override
- public final boolean getHardwareAccelerated() {
- return hardwareAccelerated;
- }
-
- /** Enables or disables hardware acceleration. */
- public void setHardwareAccelerated(final boolean enable) {
- hardwareAccelerated = enable;
- }
-
- @Override
- public final int getDepthBits() {
- return depthBits;
- }
-
- /** Sets the number of bits requested for the depth buffer. */
- public void setDepthBits(final int depthBits) {
- this.depthBits = depthBits;
- }
-
- @Override
- public final int getStencilBits() {
- return stencilBits;
- }
-
- /** Sets the number of bits requested for the stencil buffer. */
- public void setStencilBits(final int stencilBits) {
- this.stencilBits = stencilBits;
- }
-
- @Override
- public final int getAccumRedBits() {
- return accumRedBits;
- }
-
- /** Sets the number of bits requested for the accumulation buffer's
- red component. On some systems only the accumulation buffer
- depth, which is the sum of the red, green, and blue bits, is
- considered. */
- public void setAccumRedBits(final int accumRedBits) {
- this.accumRedBits = accumRedBits;
- }
-
- @Override
- public final int getAccumGreenBits() {
- return accumGreenBits;
- }
-
- /** Sets the number of bits requested for the accumulation buffer's
- green component. On some systems only the accumulation buffer
- depth, which is the sum of the red, green, and blue bits, is
- considered. */
- public void setAccumGreenBits(final int accumGreenBits) {
- this.accumGreenBits = accumGreenBits;
- }
-
- @Override
- public final int getAccumBlueBits() {
- return accumBlueBits;
- }
-
- /** Sets the number of bits requested for the accumulation buffer's
- blue component. On some systems only the accumulation buffer
- depth, which is the sum of the red, green, and blue bits, is
- considered. */
- public void setAccumBlueBits(final int accumBlueBits) {
- this.accumBlueBits = accumBlueBits;
- }
-
- @Override
- public final int getAccumAlphaBits() {
- return accumAlphaBits;
- }
-
- /** Sets number of bits requested for accumulation buffer's alpha
- component. On some systems only the accumulation buffer depth,
- which is the sum of the red, green, and blue bits, is
- considered. */
- public void setAccumAlphaBits(final int accumAlphaBits) {
- this.accumAlphaBits = accumAlphaBits;
- }
-
- /**
- * Sets the desired extension for full-scene antialiasing
- * (FSAA), default is {@link #DEFAULT_SAMPLE_EXTENSION}.
- */
- public void setSampleExtension(final String se) {
- sampleExtension = se;
- }
-
- @Override
- public final String getSampleExtension() {
- return sampleExtension;
- }
-
- /**
- * Defaults to false.
- * Indicates whether sample buffers for full-scene antialiasing
- * (FSAA) should be allocated for this drawable.
- * Mind that this requires the alpha component.
- * If enabled this method also invokes {@link #setAlphaBits(int) setAlphaBits(1)}
- * if {@link #getAlphaBits()} == 0.
- */
- public void setSampleBuffers(final boolean enable) {
- sampleBuffers = enable;
- if(sampleBuffers && getAlphaBits()==0) {
- setAlphaBits(1);
- }
- }
-
- @Override
- public final boolean getSampleBuffers() {
- return sampleBuffers;
- }
-
- /**
- * If sample buffers are enabled, indicates the number of buffers
- * to be allocated. Defaults to 2.
- * @see #getNumSamples()
- */
- public void setNumSamples(final int numSamples) {
- this.numSamples = numSamples;
- }
-
- @Override
- public final int getNumSamples() {
- return sampleBuffers ? numSamples : 0;
- }
-
- @Override
- public StringBuilder toString(StringBuilder sink) {
- if(null == sink) {
- sink = new StringBuilder();
- }
-
- final int samples = sampleBuffers ? numSamples : 0 ;
-
- super.toString(sink, false);
-
- sink.append(", accum-rgba ").append(accumRedBits).append(ESEP).append(accumGreenBits).append(ESEP).append(accumBlueBits).append(ESEP).append(accumAlphaBits);
- sink.append(", dp/st/ms ").append(depthBits).append(ESEP).append(stencilBits).append(ESEP).append(samples);
- if(samples>0) {
- sink.append(", sample-ext ").append(sampleExtension);
- }
- if(doubleBuffered) {
- sink.append(", dbl");
- } else {
- sink.append(", one");
- }
- if(stereo) {
- sink.append(", stereo");
- } else {
- sink.append(", mono ");
- }
- if(hardwareAccelerated) {
- sink.append(", hw, ");
- } else {
- sink.append(", sw, ");
- }
- sink.append(glProfile);
- if(isOnscreen()) {
- sink.append(", on-scr[");
- } else {
- sink.append(", offscr[");
- }
- boolean ns=false;
- if(isFBO()) {
- sink.append("fbo");
- ns = true;
- }
- if(isPBuffer()) {
- if(ns) { sink.append(CSEP); }
- sink.append("pbuffer");
- ns = true;
- }
- if(isBitmap()) {
- if(ns) { sink.append(CSEP); }
- sink.append("bitmap");
- ns = true;
- }
- if(!ns) { // !FBO !PBuffer !Bitmap
- if(isOnscreen()) {
- sink.append("."); // no additional off-screen modes besides on-screen
- } else {
- sink.append("auto-cfg"); // auto-config off-screen mode
- }
- }
- sink.append("]");
-
- return sink;
- }
-
- /** Returns a textual representation of this GLCapabilities
- object. */
- @Override
- public String toString() {
- final StringBuilder msg = new StringBuilder();
- msg.append("GLCaps[");
- toString(msg);
- msg.append("]");
- return msg.toString();
- }
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java
deleted file mode 100644
index 9911d1314..000000000
--- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl;
-
-import java.util.List;
-
-import com.jogamp.nativewindow.CapabilitiesImmutable;
-import com.jogamp.nativewindow.CapabilitiesChooser;
-
-import com.jogamp.opengl.GLCapabilitiesImmutable;
-
-/** Provides a mechanism by which applications can customize the
- window type selection for a given {@link GLCapabilities}.
- Developers can implement this interface and pass an instance into
- the appropriate method of {@link GLDrawableFactory}; the chooser
- will be called during the OpenGL context creation process. Note
- that this is only a marker interface; its signature is the same as
- {@link CapabilitiesChooser} and the {@link List} of
- objects extending {@link CapabilitiesImmutable}
- passed to {@link #chooseCapabilities chooseCapabilities}
- is actually a {@link List} of type {@link GLCapabilitiesImmutable}. */
-
-public interface GLCapabilitiesChooser extends CapabilitiesChooser {
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
deleted file mode 100644
index 25081a521..000000000
--- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl;
-
-import com.jogamp.nativewindow.CapabilitiesImmutable;
-
-/**
- * Specifies an immutable set of OpenGL capabilities.
- *
- * @see com.jogamp.opengl.GLCapabilities
- * @see com.jogamp.nativewindow.CapabilitiesImmutable
- */
-public interface GLCapabilitiesImmutable extends CapabilitiesImmutable {
- /**
- * One of the platform's default sample extension
- * EGL.EGL_SAMPLES, GLX.GLX_SAMPLES, WGLExt.WGL_SAMPLES_ARB
- * if available, or any other known fallback one, ie EGLExt.EGL_COVERAGE_SAMPLES_NV
- */
- public static final String DEFAULT_SAMPLE_EXTENSION = "default" ;
-
- /**
- * Returns the GL profile you desire or used by the drawable.
- */
- GLProfile getGLProfile();
-
- /**
- * Returns the number of bits for the accumulation
- * buffer's alpha component. On some systems only the accumulation
- * buffer depth, which is the sum of the red, green, and blue bits,
- * is considered.
- */
- int getAccumAlphaBits();
-
- /**
- * Returns the number of bits for the accumulation
- * buffer's blue component. On some systems only the accumulation
- * buffer depth, which is the sum of the red, green, and blue bits,
- * is considered.
- */
- int getAccumBlueBits();
-
- /**
- * Returns the number of bits for the accumulation
- * buffer's green component. On some systems only the accumulation
- * buffer depth, which is the sum of the red, green, and blue bits,
- * is considered.
- */
- int getAccumGreenBits();
-
- /**
- * Returns the number of bits for the accumulation
- * buffer's red component. On some systems only the accumulation
- * buffer depth, which is the sum of the red, green, and blue bits,
- * is considered.
- */
- int getAccumRedBits();
-
- /**
- * Returns the number of depth buffer bits.
- */
- int getDepthBits();
-
- /**
- * Returns whether double-buffering is requested, available or chosen.
- *
- * Default is true.
- *
- */
- boolean getDoubleBuffered();
-
- /**
- * Returns whether hardware acceleration is requested, available or chosen.
- *
- * Default is {@link #DEFAULT_SAMPLE_EXTENSION}.
- *
- */
- String getSampleExtension();
-
- /**
- * Returns whether sample buffers for full-scene antialiasing
- * (FSAA) should be allocated for this drawable.
- *
- * Default is false.
- *
- */
- boolean getSampleBuffers();
-
- /**
- * Returns the number of sample buffers to be allocated if sample
- * buffers are enabled, otherwise returns 0.
- *
- * Default is 0 due to disable sample buffers per default.
- *
- */
- int getNumSamples();
-
- /**
- * Returns the number of stencil buffer bits.
- *
- * Default is 0.
- *
- */
- int getStencilBits();
-
- /**
- * Returns whether stereo is requested, available or chosen.
- *
- * Default is false.
- *
- */
- boolean getStereo();
-
- /**
- * Returns whether pbuffer offscreen mode is requested, available or chosen.
- *
- * Default is false.
- *
- *
- * For chosen capabilities, only the selected offscreen surface is set to true.
- *
- */
- boolean isPBuffer();
-
- /**
- * Returns whether FBO offscreen mode is requested, available or chosen.
- *
- * Default is false.
- *
- *
- * For chosen capabilities, only the selected offscreen surface is set to true.
- *
- */
- boolean isFBO();
-
- @Override
- boolean equals(Object obj);
-
- @Override
- int hashCode();
-
- @Override
- String toString();
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
deleted file mode 100644
index 6366c4e37..000000000
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ /dev/null
@@ -1,2038 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl;
-
-import java.nio.IntBuffer;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import com.jogamp.nativewindow.AbstractGraphicsDevice;
-import com.jogamp.nativewindow.NativeSurface;
-
-import jogamp.opengl.Debug;
-import jogamp.opengl.GLContextImpl;
-import jogamp.opengl.GLContextShareSet;
-
-import com.jogamp.common.os.Platform;
-import com.jogamp.common.util.VersionNumber;
-import com.jogamp.common.util.VersionNumberString;
-import com.jogamp.common.util.locks.LockFactory;
-import com.jogamp.common.util.locks.RecursiveLock;
-import com.jogamp.opengl.GLExtensions;
-import com.jogamp.opengl.GLRendererQuirks;
-
-/** Abstraction for an OpenGL rendering context. In order to perform
- OpenGL rendering, a context must be "made current" on the current
- thread. OpenGL rendering semantics specify that only one context
- may be current on the current thread at any given time, and also
- that a given context may be current on only one thread at any
- given time. Because components can be added to and removed from
- the component hierarchy at any time, it is possible that the
- underlying OpenGL context may need to be destroyed and recreated
- multiple times over the lifetime of a given component. This
- process is handled by the implementation, and the GLContext
- abstraction provides a stable object which clients can use to
- refer to a given context. */
-public abstract class GLContext {
-
- public static final boolean DEBUG = Debug.debug("GLContext");
- public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true);
- public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH;
-
- /**
- * If true (default), bootstrapping the available GL profiles
- * will use the highest compatible GL context for each profile,
- * hence skipping querying lower profiles if a compatible higher one is found:
- *
- *
4.2-core -> 4.2-core, 3.3-core
- *
4.2-comp -> 4.2-comp, 3.3-comp, 2
- *
- * Otherwise the dedicated GL context would be queried and used:
- *
- *
4.2-core -> 4.2-core
- *
3.3-core -> 3.3-core
- *
4.2-comp -> 4.2-comp
- *
3.3-comp -> 3.3-comp
- *
3.0-comp -> 2
- *
- * Using aliasing speeds up initialization about:
- *
- *
Linux x86_64 - Nvidia: 28%, 700ms down to 500ms
- *
Linux x86_64 - AMD : 40%, 1500ms down to 900ms
- *
- * Can be turned off with property jogl.debug.GLContext.NoProfileAliasing.
- *
- */
- public static final boolean PROFILE_ALIASING = !Debug.isPropertyDefined("jogl.debug.GLContext.NoProfileAliasing", true);
-
- protected static final boolean FORCE_NO_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.none", true);
- protected static final boolean FORCE_MIN_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.min", true);
- protected static final boolean FORCE_NO_COLOR_RENDERBUFFER = Debug.isPropertyDefined("jogl.fbo.force.nocolorrenderbuffer", true);
-
- /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */
- public static final boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true);
- /** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */
- public static final boolean TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true);
-
- /** Indicates that the context was not made current during the last call to {@link #makeCurrent makeCurrent}, value {@value}. */
- public static final int CONTEXT_NOT_CURRENT = 0;
- /** Indicates that the context was made current during the last call to {@link #makeCurrent makeCurrent}, value {@value}. */
- public static final int CONTEXT_CURRENT = 1;
- /** Indicates that a newly-created context was made current during the last call to {@link #makeCurrent makeCurrent}, value {@value}. */
- public static final int CONTEXT_CURRENT_NEW = 2;
-
- /** Version 1.00, i.e. GLSL 1.00 for ES 2.0. */
- public static final VersionNumber Version1_0 = new VersionNumber(1, 0, 0);
- /** Version 1.10, i.e. GLSL 1.10 for GL 2.0. */
- public static final VersionNumber Version1_10 = new VersionNumber(1, 10, 0);
- /** Version 1.20, i.e. GLSL 1.20 for GL 2.1. */
- public static final VersionNumber Version1_20 = new VersionNumber(1, 20, 0);
- /** Version 1.30, i.e. GLSL 1.30 for GL 3.0. */
- public static final VersionNumber Version1_30 = new VersionNumber(1, 30, 0);
- /** Version 1.40, i.e. GLSL 1.40 for GL 3.1. */
- public static final VersionNumber Version1_40 = new VersionNumber(1, 40, 0);
- /** Version 1.50, i.e. GLSL 1.50 for GL 3.2. */
- public static final VersionNumber Version1_50 = new VersionNumber(1, 50, 0);
-
- /** Version 1.1, i.e. GL 1.1 */
- public static final VersionNumber Version1_1 = new VersionNumber(1, 1, 0);
-
- /** Version 1.2, i.e. GL 1.2 */
- public static final VersionNumber Version1_2 = new VersionNumber(1, 2, 0);
-
- /** Version 1.4, i.e. GL 1.4 */
- public static final VersionNumber Version1_4 = new VersionNumber(1, 4, 0);
-
- /** Version 1.5, i.e. GL 1.5 */
- public static final VersionNumber Version1_5 = new VersionNumber(1, 5, 0);
-
- /** Version 3.0. As an OpenGL version, it qualifies for desktop {@link #isGL2()} only, or ES 3.0. Or GLSL 3.00 for ES 3.0. */
- public static final VersionNumber Version3_0 = new VersionNumber(3, 0, 0);
-
- /** Version 3.1. As an OpenGL version, it qualifies for {@link #isGL3core()}, {@link #isGL3bc()} and {@link #isGL3()} */
- public static final VersionNumber Version3_1 = new VersionNumber(3, 1, 0);
-
- /** Version 3.2. As an OpenGL version, it qualifies for geometry shader */
- public static final VersionNumber Version3_2 = new VersionNumber(3, 2, 0);
-
- /** Version 4.3. As an OpenGL version, it qualifies for GL_ARB_ES3_compatibility */
- public static final VersionNumber Version4_3 = new VersionNumber(4, 3, 0);
-
- protected static final VersionNumber Version8_0 = new VersionNumber(8, 0, 0);
-
- private static final String S_EMPTY = "";
-
- //
- // Cached keys, bits [0..15]
- //
-
- /** Context option bits, full bit mask covering 16 bits [0..15], i.e. 0x0000FFFF, {@value}. */
- protected static final int CTX_IMPL_FULL_MASK = 0x0000FFFF;
-
- /** Context option bits, cached bit mask covering 10 bits [0..9], i.e. 0x000003FF, {@value}. Leaving 6 bits for non cached options, i.e. 10:6. */
- protected static final int CTX_IMPL_CACHE_MASK = 0x000003FF;
-
- /** ARB_create_context related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
- protected static final int CTX_IS_ARB_CREATED = 1 << 0;
- /** ARB_create_context related: desktop compatibility profile. Cache key value. See {@link #isGLCompatibilityProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
- protected static final int CTX_PROFILE_COMPAT = 1 << 1;
- /** ARB_create_context related: desktop core profile. Cache key value. See {@link #isGLCoreProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
- protected static final int CTX_PROFILE_CORE = 1 << 2;
- /** ARB_create_context related: ES profile. Cache key value. See {@link #isGLES()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
- protected static final int CTX_PROFILE_ES = 1 << 3;
- /** ARB_create_context related: flag forward compatible. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
- protected static final int CTX_OPTION_FORWARD = 1 << 4;
- /** ARB_create_context related: flag debug. Cache key value. See {@link #setContextCreationFlags(int)}, {@link GLAutoDrawable#setContextCreationFlags(int)}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
- public static final int CTX_OPTION_DEBUG = 1 << 5;
- /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. See {@link #isHardwareRasterizer()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
- protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 6;
-
- //
- // Non cached keys, 6 bits [10..15]
- //
-
- /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
- protected static final int CTX_IMPL_ES2_COMPAT = 1 << 10;
-
- /** GL_ARB_ES3_compatibility implementation related: Context is compatible w/ ES3. Not a cache key. See {@link #isGLES3Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
- protected static final int CTX_IMPL_ES3_COMPAT = 1 << 11;
-
- /**
- * Context supports basic FBO, details see {@link #hasBasicFBOSupport()}.
- * Not a cache key.
- * @see #hasBasicFBOSupport()
- * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)
- */
- protected static final int CTX_IMPL_FBO = 1 << 12;
-
- /**
- * Context supports OES_single_precision, fp32, fixed function point (FFP) compatibility entry points,
- * see {@link #hasFP32CompatAPI()}.
- * Not a cache key.
- * @see #hasFP32CompatAPI()
- * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)
- */
- protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 13;
-
- private static final ThreadLocal currentContext = new ThreadLocal();
-
- private final HashMap attachedObjects = new HashMap();
-
- // RecursiveLock maintains a queue of waiting Threads, ensuring the longest waiting thread will be notified at unlock.
- protected final RecursiveLock lock = LockFactory.createRecursiveLock(); // FIXME: Move to GLContextImpl when incr. minor version (incompatible change)
-
- /** The underlying native OpenGL context */
- protected volatile long contextHandle; // volatile: avoid locking for read-only access
-
- protected GLContext() {
- resetStates(true);
- }
-
- protected VersionNumber ctxVersion;
- protected int ctxOptions;
- protected String ctxVersionString;
- protected VersionNumberString ctxVendorVersion;
- protected VersionNumber ctxGLSLVersion;
- private int currentSwapInterval;
- protected GLRendererQuirks glRendererQuirks;
-
- /** Did the drawable association changed ? see {@link GLRendererQuirks#NoSetSwapIntervalPostRetarget} */
- protected boolean drawableRetargeted;
-
- /**
- * @param isInit true if called for class initialization, otherwise false (re-init or destruction).
- */
- protected void resetStates(final boolean isInit) {
- if (DEBUG) {
- System.err.println(getThreadName() + ": GLContext.resetStates(isInit "+isInit+")");
- // Thread.dumpStack();
- }
- ctxVersion = VersionNumberString.zeroVersion;
- ctxVendorVersion = VersionNumberString.zeroVersion;
- ctxOptions=0;
- ctxVersionString=null;
- ctxGLSLVersion = VersionNumber.zeroVersion;
- attachedObjects.clear();
- contextHandle=0;
- currentSwapInterval = -1;
- glRendererQuirks = null;
- drawableRetargeted = false;
- }
-
- /** Returns true if this GLContext is shared, otherwise false. */
- public final boolean isShared() {
- return GLContextShareSet.isShared(this);
- }
-
- /**
- * Returns the shared master GLContext of this GLContext if shared, otherwise return null.
- *
- * Returns this GLContext, if it is a shared master.
- *
- * @since 2.2.1
- */
- public final GLContext getSharedMaster() {
- return GLContextShareSet.getSharedMaster(this);
- }
-
- /** Returns a new list of created GLContext shared with this GLContext. */
- public final List getCreatedShares() {
- return GLContextShareSet.getCreatedShares(this);
- }
-
- /** Returns a new list of destroyed GLContext shared with this GLContext. */
- public final List getDestroyedShares() {
- return GLContextShareSet.getDestroyedShares(this);
- }
-
- /**
- * Returns the instance of {@link GLRendererQuirks}, allowing one to determine workarounds.
- * @return instance of {@link GLRendererQuirks} if context was made current once, otherwise null.
- */
- public final GLRendererQuirks getRendererQuirks() { return glRendererQuirks; }
-
- /**
- * Returns true if the quirk exist in {@link #getRendererQuirks()}, otherwise false.
- *
- *
- * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}.
- * @throws IllegalArgumentException if the quirk is out of range
- */
- public final boolean hasRendererQuirk(final int quirk) throws IllegalArgumentException {
- return null != glRendererQuirks ? glRendererQuirks.exist(quirk) : false ;
- }
-
- /**
- * Sets the read/write drawable for framebuffer operations, i.e. reassociation of the context's drawable.
- *
- * If the arguments reflect the current state of this context
- * this method is a no-operation and returns the old and current {@link GLDrawable}.
- *
- *
- * Remarks:
- *
- *
{@link GL#glFinish() glFinish()} is issued if context {@link #isCreated()} and a {@link #getGLDrawable() previous drawable} was bound before disassociation.
- *
If the context was current on this thread, it is being released before drawable reassociation
- * and made current afterwards.
- *
Implementation may issue {@link #makeCurrent()} and {@link #release()} while drawable reassociation.
- *
The user shall take extra care of thread synchronization,
- * i.e. lock the involved {@link GLDrawable#getNativeSurface() drawable's} {@link NativeSurface}s
- * to avoid a race condition. In case {@link GLAutoDrawable auto-drawable's} are used,
- * their {@link GLAutoDrawable#getUpstreamLock() upstream-lock} must be locked beforehand
- * see GLAutoDrawable Locking.
- *
- *
- * @param readWrite The read/write drawable for framebuffer operations, maybe null to remove association.
- * @param setWriteOnly Only change the write-drawable, if setWriteOnly is true and
- * if the {@link #getGLReadDrawable() read-drawable} differs
- * from the {@link #getGLDrawable() write-drawable}.
- * Otherwise set both drawables, read and write.
- * @return The previous read/write drawable if operation succeeds
- *
- * @throws GLException in case null is being passed,
- * this context is made current on another thread
- * or operation fails.
- *
- * @see #isGLReadDrawableAvailable()
- * @see #setGLReadDrawable(GLDrawable)
- * @see #getGLReadDrawable()
- * @see #setGLDrawable(GLDrawable, boolean)
- * @see #getGLDrawable()
- */
- public abstract GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly);
-
- /**
- * Returns the write-drawable this context uses for framebuffer operations.
- *
- * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)},
- * it equals to the write-drawable (default).
- *
- *
- * Method is only thread-safe while context is {@link #makeCurrent() made current}.
- *
- * @see #setGLDrawable(GLDrawable, boolean)
- * @see #setGLReadDrawable(GLDrawable)
- */
- public abstract GLDrawable getGLDrawable();
-
- /**
- * Query whether using a distinguished read-drawable is supported.
- * @return true if using a read-drawable is supported with your driver/OS, otherwise false.
- */
- public abstract boolean isGLReadDrawableAvailable();
-
- /**
- * Set the read-Drawable for read framebuffer operations.
- * The caller should query if this feature is supported via {@link #isGLReadDrawableAvailable()}.
- *
- * If the context was current on this thread, it is being released before switching the drawable
- * and made current afterwards. However the user shall take extra care that not other thread
- * attempts to make this context current. Otherwise a race condition may happen.
- *
- *
- * @param read the read-drawable for read framebuffer operations.
- * If null is passed, the default write drawable will be set.
- * @return the previous read-drawable
- *
- * @throws GLException in case a read drawable is not supported or
- * this context is made current on another thread.
- *
- * @see #isGLReadDrawableAvailable()
- * @see #getGLReadDrawable()
- */
- public abstract GLDrawable setGLReadDrawable(GLDrawable read);
-
- /**
- * Returns the read-Drawable this context uses for read framebuffer operations.
- *
- * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)},
- * it equals to the write-drawable (default).
- *
- *
- * Method is only thread-safe while context is {@link #makeCurrent() made current}.
- *
- * @see #isGLReadDrawableAvailable()
- * @see #setGLReadDrawable(GLDrawable)
- * @see #getGLReadDrawable()
- */
- public abstract GLDrawable getGLReadDrawable();
-
- /**
- * Makes this GLContext current on the calling thread.
- *
- * Recursive call to {@link #makeCurrent()} and hence {@link #release()} are supported.
- *
- *
- * There are two return values that indicate success and one that
- * indicates failure.
- *
- *
- * A return value of {@link #CONTEXT_CURRENT_NEW}
- * indicates that that context has been made current for the 1st time,
- * or that the state of the underlying context or drawable has
- * changed since the last time this context was current.
- * In this case, the application may wish to initialize the render state.
- *
- *
- * A return value of {@link #CONTEXT_CURRENT} indicates that the context has
- * been made current, with its previous state restored.
- *
- *
- * If the context could not be made current (for example, because
- * the underlying drawable has not ben realized on the display) ,
- * a value of {@link #CONTEXT_NOT_CURRENT} is returned.
- *
- *
- * This method is blocking, i.e. waits until another thread has
- * released the context.
- *
- *
- * The drawable's surface is being locked at entry
- * and unlocked at {@link #release()}
- *
- *
- * @return
- *
{@link #CONTEXT_CURRENT_NEW} if the context was successfully made current the 1st time,
- *
{@link #CONTEXT_CURRENT} if the context was successfully made current,
- *
{@link #CONTEXT_NOT_CURRENT} if the context could not be made current.
- *
- *
- * @throws GLException if the context could not be created
- * or made current due to non-recoverable, system-specific errors.
- */
- public abstract int makeCurrent() throws GLException;
-
- /**
- * Releases control of this GLContext from the current thread.
- *
- * Recursive call to {@link #release()} and hence {@link #makeCurrent()} are supported.
- *
- *
- * The drawable's surface is being unlocked at exit,
- * assumed to be locked by {@link #makeCurrent()}.
- *
- *
- * @throws GLException if the context had not previously been made
- * current on the current thread
- */
- public abstract void release() throws GLException;
-
- /**
- * Copies selected groups of OpenGL state variables from the
- * supplied source context into this one. The mask
- * parameter indicates which groups of state variables are to be
- * copied. mask contains the bitwise OR of the same
- * symbolic names that are passed to the GL command {@link
- * GL2#glPushAttrib glPushAttrib}. The single symbolic constant
- * {@link GL2#GL_ALL_ATTRIB_BITS GL_ALL_ATTRIB_BITS} can be used to
- * copy the maximum possible portion of rendering state.
- *
- * Not all values for GL state can be copied. For example, pixel
- * pack and unpack state, render mode state, and select and feedback
- * state are not copied. The state that can be copied is exactly the
- * state that is manipulated by the GL command {@link
- * GL2#glPushAttrib glPushAttrib}.
- *
- * On most platforms, this context may not be current to any thread,
- * including the calling thread, when this method is called. Some
- * platforms have additional requirements such as whether this
- * context or the source context must occasionally be made current
- * in order for the results of the copy to be seen; these
- * requirements are beyond the scope of this specification.
- *
- * @param source the source OpenGL context from which to copy state
- * @param mask a mask of symbolic names indicating which groups of state to copy
-
- * @throws GLException if an OpenGL-related error occurred
- */
- public abstract void copy(GLContext source, int mask) throws GLException;
-
- /**
- * Returns the GL object bound to this thread current context.
- * If no context is current, throw an GLException
- *
- * @return the current context's GL object on this thread
- * @throws GLException if no context is current
- */
- public static GL getCurrentGL() throws GLException {
- final GLContext glc = getCurrent();
- if(null==glc) {
- throw new GLException(getThreadName()+": No OpenGL context current on this thread");
- }
- return glc.getGL();
- }
-
- /**
- * Returns this thread current context.
- * If no context is current, returns null.
- *
- * @return the context current on this thread, or null if no context
- * is current.
- */
- public static GLContext getCurrent() {
- return currentContext.get();
- }
-
- /**
- * @return true if this GLContext is current on this thread
- */
- public final boolean isCurrent() {
- return getCurrent() == this ;
- }
-
- /**
- * @throws GLException if this GLContext is not current on this thread
- */
- public final void validateCurrent() throws GLException {
- if(getCurrent() != this) {
- throw new GLException(getThreadName()+": This context is not current. Current context: "+getCurrent()+", this context "+this);
- }
- }
-
- /** Returns a String representation of the {@link #makeCurrent()} result. */
- public static final String makeCurrentResultToString(final int res) {
- switch(res) {
- case CONTEXT_NOT_CURRENT: return "CONTEXT_NOT_CURRENT";
- case CONTEXT_CURRENT: return "CONTEXT_CURRENT";
- case CONTEXT_CURRENT_NEW: return "CONTEXT_CURRENT_NEW";
- default: return "INVALID_VALUE";
- }
- }
-
- /**
- * Sets the thread-local variable returned by {@link #getCurrent}
- * and has no other side-effects. For use by third parties adding
- * new GLContext implementations; not for use by end users.
- */
- protected static void setCurrent(final GLContext cur) {
- if( TRACE_SWITCH ) {
- if(null == cur) {
- System.err.println(getThreadName()+": GLContext.ContextSwitch: - setCurrent() - NULL");
- } else {
- System.err.println(getThreadName()+": GLContext.ContextSwitch: - setCurrent() - obj " + toHexString(cur.hashCode()) + ", ctx " + toHexString(cur.getHandle()));
- }
- }
- currentContext.set(cur);
- }
-
- /**
- * Destroys this OpenGL context and frees its associated
- * resources.
- *
- * The context may be current w/o recursion when calling destroy(),
- * in which case this method destroys the context and releases the lock.
- *
- */
- public abstract void destroy();
-
- /**
- * Returns the implementing root GL instance of this GLContext's GL object,
- * considering a wrapped pipelined hierarchy, see {@link GLBase#getDownstreamGL()}.
- * @throws GLException if the root instance is not a GL implementation
- * @see GLBase#getRootGL()
- * @see GLBase#getDownstreamGL()
- * @see #getGL()
- * @see #setGL(GL)
- */
- public abstract GL getRootGL();
-
- /**
- * Returns the GL pipeline object for this GLContext.
- *
- * @return the aggregated GL instance, or null if this context was not yet made current.
- */
- public abstract GL getGL();
-
- /**
- * Sets the GL pipeline object for this GLContext.
- *
- * @return the set GL pipeline or null if not successful
- */
- public abstract GL setGL(GL gl);
-
- /**
- * Returns the underlying native OpenGL context handle
- */
- public final long getHandle() { return contextHandle; }
-
- /**
- * Indicates whether the underlying native OpenGL context has been created.
- */
- public final boolean isCreated() {
- return 0 != contextHandle;
- }
-
- /**
- * Returns the attached user object for the given name to this GLContext.
- */
- public final Object getAttachedObject(final String name) {
- return attachedObjects.get(name);
- }
-
- /**
- * Sets the attached user object for the given name to this GLContext.
- * Returns the previously set object or null.
- */
- public final Object attachObject(final String name, final Object obj) {
- return attachedObjects.put(name, obj);
- }
-
- public final Object detachObject(final String name) {
- return attachedObjects.remove(name);
- }
-
- /**
- * Classname, GL, GLDrawable
- */
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append(getClass().getSimpleName());
- sb.append(" [");
- this.append(sb);
- sb.append("] ");
- return sb.toString();
- }
-
- public final StringBuilder append(final StringBuilder sb) {
- sb.append("Version ").append(getGLVersion()).append(" [GL ").append(getGLVersionNumber()).append(", vendor ").append(getGLVendorVersionNumber());
- sb.append("], options 0x");
- sb.append(Integer.toHexString(ctxOptions));
- sb.append(", this ");
- sb.append(toHexString(hashCode()));
- sb.append(", handle ");
- sb.append(toHexString(contextHandle));
- sb.append(", isShared "+isShared()+", ");
- sb.append(getGL());
- sb.append(",\n\t quirks: ");
- if(null != glRendererQuirks) {
- glRendererQuirks.toString(sb);
- } else {
- sb.append("n/a");
- }
- if(getGLDrawable()!=getGLReadDrawable()) {
- sb.append(",\n\tRead Drawable : ");
- sb.append(getGLReadDrawable());
- sb.append(",\n\tWrite Drawable: ");
- sb.append(getGLDrawable());
- } else {
- sb.append(",\n\tDrawable: ");
- sb.append(getGLDrawable());
- }
- return sb;
- }
-
- /**
- * Returns true if the specified OpenGL core- or extension-function can be
- * successfully called using this GL context given the current host (OpenGL
- * client) and display (OpenGL server) configuration.
- *
- * See {@link GL#isFunctionAvailable(String)} for more details.
- *
- * @param glFunctionName the name of the OpenGL function (e.g., use
- * "glPolygonOffsetEXT" or "glPolygonOffset" to check if the {@link
- * com.jogamp.opengl.GL#glPolygonOffset(float,float)} is available).
- */
- public abstract boolean isFunctionAvailable(String glFunctionName);
-
- /**
- * Returns true if the specified OpenGL extension can be
- * successfully called using this GL context given the current host (OpenGL
- * client) and display (OpenGL server) configuration.
- *
- * See {@link GL#isExtensionAvailable(String)} for more details.
- *
- * @param glExtensionName the name of the OpenGL extension (e.g.,
- * "GL_VERTEX_PROGRAM_ARB").
- */
- public abstract boolean isExtensionAvailable(String glExtensionName);
-
- /** Returns the number of platform extensions */
- public abstract int getPlatformExtensionCount();
-
- /** Returns a non-null (but possibly empty) string containing the
- space-separated list of available platform-dependent (e.g., WGL,
- GLX) extensions. Can only be called while this context is
- current. */
- public abstract String getPlatformExtensionsString();
-
- /** Returns the number of OpenGL extensions */
- public abstract int getGLExtensionCount();
-
- /** Returns a non-null (but possibly empty) string containing the
- space-separated list of available extensions.
- Can only be called while this context is current.
- This is equivalent to
- {@link com.jogamp.opengl.GL#glGetString(int) glGetString}({@link com.jogamp.opengl.GL#GL_EXTENSIONS GL_EXTENSIONS})
- */
- public abstract String getGLExtensionsString();
-
- /**
- * @return Additional context creation flags, supported: {@link GLContext#CTX_OPTION_DEBUG}.
- */
- public abstract int getContextCreationFlags();
-
- /**
- * @param flags Additional context creation flags, supported: {@link GLContext#CTX_OPTION_DEBUG}.
- * Unsupported flags are masked out.
- * Only affects this context state if not created yet via {@link #makeCurrent()}.
- * @see #enableGLDebugMessage(boolean)
- * @see GLAutoDrawable#setContextCreationFlags(int)
- */
- public abstract void setContextCreationFlags(int flags);
-
- /**
- * Returns a valid OpenGL version string, ie
- *
- */
- public final String getGLVersion() {
- return ctxVersionString;
- }
-
- /**
- * Returns this context OpenGL version.
- * @see #getGLSLVersionNumber()
- **/
- public final VersionNumber getGLVersionNumber() { return ctxVersion; }
- /**
- * Returns the vendor's version, i.e. version number at the end of GL_VERSION not being the GL version.
- *
- * In case no such version exists within GL_VERSION,
- * the {@link VersionNumberString#zeroVersion zero version} instance is returned.
- *
- *
- * The vendor's version is usually the vendor's OpenGL driver version.
- *
- */
- public final VersionNumberString getGLVendorVersionNumber() { return ctxVendorVersion; }
- public final boolean isGLCompatibilityProfile() { return ( 0 != ( CTX_PROFILE_COMPAT & ctxOptions ) ); }
- public final boolean isGLCoreProfile() { return ( 0 != ( CTX_PROFILE_CORE & ctxOptions ) ); }
- public final boolean isGLESProfile() { return ( 0 != ( CTX_PROFILE_ES & ctxOptions ) ); }
- public final boolean isGLForwardCompatible() { return ( 0 != ( CTX_OPTION_FORWARD & ctxOptions ) ); }
- public final boolean isGLDebugEnabled() { return ( 0 != ( CTX_OPTION_DEBUG & ctxOptions ) ); }
- public final boolean isCreatedWithARBMethod() { return ( 0 != ( CTX_IS_ARB_CREATED & ctxOptions ) ); }
-
- /**
- * Returns the matching GLSL version number, queried by this context GL
- * via {@link GL2ES2#GL_SHADING_LANGUAGE_VERSION} if ≥ ES2.0 or GL2.0,
- * otherwise a static match is being utilized.
- *
- * The context must have been current once,
- * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned.
- *
- * Matching could also refer to the maximum GLSL version usable by this context
- * since normal GL implementations are capable of using a lower GLSL version as well.
- * The latter is not true on OSX w/ a GL3 context.
- *
- *
- * @return GLSL version number if context has been made current at least once,
- * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned.
- *
- * @see #getGLVersionNumber()
- */
- public final VersionNumber getGLSLVersionNumber() {
- return ctxGLSLVersion;
- }
-
- /**
- * Returns the GLSL version string as to be used in a shader program, including a terminating newline '\n',
- * i.e. for desktop
- *
- * If context has not been made current yet, a string of zero length is returned.
- *
- * @see #getGLSLVersionNumber()
- */
- public final String getGLSLVersionString() {
- if( ctxGLSLVersion.isZero() ) {
- return S_EMPTY;
- }
- final int minor = ctxGLSLVersion.getMinor();
- final String profileOpt;
- if( isGLES() ) {
- profileOpt = ctxGLSLVersion.compareTo(Version3_0) >= 0 ? " es" : S_EMPTY;
- } else if( isGLCoreProfile() ) {
- profileOpt = ctxGLSLVersion.compareTo(Version1_50) >= 0 ? " core" : S_EMPTY;
- } else if( isGLCompatibilityProfile() ) {
- profileOpt = ctxGLSLVersion.compareTo(Version1_50) >= 0 ? " compatibility" : S_EMPTY;
- } else {
- throw new InternalError("Neither ES, Core nor Compat: "+this); // see validateProfileBits(..)
- }
- return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + profileOpt + "\n" ;
- }
-
- protected static final VersionNumber getStaticGLSLVersionNumber(final int glMajorVersion, final int glMinorVersion, final int ctxOptions) {
- if( 0 != ( CTX_PROFILE_ES & ctxOptions ) ) {
- if( 3 == glMajorVersion ) {
- return Version3_0; // ES 3.0 -> GLSL 3.00
- } else if( 2 == glMajorVersion ) {
- return Version1_0; // ES 2.0 -> GLSL 1.00
- }
- } else if( 1 == glMajorVersion ) {
- return Version1_10; // GL 1.x -> GLSL 1.10
- } else if( 2 == glMajorVersion ) {
- switch ( glMinorVersion ) {
- case 0: return Version1_10; // GL 2.0 -> GLSL 1.10
- default: return Version1_20; // GL 2.1 -> GLSL 1.20
- }
- } else if( 3 == glMajorVersion && 2 >= glMinorVersion ) {
- switch ( glMinorVersion ) {
- case 0: return Version1_30; // GL 3.0 -> GLSL 1.30
- case 1: return Version1_40; // GL 3.1 -> GLSL 1.40
- default: return Version1_50; // GL 3.2 -> GLSL 1.50
- }
- }
- // The new default: GL >= 3.3, ES >= 3.0
- return new VersionNumber(glMajorVersion, glMinorVersion * 10, 0); // GL M.N -> GLSL M.N
- }
-
- /**
- * @return true if this context is an ES2 context or implements
- * the extension GL_ARB_ES3_compatibility or GL_ARB_ES2_compatibility, otherwise false
- */
- public final boolean isGLES2Compatible() {
- return 0 != ( ctxOptions & ( CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ) ) ;
- }
-
- /**
- * Return true if this context is an ES3 context or implements
- * the extension GL_ARB_ES3_compatibility, otherwise false.
- *
- * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
- *
- */
- public final boolean isGLES3Compatible() {
- return 0 != ( ctxOptions & CTX_IMPL_ES3_COMPAT ) ;
- }
-
- /**
- * @return true if impl. is a hardware rasterizer, otherwise false.
- * @see #isHardwareRasterizer(AbstractGraphicsDevice, GLProfile)
- * @see GLProfile#isHardwareRasterizer()
- */
- public final boolean isHardwareRasterizer() {
- return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ;
- }
-
- /**
- * @return true if context supports GLSL, i.e. is either {@link #isGLES3()}, {@link #isGLES2()}, {@link #isGL3()} or {@link #isGL2()} and major-version > 1.
- * @see GLProfile#hasGLSL()
- */
- public final boolean hasGLSL() {
- return isGLES3() ||
- isGLES2() ||
- isGL3() ||
- isGL2() && ctxVersion.getMajor()>1 ;
- }
-
- /**
- * Returns true if basic FBO support is available, otherwise false.
- *
- * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= 3.0 [core, compat] or implements the extensions
- * GL_ARB_ES2_compatibility, GL_ARB_framebuffer_object, GL_EXT_framebuffer_object or GL_OES_framebuffer_object.
- *
- *
- * Basic FBO support may only include one color attachment and no multisampling,
- * as well as limited internal formats for renderbuffer.
- *
- * @see #CTX_IMPL_FBO
- */
- public final boolean hasBasicFBOSupport() {
- return 0 != ( ctxOptions & CTX_IMPL_FBO ) ;
- }
-
- /**
- * Returns true if full FBO support is available, otherwise false.
- *
- * Full FBO is supported if the context is either GL >= 3.0 [ES, core, compat] or implements the extensions
- * ARB_framebuffer_object, or all of
- * EXT_framebuffer_object, EXT_framebuffer_multisample,
- * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil.
- *
- *
- * Full FBO support includes multiple color attachments and multisampling.
- *
- */
- public final boolean hasFullFBOSupport() {
- return hasBasicFBOSupport() && !hasRendererQuirk(GLRendererQuirks.NoFullFBOSupport) &&
- ( isGL3ES3() || // GL >= 3.0 [ES, core, compat]
- isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object
- ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object*
- isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) &&
- isExtensionAvailable(GLExtensions.EXT_framebuffer_blit) &&
- isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil)
- )
- ) ;
- }
-
- /**
- * Returns true if OES_single_precision, fp32, fixed function point (FFP) compatibility entry points available,
- * otherwise false.
- * @see #CTX_IMPL_FP32_COMPAT_API
- */
- public final boolean hasFP32CompatAPI() {
- return 0 != ( ctxOptions & CTX_IMPL_FP32_COMPAT_API ) ;
- }
-
- /**
- * Returns the maximum number of FBO RENDERBUFFER samples
- * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false.
- */
- public final int getMaxRenderbufferSamples() {
- if( hasFullFBOSupport() ) {
- final GL gl = getGL();
- final int[] val = new int[] { 0 } ;
- try {
- gl.glGetIntegerv(GL2ES3.GL_MAX_SAMPLES, val, 0);
- final int glerr = gl.glGetError();
- if(GL.GL_NO_ERROR == glerr) {
- return val[0];
- } else if(DEBUG) {
- System.err.println("GLContext.getMaxRenderbufferSamples: GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr));
- }
- } catch (final GLException gle) { gle.printStackTrace(); }
- }
- return 0;
- }
-
- /** Note: The GL impl. may return a const value, ie {@link GLES2#isNPOTTextureAvailable()} always returns true. */
- public boolean isNPOTTextureAvailable() {
- return isGL3() || isGLES2Compatible() || isExtensionAvailable(GLExtensions.ARB_texture_non_power_of_two);
- }
-
- public boolean isTextureFormatBGRA8888Available() {
- return isGL2GL3() ||
- isExtensionAvailable(GLExtensions.EXT_texture_format_BGRA8888) ||
- isExtensionAvailable(GLExtensions.IMG_texture_format_BGRA8888) ;
- }
-
- /**
- * Indicates whether this GLContext is capable of GL4bc.
Includes [ GL4bc ].
- * @see GLProfile#isGL4bc()
- */
- public final boolean isGL4bc() {
- return 0 != (ctxOptions & CTX_PROFILE_COMPAT) &&
- ctxVersion.getMajor() >= 4;
- }
-
- /**
- * Indicates whether this GLContext is capable of GL4.
Includes [ GL4bc, GL4 ].
- * @see GLProfile#isGL4()
- */
- public final boolean isGL4() {
- return 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)) &&
- ctxVersion.getMajor() >= 4;
- }
-
- /**
- * Indicates whether this GLContext uses a GL4 core profile.
Includes [ GL4 ].
- */
- public final boolean isGL4core() {
- return 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
- ctxVersion.getMajor() >= 4;
- }
-
- /**
- * Indicates whether this GLContext is capable of GL3bc.
Includes [ GL4bc, GL3bc ].
- * @see GLProfile#isGL3bc()
- */
- public final boolean isGL3bc() {
- return 0 != (ctxOptions & CTX_PROFILE_COMPAT) &&
- ctxVersion.compareTo(Version3_1) >= 0 ;
- }
-
- /**
- * Indicates whether this GLContext is capable of GL3.
See Bug 852 - https://jogamp.org/bugzilla/show_bug.cgi?id=852
- */
- public final boolean isCPUDataSourcingAvail() {
- return isGL2ES1() || isGLES2();
- }
-
- /**
- * Indicates whether this GLContext's native profile does not implement a default vertex array object (VAO),
- * starting w/ OpenGL 3.1 core.
- *
Includes [ GL4, GL3 ].
- *
- Due to GL 3.1 core spec: E.1. DEPRECATED AND REMOVED FEATURES (p 296),
- GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331)
- there is no more default VAO buffer 0 bound, hence generating and binding one
- to avoid INVALID_OPERATION at VertexAttribPointer.
- More clear is GL 4.3 core spec: 10.4 (p 307).
- *
- *
- ES 3.x is not included here.
- Due to it's ES 2.0 backward compatibility it still supports the following features:
- client side vertex arrays
- default vertex array object
-
- Binding a custom VAO with ES 3.0 would cause client side vertex arrays via {@link GL2ES1#glVertexPointer(int, int, int, java.nio.Buffer) glVertexPointer}
- to produce GL_INVALID_OPERATION.
-
- However, they are marked deprecated:
- GL ES 3.0 spec F.1. Legacy Features (p 322).
- GL ES 3.1 spec F.1. Legacy Features (p 454).
- *
- *
- * If no default VAO is implemented in the native OpenGL profile,
- * an own default VAO is being used, see {@link #getDefaultVAO()}.
- *
- * @see #getDefaultVAO()
- */
- public final boolean hasNoDefaultVAO() {
- return // ES 3.x not included, see above. ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ) ||
- ( 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) &&
- 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
- ctxVersion.compareTo(Version3_1) >= 0
- ) ;
- }
-
- /**
- * If this GLContext does not implement a default VAO, see {@link #hasNoDefaultVAO()},
- * an own default VAO will be created and bound at context creation.
- *
- * If this GLContext does implement a default VAO, i.e. {@link #hasNoDefaultVAO()}
- * returns false, this method returns 0.
- *
- *
- * Otherwise this method returns the VAO object name
- * representing this GLContext's own default VAO.
- *
- * @see #hasNoDefaultVAO()
- */
- public abstract int getDefaultVAO();
-
- /**
- * Indicates whether this GLContext is capable of GL2.
Includes [ GL4bc, GL3bc, GL2 ].
- * @see GLProfile#isGL2()
- */
- public final boolean isGL2() {
- return 0 != ( ctxOptions & CTX_PROFILE_COMPAT ) && ctxVersion.getMajor()>=1 ;
- }
-
- /**
- * Indicates whether this GLContext is capable of GL2GL3.
Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].
- * @see GLProfile#isGL2GL3()
- */
- public final boolean isGL2GL3() {
- return isGL2() || isGL3();
- }
-
- /**
- * Indicates whether this GLContext is capable of GLES1.
Includes [ GLES1 ].
- * @see GLProfile#isGLES1()
- */
- public final boolean isGLES1() {
- return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 1 ;
- }
-
- /**
- * Indicates whether this GLContext is capable of GLES2.
Includes [ GLES2, GLES3 ].
- * @see GLProfile#isGLES2()
- */
- public final boolean isGLES2() {
- if( 0 != ( ctxOptions & CTX_PROFILE_ES ) ) {
- final int major = ctxVersion.getMajor();
- return 2 == major || 3 == major;
- }
- return false;
- }
-
- /**
- * Indicates whether this GLContext is capable of GLES3.
Includes [ GLES3 ].
- * @see GLProfile#isGLES3()
- */
- public final boolean isGLES3() {
- return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 3 ;
- }
-
- /**
- * Indicates whether this GLContext is capable of GLES.
Includes [ GLES3, GLES1, GLES2 ].
- * @see GLProfile#isGLES()
- */
- public final boolean isGLES() {
- return 0 != ( CTX_PROFILE_ES & ctxOptions ) ;
- }
-
- /**
- * Indicates whether this GLContext is capable of GL2ES1.
Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].
- * @see GLProfile#isGL2ES1()
- */
- public final boolean isGL2ES1() {
- return isGLES1() || isGL2();
- }
-
- /**
- * Indicates whether this GLContext is capable of GL2ES2.
- * @see GLProfile#isGL2ES3()
- * @see #isGL3ES3()
- * @see #isGL2GL3()
- */
- public final boolean isGL2ES3() {
- return isGL3ES3() || isGL2GL3();
- }
-
- /**
- * Indicates whether this GLContext is capable of GL3ES3.
Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].
- * @see GLProfile#isGL3ES3()
- */
- public final boolean isGL3ES3() {
- return isGL4ES3() || isGL3();
- }
-
- /**
- * Returns true if this profile is capable of GL4ES3, i.e. if {@link #isGLES3Compatible()} returns true.
- *
Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
- * @see GLProfile#isGL4ES3()
- */
- public final boolean isGL4ES3() {
- return isGLES3Compatible() ;
- }
-
- /**
- * Set the swap interval of the current context and attached drawable.
- * @param interval Should be ≥ 0. 0 disables the vertical synchronization,
- * where ≥ 1 is the number of vertical refreshes before a swap buffer occurs.
- * A value < 0 is ignored.
- * @return true if the operation was successful, otherwise false
- *
- * @throws GLException if the context is not current.
- */
- public final boolean setSwapInterval(final int interval) throws GLException {
- validateCurrent();
- if(0<=interval) {
- if( !drawableRetargeted || !hasRendererQuirk(GLRendererQuirks.NoSetSwapIntervalPostRetarget) ) {
- if( setSwapIntervalImpl(interval) ) {
- currentSwapInterval = interval;
- return true;
- }
- }
- }
- return false;
- }
- protected boolean setSwapIntervalImpl(final int interval) {
- return false;
- }
- /** Return the current swap interval.
- *
- * If the context has not been made current at all,
- * the default value -1 is returned.
- *
- *
- * For a valid context the default value is 1
- * in case of an EGL based profile (ES1 or ES2) and -1
- * (undefined) for desktop.
- *
- */
- public final int getSwapInterval() {
- return currentSwapInterval;
- }
- protected final void setDefaultSwapInterval() {
- if(this.isGLES()) {
- currentSwapInterval = 1;
- } else {
- currentSwapInterval = -1;
- }
- }
-
- public final boolean queryMaxSwapGroups(final int[] maxGroups, final int maxGroups_offset,
- final int[] maxBarriers, final int maxBarriers_offset) {
- validateCurrent();
- return queryMaxSwapGroupsImpl(maxGroups, maxGroups_offset, maxBarriers, maxBarriers_offset);
- }
- protected boolean queryMaxSwapGroupsImpl(final int[] maxGroups, final int maxGroups_offset,
- final int[] maxBarriers, final int maxBarriers_offset) { return false; }
- public final boolean joinSwapGroup(final int group) {
- validateCurrent();
- return joinSwapGroupImpl(group);
- }
- protected boolean joinSwapGroupImpl(final int group) { /** nop per default .. **/ return false; }
- protected int currentSwapGroup = -1; // default: not set yet ..
- public int getSwapGroup() {
- return currentSwapGroup;
- }
- public final boolean bindSwapBarrier(final int group, final int barrier) {
- validateCurrent();
- return bindSwapBarrierImpl(group, barrier);
- }
- protected boolean bindSwapBarrierImpl(final int group, final int barrier) { /** nop per default .. **/ return false; }
-
- /**
- * Return the framebuffer name bound to this context,
- * see {@link GL#glBindFramebuffer(int, int)}.
- *
- * Method is only thread-safe while context is {@link #makeCurrent() made current}.
- *
- */
- public abstract int getBoundFramebuffer(int target);
-
- /**
- * Return the default draw framebuffer name.
- *
- * May differ from it's default zero
- * in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
- * is being used.
- *
- *
- * Method is only thread-safe while context is {@link #makeCurrent() made current}.
- *
- */
- public abstract int getDefaultDrawFramebuffer();
-
- /**
- * Return the default read framebuffer name.
- *
- * May differ from it's default zero
- * in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
- * is being used.
- *
- *
- * Method is only thread-safe while context is {@link #makeCurrent() made current}.
- *
- */
- public abstract int getDefaultReadFramebuffer();
-
- /**
- * Returns the default color buffer within the current bound
- * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​,
- * which will be used as the source for pixel reading commands,
- * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels} etc.
- *
- * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0},
- * otherwise this is {@link GL#GL_FRONT} for single buffer configurations
- * and {@link GL#GL_BACK} for double buffer configurations.
- *
- *
- * Note-1: Neither ES1 nor ES2 supports selecting the read buffer via glReadBuffer
- * and {@link GL#GL_BACK} is the default.
- *
- *
- * Note-2: ES3 only supports {@link GL#GL_BACK}, {@link GL#GL_NONE} or {@link GL#GL_COLOR_ATTACHMENT0}+i
- *
- *
- * Note-3: See {@link com.jogamp.opengl.util.GLDrawableUtil#swapBuffersBeforeRead(GLCapabilitiesImmutable) swapBuffersBeforeRead}
- * for read-pixels and swap-buffers implications.
- *
- *
- * Method is only thread-safe while context is {@link #makeCurrent() made current}.
- *
- */
- public abstract int getDefaultReadBuffer();
-
- /**
- * Get the default pixel data type, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}.
- *
- * Method is only thread-safe while context is {@link #makeCurrent() made current}.
- *
- */
- public abstract int getDefaultPixelDataType();
-
- /**
- * Get the default pixel data format, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}.
- *
- * Method is only thread-safe while context is {@link #makeCurrent() made current}.
- *
- */
- public abstract int getDefaultPixelDataFormat();
-
- /**
- * @return The extension implementing the GLDebugOutput feature,
- * either {@link GLExtensions#ARB_debug_output} or {@link GLExtensions#AMD_debug_output}.
- * If unavailable or called before initialized via {@link #makeCurrent()}, null is returned.
- */
- public abstract String getGLDebugMessageExtension();
-
- /**
- * @return the current synchronous debug behavior, set via {@link #setGLDebugSynchronous(boolean)}.
- */
- public abstract boolean isGLDebugSynchronous();
-
- /**
- * Enables or disables the synchronous debug behavior via
- * {@link GL2GL3#GL_DEBUG_OUTPUT_SYNCHRONOUS glEnable/glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS)},
- * if extension is {@link GLExtensions#ARB_debug_output}.
- * There is no equivalent for {@link GLExtensions#AMD_debug_output}.
- *
The default is true, ie {@link GL2GL3#GL_DEBUG_OUTPUT_SYNCHRONOUS}.
- * @link {@link #isGLDebugSynchronous()}
- */
- public abstract void setGLDebugSynchronous(boolean synchronous);
-
- /**
- * @return true if the GLDebugOutput feature is enabled or not.
- */
- public abstract boolean isGLDebugMessageEnabled();
-
- /**
- * Enables or disables the GLDebugOutput feature of extension {@link GLExtensions#ARB_debug_output}
- * or {@link GLExtensions#AMD_debug_output}, if available.
- *
- *
To enable the GLDebugOutput feature {@link #enableGLDebugMessage(boolean) enableGLDebugMessage(true)}
- * or {@link #setContextCreationFlags(int) setContextCreationFlags}({@link GLContext#CTX_OPTION_DEBUG})
- * shall be called before context creation via {@link #makeCurrent()}!
- *
- *
In case {@link GLAutoDrawable} are being used,
- * {@link GLAutoDrawable#setContextCreationFlags(int) glAutoDrawable.setContextCreationFlags}({@link GLContext#CTX_OPTION_DEBUG})
- * shall be issued before context creation via {@link #makeCurrent()}!
- *
- *
After context creation, the GLDebugOutput feature may be enabled or disabled at any time using this method.
- *
- * @param enable If true enables, otherwise disables the GLDebugOutput feature.
- *
- * @throws GLException if this context is not current or GLDebugOutput registration failed (enable)
- *
- * @see #setContextCreationFlags(int)
- * @see #addGLDebugListener(GLDebugListener)
- * @see GLAutoDrawable#setContextCreationFlags(int)
- */
- public abstract void enableGLDebugMessage(boolean enable) throws GLException;
-
- /**
- * Add {@link GLDebugListener}.
- *
- * @param listener {@link GLDebugListener} handling {@link GLDebugMessage}s
- * @see #enableGLDebugMessage(boolean)
- * @see #removeGLDebugListener(GLDebugListener)
- */
- public abstract void addGLDebugListener(GLDebugListener listener);
-
- /**
- * Remove {@link GLDebugListener}.
- *
- * @param listener {@link GLDebugListener} handling {@link GLDebugMessage}s
- * @see #enableGLDebugMessage(boolean)
- * @see #addGLDebugListener(GLDebugListener)
- */
- public abstract void removeGLDebugListener(GLDebugListener listener);
-
- /**
- * Generic entry for {@link GL2GL3#glDebugMessageControl(int, int, int, int, IntBuffer, boolean)}
- * and {@link GL2GL3#glDebugMessageEnableAMD(int, int, int, IntBuffer, boolean)} of the GLDebugOutput feature.
- * @see #enableGLDebugMessage(boolean)
- */
- public abstract void glDebugMessageControl(int source, int type, int severity, int count, IntBuffer ids, boolean enabled);
-
- /**
- * Generic entry for {@link GL2GL3#glDebugMessageControl(int, int, int, int, int[], int, boolean)}
- * and {@link GL2GL3#glDebugMessageEnableAMD(int, int, int, int[], int, boolean)} of the GLDebugOutput feature.
- * @see #enableGLDebugMessage(boolean)
- */
- public abstract void glDebugMessageControl(int source, int type, int severity, int count, int[] ids, int ids_offset, boolean enabled);
-
- /**
- * Generic entry for {@link GL2GL3#glDebugMessageInsert(int, int, int, int, int, String)}
- * and {@link GL2GL3#glDebugMessageInsertAMD(int, int, int, int, String)} of the GLDebugOutput feature.
- * @see #enableGLDebugMessage(boolean)
- */
- public abstract void glDebugMessageInsert(int source, int type, int id, int severity, String buf);
-
- public static final int GL_VERSIONS[][] = {
- /* 0.*/ { -1 },
- /* 1.*/ { 0, 1, 2, 3, 4, 5 },
- /* 2.*/ { 0, 1 },
- /* 3.*/ { 0, 1, 2, 3 },
- /* 4.*/ { 0, 1, 2, 3, 4, 5 } };
-
- public static final int ES_VERSIONS[][] = {
- /* 0.*/ { -1 },
- /* 1.*/ { 0, 1 },
- /* 2.*/ { 0 },
- /* 3.*/ { 0, 1 } };
-
- public static final int getMaxMajor(final int ctxProfile) {
- return ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ? ES_VERSIONS.length-1 : GL_VERSIONS.length-1;
- }
-
- public static final int getMaxMinor(final int ctxProfile, final int major) {
- if( 1>major ) {
- return -1;
- }
- if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) {
- if( major>=ES_VERSIONS.length ) return -1;
- return ES_VERSIONS[major].length-1;
- } else {
- if( major>=GL_VERSIONS.length ) return -1;
- return GL_VERSIONS[major].length-1;
- }
- }
-
- /**
- * Returns true, if the major.minor is not inferior to the lowest
- * valid version and does not exceed the highest known major number by more than one.
- *
- * The minor version number is ignored by the upper limit validation
- * and the major version number may exceed by one.
- *
- *
- * The upper limit check is relaxed since we don't want to cut-off
- * unforseen new GL version since the release of JOGL.
- *
- *
- * Hence it is important to iterate through GL version from the upper limit
- * and {@link #decrementGLVersion(int, int[], int[])} until invalid.
- *
- */
- public static final boolean isValidGLVersion(final int ctxProfile, final int major, final int minor) {
- if( 1>major || 0>minor ) {
- return false;
- }
- if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) {
- if( major >= ES_VERSIONS.length + 1 ) return false;
- } else {
- if( major>=GL_VERSIONS.length + 1 ) return false;
- }
- return true;
- }
-
- /**
- * Clip the given GL version to the maximum known valid version if exceeding.
- * @return true if clipped, i.e. given value exceeds maximum, otherwise false.
- */
- public static final boolean clipGLVersion(final int ctxProfile, final int major[], final int minor[]) {
- final int m = major[0];
- final int n = minor[0];
-
- if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) {
- if( m >= ES_VERSIONS.length ) {
- major[0] = ES_VERSIONS.length - 1;
- minor[0] = ES_VERSIONS[major[0]].length - 1;
- return true;
- }
- if( n >= ES_VERSIONS[m].length ) {
- minor[0] = ES_VERSIONS[m].length - 1;
- return true;
- }
- } else if( m >= GL_VERSIONS.length ) { // !isES
- major[0] = GL_VERSIONS.length - 1;
- minor[0] = GL_VERSIONS[major[0]].length - 1;
- return true;
- } else if( n >= GL_VERSIONS[m].length ) { // !isES
- minor[0] = GL_VERSIONS[m].length - 1;
- return true;
- }
- return false;
- }
-
- /**
- * Decrement the given GL version by one
- * and return true if still valid, otherwise false.
- *
- * If the given version exceeds the maximum known valid version,
- * it is {@link #clipGLVersion(int, int[], int[]) clipped} and
- * true is returned.
- *
- *
- * @param ctxProfile
- * @param major
- * @param minor
- * @return
- */
- public static final boolean decrementGLVersion(final int ctxProfile, final int major[], final int minor[]) {
- if( !clipGLVersion(ctxProfile, major, minor) ) {
- int m = major[0];
- int n = minor[0] - 1;
- if(n < 0) {
- if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) {
- if( m >= 3 ) {
- m -= 1;
- } else {
- m = 0; // major decr [1,2] -> 0
- }
- n = ES_VERSIONS[m].length-1;
- } else {
- m -= 1;
- n = GL_VERSIONS[m].length-1;
- }
- }
- if( !isValidGLVersion(ctxProfile, m, n) ) {
- return false;
- }
- major[0]=m;
- minor[0]=n;
- }
- return true;
- }
-
- protected static int composeBits(final int a8, final int b8, final int c16) {
- return ( ( a8 & 0x000000FF ) << 24 ) |
- ( ( b8 & 0x000000FF ) << 16 ) |
- ( ( c16 & 0x0000FFFF ) ) ;
- }
-
- private static void validateProfileBits(final int bits, final String argName) {
- int num = 0;
- if( 0 != ( CTX_PROFILE_COMPAT & bits ) ) { num++; }
- if( 0 != ( CTX_PROFILE_CORE & bits ) ) { num++; }
- if( 0 != ( CTX_PROFILE_ES & bits ) ) { num++; }
- if(1!=num) {
- throw new GLException("Internal Error: "+argName+": 1 != num-profiles: "+num);
- }
- }
-
- //
- // version mapping
- //
-
- /**
- * @see #getDeviceVersionAvailableKey(com.jogamp.nativewindow.AbstractGraphicsDevice, int, int)
- */
- protected static final IdentityHashMap deviceVersionAvailable = new IdentityHashMap();
-
- /**
- * @see #getUniqueDeviceString(com.jogamp.nativewindow.AbstractGraphicsDevice)
- */
- private static final IdentityHashMap deviceVersionsAvailableSet = new IdentityHashMap();
-
- /** clears the device/context mappings as well as the GL/GLX proc address tables. */
- protected static void shutdown() {
- deviceVersionAvailable.clear();
- deviceVersionsAvailableSet.clear();
- GLContextImpl.shutdownImpl(); // well ..
- }
-
- protected static boolean getAvailableGLVersionsSet(final AbstractGraphicsDevice device) {
- synchronized ( deviceVersionsAvailableSet ) {
- return deviceVersionsAvailableSet.containsKey(device.getUniqueID());
- }
- }
-
- protected static void setAvailableGLVersionsSet(final AbstractGraphicsDevice device, final boolean set) {
- synchronized ( deviceVersionsAvailableSet ) {
- final String devKey = device.getUniqueID();
- if( set ) {
- deviceVersionsAvailableSet.put(devKey, devKey);
- } else {
- deviceVersionsAvailableSet.remove(devKey);
- }
- if (DEBUG) {
- System.err.println(getThreadName() + ": createContextARB: SET mappedVersionsAvailableSet "+devKey);
- System.err.println(GLContext.dumpAvailableGLVersions(null).toString());
- }
- }
- }
-
- /**
- * Returns a unique String object using {@link String#intern()} for the given arguments,
- * which object reference itself can be used as a key.
- */
- protected static String getDeviceVersionAvailableKey(final AbstractGraphicsDevice device, final int major, final int profile) {
- final String r = device.getUniqueID() + "-" + toHexString(composeBits(major, profile, 0));
- return r.intern();
- }
-
- /**
- * Called by {@link jogamp.opengl.GLContextImpl#createContextARBMapVersionsAvailable(int,int)} not intended to be used by
- * implementations. However, if {@link jogamp.opengl.GLContextImpl#createContextARB(long, boolean)} is not being used within
- * {@link com.jogamp.opengl.GLDrawableFactory#getOrCreateSharedContext(com.jogamp.nativewindow.AbstractGraphicsDevice)},
- * GLProfile has to map the available versions.
- *
- * @param reqMajor Key Value either 1, 2, 3 or 4
- * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
- * @return the old mapped value
- *
- * @see #createContextARBMapVersionsAvailable
- */
- protected static Integer mapAvailableGLVersion(final AbstractGraphicsDevice device,
- final int reqMajor, final int profile, final int resMajor, final int resMinor, int resCtp)
- {
- validateProfileBits(profile, "profile");
- validateProfileBits(resCtp, "resCtp");
-
- if(FORCE_NO_FBO_SUPPORT) {
- resCtp &= ~CTX_IMPL_FBO ;
- }
- if(DEBUG) {
- System.err.println("GLContext.mapAvailableGLVersion: "+device+": "+getGLVersion(reqMajor, 0, profile, null)+" -> "+getGLVersion(resMajor, resMinor, resCtp, null));
- // Thread.dumpStack();
- }
- final String objectKey = getDeviceVersionAvailableKey(device, reqMajor, profile);
- final Integer val = Integer.valueOf(composeBits(resMajor, resMinor, resCtp));
- synchronized(deviceVersionAvailable) {
- return deviceVersionAvailable.put( objectKey, val );
- }
- }
-
- protected static StringBuilder dumpAvailableGLVersions(StringBuilder sb) {
- if(null == sb) {
- sb = new StringBuilder();
- }
- synchronized(deviceVersionAvailable) {
- final Set keys = deviceVersionAvailable.keySet();
- boolean needsSeparator = false;
- for(final Iterator i = keys.iterator(); i.hasNext(); ) {
- if(needsSeparator) {
- sb.append(Platform.getNewline());
- }
- final String key = i.next();
- sb.append(key).append(": ");
- final Integer valI = deviceVersionAvailable.get(key);
- if(null != valI) {
- final int bits32 = valI.intValue();
- final int major = ( bits32 & 0xFF000000 ) >>> 24 ;
- final int minor = ( bits32 & 0x00FF0000 ) >>> 16 ;
- final int ctp = ( bits32 & 0x0000FFFF ) ;
- sb.append(GLContext.getGLVersion(major, minor, ctp, null));
- } else {
- sb.append("n/a");
- }
- needsSeparator = true;
- }
- }
- return sb;
- }
-
- /**
- * @param device the device to request whether the profile is available for
- * @param reqMajor Key Value either 1, 2, 3 or 4
- * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
- * @return the available GL version as encoded with {@link #composeBits(int, int, int), otherwise null
- */
- protected static Integer getAvailableGLVersion(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile) {
- final String objectKey = getDeviceVersionAvailableKey(device, reqMajor, reqProfile);
- Integer val;
- synchronized(deviceVersionAvailable) {
- val = deviceVersionAvailable.get( objectKey );
- }
- return val;
- }
-
- /**
- * @param reqMajor Key Value either 1, 2, 3 or 4
- * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
- * @param major if not null, returns the used major version
- * @param minor if not null, returns the used minor version
- * @param ctp if not null, returns the used context profile
- */
- protected static boolean getAvailableGLVersion(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile,
- final int[] major, final int minor[], final int ctp[]) {
-
- final Integer valI = getAvailableGLVersion(device, reqMajor, reqProfile);
- if(null==valI) {
- return false;
- }
-
- final int bits32 = valI.intValue();
-
- if(null!=major) {
- major[0] = ( bits32 & 0xFF000000 ) >>> 24 ;
- }
- if(null!=minor) {
- minor[0] = ( bits32 & 0x00FF0000 ) >>> 16 ;
- }
- if(null!=ctp) {
- ctp[0] = ( bits32 & 0x0000FFFF ) ;
- }
- return true;
- }
-
- /**
- * returns the highest GLProfile string regarding the implementation version and context profile bits.
- * @throws GLException if version and context profile bits could not be mapped to a GLProfile
- */
- protected static String getGLProfile(final int major, final int minor, final int ctp)
- throws GLException {
- if(0 != ( CTX_PROFILE_COMPAT & ctp )) {
- if(major >= 4) { return GLProfile.GL4bc; }
- else if(major == 3 && minor >= 1) { return GLProfile.GL3bc; }
- else { return GLProfile.GL2; }
- } else if(0 != ( CTX_PROFILE_CORE & ctp )) {
- if(major >= 4) { return GLProfile.GL4; }
- else if(major == 3 && minor >= 1) { return GLProfile.GL3; }
- } else if(0 != ( CTX_PROFILE_ES & ctp )) {
- if(major == 3) { return GLProfile.GLES3; }
- else if(major == 2) { return GLProfile.GLES2; }
- else if(major == 1) { return GLProfile.GLES1; }
- }
- throw new GLException("Unhandled OpenGL version/profile: "+GLContext.getGLVersion(major, minor, ctp, null));
- }
-
- /**
- * Returns the GLProfile's major version number at reqMajorCTP[0] and it's context property (CTP) at reqMajorCTP[1] for availability mapping request.
- */
- protected static final void getRequestMajorAndCompat(final GLProfile glp, final int[/*2*/] reqMajorCTP) {
- final GLProfile glpImpl = glp.getImpl();
- if( glpImpl.isGL4() ) {
- reqMajorCTP[0]=4;
- } else if ( glpImpl.isGL3() || glpImpl.isGLES3() ) {
- reqMajorCTP[0]=3;
- } else if (glpImpl.isGLES1()) {
- reqMajorCTP[0]=1;
- } else /* if (glpImpl.isGL2() || glpImpl.isGLES2()) */ {
- reqMajorCTP[0]=2;
- }
- if( glpImpl.isGLES() ) {
- reqMajorCTP[1]=CTX_PROFILE_ES;
- } else if( glpImpl.isGL2() ) { // incl GL3bc and GL4bc
- reqMajorCTP[1]=CTX_PROFILE_COMPAT;
- } else {
- reqMajorCTP[1]=CTX_PROFILE_CORE;
- }
- }
-
- /**
- * @param device the device the context profile is being requested for
- * @param GLProfile the GLProfile the context profile is being requested for
- * @return the GLProfile's context property (CTP) if available, otherwise 0
- */
- protected static final int getAvailableContextProperties(final AbstractGraphicsDevice device, final GLProfile glp) {
- final int[] reqMajorCTP = new int[] { 0, 0 };
- getRequestMajorAndCompat(glp, reqMajorCTP);
-
- final int _major[] = { 0 };
- final int _minor[] = { 0 };
- final int _ctp[] = { 0 };
- if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], _major, _minor, _ctp)) {
- return _ctp[0];
- }
- return 0; // n/a
- }
-
- /**
- * @param device the device the profile is being requested
- * @param major Key Value either 1, 2, 3 or 4
- * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
- * @return the highest GLProfile for the device regarding availability, version and profile bits.
- */
- protected static GLProfile getAvailableGLProfile(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile)
- throws GLException {
- final String glpName = getAvailableGLProfileName(device, reqMajor, reqProfile);
- return null != glpName ? GLProfile.get(device, glpName) : null;
- }
-
- /**
- * @param device the device the profile is being requested
- * @param major Key Value either 1, 2, 3 or 4
- * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
- * @return the highest GLProfile name for the device regarding availability, version and profile bits.
- */
- /* package */ static String getAvailableGLProfileName(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile)
- throws GLException {
- final int major[] = { 0 };
- final int minor[] = { 0 };
- final int ctp[] = { 0 };
- if(GLContext.getAvailableGLVersion(device, reqMajor, reqProfile, major, minor, ctp)) {
- return GLContext.getGLProfile(major[0], minor[0], ctp[0]);
- }
- return null;
- }
-
- /**
- * @param device the device the profile is being requested
- * @param major Key Value either 1, 2, 3 or 4
- * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
- */
- protected static String getAvailableGLVersionAsString(final AbstractGraphicsDevice device, final int major, final int profile) {
- final int _major[] = { 0 };
- final int _minor[] = { 0 };
- final int _ctp[] = { 0 };
- if(getAvailableGLVersion(device, major, profile, _major, _minor, _ctp)) {
- return getGLVersion(_major[0], _minor[0], _ctp[0], null);
- }
- return null;
- }
-
- /**
- * Returns true if it is possible to create an framebuffer object (FBO).
- *
- * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent.
- *
- *
- * FBO support is queried as described in {@link #hasBasicFBOSupport()}.
- *
- *
- * @param device the device to request whether FBO is available for
- * @param glp {@link GLProfile} to check for FBO capabilities
- * @see GLContext#hasBasicFBOSupport()
- */
- public static final boolean isFBOAvailable(final AbstractGraphicsDevice device, final GLProfile glp) {
- return 0 != ( CTX_IMPL_FBO & getAvailableContextProperties(device, glp) );
- }
-
- /**
- * @return 1 if using a hardware rasterizer, 0 if using a software rasterizer and -1 if not determined yet.
- * @see GLContext#isHardwareRasterizer()
- * @see GLProfile#isHardwareRasterizer()
- */
- public static final int isHardwareRasterizer(final AbstractGraphicsDevice device, final GLProfile glp) {
- final int r;
- final int ctp = getAvailableContextProperties(device, glp);
- if(0 == ctp) {
- r = -1;
- } else if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctp ) ) {
- r = 1;
- } else {
- r = 0;
- }
- return r;
- }
-
- /**
- * @param device the device to request whether the profile is available for
- * @param reqMajor Key Value either 1, 2, 3 or 4
- * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
- * @param isHardware return value of one boolean, whether the profile is a hardware rasterizer or not
- * @return true if the requested GL version is available regardless of a software or hardware rasterizer, otherwise false.
- */
- protected static boolean isGLVersionAvailable(final AbstractGraphicsDevice device, final int reqMajor, final int reqProfile, final boolean isHardware[]) {
- final Integer valI = getAvailableGLVersion(device, reqMajor, reqProfile);
- if(null==valI) {
- return false;
- }
- isHardware[0] = 0 == ( valI.intValue() & GLContext.CTX_IMPL_ACCEL_SOFT ) ;
- return true;
- }
-
- public static boolean isGLES1Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
- return isGLVersionAvailable(device, 1, GLContext.CTX_PROFILE_ES, isHardware);
- }
-
- public static boolean isGLES2Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
- return isGLVersionAvailable(device, 2, GLContext.CTX_PROFILE_ES, isHardware);
- }
-
- public static boolean isGLES3Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
- return isGLVersionAvailable(device, 3, GLContext.CTX_PROFILE_ES, isHardware);
- }
-
- /**
- * Returns true if a ES3 compatible profile is available,
- * i.e. either a ≥ 4.3 context or a ≥ 3.1 context supporting GL_ARB_ES3_compatibility,
- * otherwise false.
- *
- * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]
- *
- */
- public static final boolean isGLES3CompatibleAvailable(final AbstractGraphicsDevice device) {
- final int major[] = { 0 };
- final int minor[] = { 0 };
- final int ctp[] = { 0 };
- boolean ok;
-
- ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_ES, major, minor, ctp);
- if( !ok ) {
- ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_CORE, major, minor, ctp);
- }
- if( !ok ) {
- GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_COMPAT, major, minor, ctp);
- }
- return 0 != ( ctp[0] & CTX_IMPL_ES3_COMPAT );
- }
-
- public static boolean isGL4bcAvailable(final AbstractGraphicsDevice device, final boolean isHardware[]) {
- return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT, isHardware);
- }
-
- public static boolean isGL4Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
- return isGLVersionAvailable(device, 4, CTX_PROFILE_CORE, isHardware);
- }
-
- public static boolean isGL3bcAvailable(final AbstractGraphicsDevice device, final boolean isHardware[]) {
- return isGLVersionAvailable(device, 3, CTX_PROFILE_COMPAT, isHardware);
- }
-
- public static boolean isGL3Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
- return isGLVersionAvailable(device, 3, CTX_PROFILE_CORE, isHardware);
- }
-
- public static boolean isGL2Available(final AbstractGraphicsDevice device, final boolean isHardware[]) {
- return isGLVersionAvailable(device, 2, CTX_PROFILE_COMPAT, isHardware);
- }
-
- protected static String getGLVersion(final int major, final int minor, final int ctp, final String gl_version) {
- boolean needColon = false;
- final StringBuilder sb = new StringBuilder();
- sb.append(major);
- sb.append(".");
- sb.append(minor);
- sb.append(" (");
- needColon = appendString(sb, "ES profile", needColon, 0 != ( CTX_PROFILE_ES & ctp ));
- needColon = appendString(sb, "Compat profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp ));
- needColon = appendString(sb, "Core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp ));
- needColon = appendString(sb, "forward", needColon, 0 != ( CTX_OPTION_FORWARD & ctp ));
- needColon = appendString(sb, "arb", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp ));
- needColon = appendString(sb, "debug", needColon, 0 != ( CTX_OPTION_DEBUG & ctp ));
- needColon = appendString(sb, "ES2 compat", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp ));
- needColon = appendString(sb, "ES3 compat", needColon, 0 != ( CTX_IMPL_ES3_COMPAT & ctp ));
- needColon = appendString(sb, "FBO", needColon, 0 != ( CTX_IMPL_FBO & ctp ));
- needColon = appendString(sb, "FP32 compat", needColon, 0 != ( CTX_IMPL_FP32_COMPAT_API & ctp ));
- if( 0 != ( CTX_IMPL_ACCEL_SOFT & ctp ) ) {
- needColon = appendString(sb, "software", needColon, true);
- } else {
- needColon = appendString(sb, "hardware", needColon, true);
- }
- sb.append(")");
- if(null!=gl_version) {
- sb.append(" - ");
- sb.append(gl_version);
- }
- return sb.toString();
- }
-
- //
- // internal string utils
- //
-
- protected static String toHexString(final int hex) {
- return "0x" + Integer.toHexString(hex);
- }
-
- protected static String toHexString(final long hex) {
- return "0x" + Long.toHexString(hex);
- }
-
- private static boolean appendString(final StringBuilder sb, final String string, boolean needColon, final boolean condition) {
- if(condition) {
- if(needColon) {
- sb.append(", ");
- }
- sb.append(string);
- needColon=true;
- }
- return needColon;
- }
-
- protected static String getThreadName() { return Thread.currentThread().getName(); }
-
-}
-
diff --git a/src/jogl/classes/javax/media/opengl/GLDebugListener.java b/src/jogl/classes/javax/media/opengl/GLDebugListener.java
deleted file mode 100644
index 30e1a49c2..000000000
--- a/src/jogl/classes/javax/media/opengl/GLDebugListener.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package com.jogamp.opengl;
-
-/**
- * Listener for {@link GLDebugMessage}s.
- *
- *
One can enable GLDebugOutput via {@link GLContext#enableGLDebugMessage(boolean)}
- * and add listeners via {@link GLContext#addGLDebugListener(GLDebugListener)}.
- */
-public interface GLDebugListener {
- /**
- * Handle {@link GLDebugMessage} message sent from native GL implementation.
- *
- *
Since this method is invoked directly by the GL implementation, it shall
- * return as fast as possible.
- */
- void messageSent(GLDebugMessage event);
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java
deleted file mode 100644
index a8868026b..000000000
--- a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package com.jogamp.opengl;
-
-import com.jogamp.common.os.Platform;
-
-/**
- * OpenGL debug message generated by the driver
- * and delivered via {@link GLDebugListener}.
- */
-public class GLDebugMessage {
- final GLContext source;
- final long when;
- final int dbgSource;
- final int dbgType;
- final int dbgId;
- final int dbgSeverity;
- final String dbgMsg;
-
- /**
- * @param source The source of the event
- * @param when The time of the event
- * @param dbgSource The ARB source
- * @param dbgType The ARB type
- * @param dbgId The ARB id
- * @param dbgSeverity The ARB severity level
- * @param dbgMsg The debug message
- */
- public GLDebugMessage(final GLContext source, final long when, final int dbgSource, final int dbgType, final int dbgId, final int dbgSeverity, final String dbgMsg) {
- this.source = source;
- this.when = when;
- this.dbgSource = dbgSource;
- this.dbgType = dbgType;
- this.dbgId = dbgId;
- this.dbgSeverity = dbgSeverity;
- this.dbgMsg = dbgMsg;
- }
-
- /**
- *
- * @param source
- * @param when
- * @param dbgId
- * @param amdDbgCategory
- * @param dbgSeverity AMD severity level equals ARB severity level (value and semantic)
- * @param dbgMsg
- * @return
- */
- public static GLDebugMessage translateAMDEvent(final GLContext source, final long when, final int dbgId, final int amdDbgCategory, final int dbgSeverity, final String dbgMsg) {
- int dbgSource, dbgType;
-
- // AMD category == ARB source/type
- switch(amdDbgCategory) {
- case GL2GL3.GL_DEBUG_CATEGORY_API_ERROR_AMD:
- dbgSource = GL2ES2.GL_DEBUG_SOURCE_API;
- dbgType = GL2ES2.GL_DEBUG_TYPE_ERROR;
- break;
-
- //
- // def source / other type
- //
-
- case GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD:
- dbgSource = GL2ES2.GL_DEBUG_SOURCE_WINDOW_SYSTEM;
- dbgType = GL2ES2.GL_DEBUG_TYPE_OTHER;
- break;
-
- case GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD:
- dbgSource = GL2ES2.GL_DEBUG_SOURCE_SHADER_COMPILER;
- dbgType = GL2ES2.GL_DEBUG_TYPE_OTHER;
- break;
-
- case GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD:
- dbgSource = GL2ES2.GL_DEBUG_SOURCE_APPLICATION;
- dbgType = GL2ES2.GL_DEBUG_TYPE_OTHER;
- break;
-
-
- //
- // other source / def type
- //
-
- case GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD:
- dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
- dbgType = GL2ES2.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR;
- break;
-
- case GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD:
- dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
- dbgType = GL2ES2.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR;
- break;
-
- case GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD:
- dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
- dbgType = GL2ES2.GL_DEBUG_TYPE_PERFORMANCE;
- break;
-
- case GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD:
- default:
- dbgSource = GL2ES2.GL_DEBUG_SOURCE_OTHER;
- dbgType = GL2ES2.GL_DEBUG_TYPE_OTHER;
- }
-
- return new GLDebugMessage(source, when, dbgSource, dbgType, dbgId, dbgSeverity, dbgMsg);
- }
-
- public static int translateARB2AMDCategory(final int dbgSource, final int dbgType) {
- switch (dbgSource) {
- case GL2ES2.GL_DEBUG_SOURCE_WINDOW_SYSTEM:
- return GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD;
-
- case GL2ES2.GL_DEBUG_SOURCE_SHADER_COMPILER:
- return GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD;
-
- case GL2ES2.GL_DEBUG_SOURCE_APPLICATION:
- return GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD;
- }
-
- switch(dbgType) {
- case GL2ES2.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
- return GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD;
-
- case GL2ES2.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
- return GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD;
-
- case GL2ES2.GL_DEBUG_TYPE_PERFORMANCE:
- return GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD;
- }
-
- return GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD;
- }
-
- public GLContext getSource() {
- return source;
- }
-
- public long getWhen() {
- return when;
- }
-
- public int getDbgSource() {
- return dbgSource;
- }
-
- public int getDbgType() {
- return dbgType;
- }
-
- public int getDbgId() {
- return dbgId;
- }
-
- public int getDbgSeverity() {
- return dbgSeverity;
- }
-
- public String getDbgMsg() {
- return dbgMsg;
- }
-
- public StringBuilder toString(StringBuilder sb) {
- final String crtab = Platform.getNewline()+"\t";
- if(null==sb) {
- sb = new StringBuilder();
- }
- sb.append("GLDebugEvent[ id ");
- toHexString(sb, dbgId)
- .append(crtab).append("type ").append(getDbgTypeString(dbgType))
- .append(crtab).append("severity ").append(getDbgSeverityString(dbgSeverity))
- .append(crtab).append("source ").append(getDbgSourceString(dbgSource))
- .append(crtab).append("msg ").append(dbgMsg)
- .append(crtab).append("when ").append(when);
- if(null != source) {
- sb.append(crtab).append("source ").append(source.getGLVersion()).append(" - hash 0x").append(Integer.toHexString(source.hashCode()));
- }
- sb.append("]");
- return sb;
- }
-
- @Override
- public String toString() {
- return toString(null).toString();
- }
-
- public static String getDbgSourceString(final int dbgSource) {
- switch(dbgSource) {
- case GL2ES2.GL_DEBUG_SOURCE_API: return "GL API";
- case GL2ES2.GL_DEBUG_SOURCE_SHADER_COMPILER: return "GLSL or extension compiler";
- case GL2ES2.GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "Native Windowing binding";
- case GL2ES2.GL_DEBUG_SOURCE_THIRD_PARTY: return "Third party";
- case GL2ES2.GL_DEBUG_SOURCE_APPLICATION: return "Application";
- case GL2ES2.GL_DEBUG_SOURCE_OTHER: return "generic";
- default: return "Unknown (" + toHexString(dbgSource) + ")";
- }
- }
-
- public static String getDbgTypeString(final int dbgType) {
- switch(dbgType) {
- case GL2ES2.GL_DEBUG_TYPE_ERROR: return "Error";
- case GL2ES2.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "Warning: marked for deprecation";
- case GL2ES2.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "Warning: undefined behavior";
- case GL2ES2.GL_DEBUG_TYPE_PERFORMANCE: return "Warning: implementation dependent performance";
- case GL2ES2.GL_DEBUG_TYPE_PORTABILITY: return "Warning: vendor-specific extension use";
- case GL2ES2.GL_DEBUG_TYPE_OTHER: return "Warning: generic";
- default: return "Unknown (" + toHexString(dbgType) + ")";
- }
- }
-
- public static String getDbgSeverityString(final int dbgSeverity) {
- switch(dbgSeverity) {
- case GL2ES2.GL_DEBUG_SEVERITY_HIGH: return "High: dangerous undefined behavior";
- case GL2ES2.GL_DEBUG_SEVERITY_MEDIUM: return "Medium: Severe performance/deprecation/other warnings";
- case GL2ES2.GL_DEBUG_SEVERITY_LOW: return "Low: Performance warnings (redundancy/undefined)";
- default: return "Unknown (" + toHexString(dbgSeverity) + ")";
- }
- }
-
- public static StringBuilder toHexString(StringBuilder sb, final int i) {
- if(null==sb) {
- sb = new StringBuilder();
- }
- return sb.append("0x").append(Integer.toHexString(i));
- }
- public static String toHexString(final int i) {
- return "0x"+Integer.toHexString(i);
- }
-
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java
deleted file mode 100644
index c801ba463..000000000
--- a/src/jogl/classes/javax/media/opengl/GLDrawable.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl;
-
-import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
-import com.jogamp.nativewindow.NativeSurface;
-import com.jogamp.nativewindow.NativeSurfaceHolder;
-
-
-/** An abstraction for an OpenGL rendering target. A GLDrawable's
- primary functionality is to create OpenGL contexts which can be
- used to perform rendering. A GLDrawable does not automatically
- create an OpenGL context, but all implementations of {@link
- GLAutoDrawable} do so upon creation. */
-
-public interface GLDrawable extends NativeSurfaceHolder {
- /**
- * Creates a new context for drawing to this drawable that will
- * optionally share buffer objects, textures and other server-side OpenGL
- * objects with the specified GLContext.
- *
- * The GLContext share need not be associated with this
- * GLDrawable and may be null if sharing of display lists and other
- * objects is not desired. See the note in the overview
- * documentation
- * context sharing
- * as well as {@link GLSharedContextSetter}.
- *
- */
- public GLContext createContext(GLContext shareWith);
-
- /**
- * Indicates to GLDrawable implementations whether the
- * underlying {@link NativeSurface surface} has been created and can be drawn into.
- *
- * If realized, the {@link #getHandle() drawable handle} may become
- * valid while it's {@link NativeSurface surface} is being {@link NativeSurface#lockSurface() locked}.
- *
- *
- * End users do not need to call this method; it is not necessary to
- * call setRealized on a {@link GLAutoDrawable}
- * as these perform the appropriate calls on their underlying GLDrawables internally.
- *
- *
- * Developers implementing new OpenGL components for various window
- * toolkits need to call this method against GLDrawables obtained
- * from the GLDrawableFactory via the
- * {@link GLDrawableFactory#createGLDrawable(NativeSurface)} method.
- * It must typically be
- * called with an argument of true when the component
- * associated with the GLDrawable is realized and with an argument
- * of false just before the component is unrealized.
- * For the AWT, this means calling setRealized(true) in
- * the addNotify method and with an argument of
- * false in the removeNotify method.
- *
- *
- * GLDrawable implementations should handle multiple
- * cycles of setRealized(true) /
- * setRealized(false) calls. Most, if not all, Java
- * window toolkits have a persistent object associated with a given
- * component, regardless of whether that component is currently
- * realized. The GLDrawable object associated with a
- * particular component is intended to be similarly persistent. A
- * GLDrawable is intended to be created for a given
- * component when it is constructed and live as long as that
- * component. setRealized allows the
- * GLDrawable to re-initialize and destroy any
- * associated resources as the component becomes realized and
- * unrealized, respectively.
- *
- *
- * With an argument of true,
- * the minimum implementation shall call
- * {@link NativeSurface#lockSurface() NativeSurface's lockSurface()} and if successful:
- *
- *
Update the {@link GLCapabilities}, which are associated with
- * the attached {@link NativeSurface}'s {@link AbstractGraphicsConfiguration}.
- *
Release the lock with {@link NativeSurface#unlockSurface() NativeSurface's unlockSurface()}.
- *
- * This is important since {@link NativeSurface#lockSurface() NativeSurface's lockSurface()}
- * ensures resolving the window/surface handles, and the drawable's {@link GLCapabilities}
- * might have changed.
- *
- *
- * Calling this method has no other effects. For example, if
- * removeNotify is called on a Canvas implementation
- * for which a GLDrawable has been created, it is also necessary to
- * destroy all OpenGL contexts associated with that GLDrawable. This
- * is not done automatically by the implementation.
- *
- * @see #isRealized()
- * @see #getHandle()
- * @see NativeSurface#lockSurface()
- */
- public void setRealized(boolean realized);
-
- /**
- * Returns true if this drawable is realized, otherwise true.
- *
- * A drawable can be realized and unrealized via {@link #setRealized(boolean)}.
- *
- * @see #setRealized(boolean)
- */
- public boolean isRealized();
-
- /**
- * Returns the width of this {@link GLDrawable}'s {@link #getNativeSurface() surface} client area in pixel units.
- * @see NativeSurface#getSurfaceWidth()
- */
- public int getSurfaceWidth();
-
- /**
- * Returns the height of this {@link GLDrawable}'s {@link #getNativeSurface() surface} client area in pixel units.
- * @see NativeSurface#getSurfaceHeight()
- */
- public int getSurfaceHeight();
-
- /**
- * Returns true if the drawable is rendered in
- * OpenGL's coordinate system, origin at bottom left.
- * Otherwise returns false, i.e. origin at top left.
- *
- * Default impl. is true, i.e. OpenGL coordinate system.
- *
- *
- * Currently only MS-Windows bitmap offscreen drawable uses a non OpenGL orientation and hence returns false.
- * This removes the need of a vertical flip when used in AWT or Windows applications.
- *
- */
- public boolean isGLOriented();
-
- /** Swaps the front and back buffers of this drawable. For {@link
- GLAutoDrawable} implementations, when automatic buffer swapping
- is enabled (as is the default), this method is called
- automatically and should not be called by the end user. */
- public void swapBuffers() throws GLException;
-
- /** Fetches the {@link GLCapabilitiesImmutable} corresponding to the chosen
- OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
-
- This query only returns the chosen capabilities if {@link #isRealized()}.
-
-
- On some platforms, the pixel format is not directly associated
- with the drawable; a best attempt is made to return a reasonable
- value in this case.
-
-
- This object shall be directly associated to the attached {@link NativeSurface}'s
- {@link AbstractGraphicsConfiguration}, and if changes are necessary,
- they should reflect those as well.
-
- @return The immutable queried instance.
- @see #getRequestedGLCapabilities()
- */
- public GLCapabilitiesImmutable getChosenGLCapabilities();
-
- /** Fetches the {@link GLCapabilitiesImmutable} corresponding to the user requested
- OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
-
- If {@link #isRealized() realized}, {@link #getChosenGLCapabilities() the chosen capabilities}
- reflect the actual selected OpenGL capabilities.
-
- @return The immutable queried instance.
- @see #getChosenGLCapabilities()
- @since 2.2
- */
- public GLCapabilitiesImmutable getRequestedGLCapabilities();
-
- /** Fetches the {@link GLProfile} for this drawable.
- Returns the GLProfile object, no copy.
- */
- public GLProfile getGLProfile();
-
- /**
- * {@inheritDoc}
- *
- * Returns the underlying {@link NativeSurface} which {@link NativeSurface#getSurfaceHandle() native handle}
- * represents this OpenGL drawable's native resource.
- *
- *
- * @see #getHandle()
- */
- @Override
- public NativeSurface getNativeSurface();
-
- /**
- * Returns the GL drawable handle,
- * guaranteed to be valid after {@link #setRealized(boolean) realization}
- * and while it's {@link NativeSurface surface} is being {@link NativeSurface#lockSurface() locked}.
- *
- * It is usually identical to the underlying windowing toolkit {@link NativeSurface surface}'s
- * {@link com.jogamp.nativewindow.NativeSurface#getSurfaceHandle() handle}
- * or an intermediate layer to suite GL, e.g. an EGL surface.
- *
- *
- * On EGL it is represented by the EGLSurface.
- * On X11/GLX it is represented by either the Window XID, GLXPixmap, or GLXPbuffer.
- * On Windows it is represented by the HDC, which may change with each {@link NativeSurface#lockSurface()}.
- *
- * @see #setRealized(boolean)
- * @see NativeSurface#lockSurface()
- * @see NativeSurface#unlockSurface()
- */
- public long getHandle();
-
- /** Return the {@link GLDrawableFactory} being used to create this instance. */
- public GLDrawableFactory getFactory();
-
- @Override
- public String toString();
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
deleted file mode 100644
index 07c3e77e0..000000000
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ /dev/null
@@ -1,798 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.jogamp.common.util.PropertyAccess;
-import com.jogamp.common.util.ReflectionUtil;
-import com.jogamp.opengl.GLAutoDrawableDelegate;
-import com.jogamp.opengl.GLRendererQuirks;
-
-import com.jogamp.nativewindow.AbstractGraphicsDevice;
-import com.jogamp.nativewindow.AbstractGraphicsScreen;
-import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
-import com.jogamp.nativewindow.CapabilitiesImmutable;
-import com.jogamp.nativewindow.NativeSurface;
-import com.jogamp.nativewindow.NativeWindowFactory;
-import com.jogamp.nativewindow.ProxySurface;
-import com.jogamp.nativewindow.UpstreamSurfaceHook;
-
-import jogamp.opengl.Debug;
-
-/**
Provides a virtual machine- and operating system-independent
- mechanism for creating {@link GLDrawable}s.
-
-
The {@link com.jogamp.opengl.GLCapabilities} objects passed
- in to the various factory methods are used as a hint for the
- properties of the returned drawable. The default capabilities
- selection algorithm (equivalent to passing in a null {@link
- GLCapabilitiesChooser}) is described in {@link
- DefaultGLCapabilitiesChooser}. Sophisticated applications needing
- to change the selection algorithm may pass in their own {@link
- GLCapabilitiesChooser} which can select from the available pixel
- formats. The GLCapabilitiesChooser mechanism may not be supported
- by all implementations or on all platforms, in which case any
- passed GLCapabilitiesChooser will be ignored.
-
-
-
Because of the multithreaded nature of the Java platform's
- Abstract Window Toolkit, it is typically not possible to immediately
- reject a given {@link GLCapabilities} as being unsupportable by
- either returning null from the creation routines or
- raising a {@link GLException}. The semantics of the rejection
- process are (unfortunately) left unspecified for now. The current
- implementation will cause a {@link GLException} to be raised
- during the first repaint of the {@link com.jogamp.opengl.awt.GLCanvas} or {@link
- com.jogamp.opengl.awt.GLJPanel} if the capabilities can not be met.
- {@link GLOffscreenAutoDrawable} are created lazily,
- see {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) createOffscreenAutoDrawable(..)}.
-
-
-
The concrete GLDrawableFactory subclass instantiated by {@link
- #getFactory getFactory} can be changed by setting the system
- property opengl.factory.class.name to the
- fully-qualified name of the desired class.
-
-*/
-public abstract class GLDrawableFactory {
-
- protected static final boolean DEBUG = Debug.debug("GLDrawable");
-
- private static volatile boolean isInit = false;
- private static GLDrawableFactory eglFactory;
- private static GLDrawableFactory nativeOSFactory;
-
- private static ArrayList glDrawableFactories = new ArrayList();
-
- /**
- * Instantiate singleton factories if available, EGLES1, EGLES2 and the OS native ones.
- */
- public static final void initSingleton() {
- if (!isInit) { // volatile: ok
- synchronized (GLDrawableFactory.class) {
- if (!isInit) {
- isInit=true;
- initSingletonImpl();
- }
- }
- }
- }
- private static final void initSingletonImpl() {
- NativeWindowFactory.initSingleton();
- NativeWindowFactory.addCustomShutdownHook(false /* head */, new Runnable() {
- @Override
- public void run() {
- shutdown0();
- }
- });
-
- final String nwt = NativeWindowFactory.getNativeWindowType(true);
- GLDrawableFactory tmp = null;
- String factoryClassName = PropertyAccess.getProperty("jogl.gldrawablefactory.class.name", true);
- final ClassLoader cl = GLDrawableFactory.class.getClassLoader();
- if (null == factoryClassName) {
- if ( nwt == NativeWindowFactory.TYPE_X11 ) {
- factoryClassName = "jogamp.opengl.x11.glx.X11GLXDrawableFactory";
- } else if ( nwt == NativeWindowFactory.TYPE_WINDOWS ) {
- factoryClassName = "jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory";
- } else if ( nwt == NativeWindowFactory.TYPE_MACOSX ) {
- factoryClassName = "jogamp.opengl.macosx.cgl.MacOSXCGLDrawableFactory";
- } else {
- // may use egl*Factory ..
- if (DEBUG || GLProfile.DEBUG) {
- System.err.println("GLDrawableFactory.static - No native Windowing Factory for: "+nwt+"; May use EGLDrawableFactory, if available." );
- }
- }
- }
- if (null != factoryClassName && !GLProfile.disableOpenGLDesktop) {
- if (DEBUG || GLProfile.DEBUG) {
- System.err.println("GLDrawableFactory.static - Native OS Factory for: "+nwt+": "+factoryClassName);
- }
- try {
- tmp = (GLDrawableFactory) ReflectionUtil.createInstance(factoryClassName, cl);
- } catch (final Exception jre) {
- if (DEBUG || GLProfile.DEBUG) {
- System.err.println("Info: GLDrawableFactory.static - Native Platform: "+nwt+" - not available: "+factoryClassName);
- jre.printStackTrace();
- }
- }
- }
- if(null != tmp && tmp.isComplete()) {
- nativeOSFactory = tmp;
- }
- tmp = null;
-
- if(!GLProfile.disableOpenGLES) {
- try {
- tmp = (GLDrawableFactory) ReflectionUtil.createInstance("jogamp.opengl.egl.EGLDrawableFactory", cl);
- } catch (final Exception jre) {
- if (DEBUG || GLProfile.DEBUG) {
- System.err.println("Info: GLDrawableFactory.static - EGLDrawableFactory - not available");
- jre.printStackTrace();
- }
- }
- if(null != tmp && tmp.isComplete()) {
- eglFactory = tmp;
- }
- } else if( DEBUG || GLProfile.DEBUG ) {
- System.err.println("Info: GLDrawableFactory.static - EGLDrawableFactory - disabled!");
- }
- }
-
- protected static void shutdown() {
- if (isInit) { // volatile: ok
- synchronized (GLDrawableFactory.class) {
- if (isInit) {
- isInit=false;
- shutdown0();
- }
- }
- }
- }
-
- private static void shutdown0() {
- // Following code will _always_ remain in shutdown hook
- // due to special semantics of native utils, i.e. X11Utils.
- // The latter requires shutdown at JVM-Shutdown only.
- synchronized(glDrawableFactories) {
- final int gldfCount = glDrawableFactories.size();
- if( DEBUG ) {
- System.err.println("GLDrawableFactory.shutdownAll "+gldfCount+" instances, on thread "+getThreadName());
- }
- for(int i=0; isurface.
- *
- * This functionality is not available on all platforms and
- * graphics hardware. Returns true if the settings were successfully
- * changed, false if not. This method may return false for some
- * values of the incoming arguments even on hardware which does
- * support the underlying functionality.
- *
- * If this method returns true, the display settings will
- * automatically be reset to their original values upon JVM exit
- * (assuming the JVM does not crash); if the user wishes to change
- * the display settings back to normal ahead of time,
- * use {@link #resetDisplayGamma(NativeSurface)} or {@link #resetAllDisplayGamma()}.
- *
- *
- * It is recommended to call {@link #resetDisplayGamma(NativeSurface)} or {@link #resetAllDisplayGamma()}
- * before calling e.g. System.exit() from the application rather than
- * rely on the shutdown hook functionality due to inevitable race
- * conditions and unspecified behavior during JVM teardown.
- *
- *
- * This method may be called multiple times during the application's
- * execution, but calling {@link #resetDisplayGamma(NativeSurface)}
- * will only reset the settings to the values
- * before the first call to this method.
- *
- * @param surface denominates the display device
- * @param gamma The gamma value, typically > 1.0 (default values vary, but typically roughly 1.0)
- * @param brightness The brightness value between -1.0 and 1.0, inclusive (default values vary, but typically 0)
- * @param contrast The contrast, greater than 0.0 (default values vary, but typically 1)
- *
- * @return true if gamma settings were successfully changed, false if not
- * @throws IllegalArgumentException if any of the parameters were out-of-bounds
- * @see #resetDisplayGamma(NativeSurface)
- * @see #resetAllDisplayGamma()
- */
- public abstract boolean setDisplayGamma(final NativeSurface surface, final float gamma, final float brightness, final float contrast) throws IllegalArgumentException;
-
- /**
- * Resets the gamma, brightness and contrast values of the display associated with the given surface
- * to its original values before {@link #setDisplayGamma(NativeSurface, float, float, float) setDisplayGamma}
- * was called the first time.
- *
- * While it is not explicitly required that this method be called before
- * exiting manually, calling it is recommended because of the inevitable
- * unspecified behavior during JVM teardown.
- *
- */
- public abstract void resetDisplayGamma(final NativeSurface surface);
-
- /**
- * Resets the gamma, brightness and contrast values of all modified
- * displays to their original values before {@link #setDisplayGamma(NativeSurface, float, float, float) setDisplayGamma}
- * was called the first time.
- *
- * While it is not explicitly required that this method be called before
- * exiting manually, calling it is recommended because of the inevitable
- * unspecified behavior during JVM teardown.
- *
- */
- public abstract void resetAllDisplayGamma();
-
- protected abstract void resetAllDisplayGammaNoSync();
-
- /**
- * Retrieve the default device {@link AbstractGraphicsDevice#getConnection() connection},
- * {@link AbstractGraphicsDevice#getUnitID() unit ID} and {@link AbstractGraphicsDevice#getUniqueID() unique ID name}. for this factory
- * The implementation must return a non null default device, which must not be opened, ie. it's native handle is null.
- *
- * This method shall return the default device if available
- * even if the GLDrawableFactory is not functional and hence not compatible.
- * The latter situation may happen because no native OpenGL implementation is available for the specific implementation.
- *
- * @return the default shared device for this factory, eg. :0.0 on X11 desktop.
- * @see #getIsDeviceCompatible(AbstractGraphicsDevice)
- */
- public abstract AbstractGraphicsDevice getDefaultDevice();
-
- /**
- * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
- * @return true if the device is compatible with this factory, ie. if it can be used for GLDrawable creation. Otherwise false.
- * This implies validation whether the implementation is functional.
- *
- * @see #getDefaultDevice()
- */
- public abstract boolean getIsDeviceCompatible(AbstractGraphicsDevice device);
-
- protected final AbstractGraphicsDevice validateDevice(AbstractGraphicsDevice device) {
- if(null==device) {
- device = getDefaultDevice();
- if(null==device) {
- throw new InternalError("no default device available");
- }
- if (GLProfile.DEBUG) {
- System.err.println("Info: "+getClass().getSimpleName()+".validateDevice: using default device : "+device);
- }
- }
-
- // Always validate the device,
- // since even the default device may not be used by this factory.
- if( !getIsDeviceCompatible(device) ) {
- if (GLProfile.DEBUG) {
- System.err.println("Info: "+getClass().getSimpleName()+".validateDevice: device not compatible : "+device);
- }
- return null;
- }
- return device;
- }
-
- /**
- * Validate and start the shared resource runner thread if necessary and
- * if the implementation uses it.
- *
- * @return the shared resource runner thread, if implementation uses it.
- */
- protected abstract Thread getSharedResourceThread();
-
- /**
- * Create the shared resource used internally as a reference for capabilities etc.
- *
- * Returns true if a shared resource could be created
- * for the device {@link AbstractGraphicsDevice#getConnection()}.
- * This does not imply a shared resource is mapped (ie. made persistent), but is available in general .
- *
- *
- * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
- * @return true if a shared resource could been created, otherwise false.
- */
- protected final boolean createSharedResource(final AbstractGraphicsDevice device) {
- return createSharedResourceImpl(device);
- }
- protected abstract boolean createSharedResourceImpl(AbstractGraphicsDevice device);
-
- /**
- * Returns true if the quirk exist in the shared resource's context {@link GLRendererQuirks}.
- *
- *
- *
- * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
- * @param glp {@link GLProfile} to identify the device's {@link GLRendererQuirks}, maybe {@code null}
- * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}.
- * @throws IllegalArgumentException if the quirk is out of range
- * @see #getRendererQuirks(AbstractGraphicsDevice, GLProfile)
- * @see GLRendererQuirks
- */
- public final boolean hasRendererQuirk(final AbstractGraphicsDevice device, final GLProfile glp, final int quirk) {
- final GLRendererQuirks glrq = getRendererQuirks(device, glp);
- return null != glrq ? glrq.exist(quirk) : false;
- }
-
- /**
- * Returns the shared resource's context {@link GLRendererQuirks}.
- *
- * Implementation calls {@link GLContext#getRendererQuirks()} on the shared resource context.
- *
- *
- * In case no shared device exist yet or the implementation doesn't support tracking quirks,
- * the result is always null.
- *
- * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
- * @param glp {@link GLProfile} to identify the device's {@link GLRendererQuirks}, maybe {@code null}
- * @see GLContext#getRendererQuirks()
- * @see GLRendererQuirks
- */
- public abstract GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device, final GLProfile glp);
-
- /**
- * Returns the sole GLDrawableFactory instance for the desktop (X11, WGL, ..) if exist or null
- */
- public static GLDrawableFactory getDesktopFactory() {
- GLProfile.initSingleton();
- return nativeOSFactory;
- }
-
- /**
- * Returns the sole GLDrawableFactory instance for EGL if exist or null
- */
- public static GLDrawableFactory getEGLFactory() {
- GLProfile.initSingleton();
- return eglFactory;
- }
-
- /**
- * Returns the sole GLDrawableFactory instance.
- *
- * @param glProfile GLProfile to determine the factory type, ie EGLDrawableFactory,
- * or one of the native GLDrawableFactory's, ie X11/GLX, Windows/WGL or MacOSX/CGL.
- */
- public static GLDrawableFactory getFactory(final GLProfile glProfile) throws GLException {
- return getFactoryImpl(glProfile.getImplName());
- }
-
- protected static GLDrawableFactory getFactoryImpl(final String glProfileImplName) throws GLException {
- if ( GLProfile.usesNativeGLES(glProfileImplName) ) {
- if(null!=eglFactory) {
- return eglFactory;
- }
- } else if(null!=nativeOSFactory) {
- return nativeOSFactory;
- }
- throw new GLException("No GLDrawableFactory available for profile: "+glProfileImplName);
- }
-
- protected static GLDrawableFactory getFactoryImpl(final AbstractGraphicsDevice device) throws GLException {
- if(null != nativeOSFactory && nativeOSFactory.getIsDeviceCompatible(device)) {
- return nativeOSFactory;
- }
- if(null != eglFactory && eglFactory.getIsDeviceCompatible(device)) {
- return eglFactory;
- }
- throw new GLException("No native platform GLDrawableFactory, nor EGLDrawableFactory available: "+device);
- }
-
- /**
- * Returns an array of available GLCapabilities for the device.
- * The list is sorted by the native ID, ascending.
- * The chosen GLProfile statement in the result may not refer to the maximum available profile
- * due to implementation constraints, ie using the shared resource.
- *
- * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
- * @return A list of {@link com.jogamp.opengl.GLCapabilitiesImmutable}'s, maybe empty if none is available.
- */
- public final List getAvailableCapabilities(AbstractGraphicsDevice device) {
- device = validateDevice(device);
- if(null!=device) {
- return getAvailableCapabilitiesImpl(device);
- }
- return null;
- }
- protected abstract List getAvailableCapabilitiesImpl(AbstractGraphicsDevice device);
-
- //----------------------------------------------------------------------
- // Methods to create high-level objects
-
- /**
- * Returns an {@link GLDrawable#isRealized() unrealized} GLDrawable according to it's chosen {@link GLCapabilitiesImmutable},
- * which determines pixel format, on- and offscreen incl. PBuffer type.
- *
- * The chosen {@link GLCapabilitiesImmutable} are referenced within the target
- * {@link NativeSurface}'s {@link AbstractGraphicsConfiguration}.
- *
- *
- * An onscreen GLDrawable is created if {@link CapabilitiesImmutable#isOnscreen() caps.isOnscreen()} is true.
- *
- *
- * A FBO drawable is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()}
- * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true.
- *
- *
- * A Pbuffer drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()}
- * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true.
- *
- *
- * If not onscreen and neither FBO nor Pbuffer is available,
- * a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated.
- *
- *
- * @throws IllegalArgumentException if the passed target is null
- * @throws GLException if any window system-specific errors caused
- * the creation of the GLDrawable to fail.
- *
- * @see #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile)
- * @see GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile)
- * @see com.jogamp.opengl.GLCapabilities#isOnscreen()
- * @see com.jogamp.opengl.GLCapabilities#isFBO()
- * @see com.jogamp.opengl.GLCapabilities#isPBuffer()
- * @see GraphicsConfigurationFactory#chooseGraphicsConfiguration(CapabilitiesImmutable, CapabilitiesImmutable, CapabilitiesChooser, AbstractGraphicsScreen, int)
- */
- public abstract GLDrawable createGLDrawable(NativeSurface target)
- throws IllegalArgumentException, GLException;
-
- /**
- * Creates a {@link GLDrawable#isRealized() realized} {@link GLOffscreenAutoDrawable}
- * incl it's offscreen {@link NativeSurface} with the given capabilites and dimensions.
- *
- * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized}
- * without an assigned {@link GLContext}, hence not initialized completely.
- *
- * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)}
- * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
- *
- * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account
- * which has been set {@link GLOffscreenAutoDrawable#setSharedContext(GLContext) directly}
- * or {@link GLOffscreenAutoDrawable#setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}.
- *
- *
- * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e.
- * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true,
- * it is auto-configured. Auto configuration will set {@link GLCapabilitiesImmutable caps} to offscreen
- * and FBO or Pbuffer, whichever is available in that order.
- *
- *
- * A FBO based auto drawable, {@link GLOffscreenAutoDrawable.FBO}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()}
- * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true.
- *
- *
- * A Pbuffer based auto drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()}
- * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true.
- *
- *
- * If neither FBO nor Pbuffer is available,
- * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated.
- *
- *
- * The resulting {@link GLOffscreenAutoDrawable} has it's own independent device instance using device details.
- *
- *
- * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device.
- * @param caps the requested GLCapabilties
- * @param chooser the custom chooser, may be null for default
- * @param width the requested offscreen width
- * @param height the requested offscreen height
- * @return the created and realized offscreen {@link GLOffscreenAutoDrawable} instance
- *
- * @throws GLException if any window system-specific errors caused
- * the creation of the Offscreen to fail.
- *
- * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int)
- */
- public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device,
- GLCapabilitiesImmutable caps,
- GLCapabilitiesChooser chooser,
- int width, int height) throws GLException;
-
- /**
- * Creates a {@link GLDrawable#isRealized() realized} dummy {@link GLAutoDrawable}
- * incl it's dummy, invisible {@link NativeSurface}
- * as created with {@link #createDummyDrawable(AbstractGraphicsDevice, boolean, GLCapabilitiesImmutable, GLCapabilitiesChooser)}.
- *
- * The dummy {@link GLAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized}
- * without an assigned {@link GLContext}, hence not initialized completely.
- * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)}
- * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
- * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account
- * which has been set {@link GLOffscreenAutoDrawable#setSharedContext(GLContext) directly}
- * or {@link GLOffscreenAutoDrawable#setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}.
- *
- *
- * @param deviceReq which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device.
- * @param createNewDevice if true a new independent device instance is created from the deviceReq, otherwise deviceReq is used as-is and must be valid!
- * @param capsRequested the desired {@link GLCapabilitiesImmutable}, incl. it's {@link GLProfile}.
- * For shared context, same {@link GLCapabilitiesImmutable#getVisualID(com.jogamp.nativewindow.VisualIDHolder.VIDType)}
- * across shared drawables will yield best compatibility.
- * @param chooser the custom chooser, may be null for default
- * @return the created and realized dummy {@link GLAutoDrawable} instance
- *
- * @see #createDummyDrawable(AbstractGraphicsDevice, boolean, GLCapabilitiesImmutable, GLCapabilitiesChooser)
- */
- public abstract GLAutoDrawable createDummyAutoDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser);
-
- /**
- * Creates an {@link GLDrawable#isRealized() unrealized} offscreen {@link GLDrawable}
- * incl it's offscreen {@link NativeSurface} with the given capabilites and dimensions.
- *
- * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e.
- * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true,
- * it is auto-configured. The latter will set offscreen and also FBO or Pbuffer, whichever is available in that order.
- *
- *
- * A resizeable FBO drawable, {@link GLFBODrawable.Resizeable}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()}
- * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true.
- *
- *
- * A Pbuffer drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()}
- * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true.
- *
- *
- * If neither FBO nor Pbuffer is available,
- * a simple pixmap/bitmap drawable is created, which is unlikely to be hardware accelerated.
- *
- *
- * The resulting {@link GLDrawable} has it's own independent device instance using device details.
- *
- *
- * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device.
- * @param caps the requested GLCapabilties
- * @param chooser the custom chooser, may be null for default
- * @param width the requested offscreen width
- * @param height the requested offscreen height
- *
- * @return the created unrealized offscreen {@link GLDrawable}
- *
- * @throws GLException if any window system-specific errors caused
- * the creation of the Offscreen to fail.
- *
- * @see #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext)
- */
- public abstract GLDrawable createOffscreenDrawable(AbstractGraphicsDevice device,
- GLCapabilitiesImmutable caps,
- GLCapabilitiesChooser chooser,
- int width, int height) throws GLException;
-
- /**
- * Creates an {@link GLDrawable#isRealized() unrealized} dummy {@link GLDrawable}.
- * A dummy drawable is not visible on screen and will not be used to render directly to, it maybe on- or offscreen.
- *
- * It is used to allow the creation of a {@link GLContext} to query information.
- * It also allows creation of framebuffer objects which are used for rendering or creating a shared GLContext w/o actually rendering to this dummy drawable's framebuffer.
- *
- * @param deviceReq which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device.
- * @param createNewDevice if true a new independent device instance is created from the deviceReq, otherwise deviceReq is used as-is and must be valid!
- * @param capsRequested the desired {@link GLCapabilitiesImmutable}, incl. it's {@link GLProfile}.
- * For shared context, same {@link GLCapabilitiesImmutable#getVisualID(com.jogamp.nativewindow.VisualIDHolder.VIDType) visual ID}
- * or {@link GLCapabilitiesImmutable caps}
- * across shared drawables will yield best compatibility.
- * @param chooser the custom chooser, may be null for default
- * @return the created unrealized dummy {@link GLDrawable}
- */
- public abstract GLDrawable createDummyDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser);
-
- /**
- * Creates a proxy {@link NativeSurface} w/ defined surface handle,
- * i.e. a {@link jogamp.nativewindow.WrappedSurface} or {@link jogamp.nativewindow.windows.GDISurface} instance.
- *
- * It's {@link AbstractGraphicsConfiguration} is properly set according to the given
- * windowHandle's native visualID if set or the given {@link GLCapabilitiesImmutable}.
- *
- *
- * Lifecycle (creation and destruction) of the given surface handle shall be handled by the caller
- * via {@link ProxySurface#createNotify()} and {@link ProxySurface#destroyNotify()}.
- *
- *
- * Such surface can be used to instantiate a GLDrawable. With the help of {@link GLAutoDrawableDelegate}
- * you will be able to implement a new native windowing system binding almost on-the-fly,
- * see {@link com.jogamp.opengl.swt.GLCanvas}.
- *
- *
- * The resulting {@link GLOffscreenAutoDrawable} has it's own independent device instance using device details
- * which may be blocking depending on platform and windowing-toolkit requirements.
- *
- *
- * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
- * Caller has to ensure it is compatible w/ the given windowHandle
- * @param screenIdx matching screen index of given windowHandle
- * @param windowHandle the native window handle
- * @param caps the requested GLCapabilties
- * @param chooser the custom chooser, may be null for default
- * @param upstream optional {@link UpstreamSurfaceHook} allowing control of the {@link ProxySurface}'s lifecycle and data it presents.
- * @return the created {@link ProxySurface} instance w/ defined surface handle.
- */
- public abstract ProxySurface createProxySurface(AbstractGraphicsDevice device,
- int screenIdx,
- long windowHandle,
- GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream);
-
- /**
- * Returns true if it is possible to create an framebuffer object (FBO).
- *
- * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent.
- *
- *
- * FBO support is queried as described in {@link GLContext#hasBasicFBOSupport()}.
- *
- *
- * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
- * @param glp {@link GLProfile} to check for FBO capabilities
- * @see GLContext#hasBasicFBOSupport()
- */
- public abstract boolean canCreateFBO(AbstractGraphicsDevice device, GLProfile glp);
-
- /**
- * Returns true if it is possible to create an pbuffer surface.
- *
- * Some older graphics cards do not have this capability,
- * as well as some new GL implementation, i.e. OpenGL 3 core on OSX.
- *
- *
- * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
- * @param glp {@link GLProfile} to check for FBO capabilities
- */
- public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device, GLProfile glp);
-
- //----------------------------------------------------------------------
- // Methods for interacting with third-party OpenGL libraries
-
- /**
- *
Creates a GLContext object representing an existing OpenGL
- * context in an external (third-party) OpenGL-based library. This
- * GLContext object may be used to draw into this preexisting
- * context using its {@link GL} and {@link
- * com.jogamp.opengl.glu.GLU} objects. New contexts created through
- * {@link GLDrawable}s may share textures and display lists with
- * this external context.
- *
- *
The underlying OpenGL context must be current on the current
- * thread at the time this method is called. The user is responsible
- * for the maintenance of the underlying OpenGL context; calls to
- * makeCurrent and release on the returned
- * GLContext object have no effect. If the underlying OpenGL context
- * is destroyed, the destroy method should be called on
- * the GLContext. A new GLContext object
- * should be created for each newly-created underlying OpenGL
- * context.
- *
- * @throws GLException if any window system-specific errors caused
- * the creation of the external GLContext to fail.
- */
- public abstract GLContext createExternalGLContext()
- throws GLException;
-
- /**
- * Returns true if it is possible to create an external GLDrawable
- * object via {@link #createExternalGLDrawable}.
- *
- * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device.
- */
- public abstract boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device);
-
- /**
- *
Creates a {@link GLDrawable} object representing an existing
- * OpenGL drawable in an external (third-party) OpenGL-based
- * library. This GLDrawable object may be used to create new,
- * fully-functional {@link GLContext}s on the OpenGL drawable. This
- * is useful when interoperating with a third-party OpenGL-based
- * library and it is essential to not perturb the state of the
- * library's existing context, even to the point of not sharing
- * textures or display lists with that context.
- *
- *
An underlying OpenGL context must be current on the desired
- * drawable and the current thread at the time this method is
- * called. The user is responsible for the maintenance of the
- * underlying drawable. If one or more contexts are created on the
- * drawable using {@link GLDrawable#createContext}, and the drawable
- * is deleted by the third-party library, the user is responsible
- * for calling {@link GLContext#destroy} on these contexts.
- *
- *
Calls to setSize, getWidth and
- * getHeight are illegal on the returned GLDrawable. If
- * these operations are required by the user, they must be performed
- * by the third-party library.
- *
- *
It is legal to create both an external GLContext and
- * GLDrawable representing the same third-party OpenGL entities.
- * This can be used, for example, to query current state information
- * using the external GLContext and then create and set up new
- * GLContexts using the external GLDrawable.
- *
- *
This functionality may not be available on all platforms and
- * {@link #canCreateExternalGLDrawable} should be called first to
- * see if it is present. For example, on X11 platforms, this API
- * requires the presence of GLX 1.3 or later.
- *
- * @throws GLException if any window system-specific errors caused
- * the creation of the external GLDrawable to fail.
- */
- public abstract GLDrawable createExternalGLDrawable()
- throws GLException;
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLEventListener.java b/src/jogl/classes/javax/media/opengl/GLEventListener.java
deleted file mode 100644
index 8c5dfd3b3..000000000
--- a/src/jogl/classes/javax/media/opengl/GLEventListener.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl;
-
-import java.util.EventListener;
-
-/** Declares events which client code can use to manage OpenGL
- rendering into a {@link GLAutoDrawable}. At the time any of these
- methods is called, the drawable has made its associated OpenGL
- context current, so it is valid to make OpenGL calls. */
-
-public interface GLEventListener extends EventListener {
- /** Called by the drawable immediately after the OpenGL context is
- initialized. Can be used to perform one-time OpenGL
- initialization per GLContext, such as setup of lights and display lists.
-
- Note that this method may be called more than once if the underlying
- OpenGL context for the GLAutoDrawable is destroyed and
- recreated, for example if a GLCanvas is removed from the widget
- hierarchy and later added again.
- */
- public void init(GLAutoDrawable drawable);
-
- /** Notifies the listener to perform the release of all OpenGL
- resources per GLContext, such as memory buffers and GLSL programs.
-
- Called by the drawable before the OpenGL context is
- destroyed by an external event, like a reconfiguration of the
- {@link GLAutoDrawable} closing an attached window,
- but also manually by calling {@link GLAutoDrawable#destroy destroy}.
-
- Note that this event does not imply the end of life of the application.
- It could be produced with a followup call to {@link #init(GLAutoDrawable)}
- in case the GLContext has been recreated,
- e.g. due to a pixel configuration change in a multihead environment.
- */
- public void dispose(GLAutoDrawable drawable);
-
- /** Called by the drawable to initiate OpenGL rendering by the
- client. After all GLEventListeners have been notified of a
- display event, the drawable will swap its buffers if {@link
- GLAutoDrawable#setAutoSwapBufferMode setAutoSwapBufferMode} is
- enabled. */
- public void display(GLAutoDrawable drawable);
-
- /**
- * Called by the drawable during the first repaint after the
- * component has been resized.
- *
- * The client can update it's viewport associated data
- * and view volume of the window appropriately.
- *
- *
- * For efficiency the GL viewport has already been updated
- * via glViewport(x, y, width, height) when this method is called.
- *
- *
- * @param drawable the triggering {@link GLAutoDrawable}
- * @param x viewport x-coord in pixel units
- * @param y viewport y-coord in pixel units
- * @param width viewport width in pixel units
- * @param height viewport height in pixel units
- */
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height);
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLException.java b/src/jogl/classes/javax/media/opengl/GLException.java
deleted file mode 100644
index 843934ab2..000000000
--- a/src/jogl/classes/javax/media/opengl/GLException.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2014 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl;
-
-/** A generic exception for OpenGL errors used throughout the binding
- as a substitute for {@link RuntimeException}. */
-@SuppressWarnings("serial")
-public class GLException extends RuntimeException {
- /** Constructs a GLException object. */
- public GLException() {
- super();
- }
-
- /** Constructs a GLException object with the specified detail
- message. */
- public GLException(final String message) {
- super(message);
- }
-
- /** Constructs a GLException object with the specified detail
- message and root cause. */
- public GLException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- /** Constructs a GLException object with the specified root
- cause. */
- public GLException(final Throwable cause) {
- super(cause);
- }
-
- /**
- * Constructs a GLException object with the specified root
- * cause with a decorating message including the current thread name.
- * @since 2.2
- */
- public static GLException newGLException(final Throwable t) {
- return new GLException("Caught "+t.getClass().getSimpleName()+": "+t.getMessage()+" on thread "+Thread.currentThread().getName(), t);
- }
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java
deleted file mode 100644
index 69358743e..000000000
--- a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/**
- * Copyright 2012 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl;
-
-import com.jogamp.nativewindow.NativeWindowException;
-
-import com.jogamp.opengl.FBObject;
-import com.jogamp.opengl.FBObject.Colorbuffer;
-import com.jogamp.opengl.FBObject.ColorAttachment;
-import com.jogamp.opengl.FBObject.TextureAttachment;
-import com.jogamp.opengl.GLRendererQuirks;
-
-/**
- * Platform-independent {@link GLDrawable} specialization,
- * exposing {@link FBObject} functionality.
- *
- *
- * A {@link GLFBODrawable} is uninitialized until a {@link GLContext} is bound
- * and made current the first time, hence only then it's capabilities fully reflect expectations,
- * i.e. color, depth, stencil and MSAA bits will be valid only after the first {@link GLContext#makeCurrent() makeCurrent()} call.
- * On-/offscreen bits are valid after {@link #setRealized(boolean) setRealized(true)}.
- *
- *
- *
- * MSAA is used if {@link GLCapabilitiesImmutable#getNumSamples() requested}.
- *
- *
- * Double buffering is used if {@link GLCapabilitiesImmutable#getDoubleBuffered() requested}.
- *
- *
- * In MSAA mode, it always uses the implicit 2nd {@link FBObject framebuffer} {@link FBObject#getSamplingSinkFBO() sink}.
- * Hence double buffering is always the case w/ MSAA.
- *
- *
- * In non MSAA a second explicit {@link FBObject framebuffer} is being used.
- * This method allows compliance w/ the spec, i.e. read and draw framebuffer selection
- * and double buffer usage for e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)}.
- * This method also allows usage of both textures seperately.
- *
- *
- * It would be possible to implement double buffering simply using
- * {@link Colorbuffer}s with one {@link FBObject framebuffer}.
- * This would require mode selection and hence complicate the API. Besides, it would
- * not support differentiation of read and write framebuffer and hence not be spec compliant.
- *
- *
- * Actual swapping of the {@link Colorbuffer}s and/or {@link FBObject framebuffer}
- * is performed either in the {@link jogamp.opengl.GLContextImpl#contextMadeCurrent(boolean) context current hook}
- * or when {@link jogamp.opengl.GLDrawableImpl#swapBuffersImpl(boolean) swapping buffers}, whatever comes first.
- *
- */
-public interface GLFBODrawable extends GLDrawable {
- // public enum DoubleBufferMode { NONE, TEXTURE, FBO }; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support
-
- /** FBO Mode Bit: Use a {@link TextureAttachment} for the {@link #getColorbuffer(int) render colorbuffer}, see {@link #setFBOMode(int)}. */
- public static final int FBOMODE_USE_TEXTURE = 1 << 0;
-
- /**
- * @return true if initialized, i.e. a {@link GLContext} is bound and made current once, otherwise false.
- */
- public boolean isInitialized();
-
- /**
- * Set the FBO mode bits used for FBO creation.
- *
- * Default value is: {@link #FBOMODE_USE_TEXTURE}.
- *
- *
- * If {@link GLRendererQuirks#BuggyColorRenderbuffer} is set,
- * {@link #FBOMODE_USE_TEXTURE} is always added at initialization.
- *
- *
- * @param modeBits custom FBO mode bits like {@link #FBOMODE_USE_TEXTURE}.
- * @throws IllegalStateException if already initialized, see {@link #isInitialized()}.
- */
- void setFBOMode(final int modeBits) throws IllegalStateException;
-
- /**
- * @return the used FBO mode bits, mutable via {@link #setFBOMode(int)}
- */
- int getFBOMode();
-
- /**
- * Notify this instance about upstream size change
- * to reconfigure the {@link FBObject}.
- * @param gl GL context object bound to this drawable, will be made current during operation.
- * A prev. current context will be make current after operation.
- * @throws GLException if resize operation failed
- */
- void resetSize(final GL gl) throws GLException;
-
- /**
- * @return the used texture unit
- */
- int getTextureUnit();
-
- /**
- *
- * @param unit the texture unit to be used
- */
- void setTextureUnit(final int unit);
-
- /**
- * Set the number of sample buffers if using MSAA
- *
- * @param gl GL context object bound to this drawable, will be made current during operation.
- * A prev. current context will be make current after operation.
- * @param newSamples new sample size
- * @throws GLException if resetting the FBO failed
- */
- void setNumSamples(final GL gl, final int newSamples) throws GLException;
-
- /**
- * @return the number of sample buffers if using MSAA, otherwise 0
- */
- int getNumSamples();
-
- /**
- * Sets the number of buffers (FBO) being used if using {@link GLCapabilities#getDoubleBuffered() double buffering}.
- *
- * If {@link GLCapabilities#getDoubleBuffered() double buffering} is not chosen, this is a NOP.
- *
- *
- * Must be called before {@link #isInitialized() initialization}, otherwise an exception is thrown.
- *
- * @return the new number of buffers (FBO) used, maybe different than the requested bufferCount (see above)
- * @throws IllegalStateException if already initialized, see {@link #isInitialized()}.
- */
- int setNumBuffers(final int bufferCount) throws IllegalStateException, GLException;
-
- /**
- * @return the number of buffers (FBO) being used. 1 if not using {@link GLCapabilities#getDoubleBuffered() double buffering},
- * otherwise ≥ 2, depending on {@link #setNumBuffers(int)}.
- */
- int getNumBuffers();
-
- /**
- * @return the used {@link DoubleBufferMode}
- */
- // DoubleBufferMode getDoubleBufferMode(); // TODO: Add or remove TEXTURE (only) DoubleBufferMode support
-
- /**
- * Sets the {@link DoubleBufferMode}. Must be called before {@link #isInitialized() initialization},
- * otherwise an exception is thrown.
- *
- * This call has no effect is MSAA is selected, since MSAA always forces the mode to {@link DoubleBufferMode#FBO FBO}.
- * Also setting the mode to {@link DoubleBufferMode#NONE NONE} where double buffering is {@link GLCapabilitiesImmutable#getDoubleBuffered() requested}
- * or setting a double buffering mode w/o {@link GLCapabilitiesImmutable#getDoubleBuffered() request} will be ignored.
- *
- *
- * Since {@link DoubleBufferMode#TEXTURE TEXTURE} mode is currently not implemented, this method has no effect.
- *
- * @throws GLException if already initialized, see {@link #isInitialized()}.
- */
- // void setDoubleBufferMode(DoubleBufferMode mode) throws GLException; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support
-
- /**
- * If MSAA is being used and {@link GL#GL_FRONT} is requested,
- * the internal {@link FBObject} {@link FBObject#getSamplingSinkFBO() sample sink} is being returned.
- *
- * @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names
- * @return the named {@link FBObject}
- * @throws IllegalArgumentException if an illegal buffer name is being used
- */
- FBObject getFBObject(final int bufferName) throws IllegalArgumentException;
-
- /**
- * Returns the named {@link Colorbuffer} instance.
- *
- * If MSAA is being used, only the {@link GL#GL_FRONT} buffer is accessible
- * and an exception is being thrown if {@link GL#GL_BACK} is being requested.
- *
- *
- * Depending on the {@link #setFBOMode(int) fbo mode} the resulting {@link Colorbuffer}
- * is either a {@link TextureAttachment} if {@link #FBOMODE_USE_TEXTURE} is set,
- * otherwise a {@link ColorAttachment}.
- * See {@link Colorbuffer#isTextureAttachment()}.
- *
- * @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names
- * @return the named {@link Colorbuffer}
- * @throws IllegalArgumentException if using MSAA and {@link GL#GL_BACK} is requested or an illegal buffer name is being used
- */
- Colorbuffer getColorbuffer(final int bufferName) throws IllegalArgumentException;
-
- /** Resizeable {@link GLFBODrawable} specialization */
- public interface Resizeable extends GLFBODrawable {
- /**
- * Resize this {@link GLFBODrawable}'s surface.
- *
- * This drawable is being locked during operation.
- *
- * @param context the {@link GLContext} bound to this drawable, will be made current during operation
- * A prev. current context will be make current after operation.
- * @param newWidth new width in pixel units
- * @param newHeight new width in pixel units
- * @throws NativeWindowException in case the surface could no be locked
- * @throws GLException in case an error during the resize operation occurred
- */
- void setSurfaceSize(GLContext context, int newWidth, int newHeight) throws NativeWindowException, GLException;
- }
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java
deleted file mode 100644
index a2d0f5fdb..000000000
--- a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright 2012 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl;
-
-import com.jogamp.nativewindow.NativeWindowException;
-
-import com.jogamp.opengl.FBObject;
-
-/**
- * Platform-independent {@link GLAutoDrawable} specialization,
- * exposing offscreen functionality.
- *
- * This class distinguishes itself from {@link GLAutoDrawable}
- * with it's {@link #setSurfaceSize(int, int)} functionality.
- *
- * To share a {@link GLContext} see the following note in the documentation overview:
- * context sharing
- * as well as {@link GLSharedContextSetter}.
- *
- */
-public interface GLOffscreenAutoDrawable extends GLAutoDrawable, GLSharedContextSetter {
-
- /**
- * Resize this {@link GLAutoDrawable}'s surface
- * @param newWidth new width in pixel units
- * @param newHeight new height in pixel units
- * @throws NativeWindowException in case the surface could no be locked
- * @throws GLException in case of an error during the resize operation
- */
- void setSurfaceSize(int newWidth, int newHeight) throws NativeWindowException, GLException;
-
- /**
- * Set the upstream UI toolkit object.
- * @see #getUpstreamWidget()
- */
- void setUpstreamWidget(Object newUpstreamWidget);
-
- /** {@link FBObject} based {@link GLOffscreenAutoDrawable} specialization */
- public interface FBO extends GLOffscreenAutoDrawable, GLFBODrawable {
- }
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java
deleted file mode 100644
index 8d8b0428b..000000000
--- a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- */
-
-package com.jogamp.opengl;
-
-import java.lang.reflect.*;
-import java.util.StringTokenizer;
-
-import com.jogamp.common.util.ReflectionUtil;
-
-import jogamp.opengl.*;
-
-/**
- * Factory for pipelining GL instances
- */
-public class GLPipelineFactory {
- public static final boolean DEBUG = Debug.debug("GLPipelineFactory");
-
- /**
- * Creates a pipelined GL instance using the given downstream downstream
- * and optional arguments additionalArgs for the constructor.
- *
- *
- * Sample code which installs a Debug and Trace pipeline
- * automatic w/ user defined interface, here: GL2ES2:
- *
- * The upstream GL instance is determined as follows:
- *
- *
Use pipelineClazzBaseName as the class name's full basename, incl. package name
- *
For the downstream class and it's superclasses, do:
- *
- *
For all downstream class and superclass interfaces, do:
- *
- *
If reqInterface is not null and the interface is unequal, continue loop.
- *
If downstream is not instance of interface, continue loop.
- *
If upstream class is available use it, end loop.
- *
- *
- *
- *
- *
- * @param pipelineClazzBaseName the basename of the pipline class name
- * @param reqInterface optional requested interface to be used, may be null, in which case the first matching one is used
- * @param downstream is always the 1st argument for the upstream constructor
- * @param additionalArgs additional arguments for the upstream constructor
- */
- public static final GL create(final String pipelineClazzBaseName, final Class> reqInterface, final GL downstream, final Object[] additionalArgs) {
- Class> downstreamClazz = downstream.getClass();
- Class> upstreamClazz = null;
- Class> interfaceClazz = null;
-
- if(DEBUG) {
- System.out.println("GLPipelineFactory: Start "+downstreamClazz.getName()+", req. Interface: "+reqInterface+" -> "+pipelineClazzBaseName);
- }
-
- // For all classes: child -> parent
- do {
- // For all interfaces: right -> left == child -> parent
- // It is important that this matches with the gluegen cfg file's 'Implements' clause !
- final Class>[] clazzes = downstreamClazz.getInterfaces();
- for(int i=clazzes.length-1; null==upstreamClazz && i>=0; i--) {
- if(DEBUG) {
- System.out.println("GLPipelineFactory: Try "+downstreamClazz.getName()+" Interface["+i+"]: "+clazzes[i].getName());
- }
- if( reqInterface != null && !reqInterface.getName().equals(clazzes[i].getName()) ) {
- if(DEBUG) {
- System.out.println("GLPipelineFactory: requested Interface "+reqInterface+" is _not_ "+ clazzes[i].getName());
- }
- continue; // not the requested one ..
- }
- if( ! clazzes[i].isInstance(downstream) ) {
- if(DEBUG) {
- System.out.println("GLPipelineFactory: "+downstream.getClass().getName() + " is _not_ instance of "+ clazzes[i].getName());
- }
- continue; // not a compatible one
- } else {
- if(DEBUG) {
- System.out.println("GLPipelineFactory: "+downstream.getClass().getName() + " _is_ instance of "+ clazzes[i].getName());
- }
- }
- upstreamClazz = getUpstreamClazz(clazzes[i], pipelineClazzBaseName);
- if( null != upstreamClazz ) {
- interfaceClazz = clazzes[i];
- }
- }
-
- if(null==upstreamClazz) {
- downstreamClazz = downstreamClazz.getSuperclass();
- }
- } while (null!=downstreamClazz && null==upstreamClazz);
-
-
- if(null==upstreamClazz) {
- throw new GLException("No pipeline ("+pipelineClazzBaseName+"*) available for :"+downstream.getClass().getName());
- }
-
- if(DEBUG) {
- System.out.println("GLPipelineFactory: Got : "+ upstreamClazz.getName()+", base interface: "+interfaceClazz.getName());
- }
-
- final Class>[] cstrArgTypes = new Class>[ 1 + ( ( null==additionalArgs ) ? 0 : additionalArgs.length ) ] ;
- {
- int i = 0;
- cstrArgTypes[i++] = interfaceClazz;
- for(int j=0; null!=additionalArgs && j cstr = ReflectionUtil.getConstructor(upstreamClazz, cstrArgTypes);
- Object instance = null;
- try {
- final Object[] cstrArgs = new Object[ 1 + ( ( null==additionalArgs ) ? 0 : additionalArgs.length ) ] ;
- {
- int i = 0;
- cstrArgs[i++] = downstream;
- for(int j=0; null!=additionalArgs && j arg0, final Object[] args) {
- final StringBuilder sb = new StringBuilder();
- sb.append(arg0.getName());
- if(args!=null) {
- for(int j=0; j getUpstreamClazz(final Class> downstreamClazz, final String pipelineClazzBaseName) {
- final String downstreamClazzName = downstreamClazz.getName();
-
- final StringTokenizer st = new StringTokenizer(downstreamClazzName, ".");
- String downstreamClazzBaseName = downstreamClazzName;
- while(st.hasMoreTokens()) {
- downstreamClazzBaseName = st.nextToken();
- }
- final String upstreamClazzName = pipelineClazzBaseName+downstreamClazzBaseName;
-
- Class> upstreamClazz = null;
- try {
- upstreamClazz = Class.forName(upstreamClazzName, true, GLPipelineFactory.class.getClassLoader());
- } catch (final Throwable e) { e.printStackTrace(); }
-
- return upstreamClazz;
- }
-}
-
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
deleted file mode 100644
index a36a21ad5..000000000
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ /dev/null
@@ -1,2322 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- */
-
-package com.jogamp.opengl;
-
-import jogamp.opengl.Debug;
-import jogamp.opengl.GLDrawableFactoryImpl;
-import jogamp.opengl.DesktopGLDynamicLookupHelper;
-
-import com.jogamp.common.ExceptionUtils;
-import com.jogamp.common.GlueGenVersion;
-import com.jogamp.common.jvm.JNILibLoaderBase;
-import com.jogamp.common.os.Platform;
-import com.jogamp.common.util.PropertyAccess;
-import com.jogamp.common.util.ReflectionUtil;
-import com.jogamp.common.util.VersionUtil;
-import com.jogamp.common.util.cache.TempJarCache;
-import com.jogamp.common.util.locks.LockFactory;
-import com.jogamp.common.util.locks.RecursiveThreadGroupLock;
-import com.jogamp.gluegen.runtime.FunctionAddressResolver;
-import com.jogamp.nativewindow.NativeWindowVersion;
-import com.jogamp.opengl.GLRendererQuirks;
-import com.jogamp.opengl.JoglVersion;
-
-import com.jogamp.nativewindow.AbstractGraphicsDevice;
-import com.jogamp.nativewindow.NativeWindowFactory;
-import com.jogamp.opengl.fixedfunc.GLPointerFunc;
-
-import java.lang.reflect.Constructor;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Specifies the the OpenGL profile.
- *
- * This class static singleton initialization queries the availability of all OpenGL Profiles
- * and instantiates singleton GLProfile objects for each available profile.
- *
- * The platform default profile may be used, using {@link GLProfile#GetProfileDefault()},
- * or more specialized versions using the other static GetProfile methods.
- */
-public class GLProfile {
-
- public static final boolean DEBUG;
-
- /**
- * In case no native OpenGL core profiles are required
- * and if one platform may have a buggy implementation,
- * setting the property jogl.disable.openglcore disables querying possible existing native OpenGL core profiles.
- *
- * This exclusion is disabled for {@link Platform.OSType#MACOS}.
- *
- */
- public static final boolean disableOpenGLCore;
-
- /**
- * In case the implementation of the ARB_create_context
- * context creation extension is buggy on one platform,
- * setting the property jogl.disable.openglarbcontext disables utilizing it.
- *
- * This exclusion also disables {@link #disableOpenGLES OpenGL ES}.
- *
- *
- * This exclusion is disabled for {@link Platform.OSType#MACOS}.
- *
- */
- public static final boolean disableOpenGLARBContext;
-
- /**
- * In case no OpenGL ES profiles are required
- * and if one platform may have a buggy implementation,
- * setting the property jogl.disable.opengles disables querying possible existing OpenGL ES profiles.
- */
- public static final boolean disableOpenGLES;
-
- /**
- * In case no OpenGL desktop profiles are required
- * and if one platform may have a buggy implementation,
- * setting the property jogl.disable.opengldesktop disables querying possible existing OpenGL desktop profiles.
- */
- public static final boolean disableOpenGLDesktop;
-
- /**
- * Disable surfaceless OpenGL context capability and its probing
- * by setting the property jogl.disable.surfacelesscontext.
- *
- * By default surfaceless OpenGL context capability is probed,
- * i.e. whether an OpenGL context can be made current without a default framebuffer.
- *
- *
- * If probing fails or if this property is set, the {@link GLRendererQuirks quirk} {@link GLRendererQuirks#NoSurfacelessCtx}
- * is being set.
- *
- */
- public static final boolean disableSurfacelessContext;
-
- /**
- * We have to disable support for ANGLE, the D3D ES2 emulation on Windows provided w/ Firefox and Chrome.
- * When run in the mentioned browsers, the eglInitialize(..) implementation crashes.
- *
- * This can be overridden by explicitly enabling ANGLE on Windows by setting the property
- * jogl.enable.ANGLE.
- *
- * This method shall not need to be called for other reasons than having a defined initialization sequence.
- *
- *
- *
- * In case this method is not invoked, GLProfile is initialized implicit by
- * the first call to {@link #getDefault()}, {@link #get(java.lang.String)}.
- *
- *
- *
- * To initialize JOGL at startup ASAP, this method may be invoked in the main class's
- * static initializer block, in the static main() method or in the Applet init() method.
- *
- *
- *
- * Since JOGL's initialization is complex and involves multi threading, it is not recommended
- * to be have it invoked on the AWT EDT thread. In case all JOGL usage is performed
- * on the AWT EDT, invoke this method outside the AWT EDT - see above.
- *
- *
- */
- public static void initSingleton() {
- final boolean justInitialized;
- initLock.lock();
- try {
- if(!initialized) {
- initialized = true;
- justInitialized = true;
- if(DEBUG) {
- System.err.println("GLProfile.initSingleton() - thread "+Thread.currentThread().getName());
- ExceptionUtils.dumpStack(System.err);
- }
-
- if(ReflectionUtil.DEBUG_STATS_FORNAME) {
- ReflectionUtil.resetForNameCount();
- }
-
- // run the whole static initialization privileged to speed up,
- // since this skips checking further access
- AccessController.doPrivileged(new PrivilegedAction() {
- @Override
- public Object run() {
- Platform.initSingleton();
-
- if(TempJarCache.isInitialized()) {
- final ClassLoader cl = GLProfile.class.getClassLoader();
- final String newtDebugClassName = "jogamp.newt.Debug";
- final Class>[] classesFromJavaJars = new Class>[] { jogamp.nativewindow.Debug.class, jogamp.opengl.Debug.class, null };
- if( ReflectionUtil.isClassAvailable(newtDebugClassName, cl) ) {
- classesFromJavaJars[2] = ReflectionUtil.getClass(newtDebugClassName, false, cl);
- }
- JNILibLoaderBase.addNativeJarLibsJoglCfg(classesFromJavaJars);
- }
- initProfilesForDefaultDevices();
- return null;
- }
- });
- if( ReflectionUtil.DEBUG_STATS_FORNAME ) {
- if( justInitialized ) {
- System.err.println(ReflectionUtil.getForNameStats(null).toString());
- }
- }
- } else {
- justInitialized = false;
- }
- } finally {
- initLock.unlock();
- }
- if(DEBUG) {
- if( justInitialized && ( hasGL234Impl || hasGLES1Impl || hasGLES3Impl ) ) {
- System.err.println(JoglVersion.getDefaultOpenGLInfo(defaultDevice, null, true));
- }
- }
- }
-
- /**
- * Trigger eager initialization of GLProfiles for the given device,
- * in case it isn't done yet.
- *
- * @throws GLException if no profile for the given device is available.
- */
- public static void initProfiles(final AbstractGraphicsDevice device) throws GLException {
- getProfileMap(device, true);
- }
-
- /**
- * Manual shutdown method, may be called after your last JOGL use
- * within the running JVM.
- * It releases all temporary created resources, ie issues {@link com.jogamp.opengl.GLDrawableFactory#shutdown()}.
- * The shutdown implementation is called via the JVM shutdown hook, if not manually invoked.
- *
- * This method shall not need to be called for other reasons than issuing a proper shutdown of resources at a defined time.
- *
- */
- public static void shutdown() {
- initLock.lock();
- try {
- if(initialized) {
- initialized = false;
- if(DEBUG) {
- System.err.println("GLProfile.shutdown() - thread "+Thread.currentThread().getName());
- ExceptionUtils.dumpStack(System.err);
- }
- GLDrawableFactory.shutdown();
- }
- } finally {
- initLock.unlock();
- }
- }
-
- //
- // Query platform available OpenGL implementation
- //
-
- /**
- * Returns the availability of a profile on a device.
- *
- * @param device a valid AbstractGraphicsDevice, or null for the default device.
- * @param profile a valid GLProfile name ({@link #GL4bc}, {@link #GL4}, {@link #GL2}, ..),
- * or [ null, GL ] for the default profile.
- * @return true if the profile is available for the device, otherwise false.
- */
- public static boolean isAvailable(final AbstractGraphicsDevice device, final String profile) {
- initSingleton();
- return isAvailableImpl(getProfileMap(device, false), profile);
- }
- private static boolean isAvailableImpl(final HashMap map, final String profile) {
- return null != map && null != map.get(profile);
- }
-
- /**
- * Returns the availability of a profile on the default device.
- *
- * @param profile a valid GLProfile name ({@link #GL4bc}, {@link #GL4}, {@link #GL2}, ..),
- * or [ null, GL ] for the default profile.
- * @return true if the profile is available for the default device, otherwise false.
- */
- public static boolean isAvailable(final String profile) {
- return isAvailable(null, profile);
- }
-
- /**
- * Returns the availability of any profile on the default device.
- *
- * @return true if any profile is available for the default device, otherwise false.
- */
- public static boolean isAnyAvailable() {
- return isAvailable(null, null);
- }
-
- public static String glAvailabilityToString(final AbstractGraphicsDevice device) {
- return glAvailabilityToString(device, null).toString();
- }
-
- public static StringBuilder glAvailabilityToString(final AbstractGraphicsDevice device, final StringBuilder sb) {
- return glAvailabilityToString(device, sb, null, 0);
- }
- private static StringBuilder doIndent(final StringBuilder sb, final String indent, int indentCount) {
- while(indentCount>0) {
- sb.append(indent);
- indentCount--;
- }
- return sb;
- }
- public static StringBuilder glAvailabilityToString(AbstractGraphicsDevice device, StringBuilder sb, final String indent, int indentCount) {
- boolean avail;
- if(null == sb) {
- sb = new StringBuilder();
- }
- final boolean useIndent = null != indent;
-
- initSingleton();
-
- int allCount = 0;
- int nativeCount = 0;
-
- if(null==device) {
- device = defaultDevice;
- }
- final HashMap map = getProfileMap(device, false);
-
- if(useIndent) {
- doIndent(sb, indent, indentCount).append("Natives");
- indentCount++;
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4bc+" ").append(indent);
- } else {
- sb.append("Natives["+GL4bc+" ");
- }
- avail=isAvailableImpl(map, GL4bc);
- sb.append(avail);
- if(avail) {
- nativeCount++;
- glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_COMPAT);
- }
- allCount++;
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4+" ").append(indent);
- } else {
- sb.append(", "+GL4+" ");
- }
- avail=isAvailableImpl(map, GL4);
- sb.append(avail);
- if(avail) {
- nativeCount++;
- glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_CORE);
- }
- allCount++;
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES3+" ").append(indent);
- } else {
- sb.append(", "+GLES3+" ");
- }
- avail=isAvailableImpl(map, GLES3);
- sb.append(avail);
- if(avail) {
- nativeCount++;
- glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_ES);
- }
- allCount++;
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3bc+" ").append(indent);
- } else {
- sb.append(", "+GL3bc+" ");
- }
- avail=isAvailableImpl(map, GL3bc);
- sb.append(avail);
- if(avail) {
- nativeCount++;
- glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_COMPAT);
- }
- allCount++;
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3+" ").append(indent);
- } else {
- sb.append(", "+GL3+" ");
- }
- avail=isAvailableImpl(map, GL3);
- sb.append(avail);
- if(avail) {
- nativeCount++;
- glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_CORE);
- }
- allCount++;
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2+" ").append(indent);
- } else {
- sb.append(", "+GL2+" ");
- }
- avail=isAvailableImpl(map, GL2);
- sb.append(avail);
- if(avail) {
- nativeCount++;
- glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_COMPAT);
- }
- allCount++;
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES2+" ").append(indent);
- } else {
- sb.append(", "+GLES2+" ");
- }
- avail=isAvailableImpl(map, GLES2);
- sb.append(avail);
- if(avail) {
- nativeCount++;
- glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES);
- }
- allCount++;
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES1+" ").append(indent);
- } else {
- sb.append(", "+GLES1+" ");
- }
- avail=isAvailableImpl(map, GLES1);
- sb.append(avail);
- if(avail) {
- nativeCount++;
- glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES);
- }
- allCount++;
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Count\t"+nativeCount+" / "+allCount);
- indentCount--;
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Common");
- indentCount++;
- } else {
- sb.append(", count "+nativeCount+" / "+allCount+"], Common[");
- }
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4ES3+" ").append(indent);
- } else {
- sb.append(", "+GL4ES3+" ");
- }
- sb.append(isAvailableImpl(map, GL4ES3));
- allCount++;
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2GL3+" ").append(indent);
- } else {
- sb.append(", "+GL2GL3+" ");
- }
- sb.append(isAvailableImpl(map, GL2GL3));
- allCount++;
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES2+" ").append(indent);
- } else {
- sb.append(", "+GL2ES2+" ");
- }
- sb.append(isAvailableImpl(map, GL2ES2));
- allCount++;
-
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES1+" ").append(indent);
- } else {
- sb.append(", "+GL2ES1+" ");
- }
- sb.append(isAvailableImpl(map, GL2ES1));
- allCount++;
-
- if(useIndent) {
- indentCount--;
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Mappings");
- indentCount++;
- } else {
- sb.append("], Mappings[");
- }
-
- int profileCount = 0;
-
- if(null != map) {
- for (final Map.Entry entry : map.entrySet()) {
- if( GL_DEFAULT != entry.getKey() ) {
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount);
- }
- sb.append(entry.getKey()+(useIndent?" \t":" ")+entry.getValue());
- if(!useIndent) {
- sb.append(", ");
- }
- profileCount++;
- }
- }
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("default ");
- } else {
- sb.append(", default ");
- }
- try {
- sb.append(getDefault(device));
- } catch (final GLException gle) {
- sb.append("n/a");
- }
- }
- if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Count\t"+profileCount+" / "+allCount);
- sb.append(Platform.getNewline());
- } else {
- sb.append(", count "+profileCount+" / "+allCount+"]");
- }
-
- return sb;
- }
-
- /** Uses the default device */
- public static String glAvailabilityToString() {
- return glAvailabilityToString(null);
- }
-
- //
- // Public (user-visible) profiles
- //
-
- /** The desktop OpenGL compatibility profile 4.x, with x >= 0, ie GL2 plus GL4.
- bc stands for backward compatibility. */
- public static final String GL4bc = "GL4bc"; // Implicitly intern(), see Bug 1059
-
- /** The desktop OpenGL core profile 4.x, with x >= 0 */
- public static final String GL4 = "GL4"; // Implicitly intern(), see Bug 1059
-
- /** The desktop OpenGL compatibility profile 3.x, with x >= 1, ie GL2 plus GL3.
- bc stands for backward compatibility. */
- public static final String GL3bc = "GL3bc"; // Implicitly intern(), see Bug 1059
-
- /** The desktop OpenGL core profile 3.x, with x >= 1 */
- public static final String GL3 = "GL3"; // Implicitly intern(), see Bug 1059
-
- /** The desktop OpenGL profile 1.x up to 3.0 */
- public static final String GL2 = "GL2"; // Implicitly intern(), see Bug 1059
-
- /** The embedded OpenGL profile ES 1.x, with x >= 0 */
- public static final String GLES1 = "GLES1"; // Implicitly intern(), see Bug 1059
-
- /** The embedded OpenGL profile ES 2.x, with x >= 0 */
- public static final String GLES2 = "GLES2"; // Implicitly intern(), see Bug 1059
-
- /** The embedded OpenGL profile ES 3.x, with x >= 0 */
- public static final String GLES3 = "GLES3"; // Implicitly intern(), see Bug 1059
-
- /** The intersection of the desktop GL2 and embedded ES1 profile */
- public static final String GL2ES1 = "GL2ES1"; // Implicitly intern(), see Bug 1059
-
- /** The intersection of the desktop GL3, GL2 and embedded ES2 profile */
- public static final String GL2ES2 = "GL2ES2"; // Implicitly intern(), see Bug 1059
-
- /** The intersection of the desktop GL3 and GL2 profile */
- public static final String GL2GL3 = "GL2GL3"; // Implicitly intern(), see Bug 1059
-
- /** The intersection of the desktop GL4 and ES3 profile, available only if either ES3 or GL4 w/ GL_ARB_ES3_compatibility is available. */
- public static final String GL4ES3 = "GL4ES3"; // Implicitly intern(), see Bug 1059
-
- /** The default profile, used for the device default profile map */
- private static final String GL_DEFAULT = "GL_DEFAULT"; // Implicitly intern(), see Bug 1059
- /** The default profile, used for the device default profile map */
- private static final String GL_GL = "GL"; // Implicitly intern(), see Bug 1059
-
- /**
- * All GL Profiles in the order of default detection.
- * Desktop compatibility profiles (the one with fixed function pipeline) comes first
- * from highest to lowest version.
- *
This includes the generic subset profiles GL2GL3, GL2ES2 and GL2ES1.
- *
- *
- *
GL4bc
- *
GL3bc
- *
GL2
- *
GL4
- *
GL3
- *
GLES3
- *
GL4ES3
- *
GL2GL3
- *
GLES2
- *
GL2ES2
- *
GLES1
- *
GL2ES1
- *
- *
- */
- public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL4bc, GL3bc, GL2, GL4, GL3, GLES3, GL4ES3, GL2GL3, GLES2, GL2ES2, GLES1, GL2ES1 };
-
- /**
- * Order of maximum profiles.
- *
- *
- *
GL4bc
- *
GL4
- *
GL3bc
- *
GL3
- *
GLES3
- *
GL2
- *
GLES2
- *
GLES1
- *
- *
- */
- public static final String[] GL_PROFILE_LIST_MAX = new String[] { GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GLES2, GLES1 };
-
- /**
- * Order of minimum profiles.
- *
- *
- *
GLES1
- *
GLES2
- *
GL2
- *
GLES3
- *
GL3
- *
GL3bc
- *
GL4
- *
GL4bc
- *
- *
- */
- public static final String[] GL_PROFILE_LIST_MIN = new String[] { GLES1, GLES2, GL2, GLES3, GL3, GL3bc, GL4, GL4bc };
-
- /**
- * Order of minimum original desktop profiles.
- *
- *
- *
GL2
- *
GL3bc
- *
GL4bc
- *
GL3
- *
GL4
- *
- *
- */
- public static final String[] GL_PROFILE_LIST_MIN_DESKTOP = new String[] { GL2, GL3bc, GL4bc, GL3, GL4 };
-
- /**
- * Order of maximum fixed function profiles
- *
- *
- *
GL4bc
- *
GL3bc
- *
GL2
- *
GLES1
- *
- *
- */
- public static final String[] GL_PROFILE_LIST_MAX_FIXEDFUNC = new String[] { GL4bc, GL3bc, GL2, GLES1 };
-
- /**
- * Order of maximum programmable shader profiles
- *
- *
- *
GL4bc
- *
GL4
- *
GL3bc
- *
GL3
- *
GLES3
- *
GL2
- *
GLES2
- *
- *
- */
- public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER = new String[] { GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GLES2 };
-
- /**
- * Order of maximum programmable shader core only profiles
- *
- *
- *
GL4
- *
GL3
- *
GLES3
- *
GLES2
- *
- *
- */
- public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER_CORE = new String[] { GL4, GL3, GLES3, GLES2 };
-
- /** Returns a default GLProfile object, reflecting the best for the running platform.
- * It selects the first of the set {@link GLProfile#GL_PROFILE_LIST_ALL}
- * and favors hardware acceleration.
- * @throws GLException if no profile is available for the device.
- * @see #GL_PROFILE_LIST_ALL
- */
- public static GLProfile getDefault(final AbstractGraphicsDevice device) {
- final GLProfile glp = get(device, GL_DEFAULT);
- return glp;
- }
-
- /** Returns a default GLProfile object, reflecting the best for the running platform.
- * It selects the first of the set {@link GLProfile#GL_PROFILE_LIST_ALL}
- * and favors hardware acceleration.
- *
Uses the default device.
- * @throws GLException if no profile is available for the default device.
- */
- public static GLProfile getDefault() {
- return getDefault(defaultDevice);
- }
-
- /**
- * Returns the highest profile.
- * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX}
- *
- * @throws GLException if no profile is available for the device.
- * @see #GL_PROFILE_LIST_MAX
- */
- public static GLProfile getMaximum(final AbstractGraphicsDevice device, final boolean favorHardwareRasterizer)
- throws GLException
- {
- return get(device, GL_PROFILE_LIST_MAX, favorHardwareRasterizer);
- }
-
- /** Uses the default device
- * @throws GLException if no profile is available for the default device.
- * @see #GL_PROFILE_LIST_MAX
- */
- public static GLProfile getMaximum(final boolean favorHardwareRasterizer)
- throws GLException
- {
- return get(GL_PROFILE_LIST_MAX, favorHardwareRasterizer);
- }
-
- /**
- * Returns the lowest profile.
- * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MIN}
- *
- * @throws GLException if no desktop profile is available for the device.
- * @see #GL_PROFILE_LIST_MIN
- */
- public static GLProfile getMinimum(final AbstractGraphicsDevice device, final boolean favorHardwareRasterizer)
- throws GLException
- {
- return get(device, GL_PROFILE_LIST_MIN, favorHardwareRasterizer);
- }
-
- /** Uses the default device
- * @throws GLException if no desktop profile is available for the default device.
- * @see #GL_PROFILE_LIST_MIN
- */
- public static GLProfile getMinimum(final boolean favorHardwareRasterizer)
- throws GLException
- {
- return get(GL_PROFILE_LIST_MIN, favorHardwareRasterizer);
- }
-
-
- /**
- * Returns the highest profile, implementing the fixed function pipeline.
- * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX_FIXEDFUNC}
- *
- * @throws GLException if no fixed function profile is available for the device.
- * @see #GL_PROFILE_LIST_MAX_FIXEDFUNC
- */
- public static GLProfile getMaxFixedFunc(final AbstractGraphicsDevice device, final boolean favorHardwareRasterizer)
- throws GLException
- {
- return get(device, GL_PROFILE_LIST_MAX_FIXEDFUNC, favorHardwareRasterizer);
- }
-
- /** Uses the default device
- * @throws GLException if no fixed function profile is available for the default device.
- * @see #GL_PROFILE_LIST_MAX_FIXEDFUNC
- */
- public static GLProfile getMaxFixedFunc(final boolean favorHardwareRasterizer)
- throws GLException
- {
- return get(GL_PROFILE_LIST_MAX_FIXEDFUNC, favorHardwareRasterizer);
- }
-
- /**
- * Returns the highest profile, implementing the programmable shader pipeline.
- * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX_PROGSHADER}
- *
- * @throws GLException if no programmable profile is available for the device.
- * @see #GL_PROFILE_LIST_MAX_PROGSHADER
- */
- public static GLProfile getMaxProgrammable(final AbstractGraphicsDevice device, final boolean favorHardwareRasterizer)
- throws GLException
- {
- return get(device, GL_PROFILE_LIST_MAX_PROGSHADER, favorHardwareRasterizer);
- }
-
- /** Uses the default device
- * @throws GLException if no programmable profile is available for the default device.
- * @see #GL_PROFILE_LIST_MAX_PROGSHADER
- */
- public static GLProfile getMaxProgrammable(final boolean favorHardwareRasterizer)
- throws GLException
- {
- return get(GL_PROFILE_LIST_MAX_PROGSHADER, favorHardwareRasterizer);
- }
-
- /**
- * Returns the highest profile, implementing the programmable shader core pipeline only.
- * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX_PROGSHADER_CORE}
- *
- * @throws GLException if no programmable core profile is available for the device.
- * @see #GL_PROFILE_LIST_MAX_PROGSHADER_CORE
- */
- public static GLProfile getMaxProgrammableCore(final AbstractGraphicsDevice device, final boolean favorHardwareRasterizer)
- throws GLException
- {
- return get(device, GL_PROFILE_LIST_MAX_PROGSHADER_CORE, favorHardwareRasterizer);
- }
-
- /** Uses the default device
- * @throws GLException if no programmable core profile is available for the default device.
- * @see #GL_PROFILE_LIST_MAX_PROGSHADER_CORE
- */
- public static GLProfile getMaxProgrammableCore(final boolean favorHardwareRasterizer)
- throws GLException
- {
- return get(GL_PROFILE_LIST_MAX_PROGSHADER_CORE, favorHardwareRasterizer);
- }
-
- /**
- * Returns the GL2ES1 profile implementation, hence compatible w/ GL2ES1.
- * It returns:
- *
- * @see #isGL3ES3()
- * @see #isGL2GL3()
- */
- public final boolean isGL2ES3() {
- return isGL3ES3() || isGL2GL3();
- }
-
- /** Indicates whether this profile is capable of GL3ES3.
Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].
*/
- public final boolean isGL3ES3() {
- return isGL4ES3() || isGL3();
- }
-
- /** Indicates whether this profile is capable of GL4ES3.
Includes [ GL4bc, GL4, GLES3 ].
*/
- public final boolean isGL4ES3() {
- return GL4ES3 == profile || isGLES3() || isGL4();
- }
-
- /** Indicates whether this profile supports GLSL, i.e. {@link #isGL2ES2()}. */
- public final boolean hasGLSL() {
- return isGL2ES2() ;
- }
-
- /** Indicates whether this profile uses the native OpenGL ES1 implementations. */
- public final boolean usesNativeGLES1() {
- return GLES1 == getImplName();
- }
-
- /** Indicates whether this profile uses the native OpenGL ES2 implementations. */
- public final boolean usesNativeGLES2() {
- return GLES2 == getImplName();
- }
-
- /** Indicates whether this profile uses the native OpenGL ES3 implementations. */
- public final boolean usesNativeGLES3() {
- return GLES3 == getImplName();
- }
-
- /** Indicates whether this profile uses either of the native OpenGL ES implementations. */
- public final boolean usesNativeGLES() {
- return usesNativeGLES3() || usesNativeGLES2() || usesNativeGLES1();
- }
-
- /**
- * General validation if type is a valid GL data type
- * for the current profile
- */
- public boolean isValidDataType(final int type, final boolean throwException) {
- switch(type) {
- case GL.GL_UNSIGNED_BYTE:
- case GL.GL_BYTE:
- case GL.GL_UNSIGNED_SHORT:
- case GL.GL_SHORT:
- case GL.GL_FLOAT:
- case GL.GL_FIXED:
- return true;
- case com.jogamp.opengl.GL2ES2.GL_INT:
- case GL.GL_UNSIGNED_INT:
- if( isGL2ES2() ) {
- return true;
- }
- case com.jogamp.opengl.GL2GL3.GL_DOUBLE:
- if( isGL3() ) {
- return true;
- }
- case com.jogamp.opengl.GL2.GL_2_BYTES:
- case com.jogamp.opengl.GL2.GL_3_BYTES:
- case com.jogamp.opengl.GL2.GL_4_BYTES:
- if( isGL2() ) {
- return true;
- }
- }
- if(throwException) {
- throw new GLException("Illegal data type on profile "+this+": "+type);
- }
- return false;
- }
-
- public boolean isValidArrayDataType(final int index, final int comps, final int type,
- final boolean isVertexAttribPointer, final boolean throwException) {
- final String arrayName = getGLArrayName(index);
- if( isGLES1() ) {
- if(isVertexAttribPointer) {
- if(throwException) {
- throw new GLException("Illegal array type for "+arrayName+" on profile GLES1: VertexAttribPointer");
- }
- return false;
- }
- switch(index) {
- case GLPointerFunc.GL_VERTEX_ARRAY:
- case GLPointerFunc.GL_TEXTURE_COORD_ARRAY:
- switch(type) {
- case GL.GL_BYTE:
- case GL.GL_SHORT:
- case GL.GL_FIXED:
- case GL.GL_FLOAT:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal data type for "+arrayName+" on profile GLES1: "+type);
- }
- return false;
- }
- switch(comps) {
- case 0:
- case 2:
- case 3:
- case 4:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal component number for "+arrayName+" on profile GLES1: "+comps);
- }
- return false;
- }
- break;
- case GLPointerFunc.GL_NORMAL_ARRAY:
- switch(type) {
- case GL.GL_BYTE:
- case GL.GL_SHORT:
- case GL.GL_FIXED:
- case GL.GL_FLOAT:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal data type for "+arrayName+" on profile GLES1: "+type);
- }
- return false;
- }
- switch(comps) {
- case 0:
- case 3:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal component number for "+arrayName+" on profile GLES1: "+comps);
- }
- return false;
- }
- break;
- case GLPointerFunc.GL_COLOR_ARRAY:
- switch(type) {
- case GL.GL_UNSIGNED_BYTE:
- case GL.GL_FIXED:
- case GL.GL_FLOAT:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal data type for "+arrayName+" on profile GLES1: "+type);
- }
- return false;
- }
- switch(comps) {
- case 0:
- case 4:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal component number for "+arrayName+" on profile GLES1: "+comps);
- }
- return false;
- }
- break;
- }
- } else if( isGLES2() ) {
- // simply ignore !isVertexAttribPointer case, since it is simulated anyway ..
- switch(type) {
- case GL.GL_UNSIGNED_BYTE:
- case GL.GL_BYTE:
- case GL.GL_UNSIGNED_SHORT:
- case GL.GL_SHORT:
- case GL.GL_FLOAT:
- case GL.GL_FIXED:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal data type for "+arrayName+" on profile GLES2: "+type);
- }
- return false;
- }
- /** unable to validate .. could be any valid type/component combination
- switch(comps) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal component number for "+arrayName+" on profile GLES2: "+comps);
- }
- return false;
- } */
- } else if( isGL2ES2() ) {
- if(isVertexAttribPointer) {
- switch(type) {
- case GL.GL_UNSIGNED_BYTE:
- case GL.GL_BYTE:
- case GL.GL_UNSIGNED_SHORT:
- case GL.GL_SHORT:
- case GL.GL_FLOAT:
- case com.jogamp.opengl.GL2ES2.GL_INT:
- case GL.GL_UNSIGNED_INT:
- case com.jogamp.opengl.GL2GL3.GL_DOUBLE:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal data type for "+arrayName+" on profile GL2: "+type);
- }
- return false;
- }
- switch(comps) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal component number for "+arrayName+" on profile GL2: "+comps);
- }
- return false;
- }
- } else {
- switch(index) {
- case GLPointerFunc.GL_VERTEX_ARRAY:
- switch(type) {
- case GL.GL_SHORT:
- case GL.GL_FLOAT:
- case com.jogamp.opengl.GL2ES2.GL_INT:
- case com.jogamp.opengl.GL2GL3.GL_DOUBLE:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal data type for "+arrayName+" on profile GL2: "+type);
- }
- return false;
- }
- switch(comps) {
- case 0:
- case 2:
- case 3:
- case 4:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal component number for "+arrayName+" on profile GL2: "+comps);
- }
- return false;
- }
- break;
- case GLPointerFunc.GL_NORMAL_ARRAY:
- switch(type) {
- case GL.GL_BYTE:
- case GL.GL_SHORT:
- case GL.GL_FLOAT:
- case com.jogamp.opengl.GL2ES2.GL_INT:
- case com.jogamp.opengl.GL2GL3.GL_DOUBLE:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal data type for "+arrayName+" on profile GL2: "+type);
- }
- return false;
- }
- switch(comps) {
- case 0:
- case 3:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal component number for "+arrayName+" on profile GLES1: "+comps);
- }
- return false;
- }
- break;
- case GLPointerFunc.GL_COLOR_ARRAY:
- switch(type) {
- case GL.GL_UNSIGNED_BYTE:
- case GL.GL_BYTE:
- case GL.GL_UNSIGNED_SHORT:
- case GL.GL_SHORT:
- case GL.GL_FLOAT:
- case com.jogamp.opengl.GL2ES2.GL_INT:
- case GL.GL_UNSIGNED_INT:
- case com.jogamp.opengl.GL2GL3.GL_DOUBLE:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal data type for "+arrayName+" on profile GL2: "+type);
- }
- return false;
- }
- switch(comps) {
- case 0:
- case 3:
- case 4:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal component number for "+arrayName+" on profile GL2: "+comps);
- }
- return false;
- }
- break;
- case GLPointerFunc.GL_TEXTURE_COORD_ARRAY:
- switch(type) {
- case GL.GL_SHORT:
- case GL.GL_FLOAT:
- case com.jogamp.opengl.GL2ES2.GL_INT:
- case com.jogamp.opengl.GL2GL3.GL_DOUBLE:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal data type for "+arrayName+" on profile GL2: "+type);
- }
- return false;
- }
- switch(comps) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- break;
- default:
- if(throwException) {
- throw new GLException("Illegal component number for "+arrayName+" on profile GL2: "+comps);
- }
- return false;
- }
- break;
- }
- }
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "GLProfile[" + getName() + "/" + getImplName() + "."+(this.isHardwareRasterizer?"hw":"sw")+(isCustom?".custom":"")+"]";
- }
-
- private static /*final*/ boolean isAWTAvailable;
-
- private static /*final*/ boolean hasDesktopGLFactory;
- private static /*final*/ boolean hasGL234Impl;
- private static /*final*/ boolean hasEGLFactory;
- private static /*final*/ boolean hasGLES3Impl;
- private static /*final*/ boolean hasGLES1Impl;
- private static /*final*/ Constructor> ctorGL234Impl;
- private static /*final*/ Constructor> ctorGLES3Impl;
- private static /*final*/ Constructor> ctorGLES1Impl;
- private static /*final*/ Constructor> ctorGL234ProcAddr;
- private static /*final*/ Constructor> ctorGLES3ProcAddr;
- private static /*final*/ Constructor> ctorGLES1ProcAddr;
-
- private static /*final*/ GLDrawableFactoryImpl eglFactory = null;
- private static /*final*/ GLDrawableFactoryImpl desktopFactory = null;
- private static /*final*/ AbstractGraphicsDevice defaultDevice = null;
-
- private static boolean initialized = false;
- private static final RecursiveThreadGroupLock initLock = LockFactory.createRecursiveThreadGroupLock();
-
- private static final Class>[] ctorGLArgs = new Class>[] { GLProfile.class, jogamp.opengl.GLContextImpl.class };
- private static final Class>[] ctorProcArgs = new Class>[] { FunctionAddressResolver.class };
- private static final String GL4bcImplClassName = "jogamp.opengl.gl4.GL4bcImpl";
- private static final String GL4bcProcClassName = "jogamp.opengl.gl4.GL4bcProcAddressTable";
- private static final String GLES1ImplClassName = "jogamp.opengl.es1.GLES1Impl";
- private static final String GLES1ProcClassName = "jogamp.opengl.es1.GLES1ProcAddressTable";
- private static final String GLES3ImplClassName = "jogamp.opengl.es3.GLES3Impl";
- private static final String GLES3ProcClassName = "jogamp.opengl.es3.GLES3ProcAddressTable";
-
- private static final Constructor> getCtor(final String clazzName, final boolean glObject, final ClassLoader cl) {
- try {
- return ReflectionUtil.getConstructor(clazzName, glObject ? ctorGLArgs : ctorProcArgs, false, cl);
- } catch (final Throwable t) {
- if( DEBUG ) {
- System.err.println("Caught: "+t.getMessage());
- t.printStackTrace();
- }
- return null;
- }
- }
-
- private static final void initGLCtorImpl() {
- final ClassLoader classloader = GLProfile.class.getClassLoader();
-
- // depends on hasDesktopGLFactory
- {
- final Constructor> ctorGL = getCtor(GL4bcImplClassName, true, classloader);
- final Constructor> ctorProc = null != ctorGL ? getCtor(GL4bcProcClassName, false, classloader) : null;
- if( null != ctorProc ) {
- hasGL234Impl = true;
- ctorGL234Impl = ctorGL;
- ctorGL234ProcAddr = ctorProc;
- } else {
- hasGL234Impl = false;
- ctorGL234Impl = null;
- ctorGL234ProcAddr = null;
- }
- }
-
- // depends on hasEGLFactory
- {
- final Constructor> ctorGL = getCtor(GLES1ImplClassName, true, classloader);
- final Constructor> ctorProc = null != ctorGL ? getCtor(GLES1ProcClassName, false, classloader) : null;
- if( null != ctorProc ) {
- hasGLES1Impl = true;
- ctorGLES1Impl = ctorGL;
- ctorGLES1ProcAddr = ctorProc;
- } else {
- hasGLES1Impl = false;
- ctorGLES1Impl = null;
- ctorGLES1ProcAddr = null;
- }
- }
- {
- final Constructor> ctorGL = getCtor(GLES3ImplClassName, true, classloader);
- final Constructor> ctorProc = null != ctorGL ? getCtor(GLES3ProcClassName, false, classloader) : null;
- if( null != ctorProc ) {
- hasGLES3Impl = true;
- ctorGLES3Impl = ctorGL;
- ctorGLES3ProcAddr = ctorProc;
- } else {
- hasGLES3Impl = false;
- ctorGLES3Impl = null;
- ctorGLES3ProcAddr = null;
- }
- }
- }
-
- /**
- * Tries the profiles implementation and native libraries.
- */
- private static void initProfilesForDefaultDevices() {
- NativeWindowFactory.initSingleton();
- if(DEBUG) {
- System.err.println("GLProfile.init - thread: " + Thread.currentThread().getName());
- System.err.println(VersionUtil.getPlatformInfo());
- System.err.println(GlueGenVersion.getInstance());
- System.err.println(NativeWindowVersion.getInstance());
- System.err.println(JoglVersion.getInstance());
- }
-
- final ClassLoader classloader = GLProfile.class.getClassLoader();
-
- isAWTAvailable = NativeWindowFactory.isAWTAvailable() &&
- ReflectionUtil.isClassAvailable("com.jogamp.opengl.awt.GLCanvas", classloader) ; // JOGL
-
- initGLCtorImpl();
-
- //
- // Iteration of desktop GL availability detection
- // utilizing the detected GL version in the shared context.
- //
- // - Instantiate GLDrawableFactory incl its shared dummy drawable/context,
- // which will register at GLContext ..
- //
- GLDrawableFactory.initSingleton();
-
- Throwable t=null;
- // if successfull it has a shared dummy drawable and context created
- try {
- desktopFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactoryImpl(GL2);
- if(null != desktopFactory) {
- final DesktopGLDynamicLookupHelper glLookupHelper = (DesktopGLDynamicLookupHelper) desktopFactory.getGLDynamicLookupHelper(GL2);
- if(null!=glLookupHelper) {
- hasDesktopGLFactory = glLookupHelper.isLibComplete() && hasGL234Impl;
- }
- }
- } catch (final LinkageError le) {
- t=le;
- } catch (final RuntimeException re) {
- t=re;
- } catch (final Throwable tt) {
- t=tt;
- }
- if(DEBUG) {
- if(null!=t) {
- t.printStackTrace();
- }
- }
-
- final AbstractGraphicsDevice defaultDesktopDevice;
- if(null == desktopFactory) {
- hasDesktopGLFactory = false;
- hasGL234Impl = false;
- defaultDesktopDevice = null;
- if(DEBUG) {
- System.err.println("Info: GLProfile.init - Desktop GLDrawable factory not available");
- }
- } else {
- defaultDesktopDevice = desktopFactory.getDefaultDevice();
- }
-
- if ( ReflectionUtil.isClassAvailable("jogamp.opengl.egl.EGLDrawableFactory", classloader) ) {
- t=null;
- try {
- eglFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactoryImpl(GLES2);
- if(null != eglFactory) {
- hasEGLFactory = true;
- // update hasGLES1Impl, hasGLES3Impl based on EGL
- hasGLES3Impl = null!=eglFactory.getGLDynamicLookupHelper(GLES2) && hasGLES3Impl;
- hasGLES1Impl = null!=eglFactory.getGLDynamicLookupHelper(GLES1) && hasGLES1Impl;
- }
- } catch (final LinkageError le) {
- t=le;
- } catch (final SecurityException se) {
- t=se;
- } catch (final NullPointerException npe) {
- t=npe;
- } catch (final RuntimeException re) {
- t=re;
- }
- if(DEBUG) {
- if(null!=t) {
- t.printStackTrace();
- }
- }
- }
-
- final AbstractGraphicsDevice defaultEGLDevice;
- if(null == eglFactory) {
- hasGLES3Impl = false;
- hasGLES1Impl = false;
- defaultEGLDevice = null;
- if(DEBUG) {
- System.err.println("Info: GLProfile.init - EGL GLDrawable factory not available");
- }
- } else {
- defaultEGLDevice = eglFactory.getDefaultDevice();
- }
-
- if( null != defaultDesktopDevice ) {
- defaultDevice = defaultDesktopDevice;
- if(DEBUG) {
- System.err.println("Info: GLProfile.init - Default device is desktop derived: "+defaultDevice);
- }
- } else if ( null != defaultEGLDevice ) {
- defaultDevice = defaultEGLDevice;
- if(DEBUG) {
- System.err.println("Info: GLProfile.init - Default device is EGL derived: "+defaultDevice);
- }
- } else {
- if(DEBUG) {
- System.err.println("Info: GLProfile.init - Default device not available");
- }
- defaultDevice = null;
- }
-
- // we require to initialize the EGL device 1st, if available
- final boolean addedEGLProfile = null != defaultEGLDevice ? initProfilesForDevice(defaultEGLDevice) : false;
- final boolean addedDesktopProfile = null != defaultDesktopDevice ? initProfilesForDevice(defaultDesktopDevice) : false;
- final boolean addedAnyProfile = addedEGLProfile || addedDesktopProfile ;
-
- if(DEBUG) {
- System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile+" (desktop: "+addedDesktopProfile+", egl "+addedEGLProfile+")");
- System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable);
- System.err.println("GLProfile.init hasDesktopGLFactory "+hasDesktopGLFactory);
- System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl);
- System.err.println("GLProfile.init hasEGLFactory "+hasEGLFactory);
- System.err.println("GLProfile.init hasGLES1Impl "+hasGLES1Impl);
- System.err.println("GLProfile.init hasGLES3Impl "+hasGLES3Impl);
- System.err.println("GLProfile.init defaultDevice "+defaultDevice);
- System.err.println("GLProfile.init defaultDevice Desktop "+defaultDesktopDevice);
- System.err.println("GLProfile.init defaultDevice EGL "+defaultEGLDevice);
- System.err.println("GLProfile.init profile order "+array2String(GL_PROFILE_LIST_ALL));
- }
- }
-
- /**
- * @param device the device for which profiles shall be initialized
- * @return true if any profile for the device exists, otherwise false
- */
- private static boolean initProfilesForDevice(final AbstractGraphicsDevice device) {
- if(null == device) {
- return false;
- }
- initLock.lock();
- try {
- final GLDrawableFactory factory = GLDrawableFactory.getFactoryImpl(device);
- factory.enterThreadCriticalZone();
- try {
- return initProfilesForDeviceCritical(device);
- } finally {
- factory.leaveThreadCriticalZone();
- }
- } finally {
- initLock.unlock();
- }
- }
- private static boolean initProfilesForDeviceCritical(final AbstractGraphicsDevice device) {
- final boolean isSet = GLContext.getAvailableGLVersionsSet(device);
-
- if(DEBUG) {
- System.err.println("Info: GLProfile.initProfilesForDevice: "+device+" ("+device.getClass().getName()+"), isSet "+isSet+", hasDesktopGLFactory "+hasDesktopGLFactory+", hasEGLFactory "+hasEGLFactory);
- }
- if(isSet) {
- // Avoid recursion and check whether impl. is sane!
- final String deviceKey = device.getUniqueID();
- final HashMap map = deviceConn2ProfileMap.get(deviceKey);
- if( null == map ) {
- throw new InternalError("GLContext Avail. GLVersion is set - but no profile map for device: "+device);
- }
- return null != map.get(GL_DEFAULT);
- }
-
- boolean addedDesktopProfile = false;
- boolean addedEGLProfile = false;
-
- final boolean deviceIsDesktopCompatible = hasDesktopGLFactory && desktopFactory.getIsDeviceCompatible(device);
-
- if( deviceIsDesktopCompatible ) {
- // 1st pretend we have all Desktop and EGL profiles ..
- computeProfileMap(device, true /* desktopCtxUndef*/, true /* esCtxUndef */);
-
- // Triggers eager initialization of share context in GLDrawableFactory for the device,
- // hence querying all available GLProfiles
- final Thread sharedResourceThread = desktopFactory.getSharedResourceThread();
- if(null != sharedResourceThread) {
- initLock.addOwner(sharedResourceThread);
- }
- final boolean desktopSharedCtxAvail = desktopFactory.createSharedResource(device);
- if(null != sharedResourceThread) {
- initLock.removeOwner(sharedResourceThread);
- }
- if (DEBUG) {
- System.err.println("GLProfile.initProfilesForDevice: "+device+": desktop Shared Ctx "+desktopSharedCtxAvail);
- }
- if(!desktopSharedCtxAvail) {
- hasDesktopGLFactory = false;
- } else if( !GLContext.getAvailableGLVersionsSet(device) ) {
- throw new InternalError("Available GLVersions not set");
- }
- addedDesktopProfile = computeProfileMap(device, false /* desktopCtxUndef*/, false /* esCtxUndef */);
- }
-
- final boolean deviceIsEGLCompatible = hasEGLFactory && eglFactory.getIsDeviceCompatible(device);
-
- // also test GLES1, GLES2 and GLES3 on desktop, since we have implementations / emulations available.
- if( deviceIsEGLCompatible && ( hasGLES3Impl || hasGLES1Impl ) ) {
- // 1st pretend we have all EGL profiles ..
- computeProfileMap(device, true /* desktopCtxUndef*/, true /* esCtxUndef */);
-
- // Triggers eager initialization of share context in GLDrawableFactory for the device,
- // hence querying all available GLProfiles
- final Thread sharedResourceThread = eglFactory.getSharedResourceThread();
- if(null != sharedResourceThread) {
- initLock.addOwner(sharedResourceThread);
- }
- final boolean eglSharedCtxAvail = eglFactory.createSharedResource(device);
- if(null != sharedResourceThread) {
- initLock.removeOwner(sharedResourceThread);
- }
- if(!eglSharedCtxAvail) {
- // Remark: On Windows there is a libEGL.dll delivered w/ Chrome 15.0.874.121m and Firefox 8.0.1
- // but it seems even EGL.eglInitialize(eglDisplay, null, null)
- // fails in some scenarios (eg VirtualBox 4.1.6) w/ EGL error 0x3001 (EGL_NOT_INITIALIZED).
- hasEGLFactory = false;
- hasGLES3Impl = false;
- hasGLES1Impl = false;
- }
- if (DEBUG) {
- System.err.println("GLProfile.initProfilesForDevice: "+device+": egl Shared Ctx "+eglSharedCtxAvail);
- }
- addedEGLProfile = computeProfileMap(device, false /* desktopCtxUndef*/, false /* esCtxUndef */);
- }
-
- if( !addedDesktopProfile && !addedEGLProfile ) {
- setProfileMap(device, new HashMap()); // empty
- if(DEBUG) {
- System.err.println("GLProfile: device could not be initialized: "+device);
- System.err.println("GLProfile: compatible w/ desktop: "+deviceIsDesktopCompatible+
- ", egl "+deviceIsEGLCompatible);
- System.err.println("GLProfile: desktoplFactory "+desktopFactory);
- System.err.println("GLProfile: eglFactory "+eglFactory);
- System.err.println("GLProfile: hasGLES1Impl "+hasGLES1Impl);
- System.err.println("GLProfile: hasGLES3Impl "+hasGLES3Impl);
- }
- }
-
- GLContext.setAvailableGLVersionsSet(device, true);
-
- if (DEBUG) {
- System.err.println("GLProfile.initProfilesForDevice: "+device.getConnection()+": added profile(s): desktop "+addedDesktopProfile+", egl "+addedEGLProfile);
- System.err.println("GLProfile.initProfilesForDevice: "+device.getConnection()+": "+glAvailabilityToString(device));
- if(addedDesktopProfile) {
- dumpGLInfo(desktopFactory, device);
- final List availCaps = desktopFactory.getAvailableCapabilities(device);
- for(int i=0; i availCaps = eglFactory.getAvailableCapabilities(device);
- for(int i=0; i 0)
- msg.append(", ");
- msg.append(list[i]);
- }
- msg.append("]");
- return msg.toString();
- }
-
- private static void glAvailabilityToString(final AbstractGraphicsDevice device, final StringBuilder sb, final int major, final int profile) {
- final String str = GLContext.getAvailableGLVersionAsString(device, major, profile);
- if(null==str) {
- throw new GLException("Internal Error");
- }
- sb.append("[");
- sb.append(str);
- sb.append("]");
- }
-
- private static boolean computeProfileMap(final AbstractGraphicsDevice device, final boolean desktopCtxUndef, final boolean esCtxUndef) {
- if (DEBUG) {
- System.err.println("GLProfile.init map "+device.getConnection()+", desktopCtxUndef "+desktopCtxUndef+", esCtxUndef "+esCtxUndef);
- }
- final boolean isHardwareRasterizer[] = new boolean[1];
- GLProfile defaultGLProfileAny = null;
- GLProfile defaultGLProfileHW = null;
- final HashMap _mappedProfiles = new HashMap(GL_PROFILE_LIST_ALL.length + 1 /* default */);
- for(int i=0; i profileImpl "+profileImpl+" !!! not mapped ");
- }
- glProfile = new GLProfile(profile, _mglp, isHardwareRasterizer[0], false /* custom */);
- }
- _mappedProfiles.put(profile, glProfile);
- if (DEBUG) {
- System.err.println("GLProfile.init map "+glProfile+" on device "+device.getConnection());
- }
- if( null == defaultGLProfileHW && isHardwareRasterizer[0] ) {
- defaultGLProfileHW=glProfile;
- if (DEBUG) {
- System.err.println("GLProfile.init map defaultHW "+glProfile+" on device "+device.getConnection());
- }
- } else if( null == defaultGLProfileAny ) {
- defaultGLProfileAny=glProfile;
- if (DEBUG) {
- System.err.println("GLProfile.init map defaultAny "+glProfile+" on device "+device.getConnection());
- }
- }
- } else {
- if (DEBUG) {
- System.err.println("GLProfile.init map *** no mapping for "+profile+" on device "+device.getConnection());
- }
- }
- }
- if( null != defaultGLProfileHW ) {
- _mappedProfiles.put(GL_DEFAULT, defaultGLProfileHW);
- } else if( null != defaultGLProfileAny ) {
- _mappedProfiles.put(GL_DEFAULT, defaultGLProfileAny);
- }
- setProfileMap(device, _mappedProfiles);
- return _mappedProfiles.size() > 0;
- }
-
- /**
- * Returns the profile implementation
- */
- private static String computeProfileImpl(final AbstractGraphicsDevice device, final String profile, final boolean desktopCtxUndef, final boolean esCtxUndef, final boolean isHardwareRasterizer[]) {
- final boolean hardwareRasterizer[] = new boolean[1];
- if ( GL2ES1 == profile ) {
- final boolean gles1Available;
- final boolean gles1HWAvailable;
- if( hasGLES1Impl ) {
- gles1Available = esCtxUndef || GLContext.isGLES1Available(device, hardwareRasterizer);
- gles1HWAvailable = gles1Available && hardwareRasterizer[0] ;
- } else {
- gles1Available = false;
- gles1HWAvailable = false;
- }
- if(hasGL234Impl) {
- final boolean gl3bcAvailable = GLContext.isGL3bcAvailable(device, hardwareRasterizer);
- final boolean gl3bcHWAvailable = gl3bcAvailable && hardwareRasterizer[0] ;
- final boolean gl2Available = GLContext.isGL2Available(device, hardwareRasterizer);
- final boolean gl2HWAvailable = gl2Available && hardwareRasterizer[0] ;
- final boolean glAnyHWAvailable = gl3bcHWAvailable || gl2HWAvailable ||
- gles1HWAvailable ;
-
- if( GLContext.isGL4bcAvailable(device, isHardwareRasterizer) &&
- ( isHardwareRasterizer[0] || !glAnyHWAvailable ) ) {
- return GL4bc;
- }
- if( gl3bcAvailable && ( gl3bcHWAvailable || !glAnyHWAvailable ) ) {
- isHardwareRasterizer[0] = gl3bcHWAvailable;
- return GL3bc;
- }
- if( ( desktopCtxUndef || gl2Available ) && ( gl2HWAvailable || !glAnyHWAvailable ) ) {
- isHardwareRasterizer[0] = gl2HWAvailable;
- return GL2;
- }
- }
- if( gles1Available ) {
- isHardwareRasterizer[0] = gles1HWAvailable;
- return GLES1;
- }
- } else if ( GL2ES2 == profile ) {
- final boolean gles2Available, gles3Available;
- final boolean gles2HWAvailable, gles3HWAvailable;
- if( hasGLES3Impl ) {
- gles2Available = esCtxUndef || GLContext.isGLES2Available(device, hardwareRasterizer);
- gles2HWAvailable = gles2Available && hardwareRasterizer[0] ;
- gles3Available = esCtxUndef || GLContext.isGLES3Available(device, hardwareRasterizer);
- gles3HWAvailable = gles3Available && hardwareRasterizer[0] ;
- } else {
- gles2Available = false;
- gles2HWAvailable = false;
- gles3Available = false;
- gles3HWAvailable = false;
- }
- if( hasGL234Impl ) {
- final boolean gl4bcAvailable = GLContext.isGL4bcAvailable(device, hardwareRasterizer);
- final boolean gl4bcHWAvailable = gl4bcAvailable && hardwareRasterizer[0] ;
- final boolean gl3Available = GLContext.isGL3Available(device, hardwareRasterizer);
- final boolean gl3HWAvailable = gl3Available && hardwareRasterizer[0] ;
- final boolean gl3bcAvailable = GLContext.isGL3bcAvailable(device, hardwareRasterizer);
- final boolean gl3bcHWAvailable = gl3bcAvailable && hardwareRasterizer[0] ;
- final boolean gl2Available = GLContext.isGL2Available(device, hardwareRasterizer);
- final boolean gl2HWAvailable = gl2Available && hardwareRasterizer[0] ;
- final boolean glAnyHWAvailable = gl4bcHWAvailable || gl3HWAvailable || gl3bcHWAvailable || gl2HWAvailable ||
- gles3HWAvailable || gles2HWAvailable ;
-
- if( GLContext.isGL4Available(device, isHardwareRasterizer) &&
- ( isHardwareRasterizer[0] || !glAnyHWAvailable ) ) {
- return GL4;
- }
- if( gl4bcAvailable && ( gl4bcHWAvailable || !glAnyHWAvailable ) ) {
- isHardwareRasterizer[0] = gl4bcHWAvailable;
- return GL4bc;
- }
- if( gl3Available && ( gl3HWAvailable || !glAnyHWAvailable ) ) {
- isHardwareRasterizer[0] = gl3HWAvailable;
- return GL3;
- }
- if( gl3bcAvailable && ( gl3bcHWAvailable || !glAnyHWAvailable ) ) {
- isHardwareRasterizer[0] = gl3bcHWAvailable;
- return GL3bc;
- }
- if( ( desktopCtxUndef || gl2Available ) && ( gl2HWAvailable || !glAnyHWAvailable ) ) {
- isHardwareRasterizer[0] = gl2HWAvailable;
- return GL2;
- }
- }
- if( gles3Available && ( gles3HWAvailable || !gles2HWAvailable ) ) {
- isHardwareRasterizer[0] = gles3HWAvailable;
- return GLES3;
- }
- if( gles2Available ) {
- isHardwareRasterizer[0] = gles2HWAvailable;
- return GLES2;
- }
- } else if (GL4ES3 == profile) {
- final boolean gles3CompatAvail = GLContext.isGLES3CompatibleAvailable(device);
- if( desktopCtxUndef || esCtxUndef || gles3CompatAvail ) {
- final boolean es3HardwareRasterizer[] = new boolean[1];
- final boolean gles3Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, es3HardwareRasterizer) );
- final boolean gles3HWAvailable = gles3Available && es3HardwareRasterizer[0] ;
- if( hasGL234Impl ) {
- final boolean gl4bcAvailable = GLContext.isGL4bcAvailable(device, hardwareRasterizer);
- final boolean gl4bcHWAvailable = gl4bcAvailable && hardwareRasterizer[0] ;
- final boolean glAnyHWAvailable = gl4bcHWAvailable ||
- gles3HWAvailable;
-
- if( GLContext.isGL4Available(device, isHardwareRasterizer) &&
- ( isHardwareRasterizer[0] || !glAnyHWAvailable ) ) {
- return GL4;
- }
- if( ( desktopCtxUndef || gl4bcAvailable ) && ( gl4bcHWAvailable || !glAnyHWAvailable ) ) {
- isHardwareRasterizer[0] = gl4bcHWAvailable;
- return GL4bc;
- }
- }
- if(gles3Available) {
- isHardwareRasterizer[0] = es3HardwareRasterizer[0];
- return GLES3;
- }
- }
- } else if(GL2GL3 == profile) {
- if(hasGL234Impl) {
- final boolean gl4Available = GLContext.isGL4Available(device, hardwareRasterizer);
- final boolean gl4HWAvailable = gl4Available && hardwareRasterizer[0] ;
- final boolean gl3Available = GLContext.isGL3Available(device, hardwareRasterizer);
- final boolean gl3HWAvailable = gl3Available && hardwareRasterizer[0] ;
- final boolean gl3bcAvailable = GLContext.isGL3bcAvailable(device, hardwareRasterizer);
- final boolean gl3bcHWAvailable = gl3bcAvailable && hardwareRasterizer[0] ;
- final boolean gl2Available = GLContext.isGL2Available(device, hardwareRasterizer);
- final boolean gl2HWAvailable = gl2Available && hardwareRasterizer[0] ;
- final boolean glAnyHWAvailable = gl4HWAvailable || gl3HWAvailable || gl3bcHWAvailable || gl2HWAvailable;
-
- if( GLContext.isGL4bcAvailable(device, isHardwareRasterizer) &&
- ( isHardwareRasterizer[0] || !glAnyHWAvailable ) ) {
- return GL4bc;
- }
- if( gl4Available && ( gl4HWAvailable || !glAnyHWAvailable ) ) {
- isHardwareRasterizer[0] = gl4HWAvailable;
- return GL4;
- }
- if( gl3bcAvailable && ( gl3bcHWAvailable || !glAnyHWAvailable ) ) {
- isHardwareRasterizer[0] = gl3bcHWAvailable;
- return GL3bc;
- }
- if( gl3Available && ( gl3HWAvailable || !glAnyHWAvailable ) ) {
- isHardwareRasterizer[0] = gl3HWAvailable;
- return GL3;
- }
- if( desktopCtxUndef || gl2Available ) {
- isHardwareRasterizer[0] = gl2HWAvailable;
- return GL2;
- }
- }
- } else if(GL4bc == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4bcAvailable(device, isHardwareRasterizer))) {
- return desktopCtxUndef ? GL4bc : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_COMPAT);
- } else if(GL4 == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4Available(device, isHardwareRasterizer))) {
- return desktopCtxUndef ? GL4 : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_CORE);
- } else if(GL3bc == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer))) {
- return desktopCtxUndef ? GL3bc : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_COMPAT);
- } else if(GL3 == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3Available(device, isHardwareRasterizer))) {
- return desktopCtxUndef ? GL3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_CORE);
- } else if(GL2 == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer))) {
- return desktopCtxUndef ? GL2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_COMPAT);
- } else if(GLES3 == profile && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, isHardwareRasterizer))) {
- return esCtxUndef ? GLES3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_ES);
- } else if(GLES2 == profile && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) {
- return esCtxUndef ? GLES2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_ES);
- } else if(GLES1 == profile && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) {
- return esCtxUndef ? GLES1 : GLContext.getAvailableGLProfileName(device, 1, GLContext.CTX_PROFILE_ES);
- }
- return null;
- }
-
- private static /*final*/ HashMap> deviceConn2ProfileMap =
- new HashMap>();
-
- /**
- * This implementation support lazy initialization, while avoiding recursion/deadlocks.
- * If no mapping 'device -> GLProfiles-Map' exists yet, it triggers
- * - create empty mapping device -> GLProfiles-Map
- * - initialization GLProfiles-Map'
- * @param throwExceptionOnZeroProfile true if GLException shall be thrown in case of no mapped profile, otherwise false.
- * @return the GLProfile HashMap if exists, otherwise null
- * @throws GLException if no profile for the given device is available.
- */
- private static HashMap getProfileMap(AbstractGraphicsDevice device, final boolean throwExceptionOnZeroProfile)
- throws GLException
- {
- initSingleton();
-
- if(null==defaultDevice) { // avoid NPE and notify of incomplete initialization
- throw new GLException("No default device available");
- }
-
- if(null==device) {
- device = defaultDevice;
- }
-
- final String deviceKey = device.getUniqueID();
- HashMap map = deviceConn2ProfileMap.get(deviceKey);
- if( null != map ) {
- return map;
- }
- if( !initProfilesForDevice(device) ) {
- if( throwExceptionOnZeroProfile ) {
- throw new GLException("No Profile available for "+device);
- } else {
- return null;
- }
- }
- map = deviceConn2ProfileMap.get(deviceKey);
- if( null == map && throwExceptionOnZeroProfile ) {
- throw new InternalError("initProfilesForDevice(..) didn't setProfileMap(..) for "+device);
- }
- return map;
- }
-
- private static void setProfileMap(final AbstractGraphicsDevice device, final HashMap mappedProfiles) {
- synchronized ( deviceConn2ProfileMap ) {
- deviceConn2ProfileMap.put(device.getUniqueID(), mappedProfiles);
- }
- }
-
- private GLProfile(final String profile, final GLProfile profileImpl, final boolean isHardwareRasterizer, final boolean isCustom) {
- this.profile = profile;
- this.profileImpl = profileImpl;
- this.isHardwareRasterizer = isHardwareRasterizer;
- this.isCustom = isCustom;
- }
-
- public static GLProfile createCustomGLProfile(final String profile, final GLProfile profileImpl) {
- return new GLProfile(profile, profileImpl, profileImpl.isHardwareRasterizer, true);
- }
-
- private final GLProfile profileImpl;
- private final String profile;
- private final boolean isHardwareRasterizer;
- private final boolean isCustom;
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLRunnable.java b/src/jogl/classes/javax/media/opengl/GLRunnable.java
deleted file mode 100644
index 97a72d6cd..000000000
--- a/src/jogl/classes/javax/media/opengl/GLRunnable.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl;
-
-/**
- *
- * Declares a one-shot OpenGL command usable for injection
- * via {@link GLAutoDrawable#invoke(boolean, com.jogamp.opengl.GLRunnable)}.
- * {@link GLAutoDrawable} executes the GLRunnables within it's {@link GLAutoDrawable#display() display()}
- * method after all registered {@link GLEventListener}s
- * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)}
- * methods has been called.
- *
- *
- * The OpenGL context is current while executing the GLRunnable.
- *
- *
- * This might be useful to inject OpenGL commands from an I/O event listener.
- *
- */
-public interface GLRunnable {
- /**
- * @param drawable the associated drawable and current context for this call
- * @return true if the GL [back] framebuffer remains intact by this runnable, otherwise false.
- * If returning false {@link GLAutoDrawable} will call
- * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)}
- * of all registered {@link GLEventListener}s once more.
- * @see GLRunnable
- */
- boolean run(GLAutoDrawable drawable);
-}
-
diff --git a/src/jogl/classes/javax/media/opengl/GLRunnable2.java b/src/jogl/classes/javax/media/opengl/GLRunnable2.java
deleted file mode 100644
index 4b0c63da0..000000000
--- a/src/jogl/classes/javax/media/opengl/GLRunnable2.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright 2012 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl;
-
-/**
- *
- * Declares a one-shot OpenGL command.
- *
- */
-public interface GLRunnable2 {
- /**
- * @param gl a current GL object
- * @param args custom arguments
- * @return the desired object
- */
- T run(GL gl, U args);
-}
-
diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java
deleted file mode 100644
index 852ebcaa7..000000000
--- a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- * Copyright 2013 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl;
-
-import com.jogamp.opengl.GLRendererQuirks;
-
-/**
- * Adds capabilities to set a shared {@link GLContext} directly or via an {@link GLAutoDrawable}.
- *
- * Sharing of server-side OpenGL objects such as buffer objects, e.g. VBOs,
- * and textures among OpenGL contexts is supported with this interface.
- *
- *
- * A master {@link GLContext} is the {@link GLContext} which is created first.
- * Subsequent shared {@link GLContext} w/ the master are referred as slave {@link GLContext}.
- *
- *
- * Implementations of this interface control the slave's {@link GLContext} and {@link GLAutoDrawable} realization,
- * i.e. the slave {@link GLAutoDrawable} will not be realized before their associated master.
- *
- *
- * Using the nearest or same {@link GLCapabilitiesImmutable#getVisualID(com.jogamp.nativewindow.VisualIDHolder.VIDType) visual ID}
- * or {@link GLCapabilitiesImmutable caps} across the shared {@link GLDrawable}s will yield best compatibility.
- *
- * After shared objects are created on the master, the OpenGL pipeline
- * might need to be synchronized w/ the slaves, e.g. via {@link GL#glFinish()}.
- * At least this has been experienced w/ OSX 10.9.
- *
- *
- * In general, destroying a master {@link GLContext} before their shared slaves
- * shall be permissible, i.e. the OpenGL driver needs to handle pending destruction of shared resources.
- * This is confirmed to work properly on most platform/driver combinations,
- * see unit test com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 and similar.
- *
- *
- * However, to avoid scenarios with buggy drivers, users may not destroy the
- * master {@link GLContext} before its shared slave {@link GLContext} instances
- * as long as they are using them.
- * Otherwise the OpenGL driver may crash w/ SIGSEGV, due to using already destroyed shared resources,
- * if not handling the pending destruction of the latter!
- * Either proper lifecycle synchronization is implemented, e.g. by notifying the slaves about the loss of the shared resources,
- * or the slaves validate whether the resources are still valid.
- *
- *
- * To simplify above lifecycle issues, one may use a {@link GLDrawableFactory#createDummyDrawable(com.jogamp.nativewindow.AbstractGraphicsDevice, boolean, GLCapabilitiesImmutable, GLCapabilitiesChooser) dummy}
- * {@link GLDrawable} and it's {@link GLContext} as the master of all shared slave {@link GLContext}.
- * Since this dummy instance does not depend on any native windowing system, it can be controlled easily w/o being in sight.
- * Below code creates a {@link GLAutoDrawable} based on a dummy GLDrawable:
- *
- // GLProfile and GLCapabilities should be equal across all shared GL drawable/context.
- final GLCapabilitiesImmutable caps = ... ;
- final GLProfile glp = caps.getGLProfile();
- ..
- final boolean createNewDevice = true; // use 'own' display device!
- final GLAutoDrawable sharedDrawable = GLDrawableFactory.getFactory(glp).createDummyAutoDrawable(null, createNewDevice, caps, null);
- sharedDrawable.display(); // triggers GLContext object creation and native realization.
- ...
- // Later a shared 'slave' can be created e.g.:
- GLWindow glad = GLWindow.create(caps); // or any other GLAutoDrawable supporting GLSharedContextSetter
- glad.setSharedAutoDrawable(sharedDrawable);
- glad.addGLEventListener(..);
- glad.setVisible(true); // GLWindow creation ..
- *
- * Usually synchronization of shared GL objects should not be required, if the shared GL objects
- * are created and immutable before concurrent usage.
- *
- *
- * However, using drivers exposing {@link GLRendererQuirks#NeedSharedObjectSync} always
- * require the user to synchronize access of shared GL objects.
- *
- *
- * Synchronization can be avoided if accessing the shared GL objects
- * exclusively via a queue or {@link com.jogamp.common.util.Ringbuffer Ringbuffer}, see GLMediaPlayerImpl as an example.
- *
- * Error: 'intel_do_flush_locked: No such file or directory'
- * JogAmp: https://jogamp.org/bugzilla/show_bug.cgi?id=873
- * freedesktop.org: https://bugs.freedesktop.org/show_bug.cgi?id=41736#c8
- *
- * Shared context seems not to be supported w/ lock-free bound X11 display connections
- * per OpenGL drawable/context. The error message above is thrown in this case.
- * Hence the driver bug renders shared context use w/ JOGL impossible.
- *
- * Hisilicon's Immersion.16 on Android
- *
- * We failed to create a shared ES2 context on another thread.
- *
- */
-public interface GLSharedContextSetter extends GLAutoDrawable {
- /**
- * Specifies an {@link GLContext OpenGL context}, which shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}.
- *
- * Since the {@link GLDrawable drawable} and {@link GLContext context} is created
- * at {@link GLAutoDrawable#initialization GLAutoDrawable initialization}
- * this method shall be called beforehand to have any effect.
- *
- *
- * A set sharedContext will block context creation, i.e. {@link GLAutoDrawable#initialization GLAutoDrawable initialization},
- * as long it is not {@link GLContext#isCreated() created natively}.
- *
- *
- * The preferred method of assigning a shared context is
- * to {@link #setSharedAutoDrawable(GLAutoDrawable) set the shared GLAutoDrawable},
- * since this method also takes the {@link GLEventListener}
- * {@link GLAutoDrawable#areAllGLEventListenerInitialized() initialization into account}.
- *
- *
- * @param sharedContext The OpenGL context to be shared by this {@link GLAutoDrawable}'s {@link GLContext}.
- * @throws IllegalStateException if a {@link #setSharedContext(GLContext) shared GLContext}
- * or {@link #setSharedAutoDrawable(GLAutoDrawable) shared GLAutoDrawable} is already set,
- * the given sharedContext is null or equal to this {@link GLAutoDrawable}'s context.
- * @see #setSharedAutoDrawable(GLAutoDrawable)
- */
- void setSharedContext(GLContext sharedContext) throws IllegalStateException;
-
- /**
- * Specifies an {@link GLAutoDrawable}, which {@link GLContext OpenGL context} shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}.
- *
- * Since the {@link GLDrawable drawable} and {@link GLContext context} is created
- * at {@link GLAutoDrawable#initialization GLAutoDrawable initialization}
- * this method shall be called beforehand to have any effect.
- *
- *
- * A set sharedAutoDrawable will block context creation, i.e. initialization
- * as long it's
- *
- *
{@link GLContext} is null, or
- *
{@link GLContext} has not been {@link GLContext#isCreated() created natively}, or
- *
{@link GLEventListener} are not {@link GLAutoDrawable#areAllGLEventListenerInitialized() completely initialized}
- *
- * @param sharedContext The GLAutoDrawable, which OpenGL context shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}.
- * @throws IllegalStateException if a {@link #setSharedContext(GLContext) shared GLContext}
- * or {@link #setSharedAutoDrawable(GLAutoDrawable) shared GLAutoDrawable} is already set,
- * the given sharedAutoDrawable is null or equal to this GLAutoDrawable.
- * @see #setSharedContext(GLContext)
- */
- void setSharedAutoDrawable(GLAutoDrawable sharedAutoDrawable) throws IllegalStateException;
-}
diff --git a/src/jogl/classes/javax/media/opengl/GLUniformData.java b/src/jogl/classes/javax/media/opengl/GLUniformData.java
deleted file mode 100644
index 44f7f29c7..000000000
--- a/src/jogl/classes/javax/media/opengl/GLUniformData.java
+++ /dev/null
@@ -1,227 +0,0 @@
-
-package com.jogamp.opengl;
-
-import java.nio.*;
-
-import com.jogamp.common.nio.Buffers;
-import com.jogamp.opengl.math.FloatUtil;
-
-public class GLUniformData {
-
- /**
- * int atom
- *
- * Number of objects is 1
- *
- */
- public GLUniformData(final String name, final int val) {
- initScalar(name, 1, Integer.valueOf(val));
- }
-
- /**
- * float atom
- *
- * Number of objects is 1
- *
- */
- public GLUniformData(final String name, final float val) {
- initScalar(name, 1, Float.valueOf(val));
- }
-
- /**
- * Multiple IntBuffer Vector
- *
- * Number of objects is calculated by data.limit()/components
- *
- * @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
- */
- public GLUniformData(final String name, final int components, final IntBuffer data) {
- initBuffer(name, components, data);
- }
-
- /**
- * Multiple FloatBuffer Vector
- *
- * Number of objects is calculated by data.limit()/components
- *
- * @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4,
- */
- public GLUniformData(final String name, final int components, final FloatBuffer data) {
- initBuffer(name, components, data);
- }
-
- private GLUniformData(final int components, final String name) {
- initBuffer(name, components, null);
- }
-
- public static GLUniformData creatEmptyVector(final String name, final int components) {
- return new GLUniformData(components, name);
- }
-
- public static GLUniformData creatEmptyMatrix(final String name, final int rows, final int columns) {
- return new GLUniformData(name, rows, columns, null);
- }
-
- /**
- * Multiple FloatBuffer Matrix
- *
- * Number of objects is calculated by data.limit()/(rows*columns)
- *
- * @param rows the matrix rows
- * @param column the matrix column
- */
- public GLUniformData(final String name, final int rows, final int columns, final FloatBuffer data) {
- initBuffer(name, rows, columns, data);
- }
-
- public GLUniformData setData(final int data) { initScalar(Integer.valueOf(data)); return this; }
- public GLUniformData setData(final float data) { initScalar(Float.valueOf(data)); return this; }
- public GLUniformData setData(final IntBuffer data) { initBuffer(data); return this; }
- public GLUniformData setData(final FloatBuffer data) { initBuffer(data); return this; }
-
- public int intValue() { return ((Integer)data).intValue(); };
- public float floatValue() { return ((Float)data).floatValue(); };
- public IntBuffer intBufferValue() { return (IntBuffer)data; };
- public FloatBuffer floatBufferValue() { return (FloatBuffer)data; };
-
- public StringBuilder toString(StringBuilder sb) {
- if(null == sb) {
- sb = new StringBuilder();
- }
- sb.append("GLUniformData[name ").append(name).
- append(", location ").append(location).
- append(", size ").append(rows).append("x").append(columns).
- append(", count ").append(count).
- append(", data ");
- if(isMatrix() && data instanceof FloatBuffer) {
- sb.append("\n");
- final FloatBuffer fb = (FloatBuffer)getBuffer();
- for(int i=0; irows || rows>4 || 2>columns || columns>4 ) {
- throw new GLException("rowsXcolumns must be within [2..4]X[2..4], is: "+rows+"X"+columns);
- }
- this.name=name;
- this.rows=rows;
- this.columns=columns;
- this.isMatrix=true;
- this.location=-1;
- initBuffer(buffer);
- }
- private void initScalar(final String name, final int components, final Object data) {
- if( 1>components || components>4 ) {
- throw new GLException("components must be within [1..4], is: "+components);
- }
- this.name=name;
- this.columns=components;
- this.rows=1;
- this.isMatrix=false;
- this.location=-1;
- initScalar(data);
- }
- private void initBuffer(final String name, final int components, final Buffer buffer) {
- if( 1>components || components>4 ) {
- throw new GLException("components must be within [1..4], is: "+components);
- }
- this.name=name;
- this.columns=components;
- this.rows=1;
- this.isMatrix=false;
- this.location=-1;
- initBuffer(buffer);
- }
-
- private void initScalar(final Object data) {
- if(data instanceof Buffer) {
- initBuffer((Buffer)data);
- } else if( null != data ) {
- if(isMatrix) {
- throw new GLException("Atom type not allowed for matrix : "+this);
- }
- this.count=1;
- this.data=data;
- } else {
- this.count=0;
- this.data=data;
- }
- }
-
- private void initBuffer(final Buffer buffer) {
- if( null != buffer ) {
- final int sz = rows*columns;
- if(buffer.remaining()
- * No validation is performed within the implementation.
- *
- * @param gl
- * @param program
- * @return ≥0 denotes a valid uniform location as found and used in the given shader program.
- * <0 denotes an invalid location, i.e. not found or used in the given shader program.
- */
- public int setLocation(final GL2ES2 gl, final int program) {
- location = gl.glGetUniformLocation(program, name);
- return location;
- }
-
- public Object getObject() {
- return data;
- }
- public Buffer getBuffer() {
- return (data instanceof Buffer)?(Buffer)data:null;
- }
- public boolean isBuffer() {
- return (data instanceof Buffer);
- }
- public boolean isMatrix() { return isMatrix; }
-
- public int count() { return count; }
- public int components() { return rows*columns; }
- public int rows() { return rows; }
- public int columns() { return columns; }
-
- private String name;
- private int location;
- private int rows, columns;
- private int count;
- private Object data;
- private boolean isMatrix;
-}
diff --git a/src/jogl/classes/javax/media/opengl/Threading.java b/src/jogl/classes/javax/media/opengl/Threading.java
deleted file mode 100644
index 852c8081f..000000000
--- a/src/jogl/classes/javax/media/opengl/Threading.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2012 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl;
-
-import jogamp.opengl.ThreadingImpl;
-
-/** This API provides access to the threading model for the implementation of
- the classes in this package.
-
-
-
- OpenGL is specified as a thread-safe API, but in practice there
- are multithreading-related issues on most, if not all, of the
- platforms which support it. For example, some OpenGL
- implementations do not behave well when one context is made
- current first on one thread, released, and then made current on a
- second thread, although this is legal according to the OpenGL
- specification. On other platforms there are other problems.
-
-
-
- Due to these limitations, and due to the inherent multithreading
- in the Java platform (in particular, in the Abstract Window
- Toolkit), it is often necessary to limit the multithreading
- occurring in the typical application using the OpenGL API.
-
-
-
- In the current reference implementation, for instance, multithreading
- has been limited by
- forcing all OpenGL-related work for GLAutoDrawables on to a single
- thread. In other words, if an application uses only the
- GLAutoDrawable and GLEventListener callback mechanism, it is
- guaranteed to have the most correct single-threaded behavior on
- all platforms.
-
-
-
- Applications using the GLContext makeCurrent/release API directly
- will inherently break this single-threaded model, as these methods
- require that the OpenGL context be made current on the current
- thread immediately. For applications wishing to integrate better
- with an implementation that uses the single-threaded model, this
- class provides public access to the mechanism used by the implementation.
-
-
-
- Users can execute Runnables on the
- internal thread used for performing OpenGL work, and query whether
- the current thread is already this thread. Using these mechanisms
- the user can move work from the current thread on to the internal
- OpenGL thread if desired.
-
-
-
- This class also provides mechanisms for querying whether this
- internal serialization of OpenGL work is in effect, and a
- programmatic way of disabling it. In the current reference
- implementation it is enabled by default, although it could be
- disabled in the future if OpenGL drivers become more robust on
- all platforms.
-
-
-
- In addition to specifying programmatically whether the single
- thread for OpenGL work is enabled, users may switch it on and off
- using the system property jogl.1thread. Valid values
- for this system property are:
-
-
- -Djogl.1thread=false Disable single-threading of OpenGL work, hence use multithreading.
- -Djogl.1thread=true Enable single-threading of OpenGL work (default -- on a newly-created worker thread)
- -Djogl.1thread=auto Select default single-threading behavior (currently on)
- -Djogl.1thread=awt Enable single-threading of OpenGL work on AWT event dispatch thread (current default on all
- platforms, and also the default behavior older releases)
- -Djogl.1thread=worker Enable single-threading of OpenGL work on newly-created worker thread (not suitable for Mac
- OS X or X11 platforms, and risky on Windows in applet environments)
-
-*/
-
-public class Threading {
- public static enum Mode {
- /**
- * Full multithreaded OpenGL,
- * i.e. any {@link Threading#invoke(boolean, Runnable, Object) invoke}
- * {@link Threading#invokeOnOpenGLThread(boolean, Runnable) commands}
- * will be issued on the current thread immediately.
- */
- MT(0),
-
- /** Single-Threaded OpenGL on AWT EDT */
- ST_AWT(1),
-
- /** Single-Threaded OpenGL on dedicated worker thread. */
- ST_WORKER(2);
-
- public final int id;
-
- Mode(final int id){
- this.id = id;
- }
- }
-
- /** No reason to ever instantiate this class */
- private Threading() {}
-
- /** Returns the threading mode */
- public static Mode getMode() {
- return ThreadingImpl.getMode();
- }
-
- /** If an implementation of the com.jogamp.opengl APIs offers a
- multithreading option but the default behavior is single-threading,
- this API provides a mechanism for end users to disable single-threading
- in this implementation. Users are strongly discouraged from
- calling this method unless they are aware of all of the
- consequences and are prepared to enforce some amount of
- threading restrictions in their applications. Disabling
- single-threading, for example, may have unintended consequences
- on GLAutoDrawable implementations such as GLCanvas and GLJPanel.
- Currently there is no supported way to re-enable it
- once disabled, partly to discourage careless use of this
- method. This method should be called as early as possible in an
- application. */
- public static final void disableSingleThreading() {
- ThreadingImpl.disableSingleThreading();
- }
-
- /** Indicates whether OpenGL work is being automatically forced to a
- single thread in this implementation. */
- public static final boolean isSingleThreaded() {
- return ThreadingImpl.isSingleThreaded();
- }
-
- /** Indicates whether the current thread is the designated toolkit thread,
- if such semantics exists. */
- public static final boolean isToolkitThread() throws GLException {
- return ThreadingImpl.isToolkitThread();
- }
-
- /**
- * Indicates whether the current thread is capable of
- * performing OpenGL-related work.
- *
- */
- public static final boolean isOpenGLThread() throws GLException {
- return ThreadingImpl.isOpenGLThread();
- }
-
- /** Executes the passed Runnable on the single thread used for all
- OpenGL work in this com.jogamp.opengl API implementation. It is
- not specified exactly which thread is used for this
- purpose. This method should only be called if the single-thread
- model is in use and if the current thread is not the OpenGL
- thread (i.e., if isOpenGLThread() returns
- false). It is up to the end user to check to see whether the
- current thread is the OpenGL thread and either execute the
- Runnable directly or perform the work inside it.
- **/
- public static final void invokeOnOpenGLThread(final boolean wait, final Runnable r) throws GLException {
- ThreadingImpl.invokeOnOpenGLThread(wait, r);
- }
-
- /**
- * If not {@link #isOpenGLThread()}
- * and the lock is not being hold by this thread,
- * invoke Runnable r on the OpenGL thread via {@link #invokeOnOpenGLThread(boolean, Runnable)}.
- *
- * Otherwise invoke Runnable r on the current thread.
- *
- *
- * @param wait set to true for waiting until Runnable r is finished, otherwise false.
- * @param r the Runnable to be executed
- * @param lock optional lock object to be tested
- * @throws GLException
- */
- public static final void invoke(final boolean wait, final Runnable r, final Object lock) throws GLException {
- if ( !isOpenGLThread() &&
- ( null == lock || !Thread.holdsLock(lock) ) ) {
- invokeOnOpenGLThread(wait, r);
- } else {
- r.run();
- }
- }
-}
diff --git a/src/jogl/classes/javax/media/opengl/TraceGL2.java b/src/jogl/classes/javax/media/opengl/TraceGL2.java
deleted file mode 100644
index 1609398e7..000000000
--- a/src/jogl/classes/javax/media/opengl/TraceGL2.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jogamp.opengl;
-
-import java.io.PrintStream;
-
-/**
- *
- * Composable pipeline which wraps an underlying {@link GL} implementation,
- * providing tracing information to a user-specified {@link java.io.PrintStream}
- * before and after each OpenGL method call.
- *
- *
- * Sample code which installs this pipeline, manual:
- *
- * Composable pipeline which wraps an underlying {@link GL} implementation,
- * providing tracing information to a user-specified {@link java.io.PrintStream}
- * before and after each OpenGL method call.
- *
- *
- * Sample code which installs this pipeline, manual:
- *
- * Composable pipeline which wraps an underlying {@link GL} implementation,
- * providing tracing information to a user-specified {@link java.io.PrintStream}
- * before and after each OpenGL method call.
- *
- *
- * Sample code which installs this pipeline, manual:
- *
- * Composable pipeline which wraps an underlying {@link GL} implementation,
- * providing tracing information to a user-specified {@link java.io.PrintStream}
- * before and after each OpenGL method call.
- *
- *
- * Sample code which installs this pipeline, manual:
- *
- * Composable pipeline which wraps an underlying {@link GL} implementation,
- * providing tracing information to a user-specified {@link java.io.PrintStream}
- * before and after each OpenGL method call.
- *
- *
- * Sample code which installs this pipeline, manual:
- *
- * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}.
- *
- */
-public class TraceGLES2 extends TraceGLES3 {
- public TraceGLES2(final GLES2 downstream, final PrintStream stream) {
- super((GLES3)downstream, stream);
- }
-}
diff --git a/src/jogl/classes/javax/media/opengl/awt/AWTGLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/awt/AWTGLAutoDrawable.java
deleted file mode 100644
index 6e273e4e6..000000000
--- a/src/jogl/classes/javax/media/opengl/awt/AWTGLAutoDrawable.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl.awt;
-
-import com.jogamp.opengl.GLAutoDrawable;
-
-public interface AWTGLAutoDrawable extends GLAutoDrawable, ComponentEvents {
- /** Requests a new width and height for this AWTGLAutoDrawable. */
- public void setSize(int width, int height);
-
- /** Schedules a repaint of the component at some point in the
- future. */
- public void repaint();
-}
diff --git a/src/jogl/classes/javax/media/opengl/awt/ComponentEvents.java b/src/jogl/classes/javax/media/opengl/awt/ComponentEvents.java
deleted file mode 100644
index 996776c9b..000000000
--- a/src/jogl/classes/javax/media/opengl/awt/ComponentEvents.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl.awt;
-
-import com.jogamp.opengl.*;
-import java.awt.event.*;
-import java.beans.PropertyChangeListener;
-
-/** Factors out the listener manipulation for the events supported by
- all of the {@link GLDrawable} implementations. Provided to reduce
- clutter in the documentation for GLDrawable. */
-
-public interface ComponentEvents {
- public void addComponentListener(ComponentListener l);
- public void removeComponentListener(ComponentListener l);
- public void addFocusListener(FocusListener l);
- public void removeFocusListener(FocusListener l);
- public void addHierarchyBoundsListener(HierarchyBoundsListener l);
- public void removeHierarchyBoundsListener(HierarchyBoundsListener l);
- public void addHierarchyListener(HierarchyListener l);
- public void removeHierarchyListener(HierarchyListener l);
- public void addInputMethodListener(InputMethodListener l);
- public void removeInputMethodListener(InputMethodListener l);
- public void addKeyListener(KeyListener l);
- public void removeKeyListener(KeyListener l);
- public void addMouseListener(MouseListener l);
- public void removeMouseListener(MouseListener l);
- public void addMouseMotionListener(MouseMotionListener l);
- public void removeMouseMotionListener(MouseMotionListener l);
- public void addMouseWheelListener(MouseWheelListener l);
- public void removeMouseWheelListener(MouseWheelListener l);
- public void addPropertyChangeListener(PropertyChangeListener listener);
- public void removePropertyChangeListener(PropertyChangeListener listener);
- public void addPropertyChangeListener(String propertyName,
- PropertyChangeListener listener);
- public void removePropertyChangeListener(String propertyName,
- PropertyChangeListener listener);
-}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
deleted file mode 100644
index 11d217535..000000000
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ /dev/null
@@ -1,1643 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl.awt;
-
-import java.beans.Beans;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.awt.Canvas;
-import java.awt.Color;
-import java.awt.FontMetrics;
-import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.awt.event.HierarchyEvent;
-import java.awt.event.HierarchyListener;
-import java.awt.geom.NoninvertibleTransformException;
-import java.awt.geom.Rectangle2D;
-import java.awt.EventQueue;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
-import com.jogamp.nativewindow.OffscreenLayerOption;
-import com.jogamp.nativewindow.ScalableSurface;
-import com.jogamp.nativewindow.VisualIDHolder;
-import com.jogamp.nativewindow.WindowClosingProtocol;
-import com.jogamp.nativewindow.AbstractGraphicsDevice;
-import com.jogamp.nativewindow.AbstractGraphicsScreen;
-import com.jogamp.nativewindow.GraphicsConfigurationFactory;
-import com.jogamp.nativewindow.NativeSurface;
-import com.jogamp.nativewindow.NativeWindowFactory;
-import com.jogamp.opengl.GL;
-import com.jogamp.opengl.GLAnimatorControl;
-import com.jogamp.opengl.GLAutoDrawable;
-import com.jogamp.opengl.GLCapabilities;
-import com.jogamp.opengl.GLCapabilitiesChooser;
-import com.jogamp.opengl.GLCapabilitiesImmutable;
-import com.jogamp.opengl.GLContext;
-import com.jogamp.opengl.GLDrawable;
-import com.jogamp.opengl.GLDrawableFactory;
-import com.jogamp.opengl.GLEventListener;
-import com.jogamp.opengl.GLException;
-import com.jogamp.opengl.GLOffscreenAutoDrawable;
-import com.jogamp.opengl.GLProfile;
-import com.jogamp.opengl.GLRunnable;
-import com.jogamp.opengl.GLSharedContextSetter;
-import com.jogamp.opengl.Threading;
-
-import com.jogamp.common.GlueGenVersion;
-import com.jogamp.common.util.VersionUtil;
-import com.jogamp.common.util.awt.AWTEDTExecutor;
-import com.jogamp.common.util.locks.LockFactory;
-import com.jogamp.common.util.locks.RecursiveLock;
-import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration;
-import com.jogamp.nativewindow.awt.AWTGraphicsDevice;
-import com.jogamp.nativewindow.awt.AWTGraphicsScreen;
-import com.jogamp.nativewindow.awt.AWTPrintLifecycle;
-import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol;
-import com.jogamp.nativewindow.awt.JAWTWindow;
-import com.jogamp.opengl.JoglVersion;
-import com.jogamp.opengl.util.GLDrawableUtil;
-import com.jogamp.opengl.util.TileRenderer;
-
-import jogamp.nativewindow.SurfaceScaleUtils;
-import jogamp.opengl.Debug;
-import jogamp.opengl.GLContextImpl;
-import jogamp.opengl.GLDrawableHelper;
-import jogamp.opengl.GLDrawableImpl;
-import jogamp.opengl.awt.AWTTilePainter;
-
-// FIXME: Subclasses need to call resetGLFunctionAvailability() on their
-// context whenever the displayChanged() function is called on our
-// GLEventListeners
-
-/** A heavyweight AWT component which provides OpenGL rendering
- support. This is the primary implementation of an AWT {@link GLDrawable};
- {@link GLJPanel} is provided for compatibility with Swing user
- interfaces when adding a heavyweight doesn't work either because
- of Z-ordering or LayoutManager problems.
- *
- *
- *
- * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)}
- * maybe called to use an offscreen drawable (FBO or PBuffer) allowing
- * the underlying JAWT mechanism to composite the image, if supported.
- *
- * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)}
- * is being called if {@link GLCapabilitiesImmutable#isOnscreen()} is false.
- *
- *
- * To avoid any conflicts with a potential Java2D OpenGL context,
- * you shall consider setting the following JVM properties:
- *
- *
sun.java2d.opengl=false
- *
sun.java2d.noddraw=true
- *
- * This is especially true in case you want to utilize a GLProfile other than
- * {@link GLProfile#GL2}, eg. using {@link GLProfile#getMaxFixedFunc()}.
- * On the other hand, if you like to experiment with GLJPanel's utilization
- * of Java2D's OpenGL pipeline, you have to set them to
- *
- *
- * GLCanvas tries to disable background erase for the AWT Canvas
- * before native peer creation (X11) and after it (Windows),
- * utilizing the optional {@link java.awt.Toolkit} method disableBeackgroundErase(java.awt.Canvas).
- * However if this does not give you the desired results, you may want to disable AWT background erase in general:
- *
- * To share a {@link GLContext} see the following note in the documentation overview:
- * context sharing
- * as well as {@link GLSharedContextSetter}.
- *
- */
-
-@SuppressWarnings("serial")
-public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosingProtocol, OffscreenLayerOption,
- AWTPrintLifecycle, GLSharedContextSetter, ScalableSurface {
-
- private static final boolean DEBUG = Debug.debug("GLCanvas");
-
- private final RecursiveLock lock = LockFactory.createRecursiveLock();
- private final GLDrawableHelper helper = new GLDrawableHelper();
- private AWTGraphicsConfiguration awtConfig;
- private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access
- private volatile JAWTWindow jawtWindow; // the JAWTWindow presentation of this AWT Canvas, bound to the 'drawable' lifecycle
- private volatile GLContextImpl context; // volatile: avoid locking for read-only access
- private volatile boolean sendReshape = false; // volatile: maybe written by EDT w/o locking
- private final float[] minPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
- private final float[] maxPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
- private final float[] hasPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
- final float[] reqPixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
-
- // copy of the cstr args, mainly for recreation
- private final GLCapabilitiesImmutable capsReqUser;
- private final GLCapabilitiesChooser chooser;
- private int additionalCtxCreationFlags = 0;
- private final GraphicsDevice device;
- private boolean shallUseOffscreenLayer = false;
-
- private volatile boolean isShowing;
- private final HierarchyListener hierarchyListener = new HierarchyListener() {
- @Override
- public void hierarchyChanged(final HierarchyEvent e) {
- isShowing = GLCanvas.this.isShowing();
- }
- };
-
- private final AWTWindowClosingProtocol awtWindowClosingProtocol =
- new AWTWindowClosingProtocol(this, new Runnable() {
- @Override
- public void run() {
- GLCanvas.this.destroyImpl( true );
- }
- }, null);
-
- /** Creates a new GLCanvas component with a default set of OpenGL
- capabilities, using the default OpenGL capabilities selection
- mechanism, on the default screen device.
-
- * @throws GLException if no default profile is available for the default desktop device.
- */
- public GLCanvas() throws GLException {
- this(null);
- }
-
- /** Creates a new GLCanvas component with the requested set of
- OpenGL capabilities, using the default OpenGL capabilities
- selection mechanism, on the default screen device.
-
- * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device.
- * @see GLCanvas#GLCanvas(com.jogamp.opengl.GLCapabilitiesImmutable, com.jogamp.opengl.GLCapabilitiesChooser, com.jogamp.opengl.GLContext, java.awt.GraphicsDevice)
- */
- public GLCanvas(final GLCapabilitiesImmutable capsReqUser) throws GLException {
- this(capsReqUser, null, null);
- }
-
- /** Creates a new GLCanvas component. The passed GLCapabilities
- specifies the OpenGL capabilities for the component; if null, a
- default set of capabilities is used. The GLCapabilitiesChooser
- specifies the algorithm for selecting one of the available
- GLCapabilities for the component; a DefaultGLCapabilitesChooser
- is used if null is passed for this argument.
- The passed GraphicsDevice indicates the screen on
- which to create the GLCanvas; the GLDrawableFactory uses the
- default screen device of the local GraphicsEnvironment if null
- is passed for this argument.
-
- * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device.
- */
- public GLCanvas(final GLCapabilitiesImmutable capsReqUser,
- final GLCapabilitiesChooser chooser,
- final GraphicsDevice device)
- throws GLException
- {
- /*
- * Determination of the native window is made in 'super.addNotify()',
- * which creates the native peer using AWT's GraphicsConfiguration.
- * GraphicsConfiguration is returned by this class overwritten
- * 'getGraphicsConfiguration()', which returns our OpenGL compatible
- * 'chosen' GraphicsConfiguration.
- */
- super();
-
- if(null==capsReqUser) {
- this.capsReqUser = new GLCapabilities(GLProfile.getDefault(GLProfile.getDefaultDevice()));
- } else {
- // don't allow the user to change data
- this.capsReqUser = (GLCapabilitiesImmutable) capsReqUser.cloneMutable();
- }
- if( !this.capsReqUser.isOnscreen() ) {
- setShallUseOffscreenLayer(true); // trigger offscreen layer - if supported
- }
-
- if(null==device) {
- final GraphicsConfiguration gc = super.getGraphicsConfiguration();
- if(null!=gc) {
- this.device = gc.getDevice();
- } else {
- this.device = null;
- }
- } else {
- this.device = device;
- }
-
- // instantiation will be issued in addNotify()
- this.chooser = chooser;
-
- this.addHierarchyListener(hierarchyListener);
- this.isShowing = isShowing();
- }
-
- @Override
- public final void setSharedContext(final GLContext sharedContext) throws IllegalStateException {
- helper.setSharedContext(this.context, sharedContext);
- }
-
- @Override
- public final void setSharedAutoDrawable(final GLAutoDrawable sharedAutoDrawable) throws IllegalStateException {
- helper.setSharedAutoDrawable(this, sharedAutoDrawable);
- }
-
- @Override
- public final Object getUpstreamWidget() {
- return this;
- }
-
- @Override
- public final RecursiveLock getUpstreamLock() { return lock; }
-
- @Override
- public final boolean isThreadGLCapable() { return Threading.isOpenGLThread(); }
-
- @Override
- public void setShallUseOffscreenLayer(final boolean v) {
- shallUseOffscreenLayer = v;
- }
-
- @Override
- public final boolean getShallUseOffscreenLayer() {
- return shallUseOffscreenLayer;
- }
-
- @Override
- public final boolean isOffscreenLayerSurfaceEnabled() {
- final JAWTWindow _jawtWindow = jawtWindow;
- if(null != _jawtWindow) {
- return _jawtWindow.isOffscreenLayerSurfaceEnabled();
- }
- return false;
- }
-
-
- /**
- * Overridden to choose a GraphicsConfiguration on a parent container's
- * GraphicsDevice because both devices
- */
- @Override
- public GraphicsConfiguration getGraphicsConfiguration() {
- /*
- * Workaround for problems with Xinerama and java.awt.Component.checkGD
- * when adding to a container on a different graphics device than the
- * one that this Canvas is associated with.
- *
- * GC will be null unless:
- * - A native peer has assigned it. This means we have a native
- * peer, and are already comitted to a graphics configuration.
- * - This canvas has been added to a component hierarchy and has
- * an ancestor with a non-null GC, but the native peer has not
- * yet been created. This means we can still choose the GC on
- * all platforms since the peer hasn't been created.
- */
- final GraphicsConfiguration gc = super.getGraphicsConfiguration();
-
- if( Beans.isDesignTime() ) {
- return gc;
- }
-
- /*
- * chosen is only non-null on platforms where the GLDrawableFactory
- * returns a non-null GraphicsConfiguration (in the GLCanvas
- * constructor).
- *
- * if gc is from this Canvas' native peer then it should equal chosen,
- * otherwise it is from an ancestor component that this Canvas is being
- * added to, and we go into this block.
- */
- GraphicsConfiguration chosen = null != awtConfig ? awtConfig.getAWTGraphicsConfiguration() : null;
-
- if (gc != null && chosen != null && !chosen.equals(gc)) {
- /*
- * Check for compatibility with gc. If they differ by only the
- * device then return a new GCconfig with the super-class' GDevice
- * (and presumably the same visual ID in Xinerama).
- *
- */
- if (!chosen.getDevice().getIDstring().equals(gc.getDevice().getIDstring())) {
- /*
- * Here we select a GraphicsConfiguration on the alternate
- * device that is presumably identical to the chosen
- * configuration, but on the other device.
- *
- * Should really check to ensure that we select a configuration
- * with the same X visual ID for Xinerama screens, otherwise the
- * GLDrawable may have the wrong visual ID (I don't think this
- * ever gets updated). May need to add a method to
- * X11GLDrawableFactory to do this in a platform specific
- * manner.
- *
- * However, on platforms where we can actually get into this
- * block, both devices should have the same visual list, and the
- * same configuration should be selected here.
- */
- final AWTGraphicsConfiguration config = chooseGraphicsConfiguration( (GLCapabilitiesImmutable)awtConfig.getChosenCapabilities(),
- (GLCapabilitiesImmutable)awtConfig.getRequestedCapabilities(),
- chooser, gc.getDevice());
- final GraphicsConfiguration compatible = config.getAWTGraphicsConfiguration();
- final boolean equalCaps = config.getChosenCapabilities().equals(awtConfig.getChosenCapabilities());
- if(DEBUG) {
- System.err.println(getThreadName()+": Info:");
- System.err.println("Created Config (n): HAVE GC "+chosen);
- System.err.println("Created Config (n): THIS GC "+gc);
- System.err.println("Created Config (n): Choosen GC "+compatible);
- System.err.println("Created Config (n): HAVE CF "+awtConfig);
- System.err.println("Created Config (n): Choosen CF "+config);
- System.err.println("Created Config (n): EQUALS CAPS "+equalCaps);
- // Thread.dumpStack();
- }
-
- if (compatible != null) {
- /*
- * Save the new GC for equals test above, and to return to
- * any outside callers of this method.
- */
- chosen = compatible;
-
- if( !equalCaps && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED ) {
- // complete destruction!
- destroyImpl( true );
- // recreation!
- awtConfig = config;
- createJAWTDrawableAndContext();
- validateGLDrawable();
- } else {
- awtConfig = config;
- }
- }
- }
-
- /*
- * If a compatible GC was not found in the block above, this will
- * return the GC that was selected in the constructor (and might
- * cause an exception in Component.checkGD when adding to a
- * container, but in this case that would be the desired behavior).
- *
- */
- return chosen;
- } else if (gc == null) {
- /*
- * The GC is null, which means we have no native peer, and are not
- * part of a (realized) component hierarchy. So we return the
- * desired visual that was selected in the constructor (possibly
- * null).
- */
- return chosen;
- }
-
- /*
- * Otherwise we have not explicitly selected a GC in the constructor, so
- * just return what Canvas would have.
- */
- return gc;
- }
-
- @Override
- public GLContext createContext(final GLContext shareWith) {
- final RecursiveLock _lock = lock;
- _lock.lock();
- try {
- if(drawable != null) {
- final GLContext _ctx = drawable.createContext(shareWith);
- _ctx.setContextCreationFlags(additionalCtxCreationFlags);
- return _ctx;
- }
- return null;
- } finally {
- _lock.unlock();
- }
- }
-
- private final void setRealizedImpl(final boolean realized) {
- final RecursiveLock _lock = lock;
- _lock.lock();
- try {
- final GLDrawable _drawable = drawable;
- if( null == _drawable || realized == _drawable.isRealized() ||
- realized && ( 0 >= _drawable.getSurfaceWidth() || 0 >= _drawable.getSurfaceHeight() ) ) {
- return;
- }
- _drawable.setRealized(realized);
- if( realized && _drawable.isRealized() ) {
- sendReshape=true; // ensure a reshape is being send ..
- }
- } finally {
- _lock.unlock();
- }
- }
- private final Runnable realizeOnEDTAction = new Runnable() {
- @Override
- public void run() { setRealizedImpl(true); }
- };
- private final Runnable unrealizeOnEDTAction = new Runnable() {
- @Override
- public void run() { setRealizedImpl(false); }
- };
-
- @Override
- public final void setRealized(final boolean realized) {
- // Make sure drawable realization happens on AWT-EDT and only there. Consider the AWTTree lock!
- AWTEDTExecutor.singleton.invoke(getTreeLock(), false /* allowOnNonEDT */, true /* wait */, realized ? realizeOnEDTAction : unrealizeOnEDTAction);
- }
-
- @Override
- public boolean isRealized() {
- final GLDrawable _drawable = drawable;
- return ( null != _drawable ) ? _drawable.isRealized() : false;
- }
-
- @Override
- public WindowClosingMode getDefaultCloseOperation() {
- return awtWindowClosingProtocol.getDefaultCloseOperation();
- }
-
- @Override
- public WindowClosingMode setDefaultCloseOperation(final WindowClosingMode op) {
- return awtWindowClosingProtocol.setDefaultCloseOperation(op);
- }
-
- @Override
- public void display() {
- if( !validateGLDrawable() ) {
- if(DEBUG) {
- System.err.println(getThreadName()+": Info: GLCanvas display - skipped GL render, drawable not valid yet");
- }
- return; // not yet available ..
- }
- if( isShowing && !printActive ) {
- Threading.invoke(true, displayOnEDTAction, getTreeLock());
- }
- }
-
- /**
- * {@inheritDoc}
- *
- *
- * This impl. only destroys all GL related resources.
- *
- *
- * This impl. does not remove the GLCanvas from it's parent AWT container
- * so this class's {@link #removeNotify()} AWT override won't get called.
- * To do so, remove this component from it's parent AWT container.
- *
- */
- @Override
- public void destroy() {
- destroyImpl( false );
- }
-
- protected void destroyImpl(final boolean destroyJAWTWindowAndAWTDevice) {
- Threading.invoke(true, destroyOnEDTAction, getTreeLock());
- if( destroyJAWTWindowAndAWTDevice ) {
- AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, disposeJAWTWindowAndAWTDeviceOnEDT);
- }
- }
-
- /** Overridden to cause OpenGL rendering to be performed during
- repaint cycles. Subclasses which override this method must call
- super.paint() in their paint() method in order to function
- properly.
- */
- @Override
- public void paint(final Graphics g) {
- if( Beans.isDesignTime() ) {
- // Make GLCanvas behave better in NetBeans GUI builder
- g.setColor(Color.BLACK);
- g.fillRect(0, 0, getWidth(), getHeight());
- final FontMetrics fm = g.getFontMetrics();
- String name = getName();
- if (name == null) {
- name = getClass().getName();
- final int idx = name.lastIndexOf('.');
- if (idx >= 0) {
- name = name.substring(idx + 1);
- }
- }
- final Rectangle2D bounds = fm.getStringBounds(name, g);
- g.setColor(Color.WHITE);
- g.drawString(name,
- (int) ((getWidth() - bounds.getWidth()) / 2),
- (int) ((getHeight() + bounds.getHeight()) / 2));
- } else if( !this.helper.isAnimatorAnimatingOnOtherThread() ) {
- display();
- }
- }
-
- /** Overridden to track when this component is added to a container.
- Subclasses which override this method must call
- super.addNotify() in their addNotify() method in order to
- function properly.
Overridden to track when this component is removed from a
- container. Subclasses which override this method must call
- super.removeNotify() in their removeNotify() method in order to
- function properly.
-
User shall not call this method outside of EDT, read the AWT/Swing specs
- about this.
- Overrides:
-
removeNotify in class java.awt.Component
*/
- @SuppressWarnings("deprecation")
- @Override
- public void removeNotify() {
- if(DEBUG) {
- System.err.println(getThreadName()+": Info: removeNotify - start");
- // Thread.dumpStack();
- }
-
- awtWindowClosingProtocol.removeClosingListener();
-
- if( Beans.isDesignTime() ) {
- super.removeNotify();
- } else {
- try {
- destroyImpl( true );
- } finally {
- super.removeNotify();
- }
- }
- if(DEBUG) {
- System.err.println(getThreadName()+": Info: removeNotify - end, peer: "+getPeer());
- }
- }
-
- /** Overridden to cause {@link GLDrawableHelper#reshape} to be
- called on all registered {@link GLEventListener}s. Subclasses
- which override this method must call super.reshape() in
- their reshape() method in order to function properly.
- * The drawable and context handle are null'ed as well, assuming {@link #destroy()} has been called already.
- *
- *
- * @see #chooseGraphicsConfiguration(com.jogamp.opengl.GLCapabilitiesImmutable, com.jogamp.opengl.GLCapabilitiesImmutable, com.jogamp.opengl.GLCapabilitiesChooser, java.awt.GraphicsDevice)
- */
- private final Runnable disposeJAWTWindowAndAWTDeviceOnEDT = new Runnable() {
- @Override
- public void run() {
- context=null;
- drawable=null;
-
- if( null != jawtWindow ) {
- jawtWindow.destroy();
- if(DEBUG) {
- System.err.println(getThreadName()+": GLCanvas.disposeJAWTWindowAndAWTDeviceOnEDT(): post JAWTWindow: "+jawtWindow);
- }
- jawtWindow=null;
- }
- hasPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
- hasPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
- minPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
- minPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
- maxPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
- maxPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
-
- if(null != awtConfig) {
- final AbstractGraphicsConfiguration aconfig = awtConfig.getNativeGraphicsConfiguration();
- final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice();
- final String adeviceMsg;
- if(DEBUG) {
- adeviceMsg = adevice.toString();
- } else {
- adeviceMsg = null;
- }
- final boolean closed = adevice.close();
- if(DEBUG) {
- System.err.println(getThreadName()+": GLCanvas.disposeJAWTWindowAndAWTDeviceOnEDT(): post GraphicsDevice: "+adeviceMsg+", result: "+closed);
- }
- }
- awtConfig=null;
- }
- };
-
- private final Runnable initAction = new Runnable() {
- @Override
- public void run() {
- helper.init(GLCanvas.this, !sendReshape);
- }
- };
-
- private final Runnable displayAction = new Runnable() {
- @Override
- public void run() {
- if (sendReshape) {
- if(DEBUG) {
- System.err.println(getThreadName()+": Reshape: "+getSurfaceWidth()+"x"+getSurfaceHeight());
- }
- // Note: we ignore the given x and y within the parent component
- // since we are drawing directly into this heavyweight component.
- helper.reshape(GLCanvas.this, 0, 0, getSurfaceWidth(), getSurfaceHeight());
- sendReshape = false;
- }
-
- helper.display(GLCanvas.this);
- }
- };
-
- private final Runnable displayOnEDTAction = new Runnable() {
- @Override
- public void run() {
- final RecursiveLock _lock = lock;
- _lock.lock();
- try {
- if( null != drawable && drawable.isRealized() ) {
- if( GLCanvas.this.updatePixelScale() ) {
- GLCanvas.this.reshapeImpl(getWidth(), getHeight());
- }
- helper.invokeGL(drawable, context, displayAction, initAction);
- }
- } finally {
- _lock.unlock();
- }
- }
- };
-
- private final Runnable swapBuffersOnEDTAction = new Runnable() {
- @Override
- public void run() {
- final RecursiveLock _lock = lock;
- _lock.lock();
- try {
- if( null != drawable && drawable.isRealized() ) {
- drawable.swapBuffers();
- }
- } finally {
- _lock.unlock();
- }
- }
- };
-
- private class DisposeGLEventListenerAction implements Runnable {
- GLEventListener listener;
- private final boolean remove;
- private DisposeGLEventListenerAction(final GLEventListener listener, final boolean remove) {
- this.listener = listener;
- this.remove = remove;
- }
-
- @Override
- public void run() {
- final RecursiveLock _lock = lock;
- _lock.lock();
- try {
- listener = helper.disposeGLEventListener(GLCanvas.this, drawable, context, listener, remove);
- } finally {
- _lock.unlock();
- }
- }
- };
-
- // Disables the AWT's erasing of this Canvas's background on Windows
- // in Java SE 6. This internal API is not available in previous
- // releases, but the system property
- // -Dsun.awt.noerasebackground=true can be specified to get similar
- // results globally in previous releases.
- private static boolean disableBackgroundEraseInitialized;
- private static Method disableBackgroundEraseMethod;
- private void disableBackgroundErase() {
- if (!disableBackgroundEraseInitialized) {
- try {
- AccessController.doPrivileged(new PrivilegedAction() {
- @Override
- public Object run() {
- try {
- Class> clazz = getToolkit().getClass();
- while (clazz != null && disableBackgroundEraseMethod == null) {
- try {
- disableBackgroundEraseMethod =
- clazz.getDeclaredMethod("disableBackgroundErase",
- new Class[] { Canvas.class });
- disableBackgroundEraseMethod.setAccessible(true);
- } catch (final Exception e) {
- clazz = clazz.getSuperclass();
- }
- }
- } catch (final Exception e) {
- }
- return null;
- }
- });
- } catch (final Exception e) {
- }
- disableBackgroundEraseInitialized = true;
- if(DEBUG) {
- System.err.println(getThreadName()+": GLCanvas: TK disableBackgroundErase method found: "+
- (null!=disableBackgroundEraseMethod));
- }
- }
- if (disableBackgroundEraseMethod != null) {
- Throwable t=null;
- try {
- disableBackgroundEraseMethod.invoke(getToolkit(), new Object[] { this });
- } catch (final Exception e) {
- t = e;
- }
- if(DEBUG) {
- System.err.println(getThreadName()+": GLCanvas: TK disableBackgroundErase error: "+t);
- }
- }
- }
-
- /**
- * Issues the GraphicsConfigurationFactory's choosing facility within EDT,
- * since resources created (X11: Display), must be destroyed in the same thread, where they have been created.
- *
- * @param capsChosen
- * @param capsRequested
- * @param chooser
- * @param device
- * @return the chosen AWTGraphicsConfiguration
- *
- * @see #disposeJAWTWindowAndAWTDeviceOnEDT
- */
- private AWTGraphicsConfiguration chooseGraphicsConfiguration(final GLCapabilitiesImmutable capsChosen,
- final GLCapabilitiesImmutable capsRequested,
- final GLCapabilitiesChooser chooser,
- final GraphicsDevice device) {
- // Make GLCanvas behave better in NetBeans GUI builder
- if( Beans.isDesignTime() ) {
- return null;
- }
-
- final AbstractGraphicsScreen aScreen = null != device ?
- AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT):
- AWTGraphicsScreen.createDefault();
- AWTGraphicsConfiguration config = null;
-
- if( EventQueue.isDispatchThread() || Thread.holdsLock(getTreeLock()) ) {
- config = (AWTGraphicsConfiguration)
- GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, GLCapabilitiesImmutable.class).chooseGraphicsConfiguration(capsChosen,
- capsRequested,
- chooser, aScreen, VisualIDHolder.VID_UNDEFINED);
- } else {
- try {
- final ArrayList bucket = new ArrayList(1);
- EventQueue.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- final AWTGraphicsConfiguration c = (AWTGraphicsConfiguration)
- GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, GLCapabilitiesImmutable.class).chooseGraphicsConfiguration(capsChosen,
- capsRequested,
- chooser, aScreen, VisualIDHolder.VID_UNDEFINED);
- bucket.add(c);
- }
- });
- config = ( bucket.size() > 0 ) ? bucket.get(0) : null ;
- } catch (final InvocationTargetException e) {
- throw new GLException(e.getTargetException());
- } catch (final InterruptedException e) {
- throw new GLException(e);
- }
- }
-
- if ( null == config ) {
- throw new GLException("Error: Couldn't fetch AWTGraphicsConfiguration");
- }
-
- return config;
- }
-
- protected static String getThreadName() { return Thread.currentThread().getName(); }
-
- /**
- * A most simple JOGL AWT test entry
- */
- public static void main(final String args[]) {
- System.err.println(VersionUtil.getPlatformInfo());
- System.err.println(GlueGenVersion.getInstance());
- // System.err.println(NativeWindowVersion.getInstance());
- System.err.println(JoglVersion.getInstance());
-
- System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, true).toString());
-
- final GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDevice()) );
- final Frame frame = new Frame("JOGL AWT Test");
-
- final GLCanvas glCanvas = new GLCanvas(caps);
- frame.add(glCanvas);
- frame.setSize(128, 128);
-
- glCanvas.addGLEventListener(new GLEventListener() {
- @Override
- public void init(final GLAutoDrawable drawable) {
- final GL gl = drawable.getGL();
- System.err.println(JoglVersion.getGLInfo(gl, null));
- }
- @Override
- public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
- @Override
- public void display(final GLAutoDrawable drawable) { }
- @Override
- public void dispose(final GLAutoDrawable drawable) { }
- });
-
- try {
- javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- frame.setVisible(true);
- }});
- } catch (final Throwable t) {
- t.printStackTrace();
- }
- glCanvas.display();
- try {
- javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- frame.dispose();
- }});
- } catch (final Throwable t) {
- t.printStackTrace();
- }
- }
-
-}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
deleted file mode 100644
index 91b2f5e0c..000000000
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ /dev/null
@@ -1,2689 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl.awt;
-
-import java.awt.Color;
-import java.awt.EventQueue;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsEnvironment;
-import java.awt.Rectangle;
-import java.awt.event.HierarchyEvent;
-import java.awt.event.HierarchyListener;
-import java.awt.geom.NoninvertibleTransformException;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.DataBufferInt;
-import java.beans.Beans;
-import java.nio.IntBuffer;
-import java.util.List;
-
-import com.jogamp.nativewindow.AbstractGraphicsDevice;
-import com.jogamp.nativewindow.NativeSurface;
-import com.jogamp.nativewindow.ScalableSurface;
-import com.jogamp.nativewindow.SurfaceUpdatedListener;
-import com.jogamp.nativewindow.WindowClosingProtocol;
-import com.jogamp.nativewindow.util.PixelFormat;
-import com.jogamp.opengl.GL;
-import com.jogamp.opengl.GL2;
-import com.jogamp.opengl.GL2ES3;
-import com.jogamp.opengl.GL2GL3;
-import com.jogamp.opengl.GLAnimatorControl;
-import com.jogamp.opengl.GLAutoDrawable;
-import com.jogamp.opengl.GLCapabilities;
-import com.jogamp.opengl.GLCapabilitiesChooser;
-import com.jogamp.opengl.GLCapabilitiesImmutable;
-import com.jogamp.opengl.GLContext;
-import com.jogamp.opengl.GLDrawable;
-import com.jogamp.opengl.GLDrawableFactory;
-import com.jogamp.opengl.GLEventListener;
-import com.jogamp.opengl.GLException;
-import com.jogamp.opengl.GLFBODrawable;
-import com.jogamp.opengl.GLOffscreenAutoDrawable;
-import com.jogamp.opengl.GLProfile;
-import com.jogamp.opengl.GLRunnable;
-import com.jogamp.opengl.GLSharedContextSetter;
-import com.jogamp.opengl.Threading;
-import javax.swing.JPanel;
-
-import jogamp.nativewindow.SurfaceScaleUtils;
-import jogamp.nativewindow.WrappedSurface;
-import jogamp.nativewindow.jawt.JAWTUtil;
-import jogamp.opengl.Debug;
-import jogamp.opengl.GLContextImpl;
-import jogamp.opengl.GLDrawableFactoryImpl;
-import jogamp.opengl.GLDrawableHelper;
-import jogamp.opengl.GLDrawableImpl;
-import jogamp.opengl.awt.AWTTilePainter;
-import jogamp.opengl.awt.Java2D;
-import jogamp.opengl.util.glsl.GLSLTextureRaster;
-
-import com.jogamp.common.util.PropertyAccess;
-import com.jogamp.common.util.awt.AWTEDTExecutor;
-import com.jogamp.common.util.locks.LockFactory;
-import com.jogamp.common.util.locks.RecursiveLock;
-import com.jogamp.nativewindow.awt.AWTPrintLifecycle;
-import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol;
-import com.jogamp.opengl.FBObject;
-import com.jogamp.opengl.GLRendererQuirks;
-import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes;
-import com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider;
-import com.jogamp.opengl.util.GLDrawableUtil;
-import com.jogamp.opengl.util.GLPixelStorageModes;
-import com.jogamp.opengl.util.TileRenderer;
-import com.jogamp.opengl.util.awt.AWTGLPixelBuffer;
-import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider;
-import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvider;
-import com.jogamp.opengl.util.texture.TextureState;
-
-/** A lightweight Swing component which provides OpenGL rendering
- support. Provided for compatibility with Swing user interfaces
- when adding a heavyweight doesn't work either because of
- Z-ordering or LayoutManager problems.
-
- The GLJPanel can be made transparent by creating it with a
- GLCapabilities object with alpha bits specified and calling {@link
- #setOpaque}(false). Pixels with resulting OpenGL alpha values less
- than 1.0 will be overlaid on any underlying Swing rendering.
-
-
- This component attempts to use hardware-accelerated rendering via FBO or pbuffers and
- falls back on to software rendering if none of the former are available
- using {@link GLDrawableFactory#createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) GLDrawableFactory.createOffscreenDrawable(..)}.
-
-
- A vertical-flip is required, if the drawable {@link #isGLOriented()} and {@link #setSkipGLOrientationVerticalFlip(boolean) vertical flip is not skipped}.
- In this case this component performs the required vertical flip to bring the content from OpenGL's orientation into AWT's orientation.
- In case GLSL based vertical-flip is not available,
- the CPU intensive {@link System#arraycopy(Object, int, Object, int, int) System.arraycopy(..)} is used line by line.
- See details about FBO and GLSL vertical flipping.
-
-
- For performance reasons, as well as for GL state sideeffects,
- {@link #setSkipGLOrientationVerticalFlip(boolean) skipping vertical flip} is highly recommended!
-
-
- The OpenGL path is concluded by copying the rendered pixels an {@link BufferedImage} via {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)}
- for later Java2D composition.
-
-
- Finally the Java2D compositioning takes place via via {@link Graphics#drawImage(java.awt.Image, int, int, int, int, java.awt.image.ImageObserver) Graphics.drawImage(...)}
- on the prepared {@link BufferedImage} as described above.
-
- If vertical flip is required,
- FBO is used, GLSL is available and {@link #setSkipGLOrientationVerticalFlip(boolean) vertical flip is not skipped}, a fragment shader is utilized
- to flip the FBO texture vertically. This hardware-accelerated step can be disabled via system property jogl.gljpanel.noglsl.
-
- The FBO / GLSL code path uses one texture-unit and binds the FBO texture to it's active texture-target,
- see {@link #setTextureUnit(int)} and {@link #getTextureUnit()}.
-
-
- The active and dedicated texture-unit's {@link GL#GL_TEXTURE_2D} state is preserved via {@link TextureState}.
- See also {@link Texture#textureCallOrder Order of Texture Commands}.
-
-
- The current gl-viewport is preserved.
-
-
- Warning (Bug 842): Certain GL states other than viewport and texture (see above)
- influencing rendering, will also influence the GLSL vertical flip, e.g. {@link GL#glFrontFace(int) glFrontFace}({@link GL#GL_CCW}).
- It is recommended to reset those states to default when leaving the {@link GLEventListener#display(GLAutoDrawable)} method!
- We may change this behavior in the future, i.e. preserve all influencing states.
-
- * @throws GLException if no default profile is available for the default desktop device.
- */
- public GLJPanel() throws GLException {
- this(null);
- }
-
- /** Creates a new GLJPanel component with the requested set of
- OpenGL capabilities, using the default OpenGL capabilities
- selection mechanism.
-
- * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device.
- */
- public GLJPanel(final GLCapabilitiesImmutable userCapsRequest) throws GLException {
- this(userCapsRequest, null);
- }
-
- /** Creates a new GLJPanel component. The passed GLCapabilities
- specifies the OpenGL capabilities for the component; if null, a
- default set of capabilities is used. The GLCapabilitiesChooser
- specifies the algorithm for selecting one of the available
- GLCapabilities for the component; a DefaultGLCapabilitesChooser
- is used if null is passed for this argument.
-
- * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device.
- */
- public GLJPanel(final GLCapabilitiesImmutable userCapsRequest, final GLCapabilitiesChooser chooser)
- throws GLException
- {
- super();
-
- // Works around problems on many vendors' cards; we don't need a
- // back buffer for the offscreen surface anyway
- {
- GLCapabilities caps;
- if (userCapsRequest != null) {
- caps = (GLCapabilities) userCapsRequest.cloneMutable();
- } else {
- caps = new GLCapabilities(GLProfile.getDefault(GLProfile.getDefaultDevice()));
- }
- caps.setDoubleBuffered(false);
- reqOffscreenCaps = caps;
- }
- this.factory = GLDrawableFactoryImpl.getFactoryImpl( reqOffscreenCaps.getGLProfile() ); // pre-fetch, reqOffscreenCaps may changed
- this.chooser = chooser;
-
- helper = new GLDrawableHelper();
- autoSwapBufferMode = helper.getAutoSwapBufferMode();
-
- this.setFocusable(true); // allow keyboard input!
- this.addHierarchyListener(hierarchyListener);
- this.isShowing = isShowing();
- }
-
- /**
- * Attempts to initialize the backend, if not initialized yet.
- *
- * If backend is already initialized method returns true.
- *
- *
- * If offthread is true, initialization will kicked off
- * on a short lived arbitrary thread and method returns immediately.
- * If platform supports such arbitrary thread initialization method returns
- * true, otherwise false.
- *
- *
- * If offthread is false, initialization be performed
- * on the current thread and method returns after initialization.
- * Method returns true if initialization was successful, otherwise false.
- *
- * @param offthread
- */
- public final boolean initializeBackend(final boolean offthread) {
- if( offthread ) {
- new Thread(getThreadName()+"-GLJPanel_Init") {
- public void run() {
- if( !isInitialized ) {
- initializeBackendImpl();
- }
- } }.start();
- return true;
- } else {
- if( !isInitialized ) {
- return initializeBackendImpl();
- } else {
- return true;
- }
- }
- }
-
- @Override
- public final void setSharedContext(final GLContext sharedContext) throws IllegalStateException {
- helper.setSharedContext(this.getContext(), sharedContext);
- }
-
- @Override
- public final void setSharedAutoDrawable(final GLAutoDrawable sharedAutoDrawable) throws IllegalStateException {
- helper.setSharedAutoDrawable(this, sharedAutoDrawable);
- }
-
- public AWTGLPixelBufferProvider getCustomPixelBufferProvider() { return customPixelBufferProvider; }
-
- /**
- * @param custom custom {@link AWTGLPixelBufferProvider}
- * @throws IllegalArgumentException if custom is null
- * @throws IllegalStateException if backend is already realized, i.e. this instanced already painted once.
- */
- public void setPixelBufferProvider(final AWTGLPixelBufferProvider custom) throws IllegalArgumentException, IllegalStateException {
- if( null == custom ) {
- throw new IllegalArgumentException("Null PixelBufferProvider");
- }
- if( null != backend ) {
- throw new IllegalStateException("Backend already realized.");
- }
- customPixelBufferProvider = custom;
- }
-
- @Override
- public final Object getUpstreamWidget() {
- return this;
- }
-
- @Override
- public final RecursiveLock getUpstreamLock() { return lock; }
-
- @Override
- public final boolean isThreadGLCapable() { return EventQueue.isDispatchThread(); }
-
- @Override
- public void display() {
- if( isShowing || ( printActive && isVisible() ) ) {
- if (EventQueue.isDispatchThread()) {
- // Want display() to be synchronous, so call paintImmediately()
- paintImmediatelyAction.run();
- } else {
- // Multithreaded redrawing of Swing components is not allowed,
- // so do everything on the event dispatch thread
- try {
- EventQueue.invokeAndWait(paintImmediatelyAction);
- } catch (final Exception e) {
- throw new GLException(e);
- }
- }
- }
- }
-
- protected void dispose(final Runnable post) {
- if(DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.dispose() - start");
- // Thread.dumpStack();
- }
-
- if (backend != null && backend.getContext() != null) {
- final boolean animatorPaused;
- final GLAnimatorControl animator = getAnimator();
- if(null!=animator) {
- animatorPaused = animator.pause();
- } else {
- animatorPaused = false;
- }
-
- if(backend.getContext().isCreated()) {
- Threading.invoke(true, disposeAction, getTreeLock());
- }
- if(null != backend) {
- // not yet destroyed due to backend.isUsingOwnThreadManagment() == true
- backend.destroy();
- isInitialized = false;
- }
- if( null != post ) {
- post.run();
- }
-
- if( animatorPaused ) {
- animator.resume();
- }
- }
-
- if(DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.dispose() - stop");
- }
- }
-
- /**
- * Just an alias for removeNotify
- */
- @Override
- public void destroy() {
- removeNotify();
- }
-
- /** Overridden to cause OpenGL rendering to be performed during
- repaint cycles. Subclasses which override this method must call
- super.paintComponent() in their paintComponent() method in order
- to function properly.
-
-
paintComponent in class javax.swing.JComponent
*/
- @Override
- protected void paintComponent(final Graphics g) {
- if (Beans.isDesignTime()) {
- // Make GLJPanel behave better in NetBeans GUI builder
- g.setColor(Color.BLACK);
- g.fillRect(0, 0, getWidth(), getHeight());
- final FontMetrics fm = g.getFontMetrics();
- String name = getName();
- if (name == null) {
- name = getClass().getName();
- final int idx = name.lastIndexOf('.');
- if (idx >= 0) {
- name = name.substring(idx + 1);
- }
- }
- final Rectangle2D bounds = fm.getStringBounds(name, g);
- g.setColor(Color.WHITE);
- g.drawString(name,
- (int) ((getWidth() - bounds.getWidth()) / 2),
- (int) ((getHeight() + bounds.getHeight()) / 2));
- return;
- }
-
- final RecursiveLock _lock = lock;
- _lock.lock();
- try {
- if( !isInitialized ) {
- initializeBackendImpl();
- }
-
- if (!isInitialized || printActive) {
- return;
- }
-
- // NOTE: must do this when the context is not current as it may
- // involve destroying the pbuffer (current context) and
- // re-creating it -- tricky to do properly while the context is
- // current
- if( !printActive ) {
- updatePixelScale(backend);
- if ( handleReshape ) {
- handleReshape = false;
- sendReshape = handleReshape();
- }
-
- if( isShowing ) {
- updater.setGraphics(g);
- backend.doPaintComponent(g);
- }
- }
- } finally {
- _lock.unlock();
- }
- }
-
- private final void updateWrappedSurfaceScale(final GLDrawable d) {
- final NativeSurface s = d.getNativeSurface();
- if( s instanceof WrappedSurface ) {
- ((WrappedSurface)s).setSurfaceScale(hasPixelScale);
- }
- }
-
- @Override
- public final boolean setSurfaceScale(final float[] pixelScale) { // HiDPI support
- System.arraycopy(pixelScale, 0, reqPixelScale, 0, 2);
- final Backend b = backend;
- if ( isInitialized && null != b && isShowing ) {
- if( isShowing || ( printActive && isVisible() ) ) {
- if (EventQueue.isDispatchThread()) {
- setSurfaceScaleAction.run();
- } else {
- try {
- EventQueue.invokeAndWait(setSurfaceScaleAction);
- } catch (final Exception e) {
- throw new GLException(e);
- }
- }
- }
- return true;
- } else {
- return false;
- }
- }
- private final Runnable setSurfaceScaleAction = new Runnable() {
- @Override
- public void run() {
- final Backend b = backend;
- if( null != b && setSurfaceScaleImpl(b) ) {
- if( !helper.isAnimatorAnimatingOnOtherThread() ) {
- paintImmediatelyAction.run(); // display
- }
- }
- }
- };
-
- private final boolean setSurfaceScaleImpl(final Backend b) {
- if( SurfaceScaleUtils.setNewPixelScale(hasPixelScale, hasPixelScale, reqPixelScale, minPixelScale, maxPixelScale, DEBUG ? getClass().getSimpleName() : null) ) {
- reshapeImpl(getWidth(), getHeight());
- updateWrappedSurfaceScale(b.getDrawable());
- return true;
- }
- return false;
- }
-
- private final boolean updatePixelScale(final Backend b) {
- if( JAWTUtil.getPixelScale(getGraphicsConfiguration(), minPixelScale, maxPixelScale) ) {
- return setSurfaceScaleImpl(b);
- } else {
- return false;
- }
- }
-
- @Override
- public final float[] getRequestedSurfaceScale(final float[] result) {
- System.arraycopy(reqPixelScale, 0, result, 0, 2);
- return result;
- }
-
- @Override
- public final float[] getCurrentSurfaceScale(final float[] result) {
- System.arraycopy(hasPixelScale, 0, result, 0, 2);
- return result;
- }
-
- @Override
- public float[] getMinimumSurfaceScale(final float[] result) {
- System.arraycopy(minPixelScale, 0, result, 0, 2);
- return result;
- }
-
- @Override
- public float[] getMaximumSurfaceScale(final float[] result) {
- System.arraycopy(maxPixelScale, 0, result, 0, 2);
- return result;
- }
-
- /** Overridden to track when this component is added to a container.
- Subclasses which override this method must call
- super.addNotify() in their addNotify() method in order to
- function properly.
-
-
addNotify in class java.awt.Component
*/
- @Override
- public void addNotify() {
- super.addNotify();
- awtWindowClosingProtocol.addClosingListener();
-
- // HiDPI support
- JAWTUtil.getPixelScale(getGraphicsConfiguration(), minPixelScale, maxPixelScale);
- SurfaceScaleUtils.setNewPixelScale(hasPixelScale, hasPixelScale, reqPixelScale, minPixelScale, maxPixelScale, DEBUG ? getClass().getSimpleName() : null);
-
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.addNotify()");
- }
- }
-
- /** Overridden to track when this component is removed from a
- container. Subclasses which override this method must call
- super.removeNotify() in their removeNotify() method in order to
- function properly.
-
-
removeNotify in class java.awt.Component
*/
- @Override
- public void removeNotify() {
- awtWindowClosingProtocol.removeClosingListener();
-
- dispose(null);
- hasPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
- hasPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
- minPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
- minPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
- maxPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
- maxPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
-
- super.removeNotify();
- }
-
- /** Overridden to cause {@link GLDrawableHelper#reshape} to be
- called on all registered {@link GLEventListener}s. Subclasses
- which override this method must call super.reshape() in
- their reshape() method in order to function properly.
- *
- * {@inheritDoc}
- */
- @SuppressWarnings("deprecation")
- @Override
- public void reshape(final int x, final int y, final int width, final int height) {
- super.reshape(x, y, width, height);
- reshapeImpl(width, height);
- }
-
- private void reshapeImpl(final int width, final int height) {
- final int scaledWidth = SurfaceScaleUtils.scale(width, hasPixelScale[0]);
- final int scaledHeight = SurfaceScaleUtils.scale(height, hasPixelScale[1]);
- if( !printActive && ( handleReshape || scaledWidth != panelWidth || scaledHeight != panelHeight ) ) {
- reshapeWidth = scaledWidth;
- reshapeHeight = scaledHeight;
- handleReshape = true;
- }
- if( DEBUG ) {
- System.err.println(getThreadName()+": GLJPanel.reshape.0 "+this.getName()+" resize ["+(printActive?"printing":"paint")+
- "] [ this "+getWidth()+"x"+getHeight()+", pixelScale "+getPixelScaleStr()+
- ", panel "+panelWidth+"x"+panelHeight +
- "] -> "+(handleReshape?"":"[skipped] ") + width+"x"+height+" * "+getPixelScaleStr()+
- " -> "+scaledWidth+"x"+scaledHeight+", reshapeSize "+reshapeWidth+"x"+reshapeHeight);
- }
- }
-
- private volatile boolean printActive = false;
- private GLAnimatorControl printAnimator = null;
- private GLAutoDrawable printGLAD = null;
- private AWTTilePainter printAWTTiles = null;
-
- @Override
- public void setupPrint(final double scaleMatX, final double scaleMatY, final int numSamples, final int tileWidth, final int tileHeight) {
- printActive = true;
- if( DEBUG ) {
- System.err.printf(getThreadName()+": GLJPanel.setupPrint: scale %f / %f, samples %d, tileSz %d x %d%n", scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight);
- }
- final int componentCount = isOpaque() ? 3 : 4;
- final TileRenderer printRenderer = new TileRenderer();
- printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG);
- AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT);
- }
- private final Runnable setupPrintOnEDT = new Runnable() {
- @Override
- public void run() {
- final RecursiveLock _lock = lock;
- _lock.lock();
- try {
- if( !isInitialized ) {
- initializeBackendImpl();
- }
- if (!isInitialized) {
- if(DEBUG) {
- System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable not valid yet");
- }
- printActive = false;
- return; // not yet available ..
- }
- if( !isVisible() ) {
- if(DEBUG) {
- System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, panel not visible");
- }
- printActive = false;
- return; // not yet available ..
- }
- sendReshape = false; // clear reshape flag
- handleReshape = false; // ditto
- printAnimator = helper.getAnimator();
- if( null != printAnimator ) {
- printAnimator.remove(GLJPanel.this);
- }
-
- printGLAD = GLJPanel.this; // default: re-use
- final GLCapabilitiesImmutable gladCaps = getChosenGLCapabilities();
- final int printNumSamples = printAWTTiles.getNumSamples(gladCaps);
- GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
- final boolean reqNewGLADSamples = printNumSamples != gladCaps.getNumSamples();
- final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getSurfaceWidth() ||
- printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getSurfaceHeight();
-
- final GLCapabilities newGLADCaps = (GLCapabilities)gladCaps.cloneMutable();
- newGLADCaps.setDoubleBuffered(false);
- newGLADCaps.setOnscreen(false);
- if( printNumSamples != newGLADCaps.getNumSamples() ) {
- newGLADCaps.setSampleBuffers(0 < printNumSamples);
- newGLADCaps.setNumSamples(printNumSamples);
- }
- final boolean reqNewGLADSafe = GLDrawableUtil.isSwapGLContextSafe(getRequestedGLCapabilities(), gladCaps, newGLADCaps);
-
- final boolean reqNewGLAD = ( reqNewGLADSamples || reqNewGLADSize ) && reqNewGLADSafe;
-
- if( DEBUG ) {
- System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+", safe "+reqNewGLADSafe+"], "+
- ", drawableSize "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+
- ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+
- ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+
- ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
- }
- if( reqNewGLAD ) {
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile());
- GLOffscreenAutoDrawable offGLAD = null;
- try {
- offGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
- printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
- printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
- } catch (final GLException gle) {
- if( DEBUG ) {
- System.err.println("Caught: "+gle.getMessage());
- gle.printStackTrace();
- }
- }
- if( null != offGLAD ) {
- printGLAD = offGLAD;
- GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD);
- printDrawable = printGLAD.getDelegatedDrawable();
- }
- }
- printAWTTiles.setGLOrientation( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented(), printGLAD.isGLOriented() );
- printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0);
- printAWTTiles.renderer.attachAutoDrawable(printGLAD);
- if( DEBUG ) {
- System.err.println("AWT print.setup "+printAWTTiles);
- System.err.println("AWT print.setup AA "+printNumSamples+", "+newGLADCaps);
- System.err.println("AWT print.setup printGLAD: "+printGLAD.getSurfaceWidth()+"x"+printGLAD.getSurfaceHeight()+", "+printGLAD);
- System.err.println("AWT print.setup printDraw: "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+", "+printDrawable);
- }
- } finally {
- _lock.unlock();
- }
- }
- };
-
- @Override
- public void releasePrint() {
- if( !printActive ) {
- throw new IllegalStateException("setupPrint() not called");
- }
- sendReshape = false; // clear reshape flag
- handleReshape = false; // ditto
- AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT);
- }
-
- private final Runnable releasePrintOnEDT = new Runnable() {
- @Override
- public void run() {
- final RecursiveLock _lock = lock;
- _lock.lock();
- try {
- if( DEBUG ) {
- System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0 "+printAWTTiles);
- }
- printAWTTiles.dispose();
- printAWTTiles= null;
- if( printGLAD != GLJPanel.this ) {
- GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, GLJPanel.this);
- printGLAD.destroy();
- }
- printGLAD = null;
- if( null != printAnimator ) {
- printAnimator.add(GLJPanel.this);
- printAnimator = null;
- }
-
- // trigger reshape, i.e. gl-viewport and -listener - this component might got resized!
- final int awtWidth = GLJPanel.this.getWidth();
- final int awtHeight= GLJPanel.this.getHeight();
- final int scaledAWTWidth = SurfaceScaleUtils.scale(awtWidth, hasPixelScale[0]);
- final int scaledAWTHeight= SurfaceScaleUtils.scale(awtHeight, hasPixelScale[1]);
- final GLDrawable drawable = GLJPanel.this.getDelegatedDrawable();
- if( scaledAWTWidth != panelWidth || scaledAWTHeight != panelHeight ||
- drawable.getSurfaceWidth() != panelWidth || drawable.getSurfaceHeight() != panelHeight ) {
- // -> !( awtSize == panelSize == drawableSize )
- if ( DEBUG ) {
- System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0: resize [printing] panel " +panelWidth+"x"+panelHeight + " @ scale "+getPixelScaleStr()+
- ", draw "+drawable.getSurfaceWidth()+"x"+drawable.getSurfaceHeight()+
- " -> " + awtWidth+"x"+awtHeight+" * "+getPixelScaleStr()+" -> "+scaledAWTWidth+"x"+scaledAWTHeight);
- }
- reshapeWidth = scaledAWTWidth;
- reshapeHeight = scaledAWTHeight;
- sendReshape = handleReshape(); // reshapeSize -> panelSize, backend reshape w/ GL reshape
- } else {
- sendReshape = true; // only GL reshape
- }
- printActive = false;
- display();
- } finally {
- _lock.unlock();
- }
- }
- };
-
- @Override
- public void print(final Graphics graphics) {
- if( !printActive ) {
- throw new IllegalStateException("setupPrint() not called");
- }
- if(DEBUG && !EventQueue.isDispatchThread()) {
- System.err.println(getThreadName()+": Warning: GLCanvas print - not called from AWT-EDT");
- // we cannot dispatch print on AWT-EDT due to printing internal locking ..
- }
- sendReshape = false; // clear reshape flag
- handleReshape = false; // ditto
-
- final Graphics2D g2d = (Graphics2D)graphics;
- try {
- printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight());
- final TileRenderer tileRenderer = printAWTTiles.renderer;
- if( DEBUG ) {
- System.err.println("AWT print.0: "+tileRenderer);
- }
- if( !tileRenderer.eot() ) {
- try {
- do {
- if( printGLAD != GLJPanel.this ) {
- tileRenderer.display();
- } else {
- backend.doPlainPaint();
- }
- } while ( !tileRenderer.eot() );
- if( DEBUG ) {
- System.err.println("AWT print.1: "+printAWTTiles);
- }
- } finally {
- tileRenderer.reset();
- printAWTTiles.resetGraphics2D();
- }
- }
- } catch (final NoninvertibleTransformException nte) {
- System.err.println("Caught: Inversion failed of: "+g2d.getTransform());
- nte.printStackTrace();
- }
- if( DEBUG ) {
- System.err.println("AWT print.X: "+printAWTTiles);
- }
- }
- @Override
- protected void printComponent(final Graphics g) {
- if( DEBUG ) {
- System.err.println("AWT printComponent.X: "+printAWTTiles);
- }
- print(g);
- }
-
- @Override
- public void setOpaque(final boolean opaque) {
- if (backend != null) {
- backend.setOpaque(opaque);
- }
- super.setOpaque(opaque);
- }
-
- @Override
- public void addGLEventListener(final GLEventListener listener) {
- helper.addGLEventListener(listener);
- }
-
- @Override
- public void addGLEventListener(final int index, final GLEventListener listener) {
- helper.addGLEventListener(index, listener);
- }
-
- @Override
- public int getGLEventListenerCount() {
- return helper.getGLEventListenerCount();
- }
-
- @Override
- public GLEventListener getGLEventListener(final int index) throws IndexOutOfBoundsException {
- return helper.getGLEventListener(index);
- }
-
- @Override
- public boolean areAllGLEventListenerInitialized() {
- return helper.areAllGLEventListenerInitialized();
- }
-
- @Override
- public boolean getGLEventListenerInitState(final GLEventListener listener) {
- return helper.getGLEventListenerInitState(listener);
- }
-
- @Override
- public void setGLEventListenerInitState(final GLEventListener listener, final boolean initialized) {
- helper.setGLEventListenerInitState(listener, initialized);
- }
-
- @Override
- public GLEventListener disposeGLEventListener(final GLEventListener listener, final boolean remove) {
- final DisposeGLEventListenerAction r = new DisposeGLEventListenerAction(listener, remove);
- if (EventQueue.isDispatchThread()) {
- r.run();
- } else {
- // Multithreaded redrawing of Swing components is not allowed,
- // so do everything on the event dispatch thread
- try {
- EventQueue.invokeAndWait(r);
- } catch (final Exception e) {
- throw new GLException(e);
- }
- }
- return r.listener;
- }
-
- @Override
- public GLEventListener removeGLEventListener(final GLEventListener listener) {
- return helper.removeGLEventListener(listener);
- }
-
- @Override
- public void setAnimator(final GLAnimatorControl animatorControl) {
- helper.setAnimator(animatorControl);
- }
-
- @Override
- public GLAnimatorControl getAnimator() {
- return helper.getAnimator();
- }
-
- @Override
- public final Thread setExclusiveContextThread(final Thread t) throws GLException {
- return helper.setExclusiveContextThread(t, getContext());
- }
-
- @Override
- public final Thread getExclusiveContextThread() {
- return helper.getExclusiveContextThread();
- }
-
- @Override
- public boolean invoke(final boolean wait, final GLRunnable glRunnable) throws IllegalStateException {
- return helper.invoke(this, wait, glRunnable);
- }
-
- @Override
- public boolean invoke(final boolean wait, final List glRunnables) throws IllegalStateException {
- return helper.invoke(this, wait, glRunnables);
- }
-
- @Override
- public void flushGLRunnables() {
- helper.flushGLRunnables();
- }
-
- @Override
- public GLContext createContext(final GLContext shareWith) {
- final RecursiveLock _lock = lock;
- _lock.lock();
- try {
- final Backend b = backend;
- if ( null == b ) {
- return null;
- }
- return b.createContext(shareWith);
- } finally {
- _lock.unlock();
- }
- }
-
- @Override
- public void setRealized(final boolean realized) {
- }
-
- @Override
- public boolean isRealized() {
- return isInitialized;
- }
-
- @Override
- public GLContext setContext(final GLContext newCtx, final boolean destroyPrevCtx) {
- final RecursiveLock _lock = lock;
- _lock.lock();
- try {
- final Backend b = backend;
- if ( null == b ) {
- return null;
- }
- final GLContext oldCtx = b.getContext();
- GLDrawableHelper.switchContext(b.getDrawable(), oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags);
- b.setContext(newCtx);
- return oldCtx;
- } finally {
- _lock.unlock();
- }
- }
-
-
- @Override
- public final GLDrawable getDelegatedDrawable() {
- final Backend b = backend;
- if ( null == b ) {
- return null;
- }
- return b.getDrawable();
- }
-
- @Override
- public GLContext getContext() {
- final Backend b = backend;
- if ( null == b ) {
- return null;
- }
- return b.getContext();
- }
-
- @Override
- public GL getGL() {
- if (Beans.isDesignTime()) {
- return null;
- }
- final GLContext context = getContext();
- return (context == null) ? null : context.getGL();
- }
-
- @Override
- public GL setGL(final GL gl) {
- final GLContext context = getContext();
- if (context != null) {
- context.setGL(gl);
- return gl;
- }
- return null;
- }
-
- @Override
- public void setAutoSwapBufferMode(final boolean enable) {
- this.autoSwapBufferMode = enable;
- boolean backendHandlesSwapBuffer = false;
- if( isInitialized ) {
- final Backend b = backend;
- if ( null != b ) {
- backendHandlesSwapBuffer= b.handlesSwapBuffer();
- }
- }
- if( !backendHandlesSwapBuffer ) {
- helper.setAutoSwapBufferMode(enable);
- }
- }
-
- @Override
- public boolean getAutoSwapBufferMode() {
- return autoSwapBufferMode;
- }
-
- @Override
- public void swapBuffers() {
- if( isInitialized ) {
- final Backend b = backend;
- if ( null != b ) {
- b.swapBuffers();
- }
- }
- }
-
- @Override
- public void setContextCreationFlags(final int flags) {
- additionalCtxCreationFlags = flags;
- }
-
- @Override
- public int getContextCreationFlags() {
- return additionalCtxCreationFlags;
- }
-
- /** For a translucent GLJPanel (one for which {@link #setOpaque
- setOpaque}(false) has been called), indicates whether the
- application should preserve the OpenGL color buffer
- (GL_COLOR_BUFFER_BIT) for correct rendering of the GLJPanel and
- underlying widgets which may show through portions of the
- GLJPanel with alpha values less than 1. Most Swing
- implementations currently expect the GLJPanel to be completely
- cleared (e.g., by glClear(GL_COLOR_BUFFER_BIT |
- GL_DEPTH_BUFFER_BIT)), but for certain optimized Swing
- implementations which use OpenGL internally, it may be possible
- to perform OpenGL rendering using the GLJPanel into the same
- OpenGL drawable as the Swing implementation uses. */
- public boolean shouldPreserveColorBufferIfTranslucent() {
- return oglPipelineUsable();
- }
-
- @Override
- public int getSurfaceWidth() {
- return panelWidth; // scaled surface width in pixel units, current as-from reshape
- }
-
- @Override
- public int getSurfaceHeight() {
- return panelHeight; // scaled surface height in pixel units, current as-from reshape
- }
-
- /**
- * {@inheritDoc}
- *
- * Method returns a valid value only after
- * the backend has been initialized, either {@link #initializeBackend(boolean) eagerly}
- * or manually via the first display call.
- * Method always returns a valid value when called from within a {@link GLEventListener}.
- *
- */
- @Override
- public boolean isGLOriented() {
- final Backend b = backend;
- if ( null == b ) {
- return true;
- }
- return b.getDrawable().isGLOriented();
- }
-
- /**
- * Skip {@link #isGLOriented()} based vertical flip,
- * which usually is required by the offscreen backend,
- * see details about vertical flip
- * and FBO / GLSL vertical flip.
- *
- * If set to true, user needs to flip the OpenGL rendered scene
- * if {@link #isGLOriented()} == true, e.g. via the projection matrix.
- * See constraints of {@link #isGLOriented()}.
- *
- */
- public final void setSkipGLOrientationVerticalFlip(final boolean v) {
- skipGLOrientationVerticalFlip = v;
- }
- /** See {@link #setSkipGLOrientationVerticalFlip(boolean)}. */
- public final boolean getSkipGLOrientationVerticalFlip() {
- return skipGLOrientationVerticalFlip;
- }
-
- @Override
- public GLCapabilitiesImmutable getChosenGLCapabilities() {
- final Backend b = backend;
- if ( null == b ) {
- return null;
- }
- return b.getChosenGLCapabilities();
- }
-
- @Override
- public final GLCapabilitiesImmutable getRequestedGLCapabilities() {
- return reqOffscreenCaps;
- }
-
- /**
- * Set a new requested {@link GLCapabilitiesImmutable} for this GLJPanel
- * allowing reconfiguration.
- *
- * Method shall be invoked from the {@link #isThreadGLCapable() AWT-EDT thread}.
- * In case it is not invoked on the AWT-EDT thread, an attempt is made to do so.
- *
- *
- * Method will dispose a previous {@link #isRealized() realized} GLContext and offscreen backend!
- *
- * @param caps new capabilities.
- */
- public final void setRequestedGLCapabilities(final GLCapabilitiesImmutable caps) {
- if( null == caps ) {
- throw new IllegalArgumentException("null caps");
- }
- Threading.invoke(true,
- new Runnable() {
- @Override
- public void run() {
- dispose( new Runnable() {
- @Override
- public void run() {
- // switch to new caps and re-init backend
- // after actual dispose, but before resume animator
- reqOffscreenCaps = caps;
- initializeBackendImpl();
- } } );
- }
- }, getTreeLock());
- }
-
- @Override
- public final GLProfile getGLProfile() {
- return reqOffscreenCaps.getGLProfile();
- }
-
- @Override
- public NativeSurface getNativeSurface() {
- final Backend b = backend;
- if ( null == b ) {
- return null;
- }
- return b.getDrawable().getNativeSurface();
- }
-
- @Override
- public long getHandle() {
- final Backend b = backend;
- if ( null == b ) {
- return 0;
- }
- return b.getDrawable().getNativeSurface().getSurfaceHandle();
- }
-
- @Override
- public final GLDrawableFactory getFactory() {
- return factory;
- }
-
- /**
- * Returns the used texture unit, i.e. a value of [0..n], or -1 if non used.
- *
- * If implementation uses a texture-unit, it will be known only after the first initialization, i.e. display call.
- *
- */
- public final int getTextureUnit() {
- final Backend b = backend;
- if ( null == b ) {
- return -1;
- }
- return b.getTextureUnit();
- }
-
- /**
- * Allows user to request a texture unit to be used,
- * must be called before the first initialization, i.e. {@link #display()} call.
- *
- *
- * @param v requested texture unit
- * @see #getTextureUnit()
- */
- public final void setTextureUnit(final int v) {
- requestedTextureUnit = v;
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- private final Object initSync = new Object();
- private boolean initializeBackendImpl() {
- synchronized(initSync) {
- if( !isInitialized ) {
- if( handleReshape ) {
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend.1: ["+(printActive?"printing":"paint")+"] "+
- panelWidth+"x"+panelHeight+" @ scale "+getPixelScaleStr() + " -> " +
- reshapeWidth+"x"+reshapeHeight+" @ scale "+getPixelScaleStr());
- }
- panelWidth = reshapeWidth;
- panelHeight = reshapeHeight;
- handleReshape = false;
- } else {
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend.0: ["+(printActive?"printing":"paint")+"] "+
- panelWidth+"x"+panelHeight+" @ scale "+getPixelScaleStr());
- }
- }
-
- if ( 0 >= panelWidth || 0 >= panelHeight ) {
- return false;
- }
-
- if ( null == backend ) {
- if ( oglPipelineUsable() ) {
- backend = new J2DOGLBackend();
- } else {
- backend = new OffscreenBackend(customPixelBufferProvider);
- }
- isInitialized = false;
- }
-
- if (!isInitialized) {
- this.factory = GLDrawableFactoryImpl.getFactoryImpl( reqOffscreenCaps.getGLProfile() ); // reqOffscreenCaps may have changed
- backend.initialize();
- }
- return isInitialized;
- } else {
- return true;
- }
- }
- }
-
- private final String getPixelScaleStr() { return "["+hasPixelScale[0]+", "+hasPixelScale[1]+"]"; }
-
- @Override
- public WindowClosingMode getDefaultCloseOperation() {
- return awtWindowClosingProtocol.getDefaultCloseOperation();
- }
-
- @Override
- public WindowClosingMode setDefaultCloseOperation(final WindowClosingMode op) {
- return awtWindowClosingProtocol.setDefaultCloseOperation(op);
- }
-
- private boolean handleReshape() {
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.handleReshape: "+
- panelWidth+"x"+panelHeight+" @ scale "+getPixelScaleStr() + " -> " +
- reshapeWidth+"x"+reshapeHeight+" @ scale "+getPixelScaleStr());
- }
- panelWidth = reshapeWidth;
- panelHeight = reshapeHeight;
-
- return backend.handleReshape();
- }
-
- // This is used as the GLEventListener for the pbuffer-based backend
- // as well as the callback mechanism for the other backends
- class Updater implements GLEventListener {
- private Graphics g;
-
- public void setGraphics(final Graphics g) {
- this.g = g;
- }
-
- @Override
- public void init(final GLAutoDrawable drawable) {
- if (!backend.preGL(g)) {
- return;
- }
- helper.init(GLJPanel.this, !sendReshape);
- backend.postGL(g, false);
- }
-
- @Override
- public void dispose(final GLAutoDrawable drawable) {
- helper.disposeAllGLEventListener(GLJPanel.this, false);
- }
-
- @Override
- public void display(final GLAutoDrawable drawable) {
- if (!backend.preGL(g)) {
- return;
- }
- if (sendReshape) {
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.display: reshape(" + viewportX + "," + viewportY + " " + panelWidth + "x" + panelHeight + " @ scale "+getPixelScaleStr()+")");
- }
- helper.reshape(GLJPanel.this, viewportX, viewportY, panelWidth, panelHeight);
- sendReshape = false;
- }
-
- helper.display(GLJPanel.this);
- backend.postGL(g, true);
- }
-
- public void plainPaint(final GLAutoDrawable drawable) {
- helper.display(GLJPanel.this);
- }
-
- @Override
- public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
- // This is handled above and dispatched directly to the appropriate context
- }
- }
-
- @Override
- public String toString() {
- final GLDrawable d = ( null != backend ) ? backend.getDrawable() : null;
- return "AWT-GLJPanel[ drawableType "+ ( ( null != d ) ? d.getClass().getName() : "null" ) +
- ", chosenCaps " + getChosenGLCapabilities() +
- "]";
- }
-
- private final Runnable disposeAction = new Runnable() {
- @Override
- public void run() {
- final RecursiveLock _lock = lock;
- _lock.lock();
- try {
- if ( null != backend ) {
- final GLContext _context = backend.getContext();
- final boolean backendDestroy = !backend.isUsingOwnLifecycle();
-
- GLException exceptionOnDisposeGL = null;
- if( null != _context && _context.isCreated() ) {
- try {
- helper.disposeGL(GLJPanel.this, _context, !backendDestroy);
- } catch (final GLException gle) {
- exceptionOnDisposeGL = gle;
- }
- }
- Throwable exceptionBackendDestroy = null;
- if ( backendDestroy ) {
- try {
- backend.destroy();
- } catch( final Throwable re ) {
- exceptionBackendDestroy = re;
- }
- backend = null;
- isInitialized = false;
- }
-
- // throw exception in order of occurrence ..
- if( null != exceptionOnDisposeGL ) {
- throw exceptionOnDisposeGL;
- }
- if( null != exceptionBackendDestroy ) {
- throw GLException.newGLException(exceptionBackendDestroy);
- }
- }
- } finally {
- _lock.unlock();
- }
- }
- };
-
- private final Runnable updaterInitAction = new Runnable() {
- @Override
- public void run() {
- updater.init(GLJPanel.this);
- }
- };
-
- private final Runnable updaterDisplayAction = new Runnable() {
- @Override
- public void run() {
- updater.display(GLJPanel.this);
- }
- };
-
- private final Runnable updaterPlainDisplayAction = new Runnable() {
- @Override
- public void run() {
- updater.plainPaint(GLJPanel.this);
- }
- };
-
- private final Runnable paintImmediatelyAction = new Runnable() {
- @Override
- public void run() {
- paintImmediately(0, 0, getWidth(), getHeight());
- }
- };
-
- private class DisposeGLEventListenerAction implements Runnable {
- GLEventListener listener;
- private final boolean remove;
- private DisposeGLEventListenerAction(final GLEventListener listener, final boolean remove) {
- this.listener = listener;
- this.remove = remove;
- }
-
- @Override
- public void run() {
- final Backend b = backend;
- if ( null != b ) {
- listener = helper.disposeGLEventListener(GLJPanel.this, b.getDrawable(), b.getContext(), listener, remove);
- }
- }
- };
-
- private int getGLInteger(final GL gl, final int which) {
- final int[] tmp = new int[1];
- gl.glGetIntegerv(which, tmp, 0);
- return tmp[0];
- }
-
- protected static String getThreadName() { return Thread.currentThread().getName(); }
-
- //----------------------------------------------------------------------
- // Implementations of the various backends
- //
-
- /**
- * Abstraction of the different rendering backends: i.e., pure
- * software / pixmap rendering, pbuffer-based acceleration, Java 2D
- * JOGL bridge
- */
- static interface Backend {
- /** Create, Destroy, .. */
- public boolean isUsingOwnLifecycle();
-
- /** Called each time the backend needs to initialize itself */
- public void initialize();
-
- /** Called when the backend should clean up its resources */
- public void destroy();
-
- /** Called when the opacity of the GLJPanel is changed */
- public void setOpaque(boolean opaque);
-
- /**
- * Called to manually create an additional OpenGL context against
- * this GLJPanel
- */
- public GLContext createContext(GLContext shareWith);
-
- /** Called to set the current backend's GLContext */
- public void setContext(GLContext ctx);
-
- /** Called to get the current backend's GLContext */
- public GLContext getContext();
-
- /** Called to get the current backend's GLDrawable */
- public GLDrawable getDrawable();
-
- /** Returns the used texture unit, i.e. a value of [0..n], or -1 if non used. */
- public int getTextureUnit();
-
- /** Called to fetch the "real" GLCapabilities for the backend */
- public GLCapabilitiesImmutable getChosenGLCapabilities();
-
- /** Called to fetch the "real" GLProfile for the backend */
- public GLProfile getGLProfile();
-
- /**
- * Called to handle a reshape event. When this is called, the
- * OpenGL context associated with the backend is not current, to
- * make it easier to destroy and re-create pbuffers if necessary.
- */
- public boolean handleReshape();
-
- /**
- * Called before the OpenGL work is done in init() and display().
- * If false is returned, this render is aborted.
- */
- public boolean preGL(Graphics g);
-
- /**
- * Return true if backend handles 'swap buffer' itself
- * and hence the helper's setAutoSwapBuffer(enable) shall not be called.
- * In this case {@link GLJPanel#autoSwapBufferMode} is being used
- * in the backend to determine whether to swap buffers or not.
- */
- public boolean handlesSwapBuffer();
-
- /**
- * Shall invoke underlying drawable's swapBuffer.
- */
- public void swapBuffers();
-
- /**
- * Called after the OpenGL work is done in init() and display().
- * The isDisplay argument indicates whether this was called on
- * behalf of a call to display() rather than init().
- */
- public void postGL(Graphics g, boolean isDisplay);
-
- /** Called from within paintComponent() to initiate the render */
- public void doPaintComponent(Graphics g);
-
- /** Called from print .. no backend update desired onscreen */
- public void doPlainPaint();
- }
-
- // Base class used by both the software (pixmap) and pbuffer
- // backends, both of which rely on reading back the OpenGL frame
- // buffer and drawing it with a BufferedImage
- class OffscreenBackend implements Backend {
- private final AWTGLPixelBufferProvider pixelBufferProvider;
- private final boolean useSingletonBuffer;
- private AWTGLPixelBuffer pixelBuffer;
- private BufferedImage alignedImage;
-
- // One of these is used to store the read back pixels before storing
- // in the BufferedImage
- protected IntBuffer readBackIntsForCPUVFlip;
-
- // Implementation using software rendering
- private volatile GLDrawable offscreenDrawable; // volatile: avoid locking for read-only access
- private boolean offscreenIsFBO;
- private FBObject fboFlipped;
- private GLSLTextureRaster glslTextureRaster;
-
- private volatile GLContextImpl offscreenContext; // volatile: avoid locking for read-only access
- private boolean flipVertical;
- private int frameCount = 0;
-
- // For saving/restoring of OpenGL state during ReadPixels
- private final GLPixelStorageModes psm = new GLPixelStorageModes();
-
- OffscreenBackend(final AWTGLPixelBufferProvider custom) {
- if(null == custom) {
- pixelBufferProvider = getSingleAWTGLPixelBufferProvider();
- } else {
- pixelBufferProvider = custom;
- }
- if( pixelBufferProvider instanceof SingletonGLPixelBufferProvider ) {
- useSingletonBuffer = true;
- } else {
- useSingletonBuffer = false;
- }
- }
-
- @Override
- public final boolean isUsingOwnLifecycle() { return false; }
-
- @Override
- public final void initialize() {
- if(DEBUG) {
- System.err.println(getThreadName()+": OffscreenBackend: initialize() - frameCount "+frameCount);
- }
- GLException glException = null;
- try {
- final GLContext[] shareWith = { null };
- if( helper.isSharedGLContextPending(shareWith) ) {
- return; // pending ..
- }
- offscreenDrawable = factory.createOffscreenDrawable(
- null /* default platform device */,
- reqOffscreenCaps,
- chooser,
- panelWidth, panelHeight);
- updateWrappedSurfaceScale(offscreenDrawable);
- offscreenDrawable.setRealized(true);
- if( DEBUG_FRAMES ) {
- offscreenDrawable.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() {
- @Override
- public final void surfaceUpdated(final Object updater, final NativeSurface ns, final long when) {
- System.err.println(getThreadName()+": OffscreenBackend.swapBuffers - frameCount "+frameCount);
- } } );
- }
-
- //
- // Pre context configuration
- //
- flipVertical = !GLJPanel.this.skipGLOrientationVerticalFlip && offscreenDrawable.isGLOriented();
- offscreenIsFBO = offscreenDrawable.getRequestedGLCapabilities().isFBO();
- final boolean useGLSLFlip_pre = flipVertical && offscreenIsFBO && reqOffscreenCaps.getGLProfile().isGL2ES2() && USE_GLSL_TEXTURE_RASTERIZER;
- if( offscreenIsFBO && !useGLSLFlip_pre ) {
- // Texture attachment only required for GLSL vertical flip, hence simply use a color-renderbuffer attachment.
- ((GLFBODrawable)offscreenDrawable).setFBOMode(0);
- }
-
- offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith[0]);
- offscreenContext.setContextCreationFlags(additionalCtxCreationFlags);
- if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) {
- isInitialized = true;
- helper.setAutoSwapBufferMode(false); // we handle swap-buffers, see handlesSwapBuffer()
-
- final GL gl = offscreenContext.getGL();
- // Remedy for Bug 1020, i.e. OSX/Nvidia's FBO needs to be cleared before blitting,
- // otherwise first MSAA frame lacks antialiasing.
- // Clearing of FBO is performed within GLFBODrawableImpl.initialize(..):
- // gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
-
- final GLCapabilitiesImmutable chosenCaps = offscreenDrawable.getChosenGLCapabilities();
- final boolean glslCompliant = !offscreenContext.hasRendererQuirk(GLRendererQuirks.GLSLNonCompliant);
- final boolean useGLSLFlip = useGLSLFlip_pre && gl.isGL2ES2() && glslCompliant;
- if( DEBUG ) {
- System.err.println(getThreadName()+": OffscreenBackend.initialize: useGLSLFlip "+useGLSLFlip+
- " [flip "+flipVertical+", isFBO "+offscreenIsFBO+", isGL2ES2 "+gl.isGL2ES2()+
- ", noglsl "+!USE_GLSL_TEXTURE_RASTERIZER+", glslNonCompliant "+!glslCompliant+
- ", isGL2ES2 " + gl.isGL2ES2()+"\n "+offscreenDrawable+"]");
- }
- if( useGLSLFlip ) {
- final GLFBODrawable fboDrawable = (GLFBODrawable) offscreenDrawable;
- fboDrawable.setTextureUnit( GLJPanel.this.requestedTextureUnit );
- try {
- fboFlipped = new FBObject();
- fboFlipped.init(gl, panelWidth, panelHeight, 0);
- fboFlipped.attachColorbuffer(gl, 0, chosenCaps.getAlphaBits()>0);
- // fboFlipped.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT); // Bug 1020 (see above), cannot do in FBObject due to unknown 'first bind' state.
- glslTextureRaster = new GLSLTextureRaster(fboDrawable.getTextureUnit(), true);
- glslTextureRaster.init(gl.getGL2ES2());
- glslTextureRaster.reshape(gl.getGL2ES2(), 0, 0, panelWidth, panelHeight);
- } catch (final Exception ex) {
- ex.printStackTrace();
- if(null != glslTextureRaster) {
- glslTextureRaster.dispose(gl.getGL2ES2());
- glslTextureRaster = null;
- }
- if(null != fboFlipped) {
- fboFlipped.destroy(gl);
- fboFlipped = null;
- }
- }
- } else {
- fboFlipped = null;
- glslTextureRaster = null;
- }
- offscreenContext.release();
- } else {
- isInitialized = false;
- }
- } catch( final GLException gle ) {
- glException = gle;
- } finally {
- if( !isInitialized ) {
- if(null != offscreenContext) {
- offscreenContext.destroy();
- offscreenContext = null;
- }
- if(null != offscreenDrawable) {
- offscreenDrawable.setRealized(false);
- offscreenDrawable = null;
- }
- }
- if( null != glException ) {
- throw new GLException("Caught GLException: "+glException.getMessage(), glException);
- }
- }
- }
-
- @Override
- public final void destroy() {
- if(DEBUG) {
- System.err.println(getThreadName()+": OffscreenBackend: destroy() - offscreenContext: "+(null!=offscreenContext)+" - offscreenDrawable: "+(null!=offscreenDrawable)+" - frameCount "+frameCount);
- }
- if ( null != offscreenContext && offscreenContext.isCreated() ) {
- if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) {
- try {
- final GL gl = offscreenContext.getGL();
- if(null != glslTextureRaster) {
- glslTextureRaster.dispose(gl.getGL2ES2());
- }
- if(null != fboFlipped) {
- fboFlipped.destroy(gl);
- }
- } finally {
- offscreenContext.destroy();
- }
- }
- }
- offscreenContext = null;
- glslTextureRaster = null;
- fboFlipped = null;
- offscreenContext = null;
-
- if (offscreenDrawable != null) {
- final AbstractGraphicsDevice adevice = offscreenDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice();
- offscreenDrawable.setRealized(false);
- offscreenDrawable = null;
- if(null != adevice) {
- adevice.close();
- }
- }
- offscreenIsFBO = false;
-
- if( null != readBackIntsForCPUVFlip ) {
- readBackIntsForCPUVFlip.clear();
- readBackIntsForCPUVFlip = null;
- }
- if( null != pixelBuffer ) {
- if( !useSingletonBuffer ) {
- pixelBuffer.dispose();
- }
- pixelBuffer = null;
- }
- alignedImage = null;
- }
-
- @Override
- public final void setOpaque(final boolean opaque) {
- if ( opaque != isOpaque() && !useSingletonBuffer ) {
- pixelBuffer.dispose();
- pixelBuffer = null;
- alignedImage = null;
- }
- }
-
- @Override
- public final boolean preGL(final Graphics g) {
- // Empty in this implementation
- return true;
- }
-
- @Override
- public final boolean handlesSwapBuffer() {
- return true;
- }
-
- @Override
- public final void swapBuffers() {
- final GLDrawable d = offscreenDrawable;
- if( null != d ) {
- d.swapBuffers();
- }
- }
-
- @Override
- public final void postGL(final Graphics g, final boolean isDisplay) {
- if (isDisplay) {
- if( DEBUG_FRAMES ) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: - frameCount "+frameCount);
- }
-
- final GL gl = offscreenContext.getGL();
-
- //
- // Save TextureState ASAP, i.e. the user values for the used FBO texture-unit
- // and the current active texture-unit (if not same)
- //
- final TextureState usrTexState, fboTexState;
- final int fboTexUnit;
-
- if( offscreenIsFBO ) {
- fboTexUnit = GL.GL_TEXTURE0 + ((GLFBODrawable)offscreenDrawable).getTextureUnit();
- usrTexState = new TextureState(gl, GL.GL_TEXTURE_2D);
- if( fboTexUnit != usrTexState.getUnit() ) {
- // glActiveTexture(..) + glBindTexture(..) are implicit performed in GLFBODrawableImpl's
- // swapBuffers/contextMadeCurent -> swapFBOImpl.
- // We need to cache the texture unit's bound texture-id before it's overwritten.
- gl.glActiveTexture(fboTexUnit);
- fboTexState = new TextureState(gl, fboTexUnit, GL.GL_TEXTURE_2D);
- } else {
- fboTexState = usrTexState;
- }
- } else {
- fboTexUnit = 0;
- usrTexState = null;
- fboTexState = null;
- }
-
-
- if( autoSwapBufferMode ) {
- // Since we only use a single-buffer non-MSAA or double-buffered MSAA offscreenDrawable,
- // we can always swap!
- offscreenDrawable.swapBuffers();
- }
-
- final int componentCount;
- final int alignment;
- if( isOpaque() ) {
- // w/o alpha
- componentCount = 3;
- alignment = 1;
- } else {
- // with alpha
- componentCount = 4;
- alignment = 4;
- }
-
- final PixelFormat awtPixelFormat = pixelBufferProvider.getAWTPixelFormat(gl.getGLProfile(), componentCount);
- final GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount, true);
-
- if( useSingletonBuffer ) { // attempt to fetch the latest AWTGLPixelBuffer
- pixelBuffer = (AWTGLPixelBuffer) ((SingletonGLPixelBufferProvider)pixelBufferProvider).getSingleBuffer(awtPixelFormat.comp, pixelAttribs, true);
- }
- if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, panelWidth, panelHeight, 0) ) {
- pixelBuffer.dispose();
- pixelBuffer = null;
- alignedImage = null;
- }
- final boolean DEBUG_INIT;
- if ( null == pixelBuffer ) {
- if (0 >= panelWidth || 0 >= panelHeight ) {
- return;
- }
- pixelBuffer = pixelBufferProvider.allocate(gl, awtPixelFormat.comp, pixelAttribs, true, panelWidth, panelHeight, 1, 0);
- if(DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelBufferProvider isSingletonBufferProvider "+useSingletonBuffer+", 0x"+Integer.toHexString(pixelBufferProvider.hashCode())+", "+pixelBufferProvider.getClass().getSimpleName());
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelBuffer 0x"+Integer.toHexString(pixelBuffer.hashCode())+", "+pixelBuffer+", alignment "+alignment);
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster)+", isGL2ES3 "+gl.isGL2ES3());
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" panelSize "+panelWidth+"x"+panelHeight+" @ scale "+getPixelScaleStr());
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelAttribs "+pixelAttribs);
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" awtPixelFormat "+awtPixelFormat);
- DEBUG_INIT = true;
- } else {
- DEBUG_INIT = false;
- }
- } else {
- DEBUG_INIT = false;
- }
- if( offscreenDrawable.getSurfaceWidth() != panelWidth || offscreenDrawable.getSurfaceHeight() != panelHeight ) {
- throw new InternalError("OffscreenDrawable panelSize mismatch (reshape missed): panelSize "+panelWidth+"x"+panelHeight+" != drawable "+offscreenDrawable.getSurfaceWidth()+"x"+offscreenDrawable.getSurfaceHeight()+", on thread "+getThreadName());
- }
- if( null == alignedImage ||
- panelWidth != alignedImage.getWidth() || panelHeight != alignedImage.getHeight() ||
- !pixelBuffer.isDataBufferSource(alignedImage) ) {
- alignedImage = pixelBuffer.getAlignedImage(panelWidth, panelHeight);
- if(DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" new alignedImage "+alignedImage.getWidth()+"x"+alignedImage.getHeight()+" @ scale "+getPixelScaleStr()+", "+alignedImage+", pixelBuffer "+pixelBuffer.width+"x"+pixelBuffer.height+", "+pixelBuffer);
- }
- }
- final IntBuffer readBackInts;
-
- if( !flipVertical || null != glslTextureRaster ) {
- readBackInts = (IntBuffer) pixelBuffer.buffer;
- } else {
- if( null == readBackIntsForCPUVFlip || pixelBuffer.width * pixelBuffer.height > readBackIntsForCPUVFlip.remaining() ) {
- readBackIntsForCPUVFlip = IntBuffer.allocate(pixelBuffer.width * pixelBuffer.height);
- }
- readBackInts = readBackIntsForCPUVFlip;
- }
-
- // Must now copy pixels from offscreen context into surface
- if( DEBUG_FRAMES ) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.readPixels: - frameCount "+frameCount);
- }
-
- // Save PACK modes, reset them to defaults and set alignment
- psm.setPackAlignment(gl, alignment);
- if( gl.isGL2ES3() ) {
- final GL2ES3 gl2es3 = gl.getGL2ES3();
- psm.setPackRowLength(gl2es3, panelWidth);
- gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer());
- if( DEBUG_INIT ) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.0: fboDrawable "+offscreenDrawable);
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.0: isGL2ES3, readBuffer 0x"+Integer.toHexString(gl2es3.getDefaultReadBuffer()));
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.0: def-readBuffer 0x"+Integer.toHexString(gl2es3.getDefaultReadBuffer()));
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.0: def-readFBO 0x"+Integer.toHexString(gl2es3.getDefaultReadFramebuffer()));
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.0: bound-readFBO 0x"+Integer.toHexString(gl2es3.getBoundFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER)));
- }
- }
-
- if(null != glslTextureRaster) { // implies flippedVertical
- final boolean viewportChange;
- final int[] usrViewport = new int[] { 0, 0, 0, 0 };
- gl.glGetIntegerv(GL.GL_VIEWPORT, usrViewport, 0);
- viewportChange = 0 != usrViewport[0] || 0 != usrViewport[1] ||
- panelWidth != usrViewport[2] || panelHeight != usrViewport[3];
- if( DEBUG_VIEWPORT ) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: "+GLJPanel.this.getName()+" Viewport: change "+viewportChange+
- ", "+usrViewport[0]+"/"+usrViewport[1]+" "+usrViewport[2]+"x"+usrViewport[3]+
- " -> 0/0 "+panelWidth+"x"+panelHeight);
- }
- if( viewportChange ) {
- gl.glViewport(0, 0, panelWidth, panelHeight);
- }
-
- // perform vert-flipping via OpenGL/FBO
- final GLFBODrawable fboDrawable = (GLFBODrawable)offscreenDrawable;
- final FBObject.TextureAttachment fboTex = fboDrawable.getColorbuffer(GL.GL_FRONT).getTextureAttachment();
-
- fboFlipped.bind(gl);
-
- // gl.glActiveTexture(GL.GL_TEXTURE0 + fboDrawable.getTextureUnit()); // implicit by GLFBODrawableImpl: swapBuffers/contextMadeCurent -> swapFBOImpl
- gl.glBindTexture(GL.GL_TEXTURE_2D, fboTex.getName());
- // gl.glClear(GL.GL_DEPTH_BUFFER_BIT); // fboFlipped runs w/o DEPTH!
-
- glslTextureRaster.display(gl.getGL2ES2());
- if( DEBUG_INIT ) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: fboDrawable "+fboDrawable);
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: read from fbo-rb "+fboFlipped.getReadFramebuffer()+", fbo "+fboFlipped);
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: isGL2ES3, readBuffer 0x"+Integer.toHexString(gl.getDefaultReadBuffer()));
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: def-readBuffer 0x"+Integer.toHexString(gl.getDefaultReadBuffer()));
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: def-readFBO 0x"+Integer.toHexString(gl.getDefaultReadFramebuffer()));
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: bound-readFBO 0x"+Integer.toHexString(gl.getBoundFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER)));
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: "+GLJPanel.this.getName()+" pixelAttribs "+pixelAttribs);
- }
- gl.glReadPixels(0, 0, panelWidth, panelHeight, pixelAttribs.format, pixelAttribs.type, readBackInts);
-
- fboFlipped.unbind(gl);
- if( DEBUG_INIT ) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: fboDrawable "+fboDrawable);
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: read from fbo-rb "+fboFlipped.getReadFramebuffer()+", fbo "+fboFlipped);
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: isGL2ES3, readBuffer 0x"+Integer.toHexString(gl.getDefaultReadBuffer()));
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: def-readBuffer 0x"+Integer.toHexString(gl.getDefaultReadBuffer()));
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: def-readFBO 0x"+Integer.toHexString(gl.getDefaultReadFramebuffer()));
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: bound-readFBO 0x"+Integer.toHexString(gl.getBoundFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER)));
- }
- if( viewportChange ) {
- gl.glViewport(usrViewport[0], usrViewport[1], usrViewport[2], usrViewport[3]);
- }
- } else {
- gl.glReadPixels(0, 0, panelWidth, panelHeight, pixelAttribs.format, pixelAttribs.type, readBackInts);
-
- if ( flipVertical ) {
- // Copy temporary data into raster of BufferedImage for faster
- // blitting Note that we could avoid this copy in the cases
- // where !offscreenDrawable.isGLOriented(),
- // but that's the software rendering path which is very slow anyway.
- final BufferedImage image = alignedImage;
- final int[] src = readBackInts.array();
- final int[] dest = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
- final int incr = panelWidth;
- int srcPos = 0;
- int destPos = (panelHeight - 1) * panelWidth;
- for (; destPos >= 0; srcPos += incr, destPos -= incr) {
- System.arraycopy(src, srcPos, dest, destPos, incr);
- }
- }
- }
- if( 0 != fboTexUnit ) { // implies offscreenIsFBO
- fboTexState.restore(gl);
- if( fboTexUnit != usrTexState.getUnit() ) {
- usrTexState.restore(gl);
- }
- }
-
- // Restore saved modes.
- psm.restore(gl);
-
- // Note: image will be drawn back in paintComponent() for
- // correctness on all platforms
- }
- }
-
- @Override
- public final int getTextureUnit() {
- if(null != glslTextureRaster && null != offscreenDrawable) { // implies flippedVertical
- return ((GLFBODrawable)offscreenDrawable).getTextureUnit();
- }
- return -1;
- }
-
- @Override
- public final void doPaintComponent(final Graphics g) {
- helper.invokeGL(offscreenDrawable, offscreenContext, updaterDisplayAction, updaterInitAction);
-
- if ( null != alignedImage ) {
- if( DEBUG_FRAMES ) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.doPaintComponent.drawImage: - frameCount "+frameCount);
- }
- // Draw resulting image in one shot
- g.drawImage(alignedImage, 0, 0,
- SurfaceScaleUtils.scaleInv(alignedImage.getWidth(), hasPixelScale[0]),
- SurfaceScaleUtils.scaleInv(alignedImage.getHeight(), hasPixelScale[1]), null); // Null ImageObserver since image data is ready.
- }
- frameCount++;
- }
-
- @Override
- public final void doPlainPaint() {
- helper.invokeGL(offscreenDrawable, offscreenContext, updaterPlainDisplayAction, updaterInitAction);
- }
-
- @Override
- public final boolean handleReshape() {
- GLDrawableImpl _drawable = (GLDrawableImpl)offscreenDrawable;
- {
- final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, offscreenContext, panelWidth, panelHeight);
- if(_drawable != _drawableNew) {
- // write back
- _drawable = _drawableNew;
- offscreenDrawable = _drawableNew;
- updateWrappedSurfaceScale(offscreenDrawable);
- }
- }
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.handleReshape: " +panelWidth+"x"+panelHeight + " @ scale "+getPixelScaleStr() + " -> " + _drawable.getSurfaceWidth()+"x"+_drawable.getSurfaceHeight());
- }
- panelWidth = _drawable.getSurfaceWidth();
- panelHeight = _drawable.getSurfaceHeight();
-
- if( null != glslTextureRaster ) {
- if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) {
- try {
- final GL gl = offscreenContext.getGL();
- fboFlipped.reset(gl, panelWidth, panelHeight, 0);
- glslTextureRaster.reshape(gl.getGL2ES2(), 0, 0, panelWidth, panelHeight);
- } finally {
- offscreenContext.release();
- }
- }
- }
- return _drawable.isRealized();
- }
-
- @Override
- public final GLContext createContext(final GLContext shareWith) {
- return (null != offscreenDrawable) ? offscreenDrawable.createContext(shareWith) : null;
- }
-
- @Override
- public final void setContext(final GLContext ctx) {
- offscreenContext=(GLContextImpl)ctx;
- }
-
- @Override
- public final GLContext getContext() {
- return offscreenContext;
- }
-
- @Override
- public final GLDrawable getDrawable() {
- return offscreenDrawable;
- }
-
- @Override
- public final GLCapabilitiesImmutable getChosenGLCapabilities() {
- if (offscreenDrawable == null) {
- return null;
- }
- return offscreenDrawable.getChosenGLCapabilities();
- }
-
- @Override
- public final GLProfile getGLProfile() {
- if (offscreenDrawable == null) {
- return null;
- }
- return offscreenDrawable.getGLProfile();
- }
- }
-
- class J2DOGLBackend implements Backend {
- // Opaque Object identifier representing the Java2D surface we are
- // drawing to; used to determine when to destroy and recreate JOGL
- // context
- private Object j2dSurface;
- // Graphics object being used during Java2D update action
- // (absolutely essential to cache this)
- // No-op context representing the Java2D OpenGL context
- private GLContext j2dContext;
- // Context associated with no-op drawable representing the JOGL
- // OpenGL context
- private GLDrawable joglDrawable;
- // The real OpenGL context JOGL uses to render
- private GLContext joglContext;
- // State captured from Java2D OpenGL context necessary in order to
- // properly render into Java2D back buffer
- private final int[] drawBuffer = new int[1];
- private final int[] readBuffer = new int[1];
- // This is required when the FBO option of the Java2D / OpenGL
- // pipeline is active
- private final int[] frameBuffer = new int[1];
- // Current (as of this writing) NVidia drivers have a couple of bugs
- // relating to the sharing of framebuffer and renderbuffer objects
- // between contexts. It appears we have to (a) reattach the color
- // attachment and (b) actually create new depth buffer storage and
- // attach it in order for the FBO to behave properly in our context.
- private boolean checkedForFBObjectWorkarounds;
- private boolean fbObjectWorkarounds;
- private int[] frameBufferDepthBuffer;
- private int[] frameBufferTexture;
- private boolean createNewDepthBuffer;
- // Current (as of this writing) ATI drivers have problems when the
- // same FBO is bound in two different contexts. Here we check for
- // this case and explicitly release the FBO from Java2D's context
- // before switching to ours. Java2D will re-bind the FBO when it
- // makes its context current the next time. Interestingly, if we run
- // this code path on NVidia hardware, it breaks the rendering
- // results -- no output is generated. This doesn't appear to be an
- // interaction with the abovementioned NVidia-specific workarounds,
- // as even if we disable that code the FBO is still reported as
- // incomplete in our context.
- private boolean checkedGLVendor;
- private boolean vendorIsATI;
-
- // Holding on to this GraphicsConfiguration is a workaround for a
- // problem in the Java 2D / JOGL bridge when FBOs are enabled; see
- // comment related to Issue 274 below
- private GraphicsConfiguration workaroundConfig;
-
- @Override
- public final boolean isUsingOwnLifecycle() { return true; }
-
- @Override
- public final void initialize() {
- if(DEBUG) {
- System.err.println(getThreadName()+": J2DOGL: initialize()");
- }
- // No-op in this implementation; everything is done lazily
- isInitialized = true;
- }
-
- @Override
- public final void destroy() {
- Java2D.invokeWithOGLContextCurrent(null, new Runnable() {
- @Override
- public void run() {
- if(DEBUG) {
- System.err.println(getThreadName()+": J2DOGL: destroy() - joglContext: "+(null!=joglContext)+" - joglDrawable: "+(null!=joglDrawable));
- }
- if (joglContext != null) {
- joglContext.destroy();
- joglContext = null;
- }
- joglDrawable = null;
- if (j2dContext != null) {
- j2dContext.destroy();
- j2dContext = null;
- }
- }
- });
- }
-
- @Override
- public final void setOpaque(final boolean opaque) {
- // Empty in this implementation
- }
-
- @Override
- public final GLContext createContext(final GLContext shareWith) {
- if(null != shareWith) {
- throw new GLException("J2DOGLBackend cannot create context w/ additional shared context, since it already needs to share the context w/ J2D.");
- }
- return (null != joglDrawable && null != j2dContext) ? joglDrawable.createContext(j2dContext) : null;
- }
-
- @Override
- public final void setContext(final GLContext ctx) {
- joglContext=ctx;
- }
-
- @Override
- public final GLContext getContext() {
- return joglContext;
- }
-
- @Override
- public final GLDrawable getDrawable() {
- return joglDrawable;
- }
-
- @Override
- public final int getTextureUnit() { return -1; }
-
- @Override
- public final GLCapabilitiesImmutable getChosenGLCapabilities() {
- // FIXME: should do better than this; is it possible to query J2D Caps ?
- return new GLCapabilities(null);
- }
-
- @Override
- public final GLProfile getGLProfile() {
- // FIXME: should do better than this; is it possible to query J2D's Profile ?
- return GLProfile.getDefault(GLProfile.getDefaultDevice());
- }
-
- @Override
- public final boolean handleReshape() {
- // Empty in this implementation
- return true;
- }
-
- @Override
- public final boolean preGL(final Graphics g) {
- final GL2 gl = joglContext.getGL().getGL2();
- // Set up needed state in JOGL context from Java2D context
- gl.glEnable(GL.GL_SCISSOR_TEST);
- final Rectangle r = Java2D.getOGLScissorBox(g);
-
- if (r == null) {
- if (DEBUG) {
- System.err.println(getThreadName()+": Java2D.getOGLScissorBox() returned null");
- }
- return false;
- }
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel: gl.glScissor(" + r.x + ", " + r.y + ", " + r.width + ", " + r.height + ")");
- }
-
- gl.glScissor(r.x, r.y, r.width, r.height);
- final Rectangle oglViewport = Java2D.getOGLViewport(g, panelWidth, panelHeight);
- // If the viewport X or Y changes, in addition to the panel's
- // width or height, we need to send a reshape operation to the
- // client
- if ((viewportX != oglViewport.x) ||
- (viewportY != oglViewport.y)) {
- sendReshape = true;
- if (DEBUG) {
- System.err.println(getThreadName()+": Sending reshape because viewport changed");
- System.err.println(" viewportX (" + viewportX + ") ?= oglViewport.x (" + oglViewport.x + ")");
- System.err.println(" viewportY (" + viewportY + ") ?= oglViewport.y (" + oglViewport.y + ")");
- }
- }
- viewportX = oglViewport.x;
- viewportY = oglViewport.y;
-
- // If the FBO option is active, bind to the FBO from the Java2D
- // context.
- // Note that all of the plumbing in the context sharing stuff will
- // allow us to bind to this object since it's in our namespace.
- if (Java2D.isFBOEnabled() &&
- Java2D.getOGLSurfaceType(g) == Java2D.FBOBJECT) {
-
- // The texture target for Java2D's OpenGL pipeline when using FBOs
- // -- either GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB
- final int fboTextureTarget = Java2D.getOGLTextureType(g);
-
- if (!checkedForFBObjectWorkarounds) {
- checkedForFBObjectWorkarounds = true;
- gl.glBindTexture(fboTextureTarget, 0);
- gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, frameBuffer[0]);
- final int status = gl.glCheckFramebufferStatus(GL.GL_FRAMEBUFFER);
- if (status != GL.GL_FRAMEBUFFER_COMPLETE) {
- // Need to do workarounds
- fbObjectWorkarounds = true;
- createNewDepthBuffer = true;
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel: ERR GL_FRAMEBUFFER_BINDING: Discovered Invalid J2D FBO("+frameBuffer[0]+"): "+FBObject.getStatusString(status) +
- ", frame_buffer_object workarounds to be necessary");
- }
- } else {
- // Don't need the frameBufferTexture temporary any more
- frameBufferTexture = null;
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel: OK GL_FRAMEBUFFER_BINDING: "+frameBuffer[0]);
- }
- }
- }
-
- if (fbObjectWorkarounds && createNewDepthBuffer) {
- if (frameBufferDepthBuffer == null)
- frameBufferDepthBuffer = new int[1];
-
- // Create our own depth renderbuffer and associated storage
- // If we have an old one, delete it
- if (frameBufferDepthBuffer[0] != 0) {
- gl.glDeleteRenderbuffers(1, frameBufferDepthBuffer, 0);
- frameBufferDepthBuffer[0] = 0;
- }
-
- gl.glBindTexture(fboTextureTarget, frameBufferTexture[0]);
- final int[] width = new int[1];
- final int[] height = new int[1];
- gl.glGetTexLevelParameteriv(fboTextureTarget, 0, GL2GL3.GL_TEXTURE_WIDTH, width, 0);
- gl.glGetTexLevelParameteriv(fboTextureTarget, 0, GL2GL3.GL_TEXTURE_HEIGHT, height, 0);
-
- gl.glGenRenderbuffers(1, frameBufferDepthBuffer, 0);
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel: Generated frameBufferDepthBuffer " + frameBufferDepthBuffer[0] +
- " with width " + width[0] + ", height " + height[0]);
- }
-
- gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, frameBufferDepthBuffer[0]);
- // FIXME: may need a loop here like in Java2D
- gl.glRenderbufferStorage(GL.GL_RENDERBUFFER, GL.GL_DEPTH_COMPONENT24, width[0], height[0]);
-
- gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, 0);
- createNewDepthBuffer = false;
- }
-
- gl.glBindTexture(fboTextureTarget, 0);
- gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, frameBuffer[0]);
-
- if (fbObjectWorkarounds) {
- // Hook up the color and depth buffer attachment points for this framebuffer
- gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER,
- GL.GL_COLOR_ATTACHMENT0,
- fboTextureTarget,
- frameBufferTexture[0],
- 0);
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel: frameBufferDepthBuffer: " + frameBufferDepthBuffer[0]);
- }
- gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER,
- GL.GL_DEPTH_ATTACHMENT,
- GL.GL_RENDERBUFFER,
- frameBufferDepthBuffer[0]);
- }
-
- if (DEBUG) {
- final int status = gl.glCheckFramebufferStatus(GL.GL_FRAMEBUFFER);
- if (status != GL.GL_FRAMEBUFFER_COMPLETE) {
- throw new GLException("Error: framebuffer was incomplete: status = 0x" +
- Integer.toHexString(status));
- }
- }
- } else {
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel: Setting up drawBuffer " + drawBuffer[0] +
- " and readBuffer " + readBuffer[0]);
- }
-
- gl.glDrawBuffer(drawBuffer[0]);
- gl.glReadBuffer(readBuffer[0]);
- }
-
- return true;
- }
-
- @Override
- public final boolean handlesSwapBuffer() {
- return false;
- }
-
- @Override
- public final void swapBuffers() {
- final GLDrawable d = joglDrawable;
- if( null != d ) {
- d.swapBuffers();
- }
- }
-
- @Override
- public final void postGL(final Graphics g, final boolean isDisplay) {
- // Cause OpenGL pipeline to flush its results because
- // otherwise it's possible we will buffer up multiple frames'
- // rendering results, resulting in apparent mouse lag
- final GL gl = joglContext.getGL();
- gl.glFinish();
-
- if (Java2D.isFBOEnabled() &&
- Java2D.getOGLSurfaceType(g) == Java2D.FBOBJECT) {
- // Unbind the framebuffer from our context to work around
- // apparent driver bugs or at least unspecified behavior causing
- // OpenGL to run out of memory with certain cards and drivers
- gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0);
- }
- }
-
- @Override
- public final void doPaintComponent(final Graphics g) {
- // This is a workaround for an issue in the Java 2D / JOGL
- // bridge (reported by an end user as JOGL Issue 274) where Java
- // 2D can occasionally leave its internal OpenGL context current
- // to the on-screen window rather than its internal "scratch"
- // pbuffer surface to which the FBO is attached. JOGL expects to
- // find a stable OpenGL drawable (on Windows, an HDC) upon which
- // it can create another OpenGL context. It turns out that, on
- // Windows, when Java 2D makes its internal OpenGL context
- // current against the window in order to put pixels on the
- // screen, it gets the device context for the window, makes its
- // context current, and releases the device context. This means
- // that when JOGL's Runnable gets to run below, the HDC is
- // already invalid. The workaround for this is to force Java 2D
- // to make its context current to the scratch surface, which we
- // can do by executing an empty Runnable with the "shared"
- // context current. This will be fixed in a Java SE 6 update
- // release, hopefully 6u2.
- if (Java2D.isFBOEnabled()) {
- if (workaroundConfig == null) {
- workaroundConfig = GraphicsEnvironment.
- getLocalGraphicsEnvironment().
- getDefaultScreenDevice().
- getDefaultConfiguration();
- }
- Java2D.invokeWithOGLSharedContextCurrent(workaroundConfig, new Runnable() { @Override
- public void run() {}});
- }
-
- Java2D.invokeWithOGLContextCurrent(g, new Runnable() {
- @Override
- public void run() {
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.invokeWithOGLContextCurrent");
- }
-
- // Create no-op context representing Java2D context
- if (j2dContext == null) {
- j2dContext = factory.createExternalGLContext();
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.Created External Context: "+j2dContext);
- }
- if (DEBUG) {
-// j2dContext.setGL(new DebugGL2(j2dContext.getGL().getGL2()));
- }
-
- // Check to see whether we can support the requested
- // capabilities or need to fall back to a pbuffer
- // FIXME: add more checks?
-
- j2dContext.makeCurrent();
- final GL gl = j2dContext.getGL();
- if ((getGLInteger(gl, GL.GL_RED_BITS) < reqOffscreenCaps.getRedBits()) ||
- (getGLInteger(gl, GL.GL_GREEN_BITS) < reqOffscreenCaps.getGreenBits()) ||
- (getGLInteger(gl, GL.GL_BLUE_BITS) < reqOffscreenCaps.getBlueBits()) ||
- // (getGLInteger(gl, GL.GL_ALPHA_BITS) < offscreenCaps.getAlphaBits()) ||
- (getGLInteger(gl, GL2.GL_ACCUM_RED_BITS) < reqOffscreenCaps.getAccumRedBits()) ||
- (getGLInteger(gl, GL2.GL_ACCUM_GREEN_BITS) < reqOffscreenCaps.getAccumGreenBits()) ||
- (getGLInteger(gl, GL2.GL_ACCUM_BLUE_BITS) < reqOffscreenCaps.getAccumBlueBits()) ||
- (getGLInteger(gl, GL2.GL_ACCUM_ALPHA_BITS) < reqOffscreenCaps.getAccumAlphaBits()) ||
- // (getGLInteger(gl, GL2.GL_DEPTH_BITS) < offscreenCaps.getDepthBits()) ||
- (getGLInteger(gl, GL.GL_STENCIL_BITS) < reqOffscreenCaps.getStencilBits())) {
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel: Falling back to pbuffer-based support because Java2D context insufficient");
- System.err.println(" Available Required");
- System.err.println("GL_RED_BITS " + getGLInteger(gl, GL.GL_RED_BITS) + " " + reqOffscreenCaps.getRedBits());
- System.err.println("GL_GREEN_BITS " + getGLInteger(gl, GL.GL_GREEN_BITS) + " " + reqOffscreenCaps.getGreenBits());
- System.err.println("GL_BLUE_BITS " + getGLInteger(gl, GL.GL_BLUE_BITS) + " " + reqOffscreenCaps.getBlueBits());
- System.err.println("GL_ALPHA_BITS " + getGLInteger(gl, GL.GL_ALPHA_BITS) + " " + reqOffscreenCaps.getAlphaBits());
- System.err.println("GL_ACCUM_RED_BITS " + getGLInteger(gl, GL2.GL_ACCUM_RED_BITS) + " " + reqOffscreenCaps.getAccumRedBits());
- System.err.println("GL_ACCUM_GREEN_BITS " + getGLInteger(gl, GL2.GL_ACCUM_GREEN_BITS) + " " + reqOffscreenCaps.getAccumGreenBits());
- System.err.println("GL_ACCUM_BLUE_BITS " + getGLInteger(gl, GL2.GL_ACCUM_BLUE_BITS) + " " + reqOffscreenCaps.getAccumBlueBits());
- System.err.println("GL_ACCUM_ALPHA_BITS " + getGLInteger(gl, GL2.GL_ACCUM_ALPHA_BITS) + " " + reqOffscreenCaps.getAccumAlphaBits());
- System.err.println("GL_DEPTH_BITS " + getGLInteger(gl, GL.GL_DEPTH_BITS) + " " + reqOffscreenCaps.getDepthBits());
- System.err.println("GL_STENCIL_BITS " + getGLInteger(gl, GL.GL_STENCIL_BITS) + " " + reqOffscreenCaps.getStencilBits());
- }
- isInitialized = false;
- backend = null;
- java2DGLPipelineOK = false;
- handleReshape = true;
- j2dContext.destroy();
- j2dContext = null;
- return;
- }
- } else {
- j2dContext.makeCurrent();
- }
- try {
- captureJ2DState(j2dContext.getGL(), g);
- final Object curSurface = Java2D.getOGLSurfaceIdentifier(g);
- if (curSurface != null) {
- if (j2dSurface != curSurface) {
- if (joglContext != null) {
- joglContext.destroy();
- joglContext = null;
- joglDrawable = null;
- sendReshape = true;
- if (DEBUG) {
- System.err.println(getThreadName()+": Sending reshape because surface changed");
- System.err.println("New surface = " + curSurface);
- }
- }
- j2dSurface = curSurface;
- if (DEBUG) {
- System.err.print(getThreadName()+": Surface type: ");
- final int surfaceType = Java2D.getOGLSurfaceType(g);
- if (surfaceType == Java2D.UNDEFINED) {
- System.err.println("UNDEFINED");
- } else if (surfaceType == Java2D.WINDOW) {
- System.err.println("WINDOW");
- } else if (surfaceType == Java2D.PBUFFER) {
- System.err.println("PBUFFER");
- } else if (surfaceType == Java2D.TEXTURE) {
- System.err.println("TEXTURE");
- } else if (surfaceType == Java2D.FLIP_BACKBUFFER) {
- System.err.println("FLIP_BACKBUFFER");
- } else if (surfaceType == Java2D.FBOBJECT) {
- System.err.println("FBOBJECT");
- } else {
- System.err.println("(Unknown surface type " + surfaceType + ")");
- }
- }
- }
- if (joglContext == null) {
- final AbstractGraphicsDevice device = j2dContext.getGLDrawable().getNativeSurface().getGraphicsConfiguration().getScreen().getDevice();
- if (factory.canCreateExternalGLDrawable(device)) {
- joglDrawable = factory.createExternalGLDrawable();
- joglContext = joglDrawable.createContext(j2dContext);
- if (DEBUG) {
- System.err.println("-- Created External Drawable: "+joglDrawable);
- System.err.println("-- Created Context: "+joglContext);
- }
- }
- if (Java2D.isFBOEnabled() &&
- Java2D.getOGLSurfaceType(g) == Java2D.FBOBJECT &&
- fbObjectWorkarounds) {
- createNewDepthBuffer = true;
- }
- }
- helper.invokeGL(joglDrawable, joglContext, updaterDisplayAction, updaterInitAction);
- }
- } finally {
- j2dContext.release();
- }
- }
- });
- }
-
- @Override
- public final void doPlainPaint() {
- helper.invokeGL(joglDrawable, joglContext, updaterPlainDisplayAction, updaterInitAction);
- }
-
- private final void captureJ2DState(final GL gl, final Graphics g) {
- gl.glGetIntegerv(GL2GL3.GL_DRAW_BUFFER, drawBuffer, 0);
- gl.glGetIntegerv(GL2ES3.GL_READ_BUFFER, readBuffer, 0);
- if (Java2D.isFBOEnabled() &&
- Java2D.getOGLSurfaceType(g) == Java2D.FBOBJECT) {
- gl.glGetIntegerv(GL.GL_FRAMEBUFFER_BINDING, frameBuffer, 0);
- if(!gl.glIsFramebuffer(frameBuffer[0])) {
- checkedForFBObjectWorkarounds=true;
- fbObjectWorkarounds = true;
- createNewDepthBuffer = true;
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel: Fetched ERR GL_FRAMEBUFFER_BINDING: "+frameBuffer[0]+" - NOT A FBO"+
- ", frame_buffer_object workarounds to be necessary");
- }
- } else if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel: Fetched OK GL_FRAMEBUFFER_BINDING: "+frameBuffer[0]);
- }
-
- if(fbObjectWorkarounds || !checkedForFBObjectWorkarounds) {
- // See above for description of what we are doing here
- if (frameBufferTexture == null)
- frameBufferTexture = new int[1];
-
- // Query the framebuffer for its color buffer so we can hook
- // it back up in our context (should not be necessary)
- gl.glGetFramebufferAttachmentParameteriv(GL.GL_FRAMEBUFFER,
- GL.GL_COLOR_ATTACHMENT0,
- GL.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
- frameBufferTexture, 0);
- if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel: FBO COLOR_ATTACHMENT0: " + frameBufferTexture[0]);
- }
- }
-
- if (!checkedGLVendor) {
- checkedGLVendor = true;
- final String vendor = gl.glGetString(GL.GL_VENDOR);
-
- if ((vendor != null) &&
- vendor.startsWith("ATI")) {
- vendorIsATI = true;
- }
- }
-
- if (vendorIsATI) {
- // Unbind the FBO from Java2D's context as it appears that
- // driver bugs on ATI's side are causing problems if the FBO is
- // simultaneously bound to more than one context. Java2D will
- // re-bind the FBO during the next validation of its context.
- // Note: this breaks rendering at least on NVidia hardware
- gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0);
- }
- }
- }
- }
-}
diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java
deleted file mode 100644
index cf7b9da46..000000000
--- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLLightingFunc.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl.fixedfunc;
-
-public interface GLLightingFunc {
- public static final int GL_LIGHT0 = 0x4000;
- public static final int GL_LIGHT1 = 0x4001;
- public static final int GL_LIGHT2 = 0x4002;
- public static final int GL_LIGHT3 = 0x4003;
- public static final int GL_LIGHT4 = 0x4004;
- public static final int GL_LIGHT5 = 0x4005;
- public static final int GL_LIGHT6 = 0x4006;
- public static final int GL_LIGHT7 = 0x4007;
- public static final int GL_LIGHTING = 0xB50;
- public static final int GL_AMBIENT = 0x1200;
- public static final int GL_DIFFUSE = 0x1201;
- public static final int GL_SPECULAR = 0x1202;
- public static final int GL_POSITION = 0x1203;
- public static final int GL_SPOT_DIRECTION = 0x1204;
- public static final int GL_SPOT_EXPONENT = 0x1205;
- public static final int GL_SPOT_CUTOFF = 0x1206;
- public static final int GL_CONSTANT_ATTENUATION = 0x1207;
- public static final int GL_LINEAR_ATTENUATION = 0x1208;
- public static final int GL_QUADRATIC_ATTENUATION = 0x1209;
- public static final int GL_EMISSION = 0x1600;
- public static final int GL_SHININESS = 0x1601;
- public static final int GL_AMBIENT_AND_DIFFUSE = 0x1602;
- public static final int GL_COLOR_MATERIAL = 0xB57;
- public static final int GL_NORMALIZE = 0xBA1;
-
- public static final int GL_FLAT = 0x1D00;
- public static final int GL_SMOOTH = 0x1D01;
-
- public void glLightfv(int light, int pname, java.nio.FloatBuffer params);
- public void glLightfv(int light, int pname, float[] params, int params_offset);
- public void glMaterialf(int face, int pname, float param);
- public void glMaterialfv(int face, int pname, java.nio.FloatBuffer params);
- public void glMaterialfv(int face, int pname, float[] params, int params_offset);
- public void glColor4f(float red, float green, float blue, float alpha);
- public void glShadeModel(int mode);
-
-}
-
diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java
deleted file mode 100644
index 90f13faf1..000000000
--- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl.fixedfunc;
-
-import java.nio.*;
-
-import com.jogamp.opengl.GL;
-
-/**
- * Subset of OpenGL fixed function pipeline's matrix operations.
- */
-public interface GLMatrixFunc {
-
- public static final int GL_MATRIX_MODE = 0x0BA0;
- /** Matrix mode modelview */
- public static final int GL_MODELVIEW = 0x1700;
- /** Matrix mode projection */
- public static final int GL_PROJECTION = 0x1701;
- // public static final int GL_TEXTURE = 0x1702; // Use GL.GL_TEXTURE due to ambiguous GL usage
- /** Matrix access name for modelview */
- public static final int GL_MODELVIEW_MATRIX = 0x0BA6;
- /** Matrix access name for projection */
- public static final int GL_PROJECTION_MATRIX = 0x0BA7;
- /** Matrix access name for texture */
- public static final int GL_TEXTURE_MATRIX = 0x0BA8;
-
- /**
- * Copy the named matrix into the given storage.
- * @param pname {@link #GL_MODELVIEW_MATRIX}, {@link #GL_PROJECTION_MATRIX} or {@link #GL_TEXTURE_MATRIX}
- * @param params the FloatBuffer's position remains unchanged,
- * which is the same behavior than the native JOGL GL impl
- */
- public void glGetFloatv(int pname, java.nio.FloatBuffer params);
-
- /**
- * Copy the named matrix to the given storage at offset.
- * @param pname {@link #GL_MODELVIEW_MATRIX}, {@link #GL_PROJECTION_MATRIX} or {@link #GL_TEXTURE_MATRIX}
- * @param params storage
- * @param params_offset storage offset
- */
- public void glGetFloatv(int pname, float[] params, int params_offset);
-
- /**
- * glGetIntegerv
- * @param pname {@link #GL_MATRIX_MODE} to receive the current matrix mode
- * @param params the FloatBuffer's position remains unchanged
- * which is the same behavior than the native JOGL GL impl
- */
- public void glGetIntegerv(int pname, IntBuffer params);
- public void glGetIntegerv(int pname, int[] params, int params_offset);
-
- /**
- * Sets the current matrix mode.
- * @param mode {@link #GL_MODELVIEW}, {@link #GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE}.
- */
- public void glMatrixMode(int mode) ;
-
- /**
- * Push the current matrix to it's stack, while preserving it's values.
- *
- * There exist one stack per matrix mode, i.e. {@link #GL_MODELVIEW}, {@link #GL_PROJECTION} and {@link GL#GL_TEXTURE GL_TEXTURE}.
- *
- */
- public void glPushMatrix();
-
- /**
- * Pop the current matrix from it's stack.
- * @see #glPushMatrix()
- */
- public void glPopMatrix();
-
- /**
- * Load the current matrix with the identity matrix
- */
- public void glLoadIdentity() ;
-
- /**
- * Load the current matrix w/ the provided one.
- * @param params the FloatBuffer's position remains unchanged,
- * which is the same behavior than the native JOGL GL impl
- */
- public void glLoadMatrixf(java.nio.FloatBuffer m) ;
- /**
- * Load the current matrix w/ the provided one.
- */
- public void glLoadMatrixf(float[] m, int m_offset);
-
- /**
- * Multiply the current matrix: [c] = [c] x [m]
- * @param m the FloatBuffer's position remains unchanged,
- * which is the same behavior than the native JOGL GL impl
- */
- public void glMultMatrixf(java.nio.FloatBuffer m) ;
- /**
- * Multiply the current matrix: [c] = [c] x [m]
- */
- public void glMultMatrixf(float[] m, int m_offset);
-
- /**
- * Translate the current matrix.
- */
- public void glTranslatef(float x, float y, float z) ;
-
- /**
- * Rotate the current matrix.
- */
- public void glRotatef(float angle, float x, float y, float z);
-
- /**
- * Scale the current matrix.
- */
- public void glScalef(float x, float y, float z) ;
-
- /**
- * {@link #glMultMatrixf(FloatBuffer) Multiply} the current matrix with the orthogonal matrix.
- */
- public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) ;
-
- /**
- * {@link #glMultMatrixf(FloatBuffer) Multiply} the current matrix with the frustum matrix.
- */
- public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar);
-
-}
-
diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java
deleted file mode 100644
index 852d4ebba..000000000
--- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl.fixedfunc;
-
-import com.jogamp.opengl.*;
-
-public interface GLPointerFunc {
- public static final int GL_VERTEX_ARRAY = 0x8074;
- public static final int GL_NORMAL_ARRAY = 0x8075;
- public static final int GL_COLOR_ARRAY = 0x8076;
- public static final int GL_TEXTURE_COORD_ARRAY = 0x8078;
-
- public void glEnableClientState(int arrayName);
- public void glDisableClientState(int arrayName);
-
- public void glVertexPointer(GLArrayData array);
- public void glVertexPointer(int size, int type, int stride, java.nio.Buffer pointer);
- public void glVertexPointer(int size, int type, int stride, long pointer_buffer_offset);
-
- public void glColorPointer(GLArrayData array);
- public void glColorPointer(int size, int type, int stride, java.nio.Buffer pointer);
- public void glColorPointer(int size, int type, int stride, long pointer_buffer_offset);
- public void glColor4f(float red, float green, float blue, float alpha);
-
- public void glNormalPointer(GLArrayData array);
- public void glNormalPointer(int type, int stride, java.nio.Buffer pointer);
- public void glNormalPointer(int type, int stride, long pointer_buffer_offset);
-
- public void glTexCoordPointer(GLArrayData array);
- public void glTexCoordPointer(int size, int type, int stride, java.nio.Buffer pointer);
- public void glTexCoordPointer(int size, int type, int stride, long pointer_buffer_offset);
-
-}
-
diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFuncUtil.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFuncUtil.java
deleted file mode 100644
index cb1ff3827..000000000
--- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFuncUtil.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.opengl.fixedfunc;
-
-public class GLPointerFuncUtil {
- public static final String mgl_Vertex = "mgl_Vertex";
- public static final String mgl_Normal = "mgl_Normal";
- public static final String mgl_Color = "mgl_Color";
- public static final String mgl_MultiTexCoord = "mgl_MultiTexCoord" ;
- public static final String mgl_InterleaveArray = "mgl_InterleaveArray" ; // magic name for interleaved arrays w/ sub-arrays
-
- /**
- * @param glArrayIndex the fixed function array index
- * @return default fixed function array name
- */
- public static String getPredefinedArrayIndexName(final int glArrayIndex) {
- return getPredefinedArrayIndexName(glArrayIndex, -1);
- }
-
- /**
- * @param glArrayIndex the fixed function array index
- * @param multiTexCoordIndex index for multiTexCoordIndex
- * @return default fixed function array name
- */
- public static String getPredefinedArrayIndexName(final int glArrayIndex, final int multiTexCoordIndex) {
- switch(glArrayIndex) {
- case GLPointerFunc.GL_VERTEX_ARRAY:
- return mgl_Vertex;
- case GLPointerFunc.GL_NORMAL_ARRAY:
- return mgl_Normal;
- case GLPointerFunc.GL_COLOR_ARRAY:
- return mgl_Color;
- case GLPointerFunc.GL_TEXTURE_COORD_ARRAY:
- if(0<=multiTexCoordIndex) {
- return mgl_MultiTexCoord+multiTexCoordIndex;
- } else {
- return mgl_MultiTexCoord+multiTexCoordIndex;
- }
- }
- return null;
- }
-}
diff --git a/src/jogl/classes/javax/media/opengl/glu/GLUnurbs.java b/src/jogl/classes/javax/media/opengl/glu/GLUnurbs.java
deleted file mode 100644
index 0dbd54674..000000000
--- a/src/jogl/classes/javax/media/opengl/glu/GLUnurbs.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.jogamp.opengl.glu;
-
-/**
- * Wrapper for a GLU NURBS object.
- */
-
-public interface GLUnurbs {
-}
diff --git a/src/jogl/classes/javax/media/opengl/glu/GLUquadric.java b/src/jogl/classes/javax/media/opengl/glu/GLUquadric.java
deleted file mode 100644
index 45b2d054d..000000000
--- a/src/jogl/classes/javax/media/opengl/glu/GLUquadric.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.jogamp.opengl.glu;
-
-import com.jogamp.opengl.GL;
-import com.jogamp.opengl.util.ImmModeSink;
-
-/**
- * Wrapper for a GLU quadric object.
- */
-
-public interface GLUquadric {
- // enable/disables the Immediate Mode Sink module.
- // This defaults to false for GLUgl2,
- // and is always true for GLUes1.
- public void enableImmModeSink(boolean val);
-
- public boolean isImmModeSinkEnabled();
-
- // set Immediate Mode usage.
- // This defaults to false at GLU creation time.
- // If enabled rendering will happen immediately,
- // otherwise rendering will be hold in the ImmModeSink
- // object, to be rendered deferred.
- public void setImmMode(boolean val);
-
- public boolean getImmMode();
-
- // creates a new ImmModeSink (VBO Buffers) and
- // returns the old vbo buffer with it's rendering result
- public ImmModeSink replaceImmModeSink();
-
- // gl may be null, then the GL client states are not disabled
- public void resetImmModeSink(GL gl);
-}
diff --git a/src/jogl/classes/javax/media/opengl/glu/GLUtessellator.java b/src/jogl/classes/javax/media/opengl/glu/GLUtessellator.java
deleted file mode 100644
index ce9fda8e7..000000000
--- a/src/jogl/classes/javax/media/opengl/glu/GLUtessellator.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 2.0 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package com.jogamp.opengl.glu;
-
-/**
- * The GLUtessellator object is used to hold the data, such as the
- * vertices, edges and callback objects, to describe and tessellate complex
- * polygons. A GLUtessellator object is used with the
- * {@link GLU GLU} tessellator methods and
- * {@link GLUtessellatorCallback GLU callbacks}.
- *
- * @author Eric Veach, July 1994
- * @author Java Port: Pepijn Van Eechhoudt, July 2003
- * @author Java Port: Nathan Parker Burg, August 2003
- */
-public interface GLUtessellator {}
diff --git a/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallback.java b/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallback.java
deleted file mode 100644
index c616bca38..000000000
--- a/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallback.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
-* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 2.0 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package com.jogamp.opengl.glu;
-
-/**
- * GLUtessellatorCallback interface provides methods that the user will
- * override to define the callbacks for a tessellation object.
- *
- * @author Eric Veach, July 1994
- * @author Java Port: Pepijn Van Eeckhoudt, July 2003
- * @author Java Port: Nathan Parker Burg, August 2003
- */
-public interface GLUtessellatorCallback {
- /**
- * The begin callback method is invoked like
- * {@link com.jogamp.opengl.GL#glBegin glBegin} to indicate the start of a
- * (triangle) primitive. The method takes a single argument of type int. If
- * the GLU_TESS_BOUNDARY_ONLY property is set to GL_FALSE, then
- * the argument is set to either GL_TRIANGLE_FAN,
- * GL_TRIANGLE_STRIP, or GL_TRIANGLES. If the
- * GLU_TESS_BOUNDARY_ONLY property is set to GL_TRUE, then the
- * argument will be set to GL_LINE_LOOP.
- *
- * @param type
- * Specifics the type of begin/end pair being defined. The following
- * values are valid: GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP,
- * GL_TRIANGLES or GL_LINE_LOOP.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #end end
- * @see #begin begin
- */
- public void begin(int type);
-
- /**
- * The same as the {@link #begin begin} callback method except that
- * it takes an additional reference argument. This reference is
- * identical to the opaque reference provided when {@link
- * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
- *
- * @param type
- * Specifics the type of begin/end pair being defined. The following
- * values are valid: GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP,
- * GL_TRIANGLES or GL_LINE_LOOP.
- * @param polygonData
- * Specifics a reference to user-defined data.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #endData endData
- * @see #begin begin
- */
- public void beginData(int type, Object polygonData);
-
-
- /**
- * The edgeFlag callback method is similar to
- * {@link com.jogamp.opengl.GL#glEdgeFlag glEdgeFlag}. The method takes
- * a single boolean boundaryEdge that indicates which edges lie on the
- * polygon boundary. If the boundaryEdge is GL_TRUE, then each vertex
- * that follows begins an edge that lies on the polygon boundary, that is,
- * an edge that separates an interior region from an exterior one. If the
- * boundaryEdge is GL_FALSE, then each vertex that follows begins an
- * edge that lies in the polygon interior. The edge flag callback (if
- * defined) is invoked before the first vertex callback.
- *
- * Since triangle fans and triangle strips do not support edge flags, the
- * begin callback is not called with GL_TRIANGLE_FAN or
- * GL_TRIANGLE_STRIP if a non-null edge flag callback is provided.
- * (If the callback is initialized to null, there is no impact on
- * performance). Instead, the fans and strips are converted to independent
- * triangles.
- *
- * @param boundaryEdge
- * Specifics which edges lie on the polygon boundary.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #edgeFlagData edgeFlagData
- */
- public void edgeFlag(boolean boundaryEdge);
-
-
- /**
- * The same as the {@link #edgeFlag edgeFlage} callback method
- * except that it takes an additional reference argument. This
- * reference is identical to the opaque reference provided when
- * {@link GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
- *
- * @param boundaryEdge
- * Specifics which edges lie on the polygon boundary.
- * @param polygonData
- * Specifics a reference to user-defined data.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #edgeFlag edgeFlag
- */
- public void edgeFlagData(boolean boundaryEdge, Object polygonData);
-
-
- /**
- * The vertex callback method is invoked between the {@link
- * #begin begin} and {@link #end end} callback methods. It is
- * similar to {@link com.jogamp.opengl.GL#glVertex3f glVertex3f},
- * and it defines the vertices of the triangles created by the
- * tessellation process. The method takes a reference as its only
- * argument. This reference is identical to the opaque reference
- * provided by the user when the vertex was described (see {@link
- * GLU#gluTessVertex gluTessVertex}).
- *
- * @param vertexData
- * Specifics a reference to the vertices of the triangles created
- * by the tessellation process.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #vertexData vertexData
- */
- public void vertex(Object vertexData);
-
-
- /**
- * The same as the {@link #vertex vertex} callback method except
- * that it takes an additional reference argument. This reference is
- * identical to the opaque reference provided when {@link
- * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
- *
- * @param vertexData
- * Specifics a reference to the vertices of the triangles created
- * by the tessellation process.
- * @param polygonData
- * Specifics a reference to user-defined data.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #vertex vertex
- */
- public void vertexData(Object vertexData, Object polygonData);
-
-
- /**
- * The end callback serves the same purpose as
- * {@link com.jogamp.opengl.GL#glEnd glEnd}. It indicates the end of a
- * primitive and it takes no arguments.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #begin begin
- * @see #endData endData
- */
- public void end();
-
-
- /**
- * The same as the {@link #end end} callback method except that it
- * takes an additional reference argument. This reference is
- * identical to the opaque reference provided when {@link
- * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
- *
- * @param polygonData
- * Specifics a reference to user-defined data.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #beginData beginData
- * @see #end end
- */
- public void endData(Object polygonData);
-
-
- /**
- * The combine callback method is called to create a new vertex when
- * the tessellation detects an intersection, or wishes to merge features. The
- * method takes four arguments: an array of three elements each of type
- * double, an array of four references, an array of four elements each of
- * type float, and a reference to a reference.
- *
- * The vertex is defined as a linear combination of up to four existing
- * vertices, stored in data. The coefficients of the linear combination
- * are given by weight; these weights always add up to 1. All vertex
- * pointers are valid even when some of the weights are 0. coords gives
- * the location of the new vertex.
- *
- * The user must allocate another vertex, interpolate parameters using
- * data and weight, and return the new vertex pointer in
- * outData. This handle is supplied during rendering callbacks. The
- * user is responsible for freeing the memory some time after
- * {@link GLU#gluTessEndPolygon gluTessEndPolygon} is
- * called.
- *
- * For example, if the polygon lies in an arbitrary plane in 3-space, and a
- * color is associated with each vertex, the GLU_TESS_COMBINE
- * callback might look like this:
- *
- *
- * @param coords
- * Specifics the location of the new vertex.
- * @param data
- * Specifics the vertices used to create the new vertex.
- * @param weight
- * Specifics the weights used to create the new vertex.
- * @param outData
- * Reference user the put the coodinates of the new vertex.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #combineData combineData
- */
- public void combine(double[] coords, Object[] data,
- float[] weight, Object[] outData);
-
-
- /**
- * The same as the {@link #combine combine} callback method except
- * that it takes an additional reference argument. This reference is
- * identical to the opaque reference provided when {@link
- * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
- *
- * @param coords
- * Specifics the location of the new vertex.
- * @param data
- * Specifics the vertices used to create the new vertex.
- * @param weight
- * Specifics the weights used to create the new vertex.
- * @param outData
- * Reference user the put the coodinates of the new vertex.
- * @param polygonData
- * Specifics a reference to user-defined data.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #combine combine
- */
- public void combineData(double[] coords, Object[] data,
- float[] weight, Object[] outData,
- Object polygonData);
-
-
- /**
- * The error callback method is called when an error is encountered.
- * The one argument is of type int; it indicates the specific error that
- * occurred and will be set to one of GLU_TESS_MISSING_BEGIN_POLYGON,
- * GLU_TESS_MISSING_END_POLYGON, GLU_TESS_MISSING_BEGIN_CONTOUR,
- * GLU_TESS_MISSING_END_CONTOUR, GLU_TESS_COORD_TOO_LARGE,
- * GLU_TESS_NEED_COMBINE_CALLBACK or GLU_OUT_OF_MEMORY.
- * Character strings describing these errors can be retrieved with the
- * {@link GLU#gluErrorString gluErrorString} call.
- *
- * The GLU library will recover from the first four errors by inserting the
- * missing call(s). GLU_TESS_COORD_TOO_LARGE indicates that some
- * vertex coordinate exceeded the predefined constant
- * GLU_TESS_MAX_COORD in absolute value, and that the value has been
- * clamped. (Coordinate values must be small enough so that two can be
- * multiplied together without overflow.)
- * GLU_TESS_NEED_COMBINE_CALLBACK indicates that the tessellation
- * detected an intersection between two edges in the input data, and the
- * GLU_TESS_COMBINE or GLU_TESS_COMBINE_DATA callback was not
- * provided. No output is generated. GLU_OUT_OF_MEMORY indicates that
- * there is not enough memory so no output is generated.
- *
- * @param errnum
- * Specifics the error number code.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #errorData errorData
- */
- public void error(int errnum);
-
-
- /**
- * The same as the {@link #error error} callback method except that
- * it takes an additional reference argument. This reference is
- * identical to the opaque reference provided when {@link
- * GLU#gluTessBeginPolygon gluTessBeginPolygon} was called.
- *
- * @param errnum
- * Specifics the error number code.
- * @param polygonData
- * Specifics a reference to user-defined data.
- *
- * @see GLU#gluTessCallback gluTessCallback
- * @see #error error
- */
- public void errorData(int errnum, Object polygonData);
-
- //void mesh(jogamp.opengl.tessellator.GLUmesh mesh);
-}
diff --git a/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallbackAdapter.java b/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallbackAdapter.java
deleted file mode 100644
index b9503f12e..000000000
--- a/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallbackAdapter.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
-* Portions Copyright (C) 2003-2006 Sun Microsystems, Inc.
-* All rights reserved.
-*/
-
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 2.0 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** NOTE: The Original Code (as defined below) has been licensed to Sun
-** Microsystems, Inc. ("Sun") under the SGI Free Software License B
-** (Version 1.1), shown above ("SGI License"). Pursuant to Section
-** 3.2(3) of the SGI License, Sun is distributing the Covered Code to
-** you under an alternative license ("Alternative License"). This
-** Alternative License includes all of the provisions of the SGI License
-** except that Section 2.2 and 11 are omitted. Any differences between
-** the Alternative License and the SGI License are offered solely by Sun
-** and not by SGI.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-** Author: Eric Veach, July 1994
-** Java Port: Pepijn Van Eeckhoudt, July 2003
-** Java Port: Nathan Parker Burg, August 2003
-*/
-package com.jogamp.opengl.glu;
-
-/**
- * The GLUtessellatorCallbackAdapter provides a default implementation of
- * {@link GLUtessellatorCallback GLUtessellatorCallback}
- * with empty callback methods. This class can be extended to provide user
- * defined callback methods.
- *
- * @author Eric Veach, July 1994
- * @author Java Port: Pepijn Van Eechhoudt, July 2003
- * @author Java Port: Nathan Parker Burg, August 2003
- */
-
-public class GLUtessellatorCallbackAdapter implements GLUtessellatorCallback {
- @Override
- public void begin(final int type) {}
- @Override
- public void edgeFlag(final boolean boundaryEdge) {}
- @Override
- public void vertex(final Object vertexData) {}
- @Override
- public void end() {}
-// public void mesh(jogamp.opengl.tessellator.GLUmesh mesh) {}
- @Override
- public void error(final int errnum) {}
- @Override
- public void combine(final double[] coords, final Object[] data,
- final float[] weight, final Object[] outData) {}
- @Override
- public void beginData(final int type, final Object polygonData) {}
- @Override
- public void edgeFlagData(final boolean boundaryEdge,
- final Object polygonData) {}
- @Override
- public void vertexData(final Object vertexData, final Object polygonData) {}
- @Override
- public void endData(final Object polygonData) {}
- @Override
- public void errorData(final int errnum, final Object polygonData) {}
- @Override
- public void combineData(final double[] coords, final Object[] data,
- final float[] weight, final Object[] outData,
- final Object polygonData) {}
-}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsConfiguration.java
new file mode 100644
index 000000000..684f1f86a
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsConfiguration.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.nativewindow;
+
+/** A marker interface describing a graphics configuration, visual, or
+ pixel format in a toolkit-independent manner. */
+public interface AbstractGraphicsConfiguration extends VisualIDHolder, Cloneable {
+ public Object clone();
+
+ /**
+ * Return the screen this graphics configuration is valid for
+ */
+ public AbstractGraphicsScreen getScreen();
+
+ /**
+ * Return the capabilities reflecting this graphics configuration,
+ * which may differ from the capabilities used to choose this configuration.
+ *
+ * @return An immutable instance of the Capabilities to avoid mutation by
+ * the user.
+ */
+ public CapabilitiesImmutable getChosenCapabilities();
+
+ /**
+ * Return the capabilities used to choose this graphics configuration.
+ *
+ * These may be used to reconfigure the NativeWindow in case
+ * the device changes in a multiple screen environment.
+ *
+ * @return An immutable instance of the Capabilities to avoid mutation by
+ * the user.
+ */
+ public CapabilitiesImmutable getRequestedCapabilities();
+
+ /**
+ * In case the implementation utilizes a delegation pattern to wrap abstract toolkits,
+ * this method shall return the native {@link AbstractGraphicsConfiguration},
+ * otherwise this instance.
+ * @see NativeSurface#getGraphicsConfiguration()
+ */
+ public AbstractGraphicsConfiguration getNativeGraphicsConfiguration();
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsDevice.java
new file mode 100644
index 000000000..7b630b1ea
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsDevice.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.nativewindow;
+
+import jogamp.nativewindow.Debug;
+
+/** A interface describing a graphics device in a
+ toolkit-independent manner.
+ */
+public interface AbstractGraphicsDevice extends Cloneable {
+ public static final boolean DEBUG = Debug.debug("GraphicsDevice");
+
+ /** Dummy connection value for a default connection where no native support for multiple devices is available */
+ public static String DEFAULT_CONNECTION = "decon";
+
+ /** Dummy connection value for an external connection where no native support for multiple devices is available */
+ public static String EXTERNAL_CONNECTION = "excon";
+
+ /** Default unit id for the 1st device: 0 */
+ public static int DEFAULT_UNIT = 0;
+
+ public Object clone();
+
+ /**
+ * Returns the type of the underlying subsystem, ie
+ * NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..
+ */
+ public String getType();
+
+ /**
+ * Returns the semantic GraphicsDevice connection.
+ * On platforms supporting remote devices, eg via tcp/ip network,
+ * the implementation shall return a unique name for each remote address.
+ * On X11 for example, the connection string should be as the following example.
+ *
+ *
:0.0 for a local connection
+ *
remote.host.net:0.0 for a remote connection
+ *
+ *
+ * To support multiple local device, see {@link #getUnitID()}.
+ */
+ public String getConnection();
+
+ /**
+ * Returns the graphics device unit ID.
+ * The unit ID support multiple graphics device configurations
+ * on a local machine.
+ * To support remote device, see {@link #getConnection()}.
+ * @return
+ */
+ public int getUnitID();
+
+ /**
+ * Returns a unique ID object of this device using {@link #getType() type},
+ * {@link #getConnection() connection} and {@link #getUnitID() unitID} as it's key components.
+ *
+ * The unique ID does not reflect the instance of the device, hence the handle is not included.
+ * The unique ID may be used as a key for semantic device mapping.
+ *
+ *
+ * The returned string object reference is unique using {@link String#intern()}
+ * and hence can be used as a key itself.
+ *
+ */
+ public String getUniqueID();
+
+ /**
+ * Returns the native handle of the underlying native device,
+ * if such thing exist.
+ */
+ public long getHandle();
+
+ /**
+ * Optionally locking the device, utilizing eg {@link com.jogamp.nativewindow.ToolkitLock#lock()}.
+ * The lock implementation must be recursive.
+ */
+ public void lock();
+
+ /**
+ * Optionally unlocking the device, utilizing eg {@link com.jogamp.nativewindow.ToolkitLock#unlock()}.
+ * The lock implementation must be recursive.
+ *
+ * @throws RuntimeException in case the lock is not acquired by this thread.
+ */
+ public void unlock();
+
+ /**
+ * @throws RuntimeException if current thread does not hold the lock
+ */
+ public void validateLocked() throws RuntimeException;
+
+ /**
+ * Optionally [re]opening the device if handle is null.
+ *
+ * The default implementation is a NOP.
+ *
+ *
+ * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice}
+ * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice}
+ * issue the native open operation in case handle is null.
+ *
+ *
+ * @return true if the handle was null and opening was successful, otherwise false.
+ */
+ public boolean open();
+
+ /**
+ * Optionally closing the device if handle is not null.
+ *
+ * The default implementation {@link ToolkitLock#dispose() dispose} it's {@link ToolkitLock} and sets the handle to null.
+ *
+ *
+ * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice}
+ * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice}
+ * issue the native close operation or skip it depending on the {@link #isHandleOwner() handles's ownership}.
+ *
+ *
+ * @return true if the handle was not null and closing was successful, otherwise false.
+ */
+ public boolean close();
+
+ /**
+ * @return true if instance owns the handle to issue {@link #close()}, otherwise false.
+ */
+ public boolean isHandleOwner();
+
+ public void clearHandleOwner();
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsScreen.java
new file mode 100644
index 000000000..7767cf9e4
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/AbstractGraphicsScreen.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.nativewindow;
+
+/** A interface describing a graphics screen in a
+ toolkit-independent manner.
+ */
+
+public interface AbstractGraphicsScreen extends Cloneable {
+ public Object clone();
+
+ /**
+ * Return the device this graphics configuration is valid for
+ */
+ public AbstractGraphicsDevice getDevice();
+
+ /** Returns the screen index this graphics screen is valid for
+ */
+ public int getIndex();
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/Capabilities.java b/src/nativewindow/classes/com/jogamp/nativewindow/Capabilities.java
new file mode 100644
index 000000000..fa172b201
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/Capabilities.java
@@ -0,0 +1,414 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.nativewindow;
+
+/** Specifies a set of capabilities that a window's rendering context
+ must support, such as color depth per channel. It currently
+ contains the minimal number of routines which allow configuration
+ on all supported window systems. */
+public class Capabilities implements CapabilitiesImmutable, Cloneable {
+ protected final static String na_str = "----" ;
+
+ private int redBits = 8;
+ private int greenBits = 8;
+ private int blueBits = 8;
+ private int alphaBits = 0;
+
+ // Support for transparent windows containing OpenGL content
+ private boolean backgroundOpaque = true;
+ private int transparentValueRed = 0;
+ private int transparentValueGreen = 0;
+ private int transparentValueBlue = 0;
+ private int transparentValueAlpha = 0;
+
+ // Switch for on- or offscreen
+ private boolean onscreen = true;
+
+ // offscreen bitmap mode
+ private boolean isBitmap = false;
+
+ /** Creates a Capabilities object. All attributes are in a default
+ state.
+ */
+ public Capabilities() {}
+
+ @Override
+ public Object cloneMutable() {
+ return clone();
+ }
+
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (final CloneNotSupportedException e) {
+ throw new NativeWindowException(e);
+ }
+ }
+
+ /**
+ * Copies all {@link Capabilities} values
+ * from source into this instance.
+ * @return this instance
+ */
+ public Capabilities copyFrom(final CapabilitiesImmutable other) {
+ redBits = other.getRedBits();
+ greenBits = other.getGreenBits();
+ blueBits = other.getBlueBits();
+ alphaBits = other.getAlphaBits();
+ backgroundOpaque = other.isBackgroundOpaque();
+ onscreen = other.isOnscreen();
+ isBitmap = other.isBitmap();
+ transparentValueRed = other.getTransparentRedValue();
+ transparentValueGreen = other.getTransparentGreenValue();
+ transparentValueBlue = other.getTransparentBlueValue();
+ transparentValueAlpha = other.getTransparentAlphaValue();
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ // 31 * x == (x << 5) - x
+ int hash = 31 + this.redBits;
+ hash = ((hash << 5) - hash) + ( this.onscreen ? 1 : 0 );
+ hash = ((hash << 5) - hash) + ( this.isBitmap ? 1 : 0 );
+ hash = ((hash << 5) - hash) + this.greenBits;
+ hash = ((hash << 5) - hash) + this.blueBits;
+ hash = ((hash << 5) - hash) + this.alphaBits;
+ hash = ((hash << 5) - hash) + ( this.backgroundOpaque ? 1 : 0 );
+ hash = ((hash << 5) - hash) + this.transparentValueRed;
+ hash = ((hash << 5) - hash) + this.transparentValueGreen;
+ hash = ((hash << 5) - hash) + this.transparentValueBlue;
+ hash = ((hash << 5) - hash) + this.transparentValueAlpha;
+ return hash;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if(this == obj) { return true; }
+ if(!(obj instanceof CapabilitiesImmutable)) {
+ return false;
+ }
+ final CapabilitiesImmutable other = (CapabilitiesImmutable)obj;
+ boolean res = other.getRedBits()==redBits &&
+ other.getGreenBits()==greenBits &&
+ other.getBlueBits()==blueBits &&
+ other.getAlphaBits()==alphaBits &&
+ other.isBackgroundOpaque()==backgroundOpaque &&
+ other.isOnscreen()==onscreen &&
+ other.isBitmap()==isBitmap;
+ if(res && !backgroundOpaque) {
+ res = other.getTransparentRedValue()==transparentValueRed &&
+ other.getTransparentGreenValue()==transparentValueGreen &&
+ other.getTransparentBlueValue()==transparentValueBlue &&
+ other.getTransparentAlphaValue()==transparentValueAlpha;
+ }
+
+ return res;
+ }
+
+ /**
+ * Comparing RGBA values only
+ **/
+ @Override
+ public int compareTo(final CapabilitiesImmutable caps) {
+ /**
+ if ( ! ( o instanceof CapabilitiesImmutable ) ) {
+ Class> c = (null != o) ? o.getClass() : null ;
+ throw new ClassCastException("Not a CapabilitiesImmutable object, but " + c);
+ }
+ final CapabilitiesImmutable caps = (CapabilitiesImmutable) o; */
+
+ final int rgba = redBits * greenBits * blueBits * ( alphaBits + 1 );
+
+ final int xrgba = caps.getRedBits() * caps.getGreenBits() * caps.getBlueBits() * ( caps.getAlphaBits() + 1 );
+
+ if(rgba > xrgba) {
+ return 1;
+ } else if(rgba < xrgba) {
+ return -1;
+ }
+
+ return 0; // they are equal: RGBA
+ }
+
+ @Override
+ public int getVisualID(final VIDType type) throws NativeWindowException {
+ switch(type) {
+ case INTRINSIC:
+ case NATIVE:
+ return VisualIDHolder.VID_UNDEFINED;
+ default:
+ throw new NativeWindowException("Invalid type <"+type+">");
+ }
+ }
+
+ @Override
+ public final int getRedBits() {
+ return redBits;
+ }
+
+ /** Sets the number of bits requested for the color buffer's red
+ component. On some systems only the color depth, which is the
+ sum of the red, green, and blue bits, is considered. */
+ public void setRedBits(final int redBits) {
+ this.redBits = redBits;
+ }
+
+ @Override
+ public final int getGreenBits() {
+ return greenBits;
+ }
+
+ /** Sets the number of bits requested for the color buffer's green
+ component. On some systems only the color depth, which is the
+ sum of the red, green, and blue bits, is considered. */
+ public void setGreenBits(final int greenBits) {
+ this.greenBits = greenBits;
+ }
+
+ @Override
+ public final int getBlueBits() {
+ return blueBits;
+ }
+
+ /** Sets the number of bits requested for the color buffer's blue
+ component. On some systems only the color depth, which is the
+ sum of the red, green, and blue bits, is considered. */
+ public void setBlueBits(final int blueBits) {
+ this.blueBits = blueBits;
+ }
+
+ @Override
+ public final int getAlphaBits() {
+ return alphaBits;
+ }
+
+ /**
+ * Sets the number of bits requested for the color buffer's alpha
+ * component. On some systems only the color depth, which is the
+ * sum of the red, green, and blue bits, is considered.
+ *
+ * Note: If alpha bits are zero, they are set to one
+ * by {@link #setBackgroundOpaque(boolean)} and it's OpenGL specialization GLCapabilities::setSampleBuffers(boolean).
+ * Ensure to call this method after the above to ensure a zero value.
+ * The above automated settings takes into account, that the user calls this method to request alpha bits,
+ * not to reflect a current state. Nevertheless if this is the case - call it at last.
+ *
+ */
+ public void setAlphaBits(final int alphaBits) {
+ this.alphaBits = alphaBits;
+ }
+
+ /**
+ * Sets whether the surface shall be opaque or translucent.
+ *
+ * Platform implementations may need an alpha component in the surface (eg. Windows),
+ * or expect pre-multiplied alpha values (eg. X11/XRender).
+ * To unify the experience, this method also invokes {@link #setAlphaBits(int) setAlphaBits(1)}
+ * if {@link #getAlphaBits()} == 0.
+ * Please note that in case alpha is required on the platform the
+ * clear color shall have an alpha lower than 1.0 to allow anything shining through.
+ *
+ *
+ * Mind that translucency may cause a performance penalty
+ * due to the composite work required by the window manager.
+ *
+ */
+ public void setBackgroundOpaque(final boolean opaque) {
+ backgroundOpaque = opaque;
+ if(!opaque && getAlphaBits()==0) {
+ setAlphaBits(1);
+ }
+ }
+
+ @Override
+ public final boolean isBackgroundOpaque() {
+ return backgroundOpaque;
+ }
+
+ /**
+ * Sets whether the surface shall be on- or offscreen.
+ *
+ * Defaults to true.
+ *
+ *
+ * If requesting an offscreen surface without further selection of it's mode,
+ * e.g. FBO, Pbuffer or {@link #setBitmap(boolean) bitmap},
+ * the implementation will choose the best available offscreen mode.
+ *
+ * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)}.
+ *
+ *
+ * Defaults to false.
+ *
+ *
+ * Requesting offscreen bitmap mode disables the offscreen auto selection.
+ *
+ */
+ public void setBitmap(final boolean enable) {
+ if(enable) {
+ setOnscreen(false);
+ }
+ isBitmap = enable;
+ }
+
+ @Override
+ public boolean isBitmap() {
+ return isBitmap;
+ }
+
+ @Override
+ public final int getTransparentRedValue() { return transparentValueRed; }
+
+ @Override
+ public final int getTransparentGreenValue() { return transparentValueGreen; }
+
+ @Override
+ public final int getTransparentBlueValue() { return transparentValueBlue; }
+
+ @Override
+ public final int getTransparentAlphaValue() { return transparentValueAlpha; }
+
+ /** Sets the transparent red value for the frame buffer configuration,
+ ranging from 0 to the maximum frame buffer value for red.
+ This value is ignored if {@link #isBackgroundOpaque()} equals true.
+ It defaults to half of the frambuffer value for red.
+ A value of -1 is interpreted as any value. */
+ public void setTransparentRedValue(final int transValueRed) { transparentValueRed=transValueRed; }
+
+ /** Sets the transparent green value for the frame buffer configuration,
+ ranging from 0 to the maximum frame buffer value for green.
+ This value is ignored if {@link #isBackgroundOpaque()} equals true.
+ It defaults to half of the frambuffer value for green.
+ A value of -1 is interpreted as any value. */
+ public void setTransparentGreenValue(final int transValueGreen) { transparentValueGreen=transValueGreen; }
+
+ /** Sets the transparent blue value for the frame buffer configuration,
+ ranging from 0 to the maximum frame buffer value for blue.
+ This value is ignored if {@link #isBackgroundOpaque()} equals true.
+ It defaults to half of the frambuffer value for blue.
+ A value of -1 is interpreted as any value. */
+ public void setTransparentBlueValue(final int transValueBlue) { transparentValueBlue=transValueBlue; }
+
+ /** Sets the transparent alpha value for the frame buffer configuration,
+ ranging from 0 to the maximum frame buffer value for alpha.
+ This value is ignored if {@link #isBackgroundOpaque()} equals true.
+ It defaults to half of the frambuffer value for alpha.
+ A value of -1 is interpreted as any value. */
+ public void setTransparentAlphaValue(final int transValueAlpha) { transparentValueAlpha=transValueAlpha; }
+
+ @Override
+ public StringBuilder toString(final StringBuilder sink) {
+ return toString(sink, true);
+ }
+
+ /** Returns a textual representation of this Capabilities
+ object. */
+ @Override
+ public String toString() {
+ final StringBuilder msg = new StringBuilder();
+ msg.append("Caps[");
+ toString(msg);
+ msg.append("]");
+ return msg.toString();
+ }
+
+ /** Return a textual representation of this object's on/off screen state. Use the given StringBuilder [optional]. */
+ protected StringBuilder onoffScreenToString(StringBuilder sink) {
+ if(null == sink) {
+ sink = new StringBuilder();
+ }
+ if(onscreen) {
+ sink.append("on-scr");
+ } else {
+ sink.append("offscr[");
+ }
+ if(isBitmap) {
+ sink.append("bitmap");
+ } else if(onscreen) {
+ sink.append("."); // no additional off-screen modes besides on-screen
+ } else {
+ sink.append("auto-cfg"); // auto-config off-screen mode
+ }
+ sink.append("]");
+
+ return sink;
+ }
+
+ /** Element separator */
+ protected static final String ESEP = "/";
+ /** Component separator */
+ protected static final String CSEP = ", ";
+
+ protected StringBuilder toString(StringBuilder sink, final boolean withOnOffScreen) {
+ if(null == sink) {
+ sink = new StringBuilder();
+ }
+ sink.append("rgba ").append(redBits).append(ESEP).append(greenBits).append(ESEP).append(blueBits).append(ESEP).append(alphaBits);
+ if(backgroundOpaque) {
+ sink.append(", opaque");
+ } else {
+ sink.append(", trans-rgba 0x").append(toHexString(transparentValueRed)).append(ESEP).append(toHexString(transparentValueGreen)).append(ESEP).append(toHexString(transparentValueBlue)).append(ESEP).append(toHexString(transparentValueAlpha));
+ }
+ if(withOnOffScreen) {
+ sink.append(CSEP);
+ onoffScreenToString(sink);
+ }
+ return sink;
+ }
+
+ protected final String toHexString(final int val) { return Integer.toHexString(val); }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesChooser.java b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesChooser.java
new file mode 100644
index 000000000..c33ff5a3f
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesChooser.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.nativewindow;
+
+import java.util.List;
+
+/** Provides a mechanism by which applications can customize the
+ window type selection for a given {@link Capabilities}.
+ Developers can implement this interface and pass an instance into
+ the method {@link GraphicsConfigurationFactory#chooseGraphicsConfiguration}; the chooser
+ will be called at window creation time. */
+
+public interface CapabilitiesChooser {
+ /** Chooses the index (0..available.length - 1) of the {@link
+ Capabilities} most closely matching the desired one from the
+ list of all supported. Some of the entries in the
+ available array may be null; the chooser must
+ ignore these. The windowSystemRecommendedChoice
+ parameter may be provided to the chooser by the underlying
+ window system; if this index is valid, it is recommended, but
+ not necessarily required, that the chooser select that entry.
+
+
Note: this method is called automatically by the
+ {@link GraphicsConfigurationFactory#chooseGraphicsConfiguration} method
+ when an instance of this class is passed in to it.
+ It should generally not be
+ invoked by users directly, unless it is desired to delegate the
+ choice to some other CapabilitiesChooser object.
+ */
+ public int chooseCapabilities(CapabilitiesImmutable desired,
+ List extends CapabilitiesImmutable> available,
+ int windowSystemRecommendedChoice);
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesImmutable.java
new file mode 100644
index 000000000..780d537b8
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesImmutable.java
@@ -0,0 +1,139 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow;
+
+import com.jogamp.common.type.WriteCloneable;
+
+/**
+ * Specifies an immutable set of capabilities that a window's rendering context
+ * must support, such as color depth per channel.
+ *
+ * @see com.jogamp.nativewindow.Capabilities
+ */
+public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, Comparable {
+
+ /**
+ * Returns the number of bits for the color buffer's red
+ * component. On some systems only the color depth, which is the sum of the
+ * red, green, and blue bits, is considered.
+ */
+ int getRedBits();
+
+ /**
+ * Returns the number of bits for the color buffer's green
+ * component. On some systems only the color depth, which is the sum of the
+ * red, green, and blue bits, is considered.
+ */
+ int getGreenBits();
+
+ /**
+ * Returns the number of bits for the color buffer's blue
+ * component. On some systems only the color depth, which is the sum of the
+ * red, green, and blue bits, is considered.
+ */
+ int getBlueBits();
+
+ /**
+ * Returns the number of bits for the color buffer's alpha
+ * component. On some systems only the color depth, which is the sum of the
+ * red, green, and blue bits, is considered.
+ */
+ int getAlphaBits();
+
+ /**
+ * Returns whether an opaque or translucent surface is requested, supported or chosen.
+ *
+ * Default is true, i.e. opaque.
+ *
+ */
+ boolean isBackgroundOpaque();
+
+ /**
+ * Returns whether an on- or offscreen surface is requested, available or chosen.
+ *
+ * Default is true, i.e. onscreen.
+ *
+ *
+ * Mind that an capabilities intance w/ available semantics
+ * may show onscreen, but also the offscreen modes FBO, Pbuffer or {@link #setBitmap(boolean) bitmap}.
+ * This is valid, since one native configuration maybe used for either functionality.
+ *
+ */
+ boolean isOnscreen();
+
+ /**
+ * Returns whether bitmap offscreen mode is requested, available or chosen.
+ *
+ * Default is false.
+ *
+ *
+ * For chosen capabilities, only the selected offscreen surface is set to true.
+ *
+ */
+ boolean isBitmap();
+
+ /**
+ * Gets the transparent red value for the frame buffer configuration. This
+ * value is undefined if; equals true.
+ */
+ int getTransparentRedValue();
+
+ /**
+ * Gets the transparent green value for the frame buffer configuration. This
+ * value is undefined if; equals true.
+ */
+ int getTransparentGreenValue();
+
+ /**
+ * Gets the transparent blue value for the frame buffer configuration. This
+ * value is undefined if; equals true.
+ */
+ int getTransparentBlueValue();
+
+ /**
+ * Gets the transparent alpha value for the frame buffer configuration. This
+ * value is undefined if; equals true.
+ */
+ int getTransparentAlphaValue();
+
+ /** Equality over the immutable attributes of both objects */
+ @Override
+ boolean equals(Object obj);
+
+ /** hash code over the immutable attributes of both objects */
+ @Override
+ int hashCode();
+
+ /** Return a textual representation of this object. Use the given StringBuilder [optional]. */
+ StringBuilder toString(StringBuilder sink);
+
+ /** Returns a textual representation of this object. */
+ @Override
+ String toString();
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultCapabilitiesChooser.java
new file mode 100644
index 000000000..33c3f8458
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultCapabilitiesChooser.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.nativewindow;
+
+import java.util.List;
+
+import com.jogamp.common.util.PropertyAccess;
+
+import jogamp.nativewindow.Debug;
+
+/**
The default implementation of the {@link
+ CapabilitiesChooser} interface, which provides consistent visual
+ selection behavior across platforms. The precise algorithm is
+ deliberately left loosely specified. Some properties are:
+
+
Attempts to match as closely as possible the given
+ Capabilities, but will select one with fewer capabilities (i.e.,
+ lower color depth) if necessary.
+
+
If there is no exact match, prefers a more-capable visual to
+ a less-capable one.
+
+
If there is more than one exact match, chooses an arbitrary
+ one.
+
+
If a valid windowSystemRecommendedChoice parameter is
+ supplied, chooses that instead of using the cross-platform code.
+
+
+*/
+
+public class DefaultCapabilitiesChooser implements CapabilitiesChooser {
+ private static final boolean DEBUG;
+
+ static {
+ Debug.initSingleton();
+ DEBUG = PropertyAccess.isPropertyDefined("nativewindow.debug.CapabilitiesChooser", true);
+ }
+
+ private final static int NO_SCORE = -9999999;
+ private final static int COLOR_MISMATCH_PENALTY_SCALE = 36;
+
+ @Override
+ public int chooseCapabilities(final CapabilitiesImmutable desired,
+ final List extends CapabilitiesImmutable> available,
+ final int windowSystemRecommendedChoice) {
+ if (DEBUG) {
+ System.err.println("Desired: " + desired);
+ for (int i = 0; i < available.size(); i++) {
+ System.err.println("Available " + i + ": " + available.get(i));
+ }
+ System.err.println("Window system's recommended choice: " + windowSystemRecommendedChoice);
+ }
+ final int availnum = available.size();
+
+ if (windowSystemRecommendedChoice >= 0 &&
+ windowSystemRecommendedChoice < availnum &&
+ null != available.get(windowSystemRecommendedChoice)) {
+ if (DEBUG) {
+ System.err.println("Choosing window system's recommended choice of " + windowSystemRecommendedChoice);
+ System.err.println(available.get(windowSystemRecommendedChoice));
+ }
+ return windowSystemRecommendedChoice;
+ }
+
+ // Create score array
+ final int[] scores = new int[availnum];
+ for (int i = 0; i < availnum; i++) {
+ scores[i] = NO_SCORE;
+ }
+ // Compute score for each
+ for (int i = 0; i < availnum; i++) {
+ final CapabilitiesImmutable cur = available.get(i);
+ if (cur == null) {
+ continue;
+ }
+ if (desired.isOnscreen() && !cur.isOnscreen()) {
+ continue; // requested onscreen, but n/a
+ }
+
+ int score = 0;
+ // Compute difference in color depth
+ score += (COLOR_MISMATCH_PENALTY_SCALE *
+ ((cur.getRedBits() + cur.getGreenBits() + cur.getBlueBits() + cur.getAlphaBits()) -
+ (desired.getRedBits() + desired.getGreenBits() + desired.getBlueBits() + desired.getAlphaBits())));
+ scores[i] = score;
+ }
+
+ if (DEBUG) {
+ System.err.print("Scores: [");
+ for (int i = 0; i < availnum; i++) {
+ if (i > 0) {
+ System.err.print(",");
+ }
+ System.err.print(" " + scores[i]);
+ }
+ System.err.println(" ]");
+ }
+
+ // Ready to select. Choose score closest to 0.
+ int scoreClosestToZero = NO_SCORE;
+ int chosenIndex = -1;
+ for (int i = 0; i < availnum; i++) {
+ final int score = scores[i];
+ if (score == NO_SCORE) {
+ continue;
+ }
+ // Don't substitute a positive score for a smaller negative score
+ if ((scoreClosestToZero == NO_SCORE) ||
+ (Math.abs(score) < Math.abs(scoreClosestToZero) &&
+ ((sign(scoreClosestToZero) < 0) || (sign(score) > 0)))) {
+ scoreClosestToZero = score;
+ chosenIndex = i;
+ }
+ }
+ if (chosenIndex < 0) {
+ throw new NativeWindowException("Unable to select one of the provided Capabilities");
+ }
+ if (DEBUG) {
+ System.err.println("Chosen index: " + chosenIndex);
+ System.err.println("Chosen capabilities:");
+ System.err.println(available.get(chosenIndex));
+ }
+
+ return chosenIndex;
+ }
+
+ private static int sign(final int score) {
+ if (score < 0) {
+ return -1;
+ }
+ return 1;
+ }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsConfiguration.java
new file mode 100644
index 000000000..d20a6824d
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsConfiguration.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.nativewindow;
+
+import jogamp.nativewindow.Debug;
+
+public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphicsConfiguration {
+ protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
+
+ private AbstractGraphicsScreen screen;
+ protected CapabilitiesImmutable capabilitiesChosen;
+ protected CapabilitiesImmutable capabilitiesRequested;
+
+ public DefaultGraphicsConfiguration(final AbstractGraphicsScreen screen,
+ final CapabilitiesImmutable capsChosen, final CapabilitiesImmutable capsRequested) {
+ if(null == screen) {
+ throw new IllegalArgumentException("Null screen");
+ }
+ if(null == capsChosen) {
+ throw new IllegalArgumentException("Null chosen caps");
+ }
+ if(null == capsRequested) {
+ throw new IllegalArgumentException("Null requested caps");
+ }
+ this.screen = screen;
+ this.capabilitiesChosen = capsChosen;
+ this.capabilitiesRequested = capsRequested;
+ }
+
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (final CloneNotSupportedException e) {
+ throw new NativeWindowException(e);
+ }
+ }
+
+ @Override
+ final public AbstractGraphicsScreen getScreen() {
+ return screen;
+ }
+
+ @Override
+ final public CapabilitiesImmutable getChosenCapabilities() {
+ return capabilitiesChosen;
+ }
+
+ @Override
+ final public CapabilitiesImmutable getRequestedCapabilities() {
+ return capabilitiesRequested;
+ }
+
+ @Override
+ public AbstractGraphicsConfiguration getNativeGraphicsConfiguration() {
+ return this;
+ }
+
+ @Override
+ final public int getVisualID(final VIDType type) throws NativeWindowException {
+ return capabilitiesChosen.getVisualID(type);
+ }
+
+ /**
+ * Set the capabilities to a new value.
+ *
+ *
+ * The use case for setting the Capabilities at a later time is
+ * a change or re-validation of capabilities.
+ *
+ * the use case for setting a new screen at a later time is
+ * a change of the graphics device in a multi-screen environment.
+ *
+ */
+ protected void setScreen(final AbstractGraphicsScreen screen) {
+ this.screen = screen;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName()+"[" + screen +
+ ",\n\tchosen " + capabilitiesChosen+
+ ",\n\trequested " + capabilitiesRequested+
+ "]";
+ }
+
+ public static String toHexString(final int val) {
+ return "0x"+Integer.toHexString(val);
+ }
+
+ public static String toHexString(final long val) {
+ return "0x"+Long.toHexString(val);
+ }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsDevice.java
new file mode 100644
index 000000000..070b6bb28
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsDevice.java
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.nativewindow;
+
+import jogamp.nativewindow.NativeWindowFactoryImpl;
+
+public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice {
+ private static final String separator = "_";
+ private final String type;
+ protected final String connection;
+ protected final int unitID;
+ protected final String uniqueID;
+ protected long handle;
+ protected ToolkitLock toolkitLock;
+
+ /**
+ * Create an instance with the system default {@link ToolkitLock},
+ * gathered via {@link NativeWindowFactory#getDefaultToolkitLock(String)}.
+ * @param type
+ */
+ public DefaultGraphicsDevice(final String type, final String connection, final int unitID) {
+ this(type, connection, unitID, 0, NativeWindowFactory.getDefaultToolkitLock(type));
+ }
+
+ /**
+ * Create an instance with the system default {@link ToolkitLock}.
+ * gathered via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}.
+ * @param type
+ * @param handle
+ */
+ public DefaultGraphicsDevice(final String type, final String connection, final int unitID, final long handle) {
+ this(type, connection, unitID, handle, NativeWindowFactory.getDefaultToolkitLock(type, handle));
+ }
+
+ /**
+ * Create an instance with the given {@link ToolkitLock} instance, or null {@link ToolkitLock} if null.
+ * @param type
+ * @param handle
+ * @param locker if null, a non blocking null lock is used.
+ */
+ public DefaultGraphicsDevice(final String type, final String connection, final int unitID, final long handle, final ToolkitLock locker) {
+ this.type = type;
+ this.connection = connection;
+ this.unitID = unitID;
+ this.uniqueID = getUniqueID(type, connection, unitID);
+ this.handle = handle;
+ this.toolkitLock = null != locker ? locker : NativeWindowFactoryImpl.getNullToolkitLock();
+ }
+
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (final CloneNotSupportedException e) {
+ throw new NativeWindowException(e);
+ }
+ }
+
+ @Override
+ public final String getType() {
+ return type;
+ }
+
+ @Override
+ public final String getConnection() {
+ return connection;
+ }
+
+ @Override
+ public final int getUnitID() {
+ return unitID;
+ }
+
+ @Override
+ public final String getUniqueID() {
+ return uniqueID;
+ }
+
+ @Override
+ public final long getHandle() {
+ return handle;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Locking is perfomed via delegation to {@link ToolkitLock#lock()}, {@link ToolkitLock#unlock()}.
+ *
+ * Locking is perfomed via delegation to {@link ToolkitLock#lock()}, {@link ToolkitLock#unlock()}.
+ *
+ *
+ * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)
+ * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
+ */
+ @Override
+ public final void unlock() {
+ toolkitLock.unlock();
+ }
+
+ @Override
+ public boolean open() {
+ return false;
+ }
+
+ @Override
+ public boolean close() {
+ toolkitLock.dispose();
+ if(0 != handle) {
+ handle = 0;
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isHandleOwner() {
+ return false;
+ }
+
+ @Override
+ public void clearHandleOwner() {
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", owner "+isHandleOwner()+", "+toolkitLock+"]";
+ }
+
+ /**
+ * Set the native handle of the underlying native device
+ * and return the previous one.
+ */
+ protected final long setHandle(final long newHandle) {
+ final long oldHandle = handle;
+ handle = newHandle;
+ return oldHandle;
+ }
+
+ protected Object getHandleOwnership() {
+ return null;
+ }
+ protected Object setHandleOwnership(final Object newOwnership) {
+ return null;
+ }
+
+ public static final void swapDeviceHandleAndOwnership(final DefaultGraphicsDevice aDevice1, final DefaultGraphicsDevice aDevice2) {
+ aDevice1.lock();
+ try {
+ aDevice2.lock();
+ try {
+ final long aDevice1Handle = aDevice1.getHandle();
+ final long aDevice2Handle = aDevice2.setHandle(aDevice1Handle);
+ aDevice1.setHandle(aDevice2Handle);
+ final Object aOwnership1 = aDevice1.getHandleOwnership();
+ final Object aOwnership2 = aDevice2.setHandleOwnership(aOwnership1);
+ aDevice1.setHandleOwnership(aOwnership2);
+ } finally {
+ aDevice2.unlock();
+ }
+ } finally {
+ aDevice1.unlock();
+ }
+ }
+
+ /**
+ * Set the internal ToolkitLock, which is used within the
+ * {@link #lock()} and {@link #unlock()} implementation.
+ *
+ *
+ * The current ToolkitLock is being locked/unlocked while swapping the reference,
+ * ensuring no concurrent access can occur during the swap.
+ *
+ *
+ * @param locker the ToolkitLock, if null, {@link jogamp.nativewindow.NullToolkitLock} is being used
+ * @return the previous ToolkitLock instance
+ */
+ protected ToolkitLock setToolkitLock(final ToolkitLock locker) {
+ final ToolkitLock _toolkitLock = toolkitLock;
+ _toolkitLock.lock();
+ try {
+ toolkitLock = ( null == locker ) ? NativeWindowFactoryImpl.getNullToolkitLock() : locker ;
+ } finally {
+ _toolkitLock.unlock();
+ }
+ return _toolkitLock;
+ }
+
+ /**
+ * @return the used ToolkitLock
+ *
+ * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)
+ * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
+ */
+ public final ToolkitLock getToolkitLock() {
+ return toolkitLock;
+ }
+
+ /**
+ * Returns a unique String object using {@link String#intern()} for the given arguments,
+ * which object reference itself can be used as a key.
+ */
+ private static String getUniqueID(final String type, final String connection, final int unitID) {
+ return (type + separator + connection + separator + unitID).intern();
+ }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsScreen.java
new file mode 100644
index 000000000..63c79af55
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/DefaultGraphicsScreen.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.nativewindow;
+
+public class DefaultGraphicsScreen implements Cloneable, AbstractGraphicsScreen {
+ private final AbstractGraphicsDevice device;
+ private final int idx;
+
+ public DefaultGraphicsScreen(final AbstractGraphicsDevice device, final int idx) {
+ this.device = device;
+ this.idx = idx;
+ }
+
+ public static AbstractGraphicsScreen createDefault(final String type) {
+ return new DefaultGraphicsScreen(new DefaultGraphicsDevice(type, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT), 0);
+ }
+
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (final CloneNotSupportedException e) {
+ throw new NativeWindowException(e);
+ }
+ }
+
+ @Override
+ public AbstractGraphicsDevice getDevice() {
+ return device;
+ }
+
+ @Override
+ public int getIndex() {
+ return idx;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName()+"["+device+", idx "+idx+"]";
+ }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/GraphicsConfigurationFactory.java
new file mode 100644
index 000000000..929af054e
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/GraphicsConfigurationFactory.java
@@ -0,0 +1,435 @@
+/*
+ * Copyright (c) 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.nativewindow;
+
+import com.jogamp.common.ExceptionUtils;
+import com.jogamp.common.util.ReflectionUtil;
+
+import jogamp.nativewindow.Debug;
+import jogamp.nativewindow.DefaultGraphicsConfigurationFactoryImpl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Provides the mechanism by which the graphics configuration for a
+ * window can be chosen before the window is created. The graphics
+ * configuration decides parameters related to hardware accelerated rendering such
+ * as the OpenGL pixel format.
+ * On some window systems (EGL/OpenKODE and X11 in particular) it is necessary to
+ * choose the graphics configuration early at window creation time.
+ * Note that the selection of the graphics configuration is an algorithm which does not have
+ * strong dependencies on the particular Java window toolkit in use
+ * (e.g., AWT) and therefore it is strongly desirable to factor this
+ * functionality out of the core {@link NativeWindowFactory} so that
+ * new window toolkits can replace just the {@link
+ * NativeWindowFactory} and reuse the graphics configuration selection
+ * algorithm provided by, for example, an OpenGL binding.
+ */
+
+public abstract class GraphicsConfigurationFactory {
+ protected static final boolean DEBUG;
+
+ private static class DeviceCapsType {
+ public final Class> deviceType;
+ public final Class> capsType;
+ private final int hash32;
+
+ public DeviceCapsType(final Class> deviceType, final Class> capsType) {
+ this.deviceType = deviceType;
+ this.capsType = capsType;
+
+ // 31 * x == (x << 5) - x
+ int hash32 = 31 + deviceType.hashCode();
+ hash32 = ((hash32 << 5) - hash32) + capsType.hashCode();
+ this.hash32 = hash32;
+ }
+
+ @Override
+ public final int hashCode() {
+ return hash32;
+ }
+
+ @Override
+ public final boolean equals(final Object obj) {
+ if(this == obj) { return true; }
+ if (obj instanceof DeviceCapsType) {
+ final DeviceCapsType dct = (DeviceCapsType)obj;
+ return deviceType == dct.deviceType && capsType == dct.capsType;
+ }
+ return false;
+ }
+
+ @Override
+ public final String toString() {
+ return "DeviceCapsType["+deviceType.getName()+", "+capsType.getName()+"]";
+ }
+
+ }
+
+ private static final Map registeredFactories;
+ private static final DeviceCapsType defaultDeviceCapsType;
+ static boolean initialized = false;
+
+ static {
+ DEBUG = Debug.debug("GraphicsConfiguration");
+ if(DEBUG) {
+ System.err.println(Thread.currentThread().getName()+" - Info: GraphicsConfigurationFactory.");
+ // Thread.dumpStack();
+ }
+ registeredFactories = Collections.synchronizedMap(new HashMap());
+ defaultDeviceCapsType = new DeviceCapsType(AbstractGraphicsDevice.class, CapabilitiesImmutable.class);
+ }
+
+ public static synchronized void initSingleton() {
+ if(!initialized) {
+ initialized = true;
+
+ if(DEBUG) {
+ System.err.println(Thread.currentThread().getName()+" - GraphicsConfigurationFactory.initSingleton()");
+ }
+
+ // Register the default no-op factory for arbitrary
+ // AbstractGraphicsDevice implementations, including
+ // AWTGraphicsDevice instances -- the OpenGL binding will take
+ // care of handling AWTGraphicsDevices on X11 platforms (as
+ // well as X11GraphicsDevices in non-AWT situations)
+ registerFactory(defaultDeviceCapsType.deviceType, defaultDeviceCapsType.capsType, new DefaultGraphicsConfigurationFactoryImpl());
+
+ if (NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true)) {
+ try {
+ ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.X11GraphicsConfigurationFactory",
+ "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader());
+ } catch (final Exception e) {
+ throw new RuntimeException(e);
+ }
+ if(NativeWindowFactory.isAWTAvailable()) {
+ try {
+ ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.awt.X11AWTGraphicsConfigurationFactory",
+ "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader());
+ } catch (final Exception e) { /* n/a */ }
+ }
+ }
+ }
+ }
+
+ public static synchronized void shutdown() {
+ if(initialized) {
+ initialized = false;
+ if(DEBUG) {
+ System.err.println(Thread.currentThread().getName()+" - GraphicsConfigurationFactory.shutdown()");
+ }
+ registeredFactories.clear();
+ }
+ }
+
+ protected static String getThreadName() {
+ return Thread.currentThread().getName();
+ }
+
+ protected static String toHexString(final int val) {
+ return "0x" + Integer.toHexString(val);
+ }
+
+ protected static String toHexString(final long val) {
+ return "0x" + Long.toHexString(val);
+ }
+
+ /** Creates a new NativeWindowFactory instance. End users do not
+ need to call this method. */
+ protected GraphicsConfigurationFactory() {
+ }
+
+ /**
+ * Returns the graphics configuration factory for use with the
+ * given device and capability.
+ *
+ * @see #getFactory(Class, Class)
+ */
+ public static GraphicsConfigurationFactory getFactory(final AbstractGraphicsDevice device, final CapabilitiesImmutable caps) {
+ if (device == null) {
+ throw new IllegalArgumentException("null device");
+ }
+ if (caps == null) {
+ throw new IllegalArgumentException("null caps");
+ }
+ return getFactory(device.getClass(), caps.getClass());
+ }
+
+ /**
+ * Returns the graphics configuration factory for use with the
+ * given device and capability class.
+ *
+ * Note: Registered device types maybe classes or interfaces, where capabilities types are interfaces only.
+ *
+ *
+ *
+ * Pseudo code for finding a suitable factory is:
+ *
+ For-All devT := getTopDownDeviceTypes(deviceType)
+ For-All capsT := getTopDownCapabilitiesTypes(capabilitiesType)
+ f = factory.get(devT, capsT);
+ if(f) { return f; }
+ end
+ end
+ *
+ *
+ *
+ * @param deviceType the minimum capabilities class type accepted, must implement or extend {@link AbstractGraphicsDevice}
+ * @param capabilitiesType the minimum capabilities class type accepted, must implement or extend {@link CapabilitiesImmutable}
+ *
+ * @throws IllegalArgumentException if the deviceType does not implement {@link AbstractGraphicsDevice} or
+ * capabilitiesType does not implement {@link CapabilitiesImmutable}
+ */
+ public static GraphicsConfigurationFactory getFactory(final Class> deviceType, final Class> capabilitiesType)
+ throws IllegalArgumentException, NativeWindowException
+ {
+ if (!(defaultDeviceCapsType.deviceType.isAssignableFrom(deviceType))) {
+ throw new IllegalArgumentException("Given class must implement AbstractGraphicsDevice");
+ }
+ if (!(defaultDeviceCapsType.capsType.isAssignableFrom(capabilitiesType))) {
+ throw new IllegalArgumentException("Given capabilities class must implement CapabilitiesImmutable");
+ }
+ if(DEBUG) {
+ ExceptionUtils.dumpStack(System.err);
+ System.err.println("GraphicsConfigurationFactory.getFactory: "+deviceType.getName()+", "+capabilitiesType.getName());
+ dumpFactories();
+ }
+
+ final List> deviceTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.deviceType, deviceType, false);
+ if(DEBUG) {
+ System.err.println("GraphicsConfigurationFactory.getFactory() deviceTypes: " + deviceTypes);
+ }
+ final List> capabilitiesTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.capsType, capabilitiesType, true);
+ if(DEBUG) {
+ System.err.println("GraphicsConfigurationFactory.getFactory() capabilitiesTypes: " + capabilitiesTypes);
+ }
+ for(int j=0; j interfaceDevice = deviceTypes.get(j);
+ for(int i=0; i interfaceCaps = capabilitiesTypes.get(i);
+ final DeviceCapsType dct = new DeviceCapsType(interfaceDevice, interfaceCaps);
+ final GraphicsConfigurationFactory factory = registeredFactories.get(dct);
+ if (factory != null) {
+ if(DEBUG) {
+ System.err.println("GraphicsConfigurationFactory.getFactory() found "+dct+" -> "+factory);
+ }
+ return factory;
+ }
+ }
+ }
+ // Return the default
+ final GraphicsConfigurationFactory factory = registeredFactories.get(defaultDeviceCapsType);
+ if(DEBUG) {
+ System.err.println("GraphicsConfigurationFactory.getFactory() DEFAULT "+defaultDeviceCapsType+" -> "+factory);
+ }
+ return factory;
+ }
+ private static ArrayList> getAllAssignableClassesFrom(final Class> superClassOrInterface, final Class> fromClass, final boolean interfacesOnly) {
+ // Using a todo list avoiding a recursive loop!
+ final ArrayList> inspectClasses = new ArrayList>();
+ final ArrayList> resolvedInterfaces = new ArrayList>();
+ inspectClasses.add(fromClass);
+ for(int j=0; j clazz = inspectClasses.get(j);
+ getAllAssignableClassesFrom(superClassOrInterface, clazz, interfacesOnly, resolvedInterfaces, inspectClasses);
+ }
+ return resolvedInterfaces;
+ }
+ private static void getAllAssignableClassesFrom(final Class> superClassOrInterface, final Class> fromClass, final boolean interfacesOnly, final List> resolvedInterfaces, final List> inspectClasses) {
+ final ArrayList> types = new ArrayList>();
+ if( superClassOrInterface.isAssignableFrom(fromClass) && !resolvedInterfaces.contains(fromClass)) {
+ if( !interfacesOnly || fromClass.isInterface() ) {
+ types.add(fromClass);
+ }
+ }
+ types.addAll(Arrays.asList(fromClass.getInterfaces()));
+
+ for(int i=0; i iface = types.get(i);
+ if( superClassOrInterface.isAssignableFrom(iface) && !resolvedInterfaces.contains(iface) ) {
+ resolvedInterfaces.add(iface);
+ if( !superClassOrInterface.equals(iface) && !inspectClasses.contains(iface) ) {
+ inspectClasses.add(iface); // safe add to todo list, avoiding a recursive nature
+ }
+ }
+ }
+ final Class> parentClass = fromClass.getSuperclass();
+ if( null != parentClass && superClassOrInterface.isAssignableFrom(parentClass) && !inspectClasses.contains(parentClass) ) {
+ inspectClasses.add(parentClass); // safe add to todo list, avoiding a recursive nature
+ }
+ }
+ private static void dumpFactories() {
+ final Set dcts = registeredFactories.keySet();
+ int i=0;
+ for(final Iterator iter = dcts.iterator(); iter.hasNext(); ) {
+ final DeviceCapsType dct = iter.next();
+ System.err.println("Factory #"+i+": "+dct+" -> "+registeredFactories.get(dct));
+ i++;
+ }
+ }
+
+ /**
+ * Registers a GraphicsConfigurationFactory handling
+ * the given graphics device and capability class.
+ *
+ * This does not need to be called by end users, only implementors of new
+ * GraphicsConfigurationFactory subclasses.
+ *
+ *
+ *
+ * Note: Registered device types maybe classes or interfaces, where capabilities types are interfaces only.
+ *
+ *
+ *
See {@link #getFactory(Class, Class)} for a description of the find algorithm.
+ *
+ * @param deviceType the minimum capabilities class type accepted, must implement or extend interface {@link AbstractGraphicsDevice}
+ * @param capabilitiesType the minimum capabilities class type accepted, must extend interface {@link CapabilitiesImmutable}
+ * @return the previous registered factory, or null if none
+ * @throws IllegalArgumentException if the given class does not implement AbstractGraphicsDevice
+ */
+ protected static GraphicsConfigurationFactory registerFactory(final Class> abstractGraphicsDeviceImplementor, final Class> capabilitiesType, final GraphicsConfigurationFactory factory)
+ throws IllegalArgumentException
+ {
+ if (!(defaultDeviceCapsType.deviceType.isAssignableFrom(abstractGraphicsDeviceImplementor))) {
+ throw new IllegalArgumentException("Given device class must implement AbstractGraphicsDevice");
+ }
+ if (!(defaultDeviceCapsType.capsType.isAssignableFrom(capabilitiesType))) {
+ throw new IllegalArgumentException("Given capabilities class must implement CapabilitiesImmutable");
+ }
+ final DeviceCapsType dct = new DeviceCapsType(abstractGraphicsDeviceImplementor, capabilitiesType);
+ final GraphicsConfigurationFactory prevFactory;
+ if(null == factory) {
+ prevFactory = registeredFactories.remove(dct);
+ if(DEBUG) {
+ System.err.println("GraphicsConfigurationFactory.registerFactory() remove "+dct+
+ ", deleting: "+prevFactory);
+ }
+ } else {
+ prevFactory = registeredFactories.put(dct, factory);
+ if(DEBUG) {
+ System.err.println("GraphicsConfigurationFactory.registerFactory() put "+dct+" -> "+factory+
+ ", overridding: "+prevFactory);
+ }
+ }
+ return prevFactory;
+ }
+
+ /**
+ *
Selects a graphics configuration on the specified graphics
+ * device compatible with the supplied {@link Capabilities}. Some
+ * platforms (e.g.: X11, EGL, KD) require the graphics configuration
+ * to be specified when the native window is created.
+ * These architectures have seperated their device, screen, window and drawable
+ * context and hence are capable of quering the capabilities for each screen.
+ * A fully established window is not required.
+ *
+ *
Other platforms (e.g. Windows, MacOSX) don't offer the mentioned seperation
+ * and hence need a fully established window and it's drawable.
+ * Here the validation of the capabilities is performed later.
+ * In this case, the AbstractGraphicsConfiguration implementation
+ * must allow an overwrite of the Capabilites, for example
+ * {@link DefaultGraphicsConfiguration#setChosenCapabilities DefaultGraphicsConfiguration.setChosenCapabilities(..)}.
+ *
+ *
+ *
+ * This method is mainly intended to be both used and implemented by the
+ * OpenGL binding.
+ *
+ *
The concrete data type of the passed graphics device and
+ * returned graphics configuration must be specified in the
+ * documentation binding this particular API to the underlying
+ * window toolkit. The Reference Implementation accepts {@link
+ * com.jogamp.nativewindow.awt.AWTGraphicsDevice AWTGraphicsDevice} objects and returns {@link
+ * com.jogamp.nativewindow.awt.AWTGraphicsConfiguration AWTGraphicsConfiguration} objects. On
+ * X11 platforms where the AWT is not in use, it also accepts
+ * {@link com.jogamp.nativewindow.x11.X11GraphicsDevice
+ * X11GraphicsDevice} objects and returns {@link
+ * com.jogamp.nativewindow.x11.X11GraphicsConfiguration
+ * X11GraphicsConfiguration} objects.
+ *
+ * @param capsChosen the intermediate chosen capabilities to be refined by this implementation, may be equal to capsRequested
+ * @param capsRequested the original requested capabilities
+ * @param chooser the choosing implementation
+ * @param screen the referring Screen
+ * @param nativeVisualID if not {@link VisualIDHolder#VID_UNDEFINED} it reflects a pre-chosen visualID of the native platform's windowing system.
+ * @return the complete GraphicsConfiguration
+ *
+ * @throws IllegalArgumentException if the data type of the passed
+ * AbstractGraphicsDevice is not supported by this
+ * NativeWindowFactory.
+ * @throws NativeWindowException if any window system-specific errors caused
+ * the selection of the graphics configuration to fail.
+ *
+ * @see com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
+ * @see com.jogamp.nativewindow.DefaultGraphicsConfiguration#setChosenCapabilities(Capabilities caps)
+ */
+ public final AbstractGraphicsConfiguration
+ chooseGraphicsConfiguration(final CapabilitiesImmutable capsChosen, final CapabilitiesImmutable capsRequested,
+ final CapabilitiesChooser chooser,
+ final AbstractGraphicsScreen screen, final int nativeVisualID)
+ throws IllegalArgumentException, NativeWindowException {
+ if(null==capsChosen) {
+ throw new NativeWindowException("Chosen Capabilities are null");
+ }
+ if(null==capsRequested) {
+ throw new NativeWindowException("Requested Capabilities are null");
+ }
+ if(null==screen) {
+ throw new NativeWindowException("Screen is null");
+ }
+ final AbstractGraphicsDevice device = screen.getDevice();
+ if(null==device) {
+ throw new NativeWindowException("Screen's Device is null");
+ }
+ device.lock();
+ try {
+ return chooseGraphicsConfigurationImpl(capsChosen, capsRequested, chooser, screen, nativeVisualID);
+ } finally {
+ device.unlock();
+ }
+ }
+
+ protected abstract AbstractGraphicsConfiguration
+ chooseGraphicsConfigurationImpl(CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
+ CapabilitiesChooser chooser, AbstractGraphicsScreen screen, int nativeVisualID)
+ throws IllegalArgumentException, NativeWindowException;
+
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/MutableSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/MutableSurface.java
new file mode 100644
index 000000000..7686f270b
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/MutableSurface.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow;
+
+/**
+ * Provides a {@link NativeSurface} with a mutable surfaceHandle
+ * via {@link #setSurfaceHandle(long)}.
+ *
+ * @see NativeSurface
+ */
+public interface MutableSurface extends NativeSurface {
+
+ /**
+ * Sets the surface handle which is created outside of this implementation.
+ */
+ public void setSurfaceHandle(long surfaceHandle);
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java
new file mode 100644
index 000000000..ce0699c56
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurface.java
@@ -0,0 +1,238 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow;
+
+/**
+ * Provides low-level information required for
+ * hardware-accelerated rendering using a surface in a platform-independent manner.
+ *
+ * All values of this interface are represented in pixel units, if not stated otherwise.
+ * See {@link NativeWindow}.
+ *
+ *
+ * A NativeSurface created for a particular on- or offscreen component is
+ * expected to have the same lifetime as that component. As long as
+ * the component is alive and realized/visible, NativeSurface must be able
+ * provide information such as the surface handle while it is locked.
+ *
+ */
+public interface NativeSurface extends SurfaceUpdatedListener {
+ /** Unlocked state, {@value}. */
+ public static final int LOCK_SURFACE_UNLOCKED = 0;
+
+ /** Returned by {@link #lockSurface()} if the surface is not ready to be locked, {@value}. */
+ public static final int LOCK_SURFACE_NOT_READY = 1;
+
+ /** Returned by {@link #lockSurface()} if the surface is locked, but has changed, {@value}. */
+ public static final int LOCK_SURFACE_CHANGED = 2;
+
+ /** Returned by {@link #lockSurface()} if the surface is locked, and is unchanged, {@value}. */
+ public static final int LOCK_SUCCESS = 3;
+
+ /**
+ * Lock the surface of this native window.
+ *
+ * The surface handle shall be valid after a successfull call,
+ * ie return a value other than {@link #LOCK_SURFACE_UNLOCKED} and {@link #LOCK_SURFACE_NOT_READY},
+ * which is
+ *
+ * boolean ok = LOCK_SURFACE_NOT_READY < lockSurface();
+ *
+ *
+ *
+ * The caller may need to take care of the result {@link #LOCK_SURFACE_CHANGED},
+ * where the surface handle is valid but has changed.
+ *
+ *
+ * This call is blocking until the surface has been locked
+ * or a timeout is reached. The latter will throw a runtime exception.
+ *
+ *
+ * This call allows recursion from the same thread.
+ *
+ *
+ * The implementation may want to aquire the
+ * application level {@link com.jogamp.common.util.locks.RecursiveLock}
+ * first before proceeding with a native surface lock.
+ *
+ *
+ * The implementation shall also invoke {@link AbstractGraphicsDevice#lock()}
+ * for the initial lock (recursive count zero).
+ *
+ *
+ * @return {@link #LOCK_SUCCESS}, {@link #LOCK_SURFACE_CHANGED} or {@link #LOCK_SURFACE_NOT_READY}.
+ *
+ * @throws RuntimeException after timeout when waiting for the surface lock
+ * @throws NativeWindowException if native locking failed, maybe platform related
+ *
+ * @see com.jogamp.common.util.locks.RecursiveLock
+ */
+ public int lockSurface() throws NativeWindowException, RuntimeException;
+
+ /**
+ * Unlock the surface of this native window
+ *
+ * Shall not modify the surface handle, see {@link #lockSurface()}
+ *
+ * The implementation shall also invoke {@link AbstractGraphicsDevice#unlock()}
+ * for the final unlock (recursive count zero).
+ *
+ * The implementation shall be fail safe, i.e. tolerant in case the native resources
+ * are already released / unlocked. In this case the implementation shall simply ignore the call.
+ *
+ * @see #lockSurface
+ * @see com.jogamp.common.util.locks.RecursiveLock
+ */
+ public void unlockSurface();
+
+ /**
+ * Query if surface is locked by another thread, i.e. not the current one.
+ *
+ * Convenient shortcut for:
+ *
+ * final Thread o = getSurfaceLockOwner();
+ * if( null != o && Thread.currentThread() != o ) { .. }
+ *
+ */
+ public boolean isSurfaceLockedByOtherThread();
+
+ /**
+ * Return the locking owner's Thread, or null if not locked.
+ */
+ public Thread getSurfaceLockOwner();
+
+ /**
+ * Provide a mechanism to utilize custom (pre-) swap surface
+ * code. This method is called before the render toolkit (e.g. JOGL)
+ * swaps the buffer/surface if double buffering is enabled.
+ *
+ * The implementation may itself apply the swapping,
+ * in which case true shall be returned.
+ *
+ *
+ * @return true if this method completed swapping the surface,
+ * otherwise false, in which case eg the GLDrawable
+ * implementation has to swap the code.
+ */
+ public boolean surfaceSwap();
+
+ /** Appends the given {@link SurfaceUpdatedListener} to the end of the list. */
+ public void addSurfaceUpdatedListener(SurfaceUpdatedListener l);
+
+ /**
+ * Inserts the given {@link SurfaceUpdatedListener} at the
+ * specified position in the list.
+ *
+ * @param index Position where the listener will be inserted.
+ * Should be within (0 <= index && index <= size()).
+ * An index value of -1 is interpreted as the end of the list, size().
+ * @param l The listener object to be inserted
+ * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index <= size()), or -1
+ */
+ public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException;
+
+ /** Remove the specified {@link SurfaceUpdatedListener} from the list. */
+ public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l);
+
+ /**
+ * Returns the handle to the surface for this NativeSurface.
+ *
+ * The surface handle should be set/update by {@link #lockSurface()},
+ * where {@link #unlockSurface()} is not allowed to modify it.
+ * After {@link #unlockSurface()} it is no more guaranteed
+ * that the surface handle is still valid.
+ *
+ * The surface handle shall reflect the platform one
+ * for all drawable surface operations, e.g. opengl, swap-buffer.
+ *
+ * On X11 this returns an entity of type Window,
+ * since there is no differentiation of surface and window there.
+ * On Microsoft Windows this returns an entity of type HDC.
+ */
+ public long getSurfaceHandle();
+
+ /**
+ * Returns the width of the client area excluding insets (window decorations) in pixel units.
+ * @return width of the client area in pixel units
+ * @see NativeWindow#getWidth()
+ * @see #convertToWindowUnits(int[])
+ */
+ public int getSurfaceWidth();
+
+ /**
+ * Returns the height of the client area excluding insets (window decorations) in pixel units.
+ * @return height of the client area in pixel units
+ * @see NativeWindow#getHeight()
+ * @see #convertToWindowUnits(int[])
+ */
+ public int getSurfaceHeight();
+
+ /**
+ * Converts the given pixel units into window units in place.
+ * @param pixelUnitsAndResult int[2] storage holding the pixel units for the x- and y-coord to convert
+ * and the resulting values.
+ * @return result int[2] storage pixelUnitsAndResult for chaining holding the converted values
+ * @see ScalableSurface
+ */
+ public int[] convertToWindowUnits(final int[] pixelUnitsAndResult);
+
+ /**
+ * Converts the given window units into pixel units in place.
+ * @param windowUnitsAndResult int[2] storage holding the window units for the x- and y-coord to convert
+ * and the resulting values.
+ * @return result int[2] storage windowUnitsAndResult for chaining holding the converted values
+ * @see ScalableSurface
+ */
+ public int[] convertToPixelUnits(final int[] windowUnitsAndResult);
+
+ /**
+ * Returns the graphics configuration corresponding to this window.
+ *
+ * In case the implementation utilizes a delegation pattern to wrap abstract toolkits,
+ * this method shall return the native {@link AbstractGraphicsConfiguration} via {@link AbstractGraphicsConfiguration#getNativeGraphicsConfiguration()}.
+ *
+ * @see AbstractGraphicsConfiguration#getNativeGraphicsConfiguration()
+ * @see com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
+ */
+ public AbstractGraphicsConfiguration getGraphicsConfiguration();
+
+ /**
+ * Convenience: Get display handle from
+ * AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice
+ */
+ public long getDisplayHandle();
+
+ /**
+ * Convenience: Get display handle from
+ * AbstractGraphicsConfiguration . AbstractGraphicsScreen
+ */
+ public int getScreenIndex();
+
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurfaceHolder.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurfaceHolder.java
new file mode 100644
index 000000000..667f5d8af
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeSurfaceHolder.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow;
+
+/**
+ * Accessor interface for implementing classes with ownership of a {@link NativeSurface}
+ * via an is-a or has-a relation.
+ */
+public interface NativeSurfaceHolder {
+ /**
+ * Returns the associated {@link NativeSurface} of this {@link NativeSurfaceHolder}.
+ */
+ public NativeSurface getNativeSurface();
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindow.java
new file mode 100644
index 000000000..1a2d212da
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindow.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.nativewindow;
+
+import com.jogamp.nativewindow.util.InsetsImmutable;
+import com.jogamp.nativewindow.util.Point;
+
+/**
+ * Extend the {@link NativeSurface} interface with windowing
+ * information such as {@link #getWindowHandle() window-handle},
+ * {@link #getWidth() window-size} and {@link #getX() window-position}.
+ *
+ * All values of this interface are represented in window units, if not stated otherwise.
+ * See {@link NativeSurface}.
+ *
Abstract screen space has it's origin in the top-left corner, and may not be at 0/0.
+ *
Window origin is in it's top-left corner, see {@link #getX()} and {@link #getY()}.
+ *
Window client-area excludes {@link #getInsets() insets}, i.e. window decoration.
+ *
Window origin is relative to it's parent window if exist, or the screen position (top-level).
+ *
+ *
+ *
+ * A window toolkit such as the AWT may either implement this interface
+ * directly with one of its components, or provide and register an
+ * implementation of {@link NativeWindowFactory NativeWindowFactory}
+ * which can create NativeWindow objects for its components.
+ *
+ * Returns this instance, which is-a {@link NativeSurface}.
+ *
+ */
+ @Override
+ public NativeSurface getNativeSurface();
+
+ /**
+ * Destroys this window incl. releasing all related resources.
+ */
+ public void destroy();
+
+ /**
+ * @return The parent NativeWindow, or null if this NativeWindow is top level.
+ */
+ public NativeWindow getParent();
+
+ /**
+ * Returns the window handle for this NativeWindow.
+ *
+ * The window handle shall reflect the platform one
+ * for all window related operations, e.g. open, close, resize.
+ *
+ * On X11 this returns an entity of type Window.
+ * On Microsoft Windows this returns an entity of type HWND.
+ */
+ public long getWindowHandle();
+
+ /**
+ * Returns the insets defined as the width and height of the window decoration
+ * on the left, right, top and bottom in window units.
+ *
+ * Insets are zero if the window is undecorated, including child windows.
+ *
+ *
+ *
+ * Insets are available only after the native window has been created,
+ * ie. the native window has been made visible.
+ *
+ * The top-level window area's top-left corner is located at
+ *
+ *
+ * @return insets
+ */
+ public InsetsImmutable getInsets();
+
+ /** Returns the current x position of this window, relative to it's parent. */
+
+ /**
+ * Returns the x position of the top-left corner
+ * of the client area relative to it's parent in window units.
+ *
+ * If no parent exist (top-level window), this coordinate equals the screen coordinate.
+ *
+ *
+ * Since the position reflects the client area, it does not include the insets.
+ *
+ * @see #getInsets()
+ * @see #getLocationOnScreen(Point)
+ */
+ public int getX();
+
+ /**
+ * Returns the current y position of the top-left corner
+ * of the client area relative to it's parent in window units.
+ *
+ * If no parent exist (top-level window), this coordinate equals the screen coordinate.
+ *
+ *
+ * Since the position reflects the client area, it does not include the insets.
+ *
+ * @see #getInsets()
+ * @see #getLocationOnScreen(Point)
+ */
+ public int getY();
+
+ /**
+ * Returns the width of the client area excluding insets (window decorations) in window units.
+ * @return width of the client area in window units
+ * @see NativeSurface#getSurfaceWidth()
+ */
+ public int getWidth();
+
+ /**
+ * Returns the height of the client area excluding insets (window decorations) in window units.
+ * @return height of the client area in window units
+ * @see NativeSurface#getSurfaceHeight()
+ */
+ public int getHeight();
+
+ /**
+ * Returns the window's top-left client-area position in the screen.
+ *
+ * If {@link Point} is not null, it is translated about the resulting screen position
+ * and returned.
+ *
+ * Since the position reflects the client area, it does not include the insets.
+ *
+ * @param point Optional {@link Point} storage.
+ * If not null, null, it is translated about the resulting screen position
+ * and returned.
+ * @see #getX()
+ * @see #getY()
+ * @see #getInsets()
+ */
+ public Point getLocationOnScreen(Point point);
+
+ /** Returns true if this native window owns the focus, otherwise false. */
+ boolean hasFocus();
+
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowException.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowException.java
new file mode 100644
index 000000000..8f841e7ea
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowException.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.jogamp.nativewindow;
+
+/** A generic exception for OpenGL errors used throughout the binding
+ as a substitute for {@link RuntimeException}. */
+
+public class NativeWindowException extends RuntimeException {
+ /** Constructs a NativeWindowException object. */
+ public NativeWindowException() {
+ super();
+ }
+
+ /** Constructs a NativeWindowException object with the specified detail
+ message. */
+ public NativeWindowException(final String message) {
+ super(message);
+ }
+
+ /** Constructs a NativeWindowException object with the specified detail
+ message and root cause. */
+ public NativeWindowException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ /** Constructs a NativeWindowException object with the specified root
+ cause. */
+ public NativeWindowException(final Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
new file mode 100644
index 000000000..cba3a9214
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
@@ -0,0 +1,716 @@
+/*
+ * Copyright (c) 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+package com.jogamp.nativewindow;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.jogamp.nativewindow.util.PointImmutable;
+
+import jogamp.common.os.PlatformPropsImpl;
+import jogamp.nativewindow.Debug;
+import jogamp.nativewindow.NativeWindowFactoryImpl;
+import jogamp.nativewindow.ToolkitProperties;
+import jogamp.nativewindow.ResourceToolkitLock;
+import jogamp.nativewindow.WrappedWindow;
+import jogamp.nativewindow.macosx.OSXUtil;
+import jogamp.nativewindow.windows.GDIUtil;
+import jogamp.nativewindow.x11.X11Lib;
+
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.PropertyAccess;
+import com.jogamp.common.util.ReflectionUtil;
+import com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos;
+import com.jogamp.nativewindow.awt.AWTGraphicsDevice;
+import com.jogamp.nativewindow.awt.AWTGraphicsScreen;
+import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice;
+import com.jogamp.nativewindow.windows.WindowsGraphicsDevice;
+import com.jogamp.nativewindow.x11.X11GraphicsDevice;
+import com.jogamp.nativewindow.x11.X11GraphicsScreen;
+
+/** Provides a pluggable mechanism for arbitrary window toolkits to
+ adapt their components to the {@link NativeWindow} interface,
+ which provides a platform-independent mechanism of accessing the
+ information required to perform operations like
+ hardware-accelerated rendering using the OpenGL API. */
+
+public abstract class NativeWindowFactory {
+ protected static final boolean DEBUG;
+
+ /** OpenKODE/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/
+ public static final String TYPE_EGL = ".egl".intern();
+
+ /** Microsoft Windows type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
+ public static final String TYPE_WINDOWS = ".windows".intern();
+
+ /** X11 type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
+ public static final String TYPE_X11 = ".x11".intern();
+
+ /** Broadcom VC IV/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
+ public static final String TYPE_BCM_VC_IV = ".bcm.vc.iv".intern();
+
+ /** Android/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/
+ public static final String TYPE_ANDROID = ".android".intern();
+
+ /** Mac OS X type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
+ public static final String TYPE_MACOSX = ".macosx".intern();
+
+ /** Generic AWT type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
+ public static final String TYPE_AWT = ".awt".intern();
+
+ /** Generic DEFAULT type, where platform implementation don't care, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
+ public static final String TYPE_DEFAULT = ".default".intern();
+
+ private static final String nativeWindowingTypePure; // canonical String via String.intern()
+ private static final String nativeWindowingTypeCustom; // canonical String via String.intern()
+
+ private static NativeWindowFactory defaultFactory;
+ private static Map, NativeWindowFactory> registeredFactories;
+
+ private static Class> nativeWindowClass;
+ private static boolean isAWTAvailable;
+
+ private static final String JAWTUtilClassName = "jogamp.nativewindow.jawt.JAWTUtil" ;
+ /** {@link jogamp.nativewindow.x11.X11Util} implements {@link ToolkitProperties}. */
+ private static final String X11UtilClassName = "jogamp.nativewindow.x11.X11Util";
+ /** {@link jogamp.nativewindow.macosx.OSXUtil} implements {@link ToolkitProperties}. */
+ private static final String OSXUtilClassName = "jogamp.nativewindow.macosx.OSXUtil";
+ /** {@link jogamp.nativewindow.windows.GDIUtil} implements {@link ToolkitProperties}. */
+ private static final String GDIClassName = "jogamp.nativewindow.windows.GDIUtil";
+
+ private static ToolkitLock jawtUtilJAWTToolkitLock;
+
+ private static boolean requiresToolkitLock;
+ private static boolean desktopHasThreadingIssues;
+
+ // Shutdown hook mechanism for the factory
+ private static volatile boolean isJVMShuttingDown = false;
+ private static final List customShutdownHooks = new ArrayList();
+
+ /** Creates a new NativeWindowFactory instance. End users do not
+ need to call this method. */
+ protected NativeWindowFactory() {
+ }
+
+ private static final boolean guessBroadcomVCIV() {
+ return AccessController.doPrivileged(new PrivilegedAction() {
+ private final File vcliblocation = new File(
+ "/opt/vc/lib/libbcm_host.so");
+ @Override
+ public Boolean run() {
+ if ( vcliblocation.isFile() ) {
+ return Boolean.TRUE;
+ }
+ return Boolean.FALSE;
+ }
+ } ).booleanValue();
+ }
+
+ private static String _getNativeWindowingType() {
+ switch(PlatformPropsImpl.OS_TYPE) {
+ case ANDROID:
+ return TYPE_ANDROID;
+ case MACOS:
+ return TYPE_MACOSX;
+ case WINDOWS:
+ return TYPE_WINDOWS;
+ case OPENKODE:
+ return TYPE_EGL;
+
+ case LINUX:
+ case FREEBSD:
+ case SUNOS:
+ case HPUX:
+ default:
+ if( guessBroadcomVCIV() ) {
+ return TYPE_BCM_VC_IV;
+ }
+ return TYPE_X11;
+ }
+ }
+
+ static {
+ final boolean[] _DEBUG = new boolean[] { false };
+ final String[] _tmp = new String[] { null };
+
+ AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public Object run() {
+ Platform.initSingleton(); // last resort ..
+ _DEBUG[0] = Debug.debug("NativeWindow");
+ _tmp[0] = PropertyAccess.getProperty("nativewindow.ws.name", true);
+ Runtime.getRuntime().addShutdownHook(
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ NativeWindowFactory.shutdown(true);
+ } }, "NativeWindowFactory_ShutdownHook" ) ) ;
+ return null;
+ } } ) ;
+
+ DEBUG = _DEBUG[0];
+ if(DEBUG) {
+ System.err.println(Thread.currentThread().getName()+" - Info: NativeWindowFactory.");
+ // Thread.dumpStack();
+ }
+
+ // Gather the windowing TK first
+ nativeWindowingTypePure = _getNativeWindowingType();
+ if(null==_tmp[0] || _tmp[0].length()==0) {
+ nativeWindowingTypeCustom = nativeWindowingTypePure;
+ } else {
+ nativeWindowingTypeCustom = _tmp[0].intern(); // canonical representation
+ }
+ }
+
+ private static boolean initialized = false;
+
+ private static void initSingletonNativeImpl(final ClassLoader cl) {
+ final String clazzName;
+ if( TYPE_X11 == nativeWindowingTypePure ) {
+ clazzName = X11UtilClassName;
+ } else if( TYPE_WINDOWS == nativeWindowingTypePure ) {
+ clazzName = GDIClassName;
+ } else if( TYPE_MACOSX == nativeWindowingTypePure ) {
+ clazzName = OSXUtilClassName;
+ } else {
+ clazzName = null;
+ }
+ if( null != clazzName ) {
+ ReflectionUtil.callStaticMethod(clazzName, "initSingleton", null, null, cl );
+
+ final Boolean res1 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresToolkitLock", null, null, cl);
+ requiresToolkitLock = res1.booleanValue();
+ final Boolean res2 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "hasThreadingIssues", null, null, cl);
+ desktopHasThreadingIssues = res2.booleanValue();
+ } else {
+ requiresToolkitLock = false;
+ desktopHasThreadingIssues = false;
+ }
+ }
+
+ /** Returns true if the JVM is shutting down, otherwise false. */
+ public static final boolean isJVMShuttingDown() { return isJVMShuttingDown; }
+
+ /**
+ * Add a custom shutdown hook to be performed at JVM shutdown before shutting down NativeWindowFactory instance.
+ *
+ * @param head if true add runnable at the start, otherwise at the end
+ * @param runnable runnable to be added.
+ */
+ public static void addCustomShutdownHook(final boolean head, final Runnable runnable) {
+ synchronized( customShutdownHooks ) {
+ if( !customShutdownHooks.contains( runnable ) ) {
+ if( head ) {
+ customShutdownHooks.add(0, runnable);
+ } else {
+ customShutdownHooks.add( runnable );
+ }
+ }
+ }
+ }
+
+ /**
+ * Cleanup resources at JVM shutdown
+ */
+ public static synchronized void shutdown(final boolean _isJVMShuttingDown) {
+ isJVMShuttingDown = _isJVMShuttingDown;
+ if(DEBUG) {
+ System.err.println("NativeWindowFactory.shutdown() START: JVM Shutdown "+isJVMShuttingDown+", on thread "+Thread.currentThread().getName());
+ }
+ synchronized(customShutdownHooks) {
+ final int cshCount = customShutdownHooks.size();
+ for(int i=0; i < cshCount; i++) {
+ try {
+ if( DEBUG ) {
+ System.err.println("NativeWindowFactory.shutdown - customShutdownHook #"+(i+1)+"/"+cshCount);
+ }
+ customShutdownHooks.get(i).run();
+ } catch(final Throwable t) {
+ System.err.println("NativeWindowFactory.shutdown: Caught "+t.getClass().getName()+" during customShutdownHook #"+(i+1)+"/"+cshCount);
+ if( DEBUG ) {
+ t.printStackTrace();
+ }
+ }
+ }
+ customShutdownHooks.clear();
+ }
+ if(DEBUG) {
+ System.err.println("NativeWindowFactory.shutdown(): Post customShutdownHook");
+ }
+
+ if(initialized) {
+ initialized = false;
+ if(null != registeredFactories) {
+ registeredFactories.clear();
+ registeredFactories = null;
+ }
+ GraphicsConfigurationFactory.shutdown();
+ }
+
+ shutdownNativeImpl(NativeWindowFactory.class.getClassLoader()); // always re-shutdown
+ // SharedResourceToolkitLock.shutdown(DEBUG); // not used yet
+ if(DEBUG) {
+ System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() END JVM Shutdown "+isJVMShuttingDown);
+ }
+ }
+
+ private static void shutdownNativeImpl(final ClassLoader cl) {
+ final String clazzName;
+ if( TYPE_X11 == nativeWindowingTypePure ) {
+ clazzName = X11UtilClassName;
+ } else if( TYPE_WINDOWS == nativeWindowingTypePure ) {
+ clazzName = GDIClassName;
+ } else if( TYPE_MACOSX == nativeWindowingTypePure ) {
+ clazzName = OSXUtilClassName;
+ } else {
+ clazzName = null;
+ }
+ if( null != clazzName ) {
+ ReflectionUtil.callStaticMethod(clazzName, "shutdown", null, null, cl );
+ }
+ }
+
+ /** Returns true if {@link #initSingleton()} has been called w/o subsequent {@link #shutdown(boolean)}. */
+ public static synchronized boolean isInitialized() { return initialized; }
+
+ /**
+ * Static one time initialization of this factory.
+ * This initialization method must be called once by the program or utilizing modules!
+ */
+ public static synchronized void initSingleton() {
+ if(!initialized) {
+ initialized = true;
+
+ if(DEBUG) {
+ System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.initSingleton()");
+ }
+
+ final ClassLoader cl = NativeWindowFactory.class.getClassLoader();
+
+ isAWTAvailable = false; // may be set to true below
+
+ if( Platform.AWT_AVAILABLE &&
+ ReflectionUtil.isClassAvailable("com.jogamp.nativewindow.awt.AWTGraphicsDevice", cl) ) {
+
+ final Method[] jawtUtilMethods = AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public Method[] run() {
+ try {
+ final Class> _jawtUtilClass = Class.forName(JAWTUtilClassName, true, NativeWindowFactory.class.getClassLoader());
+ final Method jawtUtilIsHeadlessMethod = _jawtUtilClass.getDeclaredMethod("isHeadlessMode", (Class[])null);
+ jawtUtilIsHeadlessMethod.setAccessible(true);
+ final Method jawtUtilInitMethod = _jawtUtilClass.getDeclaredMethod("initSingleton", (Class[])null);
+ jawtUtilInitMethod.setAccessible(true);
+ final Method jawtUtilGetJAWTToolkitLockMethod = _jawtUtilClass.getDeclaredMethod("getJAWTToolkitLock", new Class[]{});
+ jawtUtilGetJAWTToolkitLockMethod.setAccessible(true);
+ return new Method[] { jawtUtilInitMethod, jawtUtilIsHeadlessMethod, jawtUtilGetJAWTToolkitLockMethod };
+ } catch (final Exception e) {
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+ });
+ if(null != jawtUtilMethods) {
+ final Method jawtUtilInitMethod = jawtUtilMethods[0];
+ final Method jawtUtilIsHeadlessMethod = jawtUtilMethods[1];
+ final Method jawtUtilGetJAWTToolkitLockMethod = jawtUtilMethods[2];
+
+ ReflectionUtil.callMethod(null, jawtUtilInitMethod);
+
+ Object resO = ReflectionUtil.callMethod(null, jawtUtilIsHeadlessMethod);
+ if(resO instanceof Boolean) {
+ // AWT is only available in case all above classes are available
+ // and AWT is not int headless mode
+ isAWTAvailable = ((Boolean)resO).equals(Boolean.FALSE);
+ } else {
+ throw new RuntimeException("JAWTUtil.isHeadlessMode() didn't return a Boolean");
+ }
+ resO = ReflectionUtil.callMethod(null, jawtUtilGetJAWTToolkitLockMethod);
+ if(resO instanceof ToolkitLock) {
+ jawtUtilJAWTToolkitLock = (ToolkitLock) resO;
+ } else {
+ throw new RuntimeException("JAWTUtil.getJAWTToolkitLock() didn't return a ToolkitLock");
+ }
+ }
+ }
+
+ // X11 initialization after possible AWT initialization
+ // This is performed post AWT initialization, allowing AWT to complete the same,
+ // which may have been triggered before NativeWindow initialization.
+ // This way behavior is more uniforms across configurations (Applet/RCP, applications, ..).
+ initSingletonNativeImpl(cl);
+
+ registeredFactories = Collections.synchronizedMap(new HashMap, NativeWindowFactory>());
+
+ // register our default factory -> NativeWindow
+ final NativeWindowFactory factory = new NativeWindowFactoryImpl();
+ nativeWindowClass = com.jogamp.nativewindow.NativeWindow.class;
+ registerFactory(nativeWindowClass, factory);
+ defaultFactory = factory;
+
+ if ( isAWTAvailable ) {
+ // register either our default factory or (if exist) the X11/AWT one -> AWT Component
+ registerFactory(ReflectionUtil.getClass(ReflectionUtil.AWTNames.ComponentClass, false, cl), factory);
+ }
+
+ if(DEBUG) {
+ System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock+", desktopHasThreadingIssues "+desktopHasThreadingIssues);
+ System.err.println("NativeWindowFactory isAWTAvailable "+isAWTAvailable+", defaultFactory "+factory);
+ }
+
+ GraphicsConfigurationFactory.initSingleton();
+ }
+ }
+
+ /** @return true if the underlying toolkit requires locking, otherwise false. */
+ public static boolean requiresToolkitLock() {
+ return requiresToolkitLock;
+ }
+
+ /** @return true if not headless, AWT Component and NativeWindow's AWT part available */
+ public static boolean isAWTAvailable() { return isAWTAvailable; }
+
+ /**
+ * @param useCustom if false return the native value, if true return a custom value if set, otherwise fallback to the native value.
+ * @return the native window type, e.g. {@link #TYPE_X11}, which is canonical via {@link String#intern()}.
+ * Hence {@link String#equals(Object)} and == produce the same result.
+ */
+ public static String getNativeWindowType(final boolean useCustom) {
+ return useCustom?nativeWindowingTypeCustom:nativeWindowingTypePure;
+ }
+
+ /** Don't know if we shall add this factory here ..
+ public static AbstractGraphicsDevice createGraphicsDevice(String type, String connection, int unitID, long handle, ToolkitLock locker) {
+ if(TYPE_EGL == type) {
+ return new
+ } else if(TYPE_X11 == type) {
+ } else if(TYPE_WINDOWS == type) {
+ } else if(TYPE_MACOSX == type)) {
+ } else if(TYPE_AWT == type) {
+ } else if(TYPE_DEFAULT == type) {
+ }
+ } */
+
+ /** Sets the default NativeWindowFactory. */
+ public static void setDefaultFactory(final NativeWindowFactory factory) {
+ defaultFactory = factory;
+ }
+
+ /** Gets the default NativeWindowFactory. */
+ public static NativeWindowFactory getDefaultFactory() {
+ return defaultFactory;
+ }
+
+ /**
+ * Returns the AWT {@link ToolkitLock} (JAWT based) if {@link #isAWTAvailable}, otherwise null.
+ *
+ * The JAWT based {@link ToolkitLock} also locks the global lock,
+ * which matters if the latter is required.
+ *
+ */
+ public static ToolkitLock getAWTToolkitLock() {
+ return jawtUtilJAWTToolkitLock;
+ }
+
+ public static ToolkitLock getNullToolkitLock() {
+ return NativeWindowFactoryImpl.getNullToolkitLock();
+ }
+
+ /**
+ * Provides the system default {@link ToolkitLock} for the default system windowing type.
+ * @see #getNativeWindowType(boolean)
+ * @see #getDefaultToolkitLock(java.lang.String)
+ */
+ public static ToolkitLock getDefaultToolkitLock() {
+ return getDefaultToolkitLock(nativeWindowingTypePure);
+ }
+
+ /**
+ * Provides the default {@link ToolkitLock} for type.
+ *
+ *
JAWT {@link ToolkitLock} if required and type is of {@link #TYPE_AWT} and AWT available,
+ *
{@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
+ *
{@link jogamp.nativewindow.NullToolkitLock}
+ *
+ */
+ public static ToolkitLock getDefaultToolkitLock(final String type) {
+ if( requiresToolkitLock ) {
+ if( TYPE_AWT == type && isAWTAvailable() ) { // uses .intern()!
+ return getAWTToolkitLock();
+ }
+ return ResourceToolkitLock.create();
+ }
+ return NativeWindowFactoryImpl.getNullToolkitLock();
+ }
+
+ /**
+ * Provides the default {@link ToolkitLock} for type and deviceHandle.
+ *
+ *
JAWT {@link ToolkitLock} if required and type is of {@link #TYPE_AWT} and AWT available,
+ *
{@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
+ *
{@link jogamp.nativewindow.NullToolkitLock}
+ *
+ */
+ public static ToolkitLock getDefaultToolkitLock(final String type, final long deviceHandle) {
+ if( requiresToolkitLock ) {
+ if( TYPE_AWT == type && isAWTAvailable() ) { // uses .intern()!
+ return getAWTToolkitLock();
+ }
+ return ResourceToolkitLock.create();
+ }
+ return NativeWindowFactoryImpl.getNullToolkitLock();
+ }
+
+ /**
+ * @param device
+ * @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen
+ * @return newly created AbstractGraphicsScreen matching device's native type
+ */
+ public static AbstractGraphicsScreen createScreen(final AbstractGraphicsDevice device, int screen) {
+ final String type = device.getType();
+ if( TYPE_X11 == type ) {
+ final X11GraphicsDevice x11Device = (X11GraphicsDevice)device;
+ if(0 > screen) {
+ screen = x11Device.getDefaultScreen();
+ }
+ return new X11GraphicsScreen(x11Device, screen);
+ }
+ if(0 > screen) {
+ screen = 0; // FIXME: Needs native API utilization
+ }
+ if( TYPE_AWT == type ) {
+ final AWTGraphicsDevice awtDevice = (AWTGraphicsDevice) device;
+ return new AWTGraphicsScreen(awtDevice);
+ }
+ return new DefaultGraphicsScreen(device, screen);
+ }
+
+ /** Returns the appropriate NativeWindowFactory to handle window
+ objects of the given type. The windowClass might be {@link
+ NativeWindow NativeWindow}, in which case the client has
+ already assumed the responsibility of creating a compatible
+ NativeWindow implementation, or it might be that of a toolkit
+ class like {@link java.awt.Component Component}. */
+ public static NativeWindowFactory getFactory(final Class> windowClass) throws IllegalArgumentException {
+ if (nativeWindowClass.isAssignableFrom(windowClass)) {
+ return registeredFactories.get(nativeWindowClass);
+ }
+ Class> clazz = windowClass;
+ while (clazz != null) {
+ final NativeWindowFactory factory = registeredFactories.get(clazz);
+ if (factory != null) {
+ return factory;
+ }
+ clazz = clazz.getSuperclass();
+ }
+ throw new IllegalArgumentException("No registered NativeWindowFactory for class " + windowClass.getName());
+ }
+
+ /** Registers a NativeWindowFactory handling window objects of the
+ given class. This does not need to be called by end users,
+ only implementors of new NativeWindowFactory subclasses. */
+ protected static void registerFactory(final Class> windowClass, final NativeWindowFactory factory) {
+ if(DEBUG) {
+ System.err.println("NativeWindowFactory.registerFactory() "+windowClass+" -> "+factory);
+ }
+ registeredFactories.put(windowClass, factory);
+ }
+
+ /** Converts the given window object and it's
+ {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration} into a
+ {@link NativeWindow NativeWindow} which can be operated upon by a custom
+ toolkit, e.g. {@link com.jogamp.opengl.GLDrawableFactory com.jogamp.opengl.GLDrawableFactory}.
+ The object may be a component for a particular window toolkit, such as an AWT
+ Canvas. It may also be a NativeWindow object itself.
+ You shall utilize {@link com.jogamp.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}
+ to construct a proper {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration}.
+ The particular implementation of the
+ NativeWindowFactory is responsible for handling objects from a
+ particular window toolkit. The built-in NativeWindowFactory
+ handles NativeWindow instances as well as AWT Components.
+
+ @throws IllegalArgumentException if the given window object
+ could not be handled by any of the registered
+ NativeWindowFactory instances
+
+ @see com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
+ */
+ public static NativeWindow getNativeWindow(final Object winObj, final AbstractGraphicsConfiguration config) throws IllegalArgumentException, NativeWindowException {
+ if (winObj == null) {
+ throw new IllegalArgumentException("Null window object");
+ }
+
+ return getFactory(winObj.getClass()).getNativeWindowImpl(winObj, config);
+ }
+
+ /** Performs the conversion from a toolkit's window object to a
+ NativeWindow. Implementors of concrete NativeWindowFactory
+ subclasses should override this method. */
+ protected abstract NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException;
+
+ /**
+ * Returns the {@link OffscreenLayerSurface} instance of this {@link NativeSurface}.
+ *
+ * In case this surface is a {@link NativeWindow}, we traverse from the given surface
+ * up to root until an implementation of {@link OffscreenLayerSurface} is found.
+ * In case ifEnabled is true, the surface must also implement {@link OffscreenLayerOption}
+ * where {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()} is true.
+ *
+ *
+ * @param surface The surface to query.
+ * @param ifEnabled If true, only return the enabled {@link OffscreenLayerSurface}, see {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()}.
+ * @return
+ */
+ public static OffscreenLayerSurface getOffscreenLayerSurface(final NativeSurface surface, final boolean ifEnabled) {
+ if(surface instanceof OffscreenLayerSurface &&
+ ( !ifEnabled || surface instanceof OffscreenLayerOption ) ) {
+ final OffscreenLayerSurface ols = (OffscreenLayerSurface) surface;
+ return ( !ifEnabled || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null;
+ }
+ if(surface instanceof NativeWindow) {
+ NativeWindow nw = ((NativeWindow) surface).getParent();
+ while(null != nw) {
+ if(nw instanceof OffscreenLayerSurface &&
+ ( !ifEnabled || nw instanceof OffscreenLayerOption ) ) {
+ final OffscreenLayerSurface ols = (OffscreenLayerSurface) nw;
+ return ( !ifEnabled || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null;
+ }
+ nw = nw.getParent();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns true if the given visualID is valid for further processing, i.e. OpenGL usage,
+ * otherwise return false.
+ *
+ * On certain platforms, i.e. X11, a valid visualID is required at window creation.
+ * Other platforms may determine it later on, e.g. OSX and Windows.
+ *
+ * If the visualID is {@link VisualIDHolder#VID_UNDEFINED} and the platform requires it
+ * at creation time (see above), it is not valid for further processing.
+ *
+ */
+ public static boolean isNativeVisualIDValidForProcessing(final int visualID) {
+ return NativeWindowFactory.TYPE_X11 != NativeWindowFactory.getNativeWindowType(false) ||
+ VisualIDHolder.VID_UNDEFINED != visualID ;
+ }
+
+ /**
+ * Creates a native device type, following {@link #getNativeWindowType(boolean) getNativeWindowType(true)}.
+ *
+ * The device will be opened if own is true, otherwise no native handle will ever be acquired.
+ *
+ * The given {@link UpstreamWindowHookMutableSizePos} maybe used to reflect resizes and repositioning of the native window.
+ *
+ *
+ * The {@link AbstractGraphicsScreen} may be created via {@link #createScreen(AbstractGraphicsDevice, int)}.
+ *
+ *
+ * The {@link AbstractGraphicsScreen} may have an underlying open {@link AbstractGraphicsDevice}
+ * or a simple dummy instance, see {@link #createDevice(String, boolean)}.
+ *
+ */
+ public static NativeWindow createWrappedWindow(final AbstractGraphicsScreen aScreen, final long surfaceHandle, final long windowHandle,
+ final UpstreamWindowHookMutableSizePos hook) {
+ final CapabilitiesImmutable caps = new Capabilities();
+ final AbstractGraphicsConfiguration config = new DefaultGraphicsConfiguration(aScreen, caps, caps);
+ return new WrappedWindow(config, surfaceHandle, hook, true, windowHandle);
+ }
+
+ /**
+ * @param nw
+ * @return top-left client-area position in window units
+ */
+ public static PointImmutable getLocationOnScreen(final NativeWindow nw) {
+ final String nwt = NativeWindowFactory.getNativeWindowType(true);
+ if( NativeWindowFactory.TYPE_X11 == nwt ) {
+ return X11Lib.GetRelativeLocation(nw.getDisplayHandle(), nw.getScreenIndex(), nw.getWindowHandle(), 0, 0, 0);
+ } else if( NativeWindowFactory.TYPE_WINDOWS == nwt ) {
+ return GDIUtil.GetRelativeLocation(nw.getWindowHandle(), 0, 0, 0);
+ } else if( NativeWindowFactory.TYPE_MACOSX == nwt ) {
+ return OSXUtil.GetLocationOnScreen(nw.getWindowHandle(), 0, 0);
+ /**
+ * FIXME: Needs service provider interface (SPI) for TK dependent implementation
+ } else if( NativeWindowFactory.TYPE_BCM_VC_IV == nwt ) {
+ } else if( NativeWindowFactory.TYPE_ANDROID== nwt ) {
+ } else if( NativeWindowFactory.TYPE_EGL == nwt ) {
+ } else if( NativeWindowFactory.TYPE_BCM_VC_IV == nwt ) {
+ } else if( NativeWindowFactory.TYPE_AWT == nwt ) {
+ */
+ }
+ throw new UnsupportedOperationException("n/a for windowing system: "+nwt);
+ }
+
+
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerOption.java b/src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerOption.java
new file mode 100644
index 000000000..2e9f2c172
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerOption.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.nativewindow;
+
+/**
+ * Handling requests for using an {@link OffscreenLayerSurface}
+ * within the implementation.
+ */
+public interface OffscreenLayerOption {
+ /**
+ * Request an offscreen layer, if supported.
+ *
+ * Shall be called before the first {@link NativeWindow#lockSurface()},
+ * and hence before realization.
+ *
+ *
+ * @see #getShallUseOffscreenLayer()
+ * @see #isOffscreenLayerSurfaceEnabled()
+ */
+ public void setShallUseOffscreenLayer(boolean v);
+
+ /** Returns the property set by {@link #setShallUseOffscreenLayer(boolean)}. */
+ public boolean getShallUseOffscreenLayer();
+
+ /**
+ * Returns true if this instance uses an offscreen layer, otherwise false.
+ *
+ * This instance is an offscreen layer, if {@link #setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)}
+ * has been called before it's realization and first lock and the underlying implementation supports it.
+ *
+ * The return value is undefined before issuing the first {@link NativeWindow#lockSurface()}.
+ *
+ * @see #setShallUseOffscreenLayer(boolean)
+ */
+ public boolean isOffscreenLayerSurfaceEnabled();
+}
\ No newline at end of file
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerSurface.java
new file mode 100644
index 000000000..abba2c126
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/OffscreenLayerSurface.java
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.nativewindow;
+
+import com.jogamp.nativewindow.util.PixelRectangle;
+import com.jogamp.nativewindow.util.PointImmutable;
+
+import com.jogamp.common.util.locks.RecursiveLock;
+
+/**
+ * Interface specifying the offscreen layer surface protocol.
+ */
+public interface OffscreenLayerSurface {
+ /**
+ * Attach the offscreen layer to this offscreen layer surface.
+ *
+ * Implementation may realize all required resources at this point.
+ *
+ *
+ * @see #isOffscreenLayerSurfaceEnabled()
+ * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
+ */
+ public void attachSurfaceLayer(final long layerHandle) throws NativeWindowException;
+
+ /**
+ * Detaches a previously attached offscreen layer from this offscreen layer surface.
+ * @see #attachSurfaceLayer(long)
+ * @see #isOffscreenLayerSurfaceEnabled()
+ * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
+ * or no surface layer is attached.
+ */
+ public void detachSurfaceLayer() throws NativeWindowException;
+
+ /** Returns the attached surface layer or null if none is attached. */
+ public long getAttachedSurfaceLayer();
+
+ /** Returns true if a surface layer is attached, otherwise false. */
+ public boolean isSurfaceLayerAttached();
+
+ /** Sets the capabilities of this instance, allowing upstream API's to refine it, i.e. OpenGL related settings. */
+ public void setChosenCapabilities(CapabilitiesImmutable caps);
+
+ /** Returns the recursive lock object of this surface, which synchronizes multithreaded access. */
+ public RecursiveLock getLock();
+
+ /**
+ * Optional method setting cursor in the corresponding on-screen surface/window, if exists.
+ *
+ * @param pixelrect cursor pixels, maybe null for default cursor
+ * @param hotSpot maybe null for default cursor
+ * @return true if successful, i.e. on-screen surface/window w/ cursor capabilities exists. Otherwise false.
+ */
+ public boolean setCursor(PixelRectangle pixelrect, PointImmutable hotSpot);
+
+ /**
+ * Optional method hiding the cursor in the corresponding on-screen surface/window, if exists.
+ *
+ * @return true if successful, i.e. on-screen surface/window w/ cursor capabilities exists. Otherwise false.
+ */
+ public boolean hideCursor();
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/ProxySurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/ProxySurface.java
new file mode 100644
index 000000000..7b36531dc
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/ProxySurface.java
@@ -0,0 +1,135 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow;
+
+import jogamp.nativewindow.Debug;
+
+/**
+ * Provides a mutable {@link NativeSurface}, i.e. {@link MutableSurface}, while allowing an
+ * {@link UpstreamSurfaceHook} to influence the lifecycle and information.
+ *
+ * @see UpstreamSurfaceHook
+ * @see MutableSurface
+ * @see NativeSurface
+ */
+public interface ProxySurface extends MutableSurface {
+ public static final boolean DEBUG = Debug.debug("ProxySurface");
+
+ /**
+ * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's surface handle
+ * @see #addUpstreamOptionBits(int)
+ * @see #clearUpstreamOptionBits(int)
+ * @see #getUpstreamOptionBits()
+ */
+ public static final int OPT_PROXY_OWNS_UPSTREAM_SURFACE = 1 << 6;
+
+ /**
+ * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's {@link AbstractGraphicsDevice}.
+ * @see #addUpstreamOptionBits(int)
+ * @see #clearUpstreamOptionBits(int)
+ * @see #getUpstreamOptionBits()
+ */
+ public static final int OPT_PROXY_OWNS_UPSTREAM_DEVICE = 1 << 7;
+
+ /**
+ * Implementation specific bitvalue stating the upstream's {@link NativeSurface} is an invisible window, i.e. maybe incomplete.
+ * @see #addUpstreamOptionBits(int)
+ * @see #clearUpstreamOptionBits(int)
+ * @see #getUpstreamOptionBits()
+ */
+ public static final int OPT_UPSTREAM_WINDOW_INVISIBLE = 1 << 8;
+
+ /**
+ * Implementation specific bitvalue stating the upstream's {@link NativeSurface}'s zero handle is valid.
+ * @see #addUpstreamOptionBits(int)
+ * @see #clearUpstreamOptionBits(int)
+ * @see #getUpstreamOptionBits()
+ */
+ public static final int OPT_UPSTREAM_SURFACELESS = 1 << 9;
+
+ /** Allow redefining the AbstractGraphicsConfiguration */
+ public void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg);
+
+ /**
+ * Returns the optional upstream {@link NativeSurface} if used by implementation, otherwise null.
+ *
+ * The upstream {@link NativeSurface} is retrieved via {@link #getUpstreamSurfaceHook() the UpstreamSurfaceHook},
+ * i.e. {@link UpstreamSurfaceHook#getUpstreamSurface()}.
+ *
+ *
+ * One example is the JOGL EGLWrappedSurface, which might be backed up by a
+ * native platform NativeSurface (X11, WGL, CGL, ..).
+ *
+ */
+ public NativeSurface getUpstreamSurface();
+
+ /** Returns the {@link UpstreamSurfaceHook} if {@link #setUpstreamSurfaceHook(UpstreamSurfaceHook) set}, otherwise null. */
+ public UpstreamSurfaceHook getUpstreamSurfaceHook();
+
+ /**
+ * Overrides the {@link UpstreamSurfaceHook}.
+ */
+ public void setUpstreamSurfaceHook(UpstreamSurfaceHook hook);
+
+ /**
+ * Enables or disables the {@link UpstreamSurfaceHook} lifecycle functions
+ * {@link UpstreamSurfaceHook#create(ProxySurface)} and {@link UpstreamSurfaceHook#destroy(ProxySurface)}.
+ *
+ * Use this for small code blocks where the native resources shall not change,
+ * i.e. resizing a derived (OpenGL) drawable.
+ *
+ */
+ public void enableUpstreamSurfaceHookLifecycle(boolean enable);
+
+ /**
+ * {@link UpstreamSurfaceHook#create(ProxySurface)} is being issued and the proxy surface/window handles shall be set.
+ */
+ public void createNotify();
+
+ /**
+ * {@link UpstreamSurfaceHook#destroy(ProxySurface)} is being issued and all proxy surface/window handles shall be cleared.
+ */
+ public void destroyNotify();
+
+ public StringBuilder getUpstreamOptionBits(StringBuilder sink);
+ public int getUpstreamOptionBits();
+
+ /** Returns true if the give bit-mask v is set in this instance upstream-option-bits, otherwise false.*/
+ public boolean containsUpstreamOptionBits(int v);
+
+ /** Add the given bit-mask to this instance upstream-option-bits using bit-or w/ v.*/
+ public void addUpstreamOptionBits(int v);
+
+ /** Clear the given bit-mask from this instance upstream-option-bits using bit-and w/ ~v*/
+ public void clearUpstreamOptionBits(int v);
+
+ public StringBuilder toString(StringBuilder sink);
+ @Override
+ public String toString();
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/ScalableSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/ScalableSurface.java
new file mode 100644
index 000000000..eea9e4bed
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/ScalableSurface.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow;
+
+/**
+ * Adding mutable surface pixel scale property to implementing class, usually to a {@link NativeSurface} implementation,
+ * see {@link #setSurfaceScale(float[])}.
+ */
+public interface ScalableSurface {
+ /** Setting surface-pixel-scale of {@value}, results in same pixel- and window-units. */
+ public static final float IDENTITY_PIXELSCALE = 1f;
+ /** Setting surface-pixel-scale of {@value}, results in maximum platform dependent pixel-scale, i.e. pixel-units >> window-units where available. */
+ public static final float AUTOMAX_PIXELSCALE = 0f;
+
+ /**
+ * Request a pixel scale in x- and y-direction for the associated {@link NativeSurface},
+ * where {@code size_in_pixel_units = pixel_scale * size_in_window_units}.
+ *
+ * Default pixel scale request for both directions is {@link #AUTOMAX_PIXELSCALE}.
+ *
+ *
+ * In case platform only supports uniform pixel scale, i.e. one scale for both directions,
+ * either {@link #AUTOMAX_PIXELSCALE} or the maximum requested pixel scale component is used.
+ *
+ *
+ * The requested pixel scale will be validated against platform limits before native scale-setup,
+ * i.e. clipped to {@link #IDENTITY_PIXELSCALE} if not supported or clipped to the platform maximum.
+ * It can be queried via {@link #getRequestedSurfaceScale(float[])}.
+ *
+ *
+ * The actual realized pixel scale values of the {@link NativeSurface}
+ * can be queried via {@link #getCurrentSurfaceScale(float[])} or
+ * computed via surface.{@link NativeSurface#convertToPixelUnits(int[]) convertToPixelUnits}(new int[] { 1, 1 })
+ *
+ * @param pixelScale requested surface pixel scale float[2] values for x- and y-direction.
+ * @return {@code true} if the {@link #getCurrentSurfaceScale(float[]) current pixel scale} has changed, otherwise {@code false}.
+ * @see #getRequestedSurfaceScale(float[])
+ */
+ public boolean setSurfaceScale(final float[] pixelScale);
+
+ /**
+ * Returns the {@link #setSurfaceScale(float[]) requested} pixel scale of the associated {@link NativeSurface}.
+ *
+ * @param result float[2] storage for the result
+ * @return the passed storage containing the current pixelScale for chaining
+ * @see #setSurfaceScale(float[])
+ */
+ public float[] getRequestedSurfaceScale(final float[] result);
+
+ /**
+ * Returns the current pixel scale of the associated {@link NativeSurface}.
+ *
+ * @param result float[2] storage for the result
+ * @return the passed storage containing the current pixelScale for chaining
+ */
+ public float[] getCurrentSurfaceScale(final float[] result);
+
+ /**
+ * Returns the minimum pixel scale of the associated {@link NativeSurface}.
+ * @param result float[2] storage for the result
+ * @return the passed storage containing the minimum pixelScale for chaining
+ */
+ public float[] getMinimumSurfaceScale(final float[] result);
+
+ /**
+ * Returns the maximum pixel scale of the associated {@link NativeSurface}.
+ *
+ * The maximum pixel scale maybe used to determine the proper dpi
+ * value of the monitor displaying this {@link NativeSurface}.
+ *
+ * surfacePpMM = monitorPpMM * currentSurfaceScale / nativeSurfaceScale,
+ * with PpMM == pixel per millimeter
+ *
+ *
+ *
+ * @param result float[2] storage for the result
+ * @return the passed storage containing the maximum pixelScale for chaining
+ */
+ public float[] getMaximumSurfaceScale(final float[] result);
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/SurfaceUpdatedListener.java b/src/nativewindow/classes/com/jogamp/nativewindow/SurfaceUpdatedListener.java
new file mode 100644
index 000000000..37e4bd0c9
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/SurfaceUpdatedListener.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.jogamp.nativewindow;
+
+/**
+ * Clients may add their SurfaceUpdateListener implementation to a {@link com.jogamp.nativewindow.NativeSurface}
+ * allowing to get notified after the surface has been updated, eg. after a swap buffer operation.
+ */
+public interface SurfaceUpdatedListener {
+ /** Notification of a surface update event, eg. after a swap buffer operation.
+ *
+ * @param updater is the caller object who updated the surface,
+ * e.g. a JOGL GLDrawable.
+ * @param ns the updated NativeSurface
+ * @param when the time in ms, when the surface was updated
+ */
+ public void surfaceUpdated(Object updater, NativeSurface ns, long when) ;
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/ToolkitLock.java b/src/nativewindow/classes/com/jogamp/nativewindow/ToolkitLock.java
new file mode 100644
index 000000000..eef11adb7
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/ToolkitLock.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow;
+
+import jogamp.nativewindow.Debug;
+
+/**
+ * Marker for a singleton global recursive blocking lock implementation,
+ * optionally locking a native windowing toolkit as well.
+ *
+ * Toolkit locks are created solely via {@link NativeWindowFactory}.
+ *
+ *
+ * One use case is the AWT locking on X11, see {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}.
+ *
+ */
+public interface ToolkitLock {
+ public static final boolean DEBUG = Debug.debug("ToolkitLock");
+ public static final boolean TRACE_LOCK = Debug.isPropertyDefined("nativewindow.debug.ToolkitLock.TraceLock", true);
+
+ /**
+ * Blocking until the lock is acquired by this Thread or a timeout is reached.
+ *
+ * Timeout is implementation specific, if used at all.
+ *
+ *
+ * @throws RuntimeException in case of a timeout
+ */
+ public void lock();
+
+ /**
+ * Release the lock.
+ *
+ * @throws RuntimeException in case the lock is not acquired by this thread.
+ */
+ public void unlock();
+
+ /**
+ * @throws RuntimeException if current thread does not hold the lock
+ */
+ public void validateLocked() throws RuntimeException;
+
+ /**
+ * Dispose this instance.
+ *
+ * Shall be called when instance is no more required.
+ *
+ * This allows implementations sharing a lock via resources
+ * to decrease the reference counter.
+ */
+ public void dispose();
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHook.java b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHook.java
new file mode 100644
index 000000000..5e9b8d293
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHook.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow;
+
+/**
+ * Interface allowing upstream caller to pass lifecycle actions and size info
+ * to a {@link ProxySurface} instance.
+ */
+public interface UpstreamSurfaceHook {
+ /** called within {@link ProxySurface#createNotify()} within lock, before using surface. */
+ public void create(ProxySurface s);
+ /** called within {@link ProxySurface#destroyNotify()} within lock, before clearing fields. */
+ public void destroy(ProxySurface s);
+
+ /**
+ * Returns the optional upstream {@link NativeSurface} if used by implementation, otherwise null.
+ *
+ * One example is the JOGL EGLWrappedSurface, which might be backed up by a
+ * native platform NativeSurface (X11, WGL, CGL, ..).
+ *
+ */
+ public NativeSurface getUpstreamSurface();
+
+ /** Returns the width of the upstream surface in pixels, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */
+ public int getSurfaceWidth(ProxySurface s);
+ /** Returns the height of the upstream surface in pixels, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */
+ public int getSurfaceHeight(ProxySurface s);
+
+ /**
+ * {@link UpstreamSurfaceHook} w/ mutable size, allowing it's {@link ProxySurface} user to resize.
+ */
+ public interface MutableSize extends UpstreamSurfaceHook {
+ /**
+ * Resizes the upstream surface.
+ * @param width new width in pixel units
+ * @param height new height in pixel units
+ */
+ public void setSurfaceSize(int width, int height);
+ }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/VisualIDHolder.java b/src/nativewindow/classes/com/jogamp/nativewindow/VisualIDHolder.java
new file mode 100644
index 000000000..69bfe50f8
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/VisualIDHolder.java
@@ -0,0 +1,136 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow;
+
+import java.util.Comparator;
+
+/**
+ * Visual ID holder interface.
+ *
+ * Allows queries of different types of native visual IDs,
+ * see {@link #getVisualID(int)}.
+ *
+ */
+public interface VisualIDHolder {
+
+ public enum VIDType {
+ // Generic Values
+ INTRINSIC(0), NATIVE(1),
+ // EGL Values
+ EGL_CONFIG(10),
+ // X11 Values
+ X11_XVISUAL(20), X11_FBCONFIG(21),
+ // Windows Values
+ WIN32_PFD(30);
+
+ public final int id;
+
+ VIDType(final int id){
+ this.id = id;
+ }
+ }
+
+ /**
+ * Returns the native visual ID of the given type
+ * if supported, or {@link #VID_UNDEFINED} if not supported.
+ *
+ * Depending on the native windowing system, type is handled as follows:
+ *
+ *
X11 throws NativeWindowException on EGL_CONFIG, WIN32_PFD
+ *
+ *
INTRINSIC: X11 XVisual ID
+ *
NATIVE: X11 XVisual ID
+ *
X11_XVISUAL: X11 XVisual ID
+ *
X11_FBCONFIG: VID_UNDEFINED
+ *
+ *
X11/GL throws NativeWindowException on EGL_CONFIG, WIN32_PFD
+ *
+ *
INTRINSIC: X11 XVisual ID
+ *
NATIVE: X11 XVisual ID
+ *
X11_XVISUAL: X11 XVisual ID
+ *
X11_FBCONFIG: X11 FBConfig ID or VID_UNDEFINED
+ *
+ *
Windows/GL throws NativeWindowException on EGL_CONFIG, X11_XVISUAL, X11_FBCONFIG
+ *
+ *
INTRINSIC: Win32 PIXELFORMATDESCRIPTOR ID
+ *
NATIVE: Win32 PIXELFORMATDESCRIPTOR ID
+ *
WIN32_PFD: Win32 PIXELFORMATDESCRIPTOR ID
+ *
+ *
EGL/GL throws NativeWindowException on X11_XVISUAL, X11_FBCONFIG, WIN32_PFD
+ *
+ *
+ * Note: INTRINSIC and NATIVE are always handled,
+ * but may result in {@link #VID_UNDEFINED}. The latter is true if
+ * the native value are actually undefined or the corresponding object is not
+ * mapped to a native visual object.
+ *
+ * @throws NativeWindowException if type is neither
+ * INTRINSIC nor NATIVE
+ * and does not match the native implementation.
+ */
+ int getVisualID(VIDType type) throws NativeWindowException ;
+
+ /**
+ * {@link #getVisualID(VIDType)} result indicating an undefined value,
+ * which could be cause by an unsupported query.
+ *
+ * We assume the const value 0 doesn't reflect a valid native visual ID
+ * and is interpreted as no value on all platforms.
+ * This is currently true for Android, X11 and Windows.
+ *
+ */
+ static final int VID_UNDEFINED = 0;
+
+ /** Comparing {@link VIDType#NATIVE} */
+ public static class VIDComparator implements Comparator {
+ private final VIDType type;
+
+ public VIDComparator(final VIDType type) {
+ this.type = type;
+ }
+
+ @Override
+ public int compare(final VisualIDHolder vid1, final VisualIDHolder vid2) {
+ final int id1 = vid1.getVisualID(type);
+ final int id2 = vid2.getVisualID(type);
+
+ if(id1 > id2) {
+ return 1;
+ } else if(id1 < id2) {
+ return -1;
+ }
+ return 0;
+ }
+ }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/WindowClosingProtocol.java b/src/nativewindow/classes/com/jogamp/nativewindow/WindowClosingProtocol.java
new file mode 100644
index 000000000..f4f8a02e1
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/WindowClosingProtocol.java
@@ -0,0 +1,73 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow;
+
+/**
+ * Protocol for handling window closing events.
+ *
+ * The implementation shall obey either the user value set by this interface,
+ * an underlying toolkit set user value or it's default, eg. {@link WindowClosingMode#DO_NOTHING_ON_CLOSE DO_NOTHING_ON_CLOSE} within an AWT environment.
+ * If none of the above determines the operation,
+ * this protocol default behavior {@link WindowClosingMode#DISPOSE_ON_CLOSE DISPOSE_ON_CLOSE} shall be used.
+ */
+public interface WindowClosingProtocol {
+
+ /**
+ * Window closing mode if triggered by toolkit close operation.
+ */
+ public enum WindowClosingMode {
+ /**
+ * Do nothing on native window close operation.
+ * This is the default behavior within an AWT environment.
+ */
+ DO_NOTHING_ON_CLOSE,
+
+ /**
+ * Dispose resources on native window close operation.
+ * This is the default behavior in case no underlying toolkit defines otherwise.
+ */
+ DISPOSE_ON_CLOSE;
+ }
+
+
+ /**
+ * @return the current close operation value
+ * @see WindowClosingMode#DISPOSE_ON_CLOSE
+ * @see WindowClosingMode#DO_NOTHING_ON_CLOSE
+ */
+ WindowClosingMode getDefaultCloseOperation();
+
+ /**
+ * @param op the new close operation value
+ * @return the previous close operation value
+ * @see WindowClosingMode#DISPOSE_ON_CLOSE
+ * @see WindowClosingMode#DO_NOTHING_ON_CLOSE
+ */
+ WindowClosingMode setDefaultCloseOperation(WindowClosingMode op);
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/package.html b/src/nativewindow/classes/com/jogamp/nativewindow/package.html
new file mode 100644
index 000000000..1fe52eea4
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/package.html
@@ -0,0 +1,101 @@
+
+
+
+ NativeWindow Specification Overview
+
+
+
+
NativeWindow Protocol Specification Overview
+
+
Preface
+ This specification, an optional set of packages, describing a protocol for a
+ native windowing interface binding to Java(TM).
+ Currently specified native windowing systems are:
+
+
EGL/OpenKODE Windowing System
+
X11 Windowing System
+
Microsoft Windows
+
Apple MacOSX
+
Java's AWT
+
+
+ However, any other native windowing system may be added to the implementation,
+ using a generic string identifier and an optional specialisation of:
+
The specialisation of the abstract class {@link com.jogamp.nativewindow.NativeWindowFactory NativeWindowFactory}
+
shall be registered with {@link com.jogamp.nativewindow.NativeWindowFactory#registerFactory NativeWindowFactory.registerFactory(..)}.
+
+
The specialisation of the abstract class {@link com.jogamp.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}
+
shall be registered with {@link com.jogamp.nativewindow.GraphicsConfigurationFactory#registerFactory GraphicsConfigurationFactory.registerFactory(..)}.
+
+
This protocol does not describe how to create native windows, but how to bind a native surface to an implementation of
+ and window to an implementation of {@link com.jogamp.nativewindow.NativeSurface NativeSurface}.
+
{@link com.jogamp.nativewindow.NativeWindow NativeWindow} specializes the NativeSurface.
+
However, an implementation of this protocol (e.g. {@link com.jogamp.newt}) may support the creation.
+
+
Dependencies
+ This binding has dependencies to the following:
+
+ The packages defined by this specification include:
+
+
The com.jogamp.nativewindow package
+
This package contains Java bindings for a native windowing system.
+
Subsequent packages contain marker type classes, containing native characteristics of the windowing system.
+
+
The com.jogamp.nativewindow.awt package
+
This sub package contains classes to cover the native characteristics of the AWT windowing system.
+
+
The com.jogamp.nativewindow.x11 package
+
This sub package contains classes to cover the native characteristics of the X11 windowing system.
+
+
The com.jogamp.nativewindow.windows package
+
This sub package contains classes to cover the native characteristics of the Windows windowing system.
+
+
The com.jogamp.nativewindow.macosx package
+
This sub package contains classes to cover the native characteristics of the MacOSX windowing system.
+
+
The com.jogamp.nativewindow.egl package
+
This sub package contains classes to cover the native characteristics of the EGL/OpenKODE windowing system.
+
+
+
+
Factory Model
+
Running on a platform with a supported windowing system, the factory model shall be used
+to instantiate a native window, see {@link com.jogamp.nativewindow.NativeWindowFactory NativeWindowFactory}.
+
+
Revision History
+
+
+
Early Draft Review, June 2009
+
2.0.0 Maintenance Release, February 2011
+
2.0.2 Major Release, July 18th 2013
+
+
+
+
+
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/Dimension.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/Dimension.java
new file mode 100644
index 000000000..28c5dd90e
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/Dimension.java
@@ -0,0 +1,128 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow.util;
+
+public class Dimension implements Cloneable, DimensionImmutable {
+ int width;
+ int height;
+
+ public Dimension() {
+ this(0, 0);
+ }
+
+ public Dimension(final int[] size) {
+ this(size[0], size[1]);
+ }
+
+ public Dimension(final int width, final int height) {
+ if(width<0 || height<0) {
+ throw new IllegalArgumentException("width and height must be within: ["+0+".."+Integer.MAX_VALUE+"]");
+ }
+ this.width=width;
+ this.height=height;
+ }
+
+ @Override
+ public Object cloneMutable() {
+ return clone();
+ }
+
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (final CloneNotSupportedException ex) {
+ throw new InternalError();
+ }
+ }
+
+ @Override
+ public final int getWidth() { return width; }
+ @Override
+ public final int getHeight() { return height; }
+
+ public final void set(final int width, final int height) {
+ this.width = width;
+ this.height = height;
+ }
+ public final void setWidth(final int width) {
+ this.width = width;
+ }
+ public final void setHeight(final int height) {
+ this.height = height;
+ }
+ public final Dimension scale(final int s) {
+ width *= s;
+ height *= s;
+ return this;
+ }
+ public final Dimension add(final Dimension pd) {
+ width += pd.width ;
+ height += pd.height ;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return width + " x " + height;
+ }
+
+ @Override
+ public int compareTo(final DimensionImmutable d) {
+ final int tsq = width*height;
+ final int xsq = d.getWidth()*d.getHeight();
+
+ if(tsq > xsq) {
+ return 1;
+ } else if(tsq < xsq) {
+ return -1;
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if(this == obj) { return true; }
+ if (obj instanceof Dimension) {
+ final Dimension p = (Dimension)obj;
+ return height == p.height &&
+ width == p.width ;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ // 31 * x == (x << 5) - x
+ final int hash = 31 + width;
+ return ((hash << 5) - hash) + height;
+ }
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/DimensionImmutable.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/DimensionImmutable.java
new file mode 100644
index 000000000..6de77a716
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/DimensionImmutable.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow.util;
+
+import com.jogamp.common.type.WriteCloneable;
+
+/** Immutable Dimension Interface, consisting of it's read only components:
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public int compareTo(final DimensionImmutable d);
+
+ /**
+ * Checks whether two dimensions objects are equal. Two instances
+ * of DimensionReadOnly are equal if two components
+ * height and width are equal.
+ * @return true if the two dimensions are equal;
+ * otherwise false.
+ */
+ @Override
+ boolean equals(Object obj);
+
+ @Override
+ int hashCode();
+
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/Insets.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/Insets.java
new file mode 100644
index 000000000..205e18346
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/Insets.java
@@ -0,0 +1,136 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow.util;
+
+/**
+ * Mutable insets representing rectangular window decoration insets on all four edges
+ * in window units.
+ */
+public class Insets implements Cloneable, InsetsImmutable {
+ static final InsetsImmutable zeroInsets = new Insets();
+ public static final InsetsImmutable getZero() { return zeroInsets; }
+
+ private int l, r, t, b;
+
+ public Insets() {
+ this(0, 0, 0, 0);
+ }
+
+ public Insets(final int left, final int right, final int top, final int bottom) {
+ this.l=left;
+ this.r=right;
+ this.t=top;
+ this.b=bottom;
+ }
+
+ @Override
+ public Object cloneMutable() {
+ return clone();
+ }
+
+ @Override
+ protected Object clone() {
+ try {
+ return super.clone();
+ } catch (final CloneNotSupportedException ex) {
+ throw new InternalError();
+ }
+ }
+
+ @Override
+ public final int getLeftWidth() { return l; }
+ @Override
+ public final int getRightWidth() { return r; }
+ @Override
+ public final int getTotalWidth() { return l + r; }
+ @Override
+ public final int getTopHeight() { return t; }
+ @Override
+ public final int getBottomHeight() { return b; }
+ @Override
+ public final int getTotalHeight() { return t + b; }
+
+ /**
+ * Set the inset values of this instance in window units.
+ * @param left left inset width in window units.
+ * @param right right inset width in window units.
+ * @param top top inset width in window units.
+ * @param bottom bottom inset width in window units.
+ */
+ public final void set(final int left, final int right, final int top, final int bottom) {
+ l = left; r = right; t = top; b = bottom;
+ }
+ /**
+ * Set the left inset value of this instance in window units.
+ * @param left left inset width in window units.
+ */
+ public final void setLeftWidth(final int left) { l = left; }
+ /**
+ * Set the right inset value of this instance in window units.
+ * @param right right inset width in window units.
+ */
+ public final void setRightWidth(final int right) { r = right; }
+ /**
+ * Set the top inset value of this instance in window units.
+ * @param top top inset width in window units.
+ */
+ public final void setTopHeight(final int top) { t = top; }
+ /**
+ * Set the bottom inset value of this instance in window units.
+ * @param bottom bottom inset width in window units.
+ */
+ public final void setBottomHeight(final int bottom) { b = bottom; }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if(this == obj) { return true; }
+ if (obj instanceof Insets) {
+ final Insets insets = (Insets)obj;
+ return (r == insets.r) && (l == insets.l) &&
+ (b == insets.b) && (t == insets.t);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ final int sum1 = l + b;
+ final int sum2 = t + r;
+ final int val1 = sum1 * (sum1 + 1)/2 + l;
+ final int val2 = sum2 * (sum2 + 1)/2 + r;
+ final int sum3 = val1 + val2;
+ return sum3 * (sum3 + 1)/2 + val2;
+ }
+
+ @Override
+ public String toString() {
+ return "[ l "+l+", r "+r+" - t "+t+", b "+b+" - "+getTotalWidth()+"x"+getTotalHeight()+"]";
+ }
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/InsetsImmutable.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/InsetsImmutable.java
new file mode 100644
index 000000000..e626a507e
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/InsetsImmutable.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow.util;
+
+import com.jogamp.common.type.WriteCloneable;
+
+/**
+ * Immutable insets representing rectangular window decoration insets on all four edges
+ * in window units.
+ */
+public interface InsetsImmutable extends WriteCloneable {
+
+ /** @return left inset width in window units. */
+ int getLeftWidth();
+
+ /** @return right inset width in window units. */
+ int getRightWidth();
+
+ /** @return total width in window units, ie. left_width + right_width */
+ int getTotalWidth();
+
+ /** @return top inset height in window units. */
+ int getTopHeight();
+
+ /** @return bottom inset height in window units. */
+ int getBottomHeight();
+
+ /** @return total height in window units, ie. top_height + bottom_height */
+ int getTotalHeight();
+
+ /**
+ * Checks whether two rect objects are equal. Two instances
+ * of Insets are equal if the four integer values
+ * of the fields left, right,
+ * top, and bottom are all equal.
+ * @return true if the two Insets are equal;
+ * otherwise false.
+ */
+ @Override
+ boolean equals(Object obj);
+
+ @Override
+ int hashCode();
+
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java
new file mode 100644
index 000000000..8b1e91564
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormat.java
@@ -0,0 +1,739 @@
+/**
+ * Copyright (c) 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow.util;
+
+import java.util.Arrays;
+
+import com.jogamp.common.util.IntBitfield;
+
+/**
+ * Basic pixel formats
+ *
+ * Notation follows OpenGL notation, i.e.
+ * name consist of all it's component names
+ * followed by their bit size.
+ *
+ *
+ * Order of component names is from lowest-bit to highest-bit.
+ *
+ *
+ * In case component-size is 1 byte (e.g. OpenGL data-type GL_UNSIGNED_BYTE),
+ * component names are ordered from lowest-byte to highest-byte.
+ * Note that OpenGL applies special interpretation if
+ * data-type is e.g. GL_UNSIGNED_8_8_8_8_REV or GL_UNSIGNED_8_8_8_8_REV.
+ *
+ *
+ * PixelFormat can be converted to OpenGL GLPixelAttributes
+ * via
+ *
+ *
+ */
+ BGRA8888(new CType[]{ CType.B, CType.G, CType.R, CType.A }, 4, 8, 32);
+
+ /** Unique {@link Composition Pixel Composition}, i.e. layout of its components. */
+ public final Composition comp;
+
+ /**
+ * @param componentOrder {@link CType Component type} order of all components, see {@link Composition#componentBitMask()}.
+ * @param componentCount number of components
+ * @param bpc bits per component
+ * @param bitStride stride bits to next pixel
+ */
+ private PixelFormat(final CType[] componentOrder, final int componentCount, final int bpc, final int bitStride) {
+ this.comp = new PackedComposition(componentOrder, componentCount, bpc, bitStride);
+ }
+
+ /**
+ * @param componentOrder {@link CType Component type} order of all components, see {@link Composition#componentBitMask()}.
+ * @param componentMask bit-mask of of all components, see {@link Composition##componentBitMask()}.
+ * @param componentBitShift bit-shift of all components, see {@link Composition##componentBitMask()}.
+ * @param bitStride stride bits to next pixel
+ */
+ private PixelFormat(final CType[] componentOrder, final int[] componentMask, final int[] componentBitShift, final int bitStride) {
+ this.comp = new PackedComposition(componentOrder, componentMask, componentBitShift, bitStride);
+ }
+
+ /**
+ * Returns the unique matching {@link PixelFormat} of the given {@link Composition}
+ * or {@code null} if none is available.
+ */
+ public static PixelFormat valueOf(final Composition comp) {
+ final PixelFormat[] all = PixelFormat.values();
+ for(int i=all.length-1; i>=0; i--) {
+ final PixelFormat pf = all[i];
+ if( comp.hashCode() == pf.comp.hashCode() && comp.equals(pf.comp) ) {
+ return pf;
+ }
+ }
+ return null;
+ }
+
+ /** Component types */
+ public static enum CType {
+ /** Red component */
+ R,
+ /** Green component */
+ G,
+ /** Blue component */
+ B,
+ /** Alpha component */
+ A,
+ /** Luminance component, e.g. grayscale or Y of YUV */
+ Y,
+ /** U component of YUV */
+ U,
+ /** V component of YUV */
+ V;
+ }
+
+ /**
+ * Pixel composition, i.e. layout of its components.
+ */
+ public static interface Composition {
+ /** {@value} */
+ public static final int UNDEF = -1;
+
+ /**
+ * Returns {@code true} if all components are of same bit-size, e.g. {@link PixelFormat#RGBA8888 RGBA8888},
+ * otherwise {@code false}, e.g. {@link PixelFormat#RGBA5551 RGBA5551}
+ */
+ boolean isUniform();
+
+ /**
+ * Returns {@code true} if all components are packed, i.e. interleaved, e.g. {@link PixelFormat#RGBA8888 RGBA8888},
+ * otherwise {@code false}.
+ */
+ boolean isInterleaved();
+
+ /** Number of components per pixel, e.g. 3 for {@link PixelFormat#RGBx8888 RGBx8888}. */
+ int componenCount();
+ /** Number of bits per pixel, e.g. 24 bits for {@link PixelFormat#RGBx8888 RGBx8888}. */
+ int bitsPerPixel();
+ /**
+ * Bit distance between pixels.
+ *
+ * For packed pixels e.g. 32 bits for {@link PixelFormat#RGBx8888 RGBx8888}.
+ *
+ */
+ int bitStride();
+ /** Number of bytes per pixel, i.e. packed {@link #bitStride()} in bytes, e.g. 4 for {@link PixelFormat#RGBx8888 RGBx8888}. */
+ int bytesPerPixel();
+ /**
+ * Returns the {@link CType Component type} order of all components, see {@link #componentBitMask()}.
+ */
+ CType[] componentOrder();
+ /**
+ * Returns the index of given {@link CType} within {@link #componentOrder()}, -1 if not exists.
+ */
+ int find(final PixelFormat.CType s);
+ /**
+ * Returns the un-shifted bit-mask of all components.
+ *
+ * Components mask is returned in the order Low-Index to High-Index, e.g.:
+ *
+ *
{@link PixelFormat#RGB565 RGB565}: 0: R 0x1F, 1: G 0x3F, 2: B 0x1F
+ *
{@link PixelFormat#RGBA5551 RGBA5551}: 0: R 0x1F, 1: G 0x1F, 2: B 0x1F, 3: A 0x01
+ *
{@link PixelFormat#RGBA8888 RGBA8888}: 0: R 0xFF, 1: G 0xFF, 2: B 0xFF, 3: A 0xFF
+ *
+ *
+ *
+ */
+ int[] componentBitMask();
+ /**
+ * Returns the number of bits of all components, see {@link #componentBitMask()}.
+ */
+ int[] componentBitCount();
+ /**
+ * Returns the bit-shift of all components, see {@link #componentBitMask()}.
+ */
+ int[] componentBitShift();
+
+ /**
+ * Decodes a component from the shifted pixel data with a {@link #bytesPerPixel()} of up to 32bit.
+ * @param shifted complete pixel encoded into on 32bit integer
+ * @param cIdx the desired component index
+ * @return the decoded component value
+ */
+ int decodeSingleI32(final int shifted, final int cIdx);
+ /**
+ * Decodes a component from the shifted pixel data with a {@link #bytesPerPixel()} of up to 64bit.
+ * @param shifted complete pixel encoded into on 64bit integer
+ * @param cIdx the desired component index
+ * @return the decoded component value
+ */
+ int decodeSingleI64(final long shifted, final int cIdx);
+
+ int encodeSingleI32(final int norm, final int cIdx);
+ long encodeSingleI64(final int norm, final int cIdx);
+
+ int encode3CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32);
+ int encode4CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32, final int c4NormI32);
+
+ int encodeSingleI8(final byte normalI8, final int cIdx);
+ int encode3CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8);
+ int encode4CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8, final byte c4NormI8);
+
+ float toFloat(final int i32, final int cIdx, final boolean i32Shifted);
+ int fromFloat(final float f, final int cIdx, final boolean shiftResult);
+
+ int defaultValue(final int cIdx, final boolean shiftResult);
+
+ /**
+ * Returns cached immutable hash value, see {@link Object#hashCode()}.
+ */
+ int hashCode();
+ /**
+ * Returns {@link Object#equals(Object)}
+ */
+ boolean equals(final Object o);
+
+ /**
+ * Returns {@link Object#toString()}.
+ */
+ String toString();
+ }
+
+ /**
+ * Packed pixel composition, see {@link Composition}.
+ *
+ * Components are interleaved, i.e. packed.
+ *
+ */
+ public static class PackedComposition implements Composition {
+ private final CType[] compOrder;
+ private final int[] compMask;
+ private final int[] compBitCount;
+ private final int[] compBitShift;
+ private final int bitsPerPixel;
+ private final int bitStride;
+ private final boolean uniform;
+ private final int hashCode;
+
+ public final String toString() {
+ return String.format("PackedComp[order %s, stride %d, bpp %d, uni %b, comp %d: %s]",
+ Arrays.toString(compOrder), bitStride, bitsPerPixel, uniform,
+ compMask.length, toHexString(compBitCount, compMask, compBitShift));
+ }
+
+ /**
+ * @param componentOrder {@link CType Component type} order of all components, see {@link #componentBitMask()}.
+ * @param componentCount number of components
+ * @param bpc bits per component
+ * @param bitStride stride bits to next pixel
+ */
+ public PackedComposition(final CType[] componentOrder, final int componentCount, final int bpc, final int bitStride) {
+ this.compOrder = componentOrder;
+ this.compMask = new int[componentCount];
+ this.compBitShift = new int[componentCount];
+ this.compBitCount = new int[componentCount];
+ final int compMask = ( 1 << bpc ) - 1;
+ for(int i=0; i=0; i--) {
+ final int cmask = componentMask[i];
+ final int bitCount = IntBitfield.getBitCount(cmask);
+ bpp += bitCount;
+ this.compBitCount[i] = bitCount;
+ if( i > 0 && uniform ) {
+ uniform = componentMask[i-1] == cmask;
+ }
+ }
+ this.uniform = uniform;
+ this.bitsPerPixel = bpp;
+ this.bitStride = bitStride;
+ if( this.bitStride < this.bitsPerPixel ) {
+ throw new IllegalArgumentException(String.format("bit-stride %d < bitsPerPixel %d", this.bitStride, this.bitsPerPixel));
+ }
+ this.hashCode = hashCodeImpl();
+ }
+
+ @Override
+ public final boolean isUniform() { return uniform; }
+ /**
+ * {@inheritDoc}
+ *
+ */
+ @Override
+ public final boolean isInterleaved() { return true; }
+ @Override
+ public final int componenCount() { return compMask.length; }
+ @Override
+ public final int bitsPerPixel() { return bitsPerPixel; }
+ @Override
+ public final int bitStride() { return bitStride; }
+ @Override
+ public final int bytesPerPixel() { return (7+bitStride)/8; }
+ @Override
+ public final CType[] componentOrder() { return compOrder; }
+ @Override
+ public final int find(final PixelFormat.CType s) { return PixelFormatUtil.find(s, compOrder, false /* mapRGB2Y */); }
+ @Override
+ public final int[] componentBitMask() { return compMask; }
+ @Override
+ public final int[] componentBitCount() { return compBitCount; }
+ @Override
+ public final int[] componentBitShift() { return compBitShift; }
+
+ @Override
+ public final int decodeSingleI32(final int shifted, final int cIdx) {
+ return ( shifted >>> compBitShift[cIdx] ) & compMask[cIdx];
+ }
+ @Override
+ public final int decodeSingleI64(final long shifted, final int cIdx) {
+ return ( (int)( 0xffffffffL & ( shifted >>> compBitShift[cIdx] ) ) ) & compMask[cIdx];
+ }
+ @Override
+ public final int encodeSingleI32(final int norm, final int cIdx) {
+ return ( norm & compMask[cIdx] ) << compBitShift[cIdx] ;
+ }
+ @Override
+ public final long encodeSingleI64(final int norm, final int cIdx) {
+ return ( 0xffffffffL & ( norm & compMask[cIdx] ) ) << compBitShift[cIdx] ;
+ }
+ @Override
+ public final int encode3CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32) {
+ return ( c1NormI32 & compMask[0] ) << compBitShift[0] |
+ ( c2NormI32 & compMask[1] ) << compBitShift[1] |
+ ( c3NormI32 & compMask[2] ) << compBitShift[2] ;
+ }
+ @Override
+ public final int encode4CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32, final int c4NormI32) {
+ return ( c1NormI32 & compMask[0] ) << compBitShift[0] |
+ ( c2NormI32 & compMask[1] ) << compBitShift[1] |
+ ( c3NormI32 & compMask[2] ) << compBitShift[2] |
+ ( c4NormI32 & compMask[3] ) << compBitShift[3] ;
+ }
+ @Override
+ public final int encodeSingleI8(final byte normI8, final int cIdx) {
+ return ( normI8 & compMask[cIdx] ) << compBitShift[cIdx] ;
+ }
+ @Override
+ public final int encode3CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8) {
+ return ( c1NormI8 & compMask[0] ) << compBitShift[0] |
+ ( c2NormI8 & compMask[1] ) << compBitShift[1] |
+ ( c3NormI8 & compMask[2] ) << compBitShift[2] ;
+ }
+ @Override
+ public final int encode4CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8, final byte c4NormI8) {
+ return ( c1NormI8 & compMask[0] ) << compBitShift[0] |
+ ( c2NormI8 & compMask[1] ) << compBitShift[1] |
+ ( c3NormI8 & compMask[2] ) << compBitShift[2] |
+ ( c4NormI8 & compMask[3] ) << compBitShift[3] ;
+ }
+
+ @Override
+ public final float toFloat(final int i32, final int cIdx, final boolean i32Shifted) {
+ if( i32Shifted ) {
+ return ( ( i32 >>> compBitShift[cIdx] ) & compMask[cIdx] ) / (float)( compMask[cIdx] ) ;
+ } else {
+ return ( i32 & compMask[cIdx] ) / (float)( compMask[cIdx] ) ;
+ }
+ }
+ @Override
+ public final int fromFloat(final float f, final int cIdx, final boolean shiftResult) {
+ final int v = (int)(f * compMask[cIdx] + 0.5f);
+ return shiftResult ? v << compBitShift[cIdx] : v;
+ }
+
+ @Override
+ public final int defaultValue(final int cIdx, final boolean shiftResult) {
+ final int v = ( CType.A == compOrder[cIdx] || CType.Y == compOrder[cIdx] )
+ ? compMask[cIdx] : 0;
+ return shiftResult ? v << compBitShift[cIdx] : v;
+ }
+
+ @Override
+ public final int hashCode() { return hashCode; }
+ private final int hashCodeImpl() {
+ // 31 * x == (x << 5) - x
+ int hash = 31 + bitStride;
+ hash = ((hash << 5) - hash) + bitsPerPixel;
+ hash = ((hash << 5) - hash) + compMask.length;
+ for(int i=compOrder.length-1; i>=0; i--) {
+ hash = ((hash << 5) - hash) + compOrder[i].ordinal();
+ }
+ for(int i=compMask.length-1; i>=0; i--) {
+ hash = ((hash << 5) - hash) + compMask[i];
+ }
+ for(int i=compBitShift.length-1; i>=0; i--) {
+ hash = ((hash << 5) - hash) + compBitShift[i];
+ }
+ return hash;
+ }
+
+ @Override
+ public final boolean equals(final Object obj) {
+ if(this == obj) { return true; }
+ if( obj instanceof PackedComposition ) {
+ final PackedComposition other = (PackedComposition) obj;
+ return bitStride == other.bitStride &&
+ bitsPerPixel == other.bitsPerPixel &&
+ Arrays.equals(compOrder, other.compOrder) &&
+ Arrays.equals(compMask, other.compMask) &&
+ Arrays.equals(compBitShift, other.compBitShift);
+ } else {
+ return false;
+ }
+ }
+ }
+
+ private static String toHexString(final int[] bitCount, final int[] mask, final int[] shift) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("[");
+ final int l = mask.length;
+ for(int i=0; i < l; i++) {
+ if(i > 0) {
+ sb.append(", ");
+ }
+ sb.append(bitCount[i]).append(": ").
+ append("0x").append(Integer.toHexString(mask[i])).append(" << ").append(shift[i]);
+ }
+ return sb.append("]").toString();
+ }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java
new file mode 100644
index 000000000..180f02d72
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelFormatUtil.java
@@ -0,0 +1,600 @@
+/**
+ * Copyright (c) 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.nativewindow.util;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.common.util.Bitstream;
+
+/**
+ * Pixel Rectangle Utilities.
+ *
+ * All conversion methods are endian independent.
+ *
+ */
+public class PixelFormatUtil {
+ private static boolean DEBUG = false;
+
+ public static class ComponentMap {
+ /**
+ * Contains the source index for each destination index,
+ * length is {@link Composition#componenCount()} of destination.
+ */
+ final int[] dst2src;
+ /**
+ * Contains the destination index for each source index,
+ * length is {@link Composition#componenCount()} of source.
+ */
+ final int[] src2dst;
+
+ /**
+ * Contains the source index of RGBA components.
+ */
+ final int[] srcRGBA;
+ final boolean hasSrcRGB;
+
+ public ComponentMap(final PixelFormat.Composition src, final PixelFormat.Composition dst) {
+ final int sCompCount = src.componenCount();
+ final int dCompCount = dst.componenCount();
+ final PixelFormat.CType[] sCompOrder = src.componentOrder();
+ final PixelFormat.CType[] dCompOrder = dst.componentOrder();
+
+ dst2src = new int[dCompCount];
+ for(int dIdx=0; dIdx= 0 && pool[i] != s) { i--; }
+
+ if( 0 > i && mapRGB2Y && 1 == pool.length && pool[0] == PixelFormat.CType.Y &&
+ ( PixelFormat.CType.R == s ||
+ PixelFormat.CType.G == s ||
+ PixelFormat.CType.B == s ) )
+ {
+ // Special case, fallback for RGB mapping -> LUMINANCE/Y
+ return 0;
+ } else {
+ return i;
+ }
+ }
+
+ /**
+ * Returns shifted bytes from the given {@code data} at given {@code offset}
+ * of maximal 4 {@code bytesPerPixel}.
+ * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
+ * @param data byte buffer covering complete pixel at position {@code offset}
+ * @param offset byte offset of pixel {@code data} start
+ * @return the shifted 32bit integer value of the pixel
+ */
+ public static int getShiftedI32(final int bytesPerPixel, final byte[] data, final int offset) {
+ if( bytesPerPixel <= 4 ) {
+ int shiftedI32 = 0;
+ for(int i=0; i 4");
+ }
+ }
+ /**
+ * Returns shifted bytes from the given {@code data} at given {@code offset}
+ * of maximal 8 {@code bytesPerPixel}.
+ * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
+ * @param data byte buffer covering complete pixel at position {@code offset}
+ * @param offset byte offset of pixel {@code data} start
+ * @return the shifted 64bit integer value of the pixel
+ */
+ public static long getShiftedI64(final int bytesPerPixel, final byte[] data, final int offset) {
+ if( bytesPerPixel <= 8 ) {
+ long shiftedI64 = 0;
+ for(int i=0; i 8");
+ }
+ }
+ /**
+ * Returns shifted bytes from the given {@code data} at current position
+ * of maximal 4 {@code bytesPerPixel}.
+ * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
+ * @param data byte buffer covering complete pixel at position {@code offset}
+ * @param retainDataPos if true, absolute {@link ByteBuffer#get(int)} is used and the {@code data} position stays unchanged.
+ * Otherwise relative {@link ByteBuffer#get()} is used and the {@code data} position changes.
+ * @return the shifted 32bit integer value of the pixel
+ */
+ public static int getShiftedI32(final int bytesPerPixel, final ByteBuffer data, final boolean retainDataPos) {
+ if( bytesPerPixel <= 4 ) {
+ int shiftedI32 = 0;
+ if( retainDataPos ) {
+ final int offset = data.position();
+ for(int i=0; i 4");
+ }
+ }
+ /**
+ * Returns shifted bytes from the given {@code data} at current position
+ * of maximal 8 {@code bytesPerPixel}.
+ * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
+ * @param data byte buffer covering complete pixel at position {@code offset}
+ * @param retainDataPos if true, absolute {@link ByteBuffer#get(int)} is used and the {@code data} position stays unchanged.
+ * Otherwise relative {@link ByteBuffer#get()} is used and the {@code data} position changes.
+ * @return the shifted 64bit integer value of the pixel
+ */
+ public static long getShiftedI64(final int bytesPerPixel, final ByteBuffer data, final boolean retainDataPos) {
+ if( bytesPerPixel <= 8 ) {
+ long shiftedI64 = 0;
+ if( retainDataPos ) {
+ final int offset = data.position();
+ for(int i=0; i 8");
+ }
+ }
+
+ /**
+ * Returns the {@link PixelFormat} with reversed components of fmt.
+ * If no reversed {@link PixelFormat} is available, returns fmt.
+ */
+ public static PixelFormat getReversed(final PixelFormat fmt) {
+ switch(fmt) {
+ case RGB565:
+ return PixelFormat.BGR565;
+ case BGR565:
+ return PixelFormat.RGB565;
+ case RGBA5551:
+ return PixelFormat.ABGR1555;
+ case ABGR1555:
+ return PixelFormat.RGBA5551;
+ case RGB888:
+ return PixelFormat.BGR888;
+ case BGR888:
+ return PixelFormat.RGB888;
+ case RGBA8888:
+ return PixelFormat.ABGR8888;
+ case ABGR8888:
+ return PixelFormat.RGBA8888;
+ case ARGB8888:
+ return PixelFormat.BGRA8888;
+ case BGRA8888:
+ return PixelFormat.ABGR8888;
+ default:
+ return fmt;
+ }
+ }
+
+ public static int convertToInt32(final PixelFormat dst_fmt, final byte r, final byte g, final byte b, final byte a) {
+ switch(dst_fmt) {
+ case LUMINANCE: {
+ final byte l = ( byte) ( ( ( ( 0xff & r ) + ( 0xff & g ) + ( 0xff & b ) ) / 3 ) * a );
+ return ( 0xff ) << 24 | ( 0xff & l ) << 16 | ( 0xff & l ) << 8 | ( 0xff & l );
+ }
+ case RGB888:
+ return ( 0xff ) << 24 | ( 0xff & b ) << 16 | ( 0xff & g ) << 8 | ( 0xff & r );
+ case BGR888:
+ return ( 0xff ) << 24 | ( 0xff & r ) << 16 | ( 0xff & g ) << 8 | ( 0xff & b );
+ case RGBA8888:
+ return ( 0xff & a ) << 24 | ( 0xff & b ) << 16 | ( 0xff & g ) << 8 | ( 0xff & r );
+ case ABGR8888:
+ return ( 0xff & r ) << 24 | ( 0xff & g ) << 16 | ( 0xff & b ) << 8 | ( 0xff & a );
+ case ARGB8888:
+ return ( 0xff & b ) << 24 | ( 0xff & g ) << 16 | ( 0xff & r ) << 8 | ( 0xff & a );
+ case BGRA8888:
+ return ( 0xff & a ) << 24 | ( 0xff & r ) << 16 | ( 0xff & g ) << 8 | ( 0xff & b );
+ default:
+ throw new InternalError("Unhandled format "+dst_fmt);
+ }
+ }
+
+ public static int convertToInt32(final PixelFormat dst_fmt, final PixelFormat src_fmt, final ByteBuffer src, int srcOff) {
+ final byte r, g, b, a;
+ switch(src_fmt) {
+ case LUMINANCE:
+ r = src.get(srcOff++); // R
+ g = r; // G
+ b = r; // B
+ a = (byte) 0xff; // A
+ break;
+ case RGB888:
+ r = src.get(srcOff++); // R
+ g = src.get(srcOff++); // G
+ b = src.get(srcOff++); // B
+ a = (byte) 0xff; // A
+ break;
+ case BGR888:
+ b = src.get(srcOff++); // B
+ g = src.get(srcOff++); // G
+ r = src.get(srcOff++); // R
+ a = (byte) 0xff; // A
+ break;
+ case RGBA8888:
+ r = src.get(srcOff++); // R
+ g = src.get(srcOff++); // G
+ b = src.get(srcOff++); // B
+ a = src.get(srcOff++); // A
+ break;
+ case ABGR8888:
+ a = src.get(srcOff++); // A
+ b = src.get(srcOff++); // B
+ g = src.get(srcOff++); // G
+ r = src.get(srcOff++); // R
+ break;
+ case ARGB8888:
+ a = src.get(srcOff++); // A
+ r = src.get(srcOff++); // R
+ g = src.get(srcOff++); // G
+ b = src.get(srcOff++); // B
+ break;
+ case BGRA8888:
+ b = src.get(srcOff++); // B
+ g = src.get(srcOff++); // G
+ r = src.get(srcOff++); // R
+ a = src.get(srcOff++); // A
+ break;
+ default:
+ throw new InternalError("Unhandled format "+src_fmt);
+ }
+ return convertToInt32(dst_fmt, r, g, b, a);
+ }
+
+ public static int convertToInt32(final PixelFormat dest_fmt, final PixelFormat src_fmt, final int src_pixel) {
+ final byte r, g, b, a;
+ switch(src_fmt) {
+ case LUMINANCE:
+ r = (byte) ( src_pixel ); // R
+ g = r; // G
+ b = r; // B
+ a = (byte) 0xff; // A
+ break;
+ case RGB888:
+ r = (byte) ( src_pixel ); // R
+ g = (byte) ( src_pixel >>> 8 ); // G
+ b = (byte) ( src_pixel >>> 16 ); // B
+ a = (byte) 0xff; // A
+ break;
+ case BGR888:
+ b = (byte) ( src_pixel ); // B
+ g = (byte) ( src_pixel >>> 8 ); // G
+ r = (byte) ( src_pixel >>> 16 ); // R
+ a = (byte) 0xff; // A
+ break;
+ case RGBA8888:
+ r = (byte) ( src_pixel ); // R
+ g = (byte) ( src_pixel >>> 8 ); // G
+ b = (byte) ( src_pixel >>> 16 ); // B
+ a = (byte) ( src_pixel >>> 24 ); // A
+ break;
+ case ABGR8888:
+ a = (byte) ( src_pixel ); // A
+ b = (byte) ( src_pixel >>> 8 ); // B
+ g = (byte) ( src_pixel >>> 16 ); // G
+ r = (byte) ( src_pixel >>> 24 ); // R
+ break;
+ case ARGB8888:
+ a = (byte) ( src_pixel ); // A
+ r = (byte) ( src_pixel >>> 8 ); // R
+ g = (byte) ( src_pixel >>> 16 ); // G
+ b = (byte) ( src_pixel >>> 24 ); // B
+ break;
+ case BGRA8888:
+ b = (byte) ( src_pixel ); // B
+ g = (byte) ( src_pixel >>> 8 ); // G
+ r = (byte) ( src_pixel >>> 16 ); // R
+ a = (byte) ( src_pixel >>> 24 ); // A
+ break;
+ default:
+ throw new InternalError("Unhandled format "+src_fmt);
+ }
+ return convertToInt32(dest_fmt, r, g, b, a);
+ }
+
+ public static PixelRectangle convert(final PixelRectangle src,
+ final PixelFormat destFmt, final int ddestStride, final boolean isGLOriented,
+ final boolean destIsDirect) {
+ final int width = src.getSize().getWidth();
+ final int height = src.getSize().getHeight();
+ final int bpp = destFmt.comp.bytesPerPixel();
+ final int destStride;
+ if( 0 != ddestStride ) {
+ destStride = ddestStride;
+ } else {
+ destStride = bpp * width;
+ }
+ final int capacity = destStride*height;
+ final ByteBuffer destBB = destIsDirect ? Buffers.newDirectByteBuffer(capacity) : ByteBuffer.allocate(capacity).order(src.getPixels().order());
+ convert(src, destBB, destFmt, isGLOriented, destStride);
+ return new PixelRectangle.GenericPixelRect(destFmt, src.getSize(), destStride, isGLOriented, destBB);
+ }
+
+ /**
+ * @param src
+ * @param dst_bb {@link ByteBuffer} sink
+ * @param dst_fmt destination {@link PixelFormat}
+ * @param dst_glOriented if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left,
+ * otherwise origin at top left.
+ * @param dst_lineStride line stride in byte-size for destination, i.e. byte count from one line to the next.
+ * Must be >= {@link PixelFormat.Composition#bytesPerPixel() dst_fmt.comp.bytesPerPixel()} * width
+ * or {@code zero} for default stride.
+ *
+ * @throws IllegalStateException
+ * @throws IllegalArgumentException if {@code src_lineStride} or {@code dst_lineStride} is invalid
+ */
+ public static void convert(final PixelRectangle src,
+ final ByteBuffer dst_bb, final PixelFormat dst_fmt, final boolean dst_glOriented, final int dst_lineStride)
+ throws IllegalStateException
+ {
+ convert(src.getSize().getWidth(), src.getSize().getHeight(),
+ src.getPixels(), src.getPixelformat(), src.isGLOriented(), src.getStride(),
+ dst_bb, dst_fmt, dst_glOriented, dst_lineStride);
+ }
+
+
+ /**
+ * @param width width of the to be converted pixel rectangle
+ * @param height height of the to be converted pixel rectangle
+ * @param src_bb {@link ByteBuffer} source
+ * @param src_fmt source {@link PixelFormat}
+ * @param src_glOriented if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left,
+ * otherwise origin at top left.
+ * @param src_lineStride line stride in byte-size for source, i.e. byte count from one line to the next.
+ * Must be >= {@link PixelFormat.Composition#bytesPerPixel() src_fmt.comp.bytesPerPixel()} * width
+ * or {@code zero} for default stride.
+ * @param dst_bb {@link ByteBuffer} sink
+ * @param dst_fmt destination {@link PixelFormat}
+ * @param dst_glOriented if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left,
+ * otherwise origin at top left.
+ * @param dst_lineStride line stride in byte-size for destination, i.e. byte count from one line to the next.
+ * Must be >= {@link PixelFormat.Composition#bytesPerPixel() dst_fmt.comp.bytesPerPixel()} * width
+ * or {@code zero} for default stride.
+ *
+ * @throws IllegalStateException
+ * @throws IllegalArgumentException if {@code src_lineStride} or {@code dst_lineStride} is invalid
+ */
+ public static void convert(final int width, final int height,
+ final ByteBuffer src_bb, final PixelFormat src_fmt, final boolean src_glOriented, int src_lineStride,
+ final ByteBuffer dst_bb, final PixelFormat dst_fmt, final boolean dst_glOriented, int dst_lineStride
+ ) throws IllegalStateException, IllegalArgumentException {
+ final PixelFormat.Composition src_comp = src_fmt.comp;
+ final PixelFormat.Composition dst_comp = dst_fmt.comp;
+ final int src_bpp = src_comp.bytesPerPixel();
+ final int dst_bpp = dst_comp.bytesPerPixel();
+
+ if( 0 != src_lineStride ) {
+ if( src_lineStride < src_bpp * width ) {
+ throw new IllegalArgumentException(String.format("Invalid %s stride %d, must be greater than bytesPerPixel %d * width %d",
+ "source", src_lineStride, src_bpp, width));
+ }
+ } else {
+ src_lineStride = src_bpp * width;
+ }
+ if( 0 != dst_lineStride ) {
+ if( dst_lineStride < dst_bpp * width ) {
+ throw new IllegalArgumentException(String.format("Invalid %s stride %d, must be greater than bytesPerPixel %d * width %d",
+ "destination", dst_lineStride, dst_bpp, width));
+ }
+ } else {
+ dst_lineStride = dst_bpp * width;
+ }
+
+ // final int src_comp_bitStride = src_comp.bitStride();
+ final int dst_comp_bitStride = dst_comp.bitStride();
+ final boolean vert_flip = src_glOriented != dst_glOriented;
+ final boolean fast_copy = src_comp.equals(dst_comp) && 0 == dst_comp_bitStride%8;
+ if( DEBUG ) {
+ System.err.println("XXX: size "+width+"x"+height+", fast_copy "+fast_copy);
+ System.err.println("XXX: SRC fmt "+src_fmt+", "+src_comp+", stride "+src_lineStride+", isGLOrient "+src_glOriented);
+ System.err.println("XXX: DST fmt "+dst_fmt+", "+dst_comp+", stride "+dst_lineStride+", isGLOrient "+dst_glOriented);
+ }
+
+ if( fast_copy ) {
+ // Fast copy
+ for(int y=0; y srcBitStream = new Bitstream(srcBBS, false /* outputMode */);
+ srcBitStream.setThrowIOExceptionOnEOF(true);
+
+ final Bitstream.ByteBufferStream dstBBS = new Bitstream.ByteBufferStream(dst_bb);
+ final Bitstream dstBitStream = new Bitstream(dstBBS, true /* outputMode */);
+ dstBitStream.setThrowIOExceptionOnEOF(true);
+
+ if( DEBUG ) {
+ System.err.println("XXX: cmap.dst2src "+Arrays.toString(cmap.dst2src));
+ System.err.println("XXX: cmap.src2dst "+Arrays.toString(cmap.src2dst));
+ System.err.println("XXX: cmap.srcRGBA "+Arrays.toString(cmap.srcRGBA));
+ System.err.println("XXX: srcBitStream "+srcBitStream);
+ System.err.println("XXX: dstBitStream "+dstBitStream);
+ }
+ try {
+ for(int y=0; y dstBitStream,
+ final PixelFormat.Composition srcComp,
+ final Bitstream srcBitStream) throws IllegalStateException, IOException {
+ final int sCompCount = srcComp.componenCount();
+ final int dCompCount = dstComp.componenCount();
+ final int[] sc = new int[sCompCount];
+ final int[] dcDef = new int[dCompCount];
+ final int[] srcCompBitCount = srcComp.componentBitCount();
+ final int[] srcCompBitMask = srcComp.componentBitMask();
+ final int[] dstCompBitCount = dstComp.componentBitCount();
+
+ // Fill w/ source values
+ for(int sIdx=0; sIdx Y conversion
+ final int r = sc[cmap.srcRGBA[0]];
+ final int g = sc[cmap.srcRGBA[1]];
+ final int b = sc[cmap.srcRGBA[2]];
+ final float rF = srcComp.toFloat(r, cmap.srcRGBA[0], false);
+ final float gF = srcComp.toFloat(g, cmap.srcRGBA[1], false);
+ final float bF = srcComp.toFloat(b, cmap.srcRGBA[2], false);
+ final int a;
+ final float aF;
+ /** if( 0 <= cmap.srcRGBA[3] ) { // disable premultiplied-alpha
+ a = sc[cmap.srcRGBA[3]];
+ aF = srcComp.toFloat(a, false, cmap.srcRGBA[3]);
+ } else */ {
+ a = 1;
+ aF = 1f;
+ }
+ final float lF = ( rF + gF + bF ) * aF / 3f;
+ final int v = dstComp.fromFloat(lF, 0, false);
+
+ dstBitStream.writeBits31(dstCompBitCount[0], v);
+ dstBitStream.skip(dstComp.bitStride() - dstComp.bitsPerPixel());
+ if( DEBUG ) {
+ if( srcBitStream.position() <= 8*4 ) {
+ System.err.printf("convert: rgb[a] -> Y: rgb 0x%02X 0x%02X 0x%02X 0x%02X -> %f %f %f %f"+
+ " -> %f -> dstC 0 0x%08X (%d bits: %s)%n",
+ r, g, b, a,
+ rF, gF, bF, aF,
+ lF, v, dstCompBitCount[0], Bitstream.toBinString(true, v, dstCompBitCount[0])
+ );
+ }
+ }
+ return;
+ }
+
+ for(int dIdx=0; dIdx %f -> dstC %d 0x%08X (%d bits: %s)%n",
+ sIdx, sc[sIdx], f, dIdx, v, dstCompBitCount[dIdx], Bitstream.toBinString(true, v, dstCompBitCount[dIdx]));
+ }
+ }
+ } else {
+ dstBitStream.writeBits31(dstCompBitCount[dIdx], dcDef[dIdx]);
+ if( DEBUG ) {
+ if( srcBitStream.position() <= 8*4 ) {
+ System.err.printf("convert: srcC %d: undef -> dstC %d 0x%08X (%d bits: %s)%n",
+ sIdx, dIdx, dcDef[dIdx], dstCompBitCount[dIdx], Bitstream.toBinString(true, dcDef[dIdx], dstCompBitCount[dIdx]));
+ }
+ }
+ }
+ }
+ dstBitStream.skip(dstComp.bitStride() - dstComp.bitsPerPixel());
+ return;
+ }
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelRectangle.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelRectangle.java
new file mode 100644
index 000000000..f58ba0ce2
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/PixelRectangle.java
@@ -0,0 +1,194 @@
+/**
+ * Copyright (c) 2014 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.nativewindow.util;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Pixel Rectangle identified by it's {@link #hashCode()}.
+ *
+ * The {@link #getPixels()} are assumed to be immutable.
+ *
+ */
+public interface PixelRectangle {
+ /**
+ *
+ * Computes a hash code over:
+ *
+ *
pixelformat
+ *
size
+ *
stride
+ *
isGLOriented
+ *
pixels
+ *
+ *
+ *
+ * The hashCode shall be computed only once with first call
+ * and stored for later retrieval to enhance performance.
+ *
+ *
+ * {@inheritDoc}
+ *
+ */
+ @Override
+ int hashCode();
+
+ /** Returns the {@link PixelFormat}. */
+ PixelFormat getPixelformat();
+
+ /** Returns the size, i.e. width and height. */
+ DimensionImmutable getSize();
+
+ /**
+ * Returns stride in byte-size, i.e. byte count from one line to the next.
+ *
+ * Must be >= {@link #getPixelformat()}.{@link PixelFormat#bytesPerPixel() bytesPerPixel()} * {@link #getSize()}.{@link DimensionImmutable#getWidth() getWidth()}.
+ *
+ */
+ int getStride();
+
+ /**
+ * Returns true if the memory is laid out in
+ * OpenGL's coordinate system, origin at bottom left.
+ * Otherwise returns false, i.e. origin at top left.
+ */
+ public boolean isGLOriented();
+
+ /** Returns the pixels. */
+ ByteBuffer getPixels();
+
+ @Override
+ String toString();
+
+ /**
+ * Generic PixelRectangle implementation
+ */
+ public static class GenericPixelRect implements PixelRectangle {
+ protected final PixelFormat pixelformat;
+ protected final DimensionImmutable size;
+ protected final int strideInBytes;
+ protected final boolean isGLOriented;
+ protected final ByteBuffer pixels;
+ private int hashCode = 0;
+ private volatile boolean hashCodeComputed = false;
+
+ /**
+ *
+ * @param pixelformat
+ * @param size
+ * @param strideInBytes stride in byte-size, i.e. byte count from one line to the next.
+ * If not zero, value must be >= width * bytes-per-pixel.
+ * If zero, stride is set to width * bytes-per-pixel.
+ * @param isGLOriented
+ * @param pixels
+ * @throws IllegalArgumentException if strideInBytes is invalid.
+ * @throws IndexOutOfBoundsException if pixels has insufficient bytes left
+ */
+ public GenericPixelRect(final PixelFormat pixelformat, final DimensionImmutable size, int strideInBytes, final boolean isGLOriented, final ByteBuffer pixels)
+ throws IllegalArgumentException, IndexOutOfBoundsException
+ {
+ if( 0 != strideInBytes ) {
+ if( strideInBytes < pixelformat.comp.bytesPerPixel() * size.getWidth()) {
+ throw new IllegalArgumentException("Invalid stride "+strideInBytes+", must be greater than bytesPerPixel "+pixelformat.comp.bytesPerPixel()+" * width "+size.getWidth());
+ }
+ } else {
+ strideInBytes = pixelformat.comp.bytesPerPixel() * size.getWidth();
+ }
+ final int reqBytes = strideInBytes * size.getHeight();
+ if( pixels.limit() < reqBytes ) {
+ throw new IndexOutOfBoundsException("Dest buffer has insufficient bytes left, needs "+reqBytes+": "+pixels);
+ }
+ this.pixelformat = pixelformat;
+ this.size = size;
+ this.strideInBytes = strideInBytes;
+ this.isGLOriented = isGLOriented;
+ this.pixels = pixels;
+ }
+
+ /**
+ * Copy ctor validating src.
+ * @param src
+ * @throws IllegalArgumentException if strideInBytes is invalid.
+ * @throws IndexOutOfBoundsException if pixels has insufficient bytes left
+ */
+ public GenericPixelRect(final PixelRectangle src)
+ throws IllegalArgumentException, IndexOutOfBoundsException
+ {
+ this(src.getPixelformat(), src.getSize(), src.getStride(), src.isGLOriented(), src.getPixels());
+ }
+
+ @Override
+ public int hashCode() {
+ if( !hashCodeComputed ) { // DBL CHECKED OK VOLATILE
+ synchronized (this) {
+ if( !hashCodeComputed ) {
+ // 31 * x == (x << 5) - x
+ int hash = pixelformat.comp.hashCode();
+ hash = ((hash << 5) - hash) + size.hashCode();
+ hash = ((hash << 5) - hash) + strideInBytes;
+ hash = ((hash << 5) - hash) + ( isGLOriented ? 1 : 0);
+ hashCode = ((hash << 5) - hash) + pixels.hashCode();
+ hashCodeComputed = true;
+ }
+ }
+ }
+ return hashCode;
+ }
+
+ @Override
+ public PixelFormat getPixelformat() {
+ return pixelformat;
+ }
+
+ @Override
+ public DimensionImmutable getSize() {
+ return size;
+ }
+
+ @Override
+ public int getStride() {
+ return strideInBytes;
+ }
+
+ @Override
+ public boolean isGLOriented() {
+ return isGLOriented;
+ }
+
+ @Override
+ public ByteBuffer getPixels() {
+ return pixels;
+ }
+
+ @Override
+ public final String toString() {
+ return "PixelRect[obj 0x"+Integer.toHexString(super.hashCode())+", "+pixelformat+", "+size+", stride "+strideInBytes+", isGLOrient "+isGLOriented+", pixels "+pixels+"]";
+ }
+ }
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/Point.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/Point.java
new file mode 100644
index 000000000..fc5465bbf
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/Point.java
@@ -0,0 +1,190 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow.util;
+
+public class Point implements Cloneable, PointImmutable {
+ int x;
+ int y;
+
+ public Point(final int x, final int y) {
+ this.x=x;
+ this.y=y;
+ }
+
+ public Point() {
+ this(0, 0);
+ }
+
+ @Override
+ public Object cloneMutable() {
+ return clone();
+ }
+
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (final CloneNotSupportedException ex) {
+ throw new InternalError();
+ }
+ }
+
+ @Override
+ public int compareTo(final PointImmutable d) {
+ final int sq = x*y;
+ final int xsq = d.getX()*d.getY();
+
+ if(sq > xsq) {
+ return 1;
+ } else if(sq < xsq) {
+ return -1;
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if(this == obj) { return true; }
+ if (obj instanceof Point) {
+ final Point p = (Point)obj;
+ return y == p.y && x == p.x;
+ }
+ return false;
+ }
+
+ @Override
+ public final int getX() {
+ return x;
+ }
+
+ @Override
+ public final int getY() {
+ return y;
+ }
+
+ @Override
+ public int hashCode() {
+ // 31 * x == (x << 5) - x
+ int hash = 31 + x;
+ hash = ((hash << 5) - hash) + y;
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ return x + " / " + y;
+ }
+
+ public final void set(final int x, final int y) { this.x = x; this.y = y; }
+ public final void setX(final int x) { this.x = x; }
+ public final void setY(final int y) { this.y = y; }
+
+ /**
+ * Translate this instance's x- and y-components,
+ * i.e. add the values of the given delta point to them.
+ * @param pd delta point
+ * @return this instance for scaling
+ */
+ public final Point translate(final Point pd) {
+ x += pd.x ;
+ y += pd.y ;
+ return this;
+ }
+
+ /**
+ * Translate this instance's x- and y-components,
+ * i.e. add the given deltas to them.
+ * @param dx delta for x
+ * @param dy delta for y
+ * @return this instance for scaling
+ */
+ public final Point translate(final int dx, final int dy) {
+ x += dx ;
+ y += dy ;
+ return this;
+ }
+
+ /**
+ * Scale this instance's x- and y-components,
+ * i.e. multiply them by the given scale factors.
+ * @param sx scale factor for x
+ * @param sy scale factor for y
+ * @return this instance for scaling
+ */
+ public final Point scale(final int sx, final int sy) {
+ x *= sx ;
+ y *= sy ;
+ return this;
+ }
+
+ /**
+ * Scale this instance's x- and y-components,
+ * i.e. multiply them by the given scale factors.
+ *
+ * The product is rounded back to integer.
+ *
+ * @param sx scale factor for x
+ * @param sy scale factor for y
+ * @return this instance for scaling
+ */
+ public final Point scale(final float sx, final float sy) {
+ x = (int)(x * sx + 0.5f);
+ y = (int)(y * sy + 0.5f);
+ return this;
+ }
+
+ /**
+ * Inverse scale this instance's x- and y-components,
+ * i.e. divide them by the given scale factors.
+ * @param sx inverse scale factor for x
+ * @param sy inverse scale factor for y
+ * @return this instance for scaling
+ */
+ public final Point scaleInv(final int sx, final int sy) {
+ x /= sx ;
+ y /= sy ;
+ return this;
+ }
+ /**
+ * Inverse scale this instance's x- and y-components,
+ * i.e. divide them by the given scale factors.
+ *
+ * The product is rounded back to integer.
+ *
+ * @param sx inverse scale factor for x
+ * @param sy inverse scale factor for y
+ * @return this instance for scaling
+ */
+ public final Point scaleInv(final float sx, final float sy) {
+ x = (int)(x / sx + 0.5f);
+ y = (int)(y / sy + 0.5f);
+ return this;
+ }
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/PointImmutable.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/PointImmutable.java
new file mode 100644
index 000000000..59372f67d
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/PointImmutable.java
@@ -0,0 +1,63 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow.util;
+
+import com.jogamp.common.type.WriteCloneable;
+
+/** Immutable Point interface */
+public interface PointImmutable extends WriteCloneable, Comparable {
+
+ int getX();
+
+ int getY();
+
+ /**
+ *
+ * Compares the square of the position.
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public int compareTo(final PointImmutable d);
+
+ /**
+ * Checks whether two points objects are equal. Two instances
+ * of PointReadOnly are equal if the two components
+ * y and x are equal.
+ * @return true if the two points are equal;
+ * otherwise false.
+ */
+ @Override
+ public boolean equals(Object obj);
+
+ @Override
+ public int hashCode();
+
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java
new file mode 100644
index 000000000..33a1955e8
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/Rectangle.java
@@ -0,0 +1,237 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow.util;
+
+import java.util.List;
+
+public class Rectangle implements Cloneable, RectangleImmutable {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ public Rectangle() {
+ this(0, 0, 0, 0);
+ }
+
+ public Rectangle(final int x, final int y, final int width, final int height) {
+ this.x=x;
+ this.y=y;
+ this.width=width;
+ this.height=height;
+ }
+
+ @Override
+ public Object cloneMutable() {
+ return clone();
+ }
+
+ @Override
+ protected Object clone() {
+ try {
+ return super.clone();
+ } catch (final CloneNotSupportedException ex) {
+ throw new InternalError();
+ }
+ }
+
+ @Override
+ public final int getX() { return x; }
+ @Override
+ public final int getY() { return y; }
+ @Override
+ public final int getWidth() { return width; }
+ @Override
+ public final int getHeight() { return height; }
+
+ public final void set(final int x, final int y, final int width, final int height) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+ public final void set(final Rectangle s) {
+ this.x = s.x;
+ this.y = s.y;
+ this.width = s.width;
+ this.height = s.height;
+ }
+ public final void setX(final int x) { this.x = x; }
+ public final void setY(final int y) { this.y = y; }
+ public final void setWidth(final int width) { this.width = width; }
+ public final void setHeight(final int height) { this.height = height; }
+
+ @Override
+ public final RectangleImmutable union(final RectangleImmutable r) {
+ return union(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight());
+ }
+ @Override
+ public final RectangleImmutable union(final int rx1, final int ry1, final int rx2, final int ry2) {
+ final int x1 = Math.min(x, rx1);
+ final int y1 = Math.min(y, ry1);
+ final int x2 = Math.max(x + width, rx2);
+ final int y2 = Math.max(y + height, ry2);
+ return new Rectangle(x1, y1, x2 - x1, y2 - y1);
+ }
+ /**
+ * Calculates the union of the given rectangles, stores it in this instance and returns this instance.
+ * @param rectangles given list of rectangles
+ * @return this instance holding the union of given rectangles.
+ */
+ public final Rectangle union(final List rectangles) {
+ int x1=Integer.MAX_VALUE, y1=Integer.MAX_VALUE;
+ int x2=Integer.MIN_VALUE, y2=Integer.MIN_VALUE;
+ for(int i=rectangles.size()-1; i>=0; i--) {
+ final RectangleImmutable vp = rectangles.get(i);
+ x1 = Math.min(x1, vp.getX());
+ x2 = Math.max(x2, vp.getX() + vp.getWidth());
+ y1 = Math.min(y1, vp.getY());
+ y2 = Math.max(y2, vp.getY() + vp.getHeight());
+ }
+ set(x1, y1, x2 - x1, y2 - y1);
+ return this;
+ }
+
+ @Override
+ public final RectangleImmutable intersection(final RectangleImmutable r) {
+ return intersection(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight());
+ }
+ @Override
+ public final RectangleImmutable intersection(final int rx1, final int ry1, final int rx2, final int ry2) {
+ final int x1 = Math.max(x, rx1);
+ final int y1 = Math.max(y, ry1);
+ final int x2 = Math.min(x + width, rx2);
+ final int y2 = Math.min(y + height, ry2);
+ final int ix, iy, iwidth, iheight;
+ if( x2 < x1 ) {
+ ix = 0;
+ iwidth = 0;
+ } else {
+ ix = x1;
+ iwidth = x2 - x1;
+ }
+ if( y2 < y1 ) {
+ iy = 0;
+ iheight = 0;
+ } else {
+ iy = y1;
+ iheight = y2 - y1;
+ }
+ return new Rectangle (ix, iy, iwidth, iheight);
+ }
+ @Override
+ public final float coverage(final RectangleImmutable r) {
+ final RectangleImmutable isect = intersection(r);
+ final float sqI = isect.getWidth()*isect.getHeight();
+ final float sqT = width*height;
+ return sqI / sqT;
+ }
+
+ /**
+ * Scale this instance's components,
+ * i.e. multiply them by the given scale factors.
+ * @param sx scale factor for x
+ * @param sy scale factor for y
+ * @return this instance for scaling
+ */
+ public final Rectangle scale(final int sx, final int sy) {
+ x *= sx ;
+ y *= sy ;
+ width *= sx ;
+ height *= sy ;
+ return this;
+ }
+
+ /**
+ * Inverse scale this instance's components,
+ * i.e. divide them by the given scale factors.
+ * @param sx inverse scale factor for x
+ * @param sy inverse scale factor for y
+ * @return this instance for scaling
+ */
+ public final Rectangle scaleInv(final int sx, final int sy) {
+ x /= sx ;
+ y /= sy ;
+ width /= sx ;
+ height /= sy ;
+ return this;
+ }
+
+ @Override
+ public int compareTo(final RectangleImmutable d) {
+ {
+ final int sq = width*height;
+ final int xsq = d.getWidth()*d.getHeight();
+
+ if(sq > xsq) {
+ return 1;
+ } else if(sq < xsq) {
+ return -1;
+ }
+ }
+ {
+ final int sq = x*y;
+ final int xsq = d.getX()*d.getY();
+
+ if(sq > xsq) {
+ return 1;
+ } else if(sq < xsq) {
+ return -1;
+ }
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if(this == obj) { return true; }
+ if (obj instanceof Rectangle) {
+ final Rectangle rect = (Rectangle)obj;
+ return (y == rect.y) && (x == rect.x) &&
+ (height == rect.height) && (width == rect.width);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ final int sum1 = x + height;
+ final int sum2 = width + y;
+ final int val1 = sum1 * (sum1 + 1)/2 + x;
+ final int val2 = sum2 * (sum2 + 1)/2 + y;
+ final int sum3 = val1 + val2;
+ return sum3 * (sum3 + 1)/2 + val2;
+ }
+
+ @Override
+ public String toString() {
+ return "[ "+x+" / "+y+" "+width+" x "+height+" ]";
+ }
+}
+
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/RectangleImmutable.java
new file mode 100644
index 000000000..ff2209598
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/RectangleImmutable.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow.util;
+
+import com.jogamp.common.type.WriteCloneable;
+
+/** Immutable Rectangle interface */
+public interface RectangleImmutable extends WriteCloneable, Comparable {
+
+ int getHeight();
+
+ int getWidth();
+
+ int getX();
+
+ int getY();
+
+ /** Returns the union of this rectangle and the given rectangle. */
+ RectangleImmutable union(final RectangleImmutable r);
+ /** Returns the union of this rectangleand the given coordinates. */
+ RectangleImmutable union(final int rx1, final int ry1, final int rx2, final int ry2);
+ /** Returns the intersection of this rectangleand the given rectangle. */
+ RectangleImmutable intersection(RectangleImmutable r);
+ /** Returns the intersection of this rectangleand the given coordinates. */
+ RectangleImmutable intersection(final int rx1, final int ry1, final int rx2, final int ry2);
+ /**
+ * Returns the coverage of given rectangle w/ this this one, i.e. between 0.0 and 1.0.
+ *
+ * Compares square of size 1st, if equal the square of position.
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public int compareTo(final RectangleImmutable d);
+
+ /**
+ * Checks whether two rect objects are equal. Two instances
+ * of Rectangle are equal if the four integer values
+ * of the fields y, x,
+ * height, and width are all equal.
+ * @return true if the two rectangles are equal;
+ * otherwise false.
+ */
+ @Override
+ boolean equals(Object obj);
+
+ @Override
+ int hashCode();
+
+}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/util/SurfaceSize.java
new file mode 100644
index 000000000..b9e6ded95
--- /dev/null
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/util/SurfaceSize.java
@@ -0,0 +1,113 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.nativewindow.util;
+
+/**
+ * Immutable SurfaceSize Class, consisting of it's read only components:
+ *
+ *
{@link com.jogamp.nativewindow.util.DimensionImmutable size in pixels}
+ *
bits per pixel
+ *
+ */
+public class SurfaceSize implements Comparable {
+ final DimensionImmutable resolution;
+ final int bitsPerPixel;
+
+ public SurfaceSize(final DimensionImmutable resolution, final int bitsPerPixel) {
+ if(null==resolution || bitsPerPixel<=0) {
+ throw new IllegalArgumentException("resolution must be set and bitsPerPixel greater 0");
+ }
+ this.resolution=resolution;
+ this.bitsPerPixel=bitsPerPixel;
+ }
+
+ /** Returns the resolution in pixel units */
+ public final DimensionImmutable getResolution() {
+ return resolution;
+ }
+
+ public final int getBitsPerPixel() {
+ return bitsPerPixel;
+ }
+
+ @Override
+ public final String toString() {
+ return "[ "+resolution+" pixels x "+bitsPerPixel+" bpp ]";
+ }
+
+ /**
+ *
+ * Compares {@link DimensionImmutable#compareTo(DimensionImmutable) resolution} 1st, if equal the bitsPerPixel.
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public int compareTo(final SurfaceSize ssz) {
+ final int rres = resolution.compareTo(ssz.getResolution());
+ if( 0 != rres ) {
+ return rres;
+ }
+ final int xbpp = ssz.getBitsPerPixel();
+ if(bitsPerPixel > xbpp) {
+ return 1;
+ } else if(bitsPerPixel < xbpp) {
+ return -1;
+ }
+ return 0;
+ }
+
+ /**
+ * Checks whether two size objects are equal. Two instances
+ * of SurfaceSize are equal if the two components
+ * resolution and bitsPerPixel
+ * are equal.
+ * @return true if the two dimensions are equal;
+ * otherwise false.
+ */
+ @Override
+ public final boolean equals(final Object obj) {
+ if(this == obj) { return true; }
+ if (obj instanceof SurfaceSize) {
+ final SurfaceSize p = (SurfaceSize)obj;
+ return getResolution().equals(p.getResolution()) &&
+ getBitsPerPixel() == p.getBitsPerPixel();
+ }
+ return false;
+ }
+
+ @Override
+ public final int hashCode() {
+ // 31 * x == (x << 5) - x
+ int hash = getResolution().hashCode();
+ hash = ((hash << 5) - hash) + getBitsPerPixel();
+ return hash;
+ }
+}
+
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
deleted file mode 100644
index 684f1f86a..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.nativewindow;
-
-/** A marker interface describing a graphics configuration, visual, or
- pixel format in a toolkit-independent manner. */
-public interface AbstractGraphicsConfiguration extends VisualIDHolder, Cloneable {
- public Object clone();
-
- /**
- * Return the screen this graphics configuration is valid for
- */
- public AbstractGraphicsScreen getScreen();
-
- /**
- * Return the capabilities reflecting this graphics configuration,
- * which may differ from the capabilities used to choose this configuration.
- *
- * @return An immutable instance of the Capabilities to avoid mutation by
- * the user.
- */
- public CapabilitiesImmutable getChosenCapabilities();
-
- /**
- * Return the capabilities used to choose this graphics configuration.
- *
- * These may be used to reconfigure the NativeWindow in case
- * the device changes in a multiple screen environment.
- *
- * @return An immutable instance of the Capabilities to avoid mutation by
- * the user.
- */
- public CapabilitiesImmutable getRequestedCapabilities();
-
- /**
- * In case the implementation utilizes a delegation pattern to wrap abstract toolkits,
- * this method shall return the native {@link AbstractGraphicsConfiguration},
- * otherwise this instance.
- * @see NativeSurface#getGraphicsConfiguration()
- */
- public AbstractGraphicsConfiguration getNativeGraphicsConfiguration();
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
deleted file mode 100644
index 7b630b1ea..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.nativewindow;
-
-import jogamp.nativewindow.Debug;
-
-/** A interface describing a graphics device in a
- toolkit-independent manner.
- */
-public interface AbstractGraphicsDevice extends Cloneable {
- public static final boolean DEBUG = Debug.debug("GraphicsDevice");
-
- /** Dummy connection value for a default connection where no native support for multiple devices is available */
- public static String DEFAULT_CONNECTION = "decon";
-
- /** Dummy connection value for an external connection where no native support for multiple devices is available */
- public static String EXTERNAL_CONNECTION = "excon";
-
- /** Default unit id for the 1st device: 0 */
- public static int DEFAULT_UNIT = 0;
-
- public Object clone();
-
- /**
- * Returns the type of the underlying subsystem, ie
- * NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..
- */
- public String getType();
-
- /**
- * Returns the semantic GraphicsDevice connection.
- * On platforms supporting remote devices, eg via tcp/ip network,
- * the implementation shall return a unique name for each remote address.
- * On X11 for example, the connection string should be as the following example.
- *
- *
:0.0 for a local connection
- *
remote.host.net:0.0 for a remote connection
- *
- *
- * To support multiple local device, see {@link #getUnitID()}.
- */
- public String getConnection();
-
- /**
- * Returns the graphics device unit ID.
- * The unit ID support multiple graphics device configurations
- * on a local machine.
- * To support remote device, see {@link #getConnection()}.
- * @return
- */
- public int getUnitID();
-
- /**
- * Returns a unique ID object of this device using {@link #getType() type},
- * {@link #getConnection() connection} and {@link #getUnitID() unitID} as it's key components.
- *
- * The unique ID does not reflect the instance of the device, hence the handle is not included.
- * The unique ID may be used as a key for semantic device mapping.
- *
- *
- * The returned string object reference is unique using {@link String#intern()}
- * and hence can be used as a key itself.
- *
- */
- public String getUniqueID();
-
- /**
- * Returns the native handle of the underlying native device,
- * if such thing exist.
- */
- public long getHandle();
-
- /**
- * Optionally locking the device, utilizing eg {@link com.jogamp.nativewindow.ToolkitLock#lock()}.
- * The lock implementation must be recursive.
- */
- public void lock();
-
- /**
- * Optionally unlocking the device, utilizing eg {@link com.jogamp.nativewindow.ToolkitLock#unlock()}.
- * The lock implementation must be recursive.
- *
- * @throws RuntimeException in case the lock is not acquired by this thread.
- */
- public void unlock();
-
- /**
- * @throws RuntimeException if current thread does not hold the lock
- */
- public void validateLocked() throws RuntimeException;
-
- /**
- * Optionally [re]opening the device if handle is null.
- *
- * The default implementation is a NOP.
- *
- *
- * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice}
- * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice}
- * issue the native open operation in case handle is null.
- *
- *
- * @return true if the handle was null and opening was successful, otherwise false.
- */
- public boolean open();
-
- /**
- * Optionally closing the device if handle is not null.
- *
- * The default implementation {@link ToolkitLock#dispose() dispose} it's {@link ToolkitLock} and sets the handle to null.
- *
- *
- * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice}
- * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice}
- * issue the native close operation or skip it depending on the {@link #isHandleOwner() handles's ownership}.
- *
- *
- * @return true if the handle was not null and closing was successful, otherwise false.
- */
- public boolean close();
-
- /**
- * @return true if instance owns the handle to issue {@link #close()}, otherwise false.
- */
- public boolean isHandleOwner();
-
- public void clearHandleOwner();
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java
deleted file mode 100644
index 7767cf9e4..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.nativewindow;
-
-/** A interface describing a graphics screen in a
- toolkit-independent manner.
- */
-
-public interface AbstractGraphicsScreen extends Cloneable {
- public Object clone();
-
- /**
- * Return the device this graphics configuration is valid for
- */
- public AbstractGraphicsDevice getDevice();
-
- /** Returns the screen index this graphics screen is valid for
- */
- public int getIndex();
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
deleted file mode 100644
index fa172b201..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.nativewindow;
-
-/** Specifies a set of capabilities that a window's rendering context
- must support, such as color depth per channel. It currently
- contains the minimal number of routines which allow configuration
- on all supported window systems. */
-public class Capabilities implements CapabilitiesImmutable, Cloneable {
- protected final static String na_str = "----" ;
-
- private int redBits = 8;
- private int greenBits = 8;
- private int blueBits = 8;
- private int alphaBits = 0;
-
- // Support for transparent windows containing OpenGL content
- private boolean backgroundOpaque = true;
- private int transparentValueRed = 0;
- private int transparentValueGreen = 0;
- private int transparentValueBlue = 0;
- private int transparentValueAlpha = 0;
-
- // Switch for on- or offscreen
- private boolean onscreen = true;
-
- // offscreen bitmap mode
- private boolean isBitmap = false;
-
- /** Creates a Capabilities object. All attributes are in a default
- state.
- */
- public Capabilities() {}
-
- @Override
- public Object cloneMutable() {
- return clone();
- }
-
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (final CloneNotSupportedException e) {
- throw new NativeWindowException(e);
- }
- }
-
- /**
- * Copies all {@link Capabilities} values
- * from source into this instance.
- * @return this instance
- */
- public Capabilities copyFrom(final CapabilitiesImmutable other) {
- redBits = other.getRedBits();
- greenBits = other.getGreenBits();
- blueBits = other.getBlueBits();
- alphaBits = other.getAlphaBits();
- backgroundOpaque = other.isBackgroundOpaque();
- onscreen = other.isOnscreen();
- isBitmap = other.isBitmap();
- transparentValueRed = other.getTransparentRedValue();
- transparentValueGreen = other.getTransparentGreenValue();
- transparentValueBlue = other.getTransparentBlueValue();
- transparentValueAlpha = other.getTransparentAlphaValue();
- return this;
- }
-
- @Override
- public int hashCode() {
- // 31 * x == (x << 5) - x
- int hash = 31 + this.redBits;
- hash = ((hash << 5) - hash) + ( this.onscreen ? 1 : 0 );
- hash = ((hash << 5) - hash) + ( this.isBitmap ? 1 : 0 );
- hash = ((hash << 5) - hash) + this.greenBits;
- hash = ((hash << 5) - hash) + this.blueBits;
- hash = ((hash << 5) - hash) + this.alphaBits;
- hash = ((hash << 5) - hash) + ( this.backgroundOpaque ? 1 : 0 );
- hash = ((hash << 5) - hash) + this.transparentValueRed;
- hash = ((hash << 5) - hash) + this.transparentValueGreen;
- hash = ((hash << 5) - hash) + this.transparentValueBlue;
- hash = ((hash << 5) - hash) + this.transparentValueAlpha;
- return hash;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if(this == obj) { return true; }
- if(!(obj instanceof CapabilitiesImmutable)) {
- return false;
- }
- final CapabilitiesImmutable other = (CapabilitiesImmutable)obj;
- boolean res = other.getRedBits()==redBits &&
- other.getGreenBits()==greenBits &&
- other.getBlueBits()==blueBits &&
- other.getAlphaBits()==alphaBits &&
- other.isBackgroundOpaque()==backgroundOpaque &&
- other.isOnscreen()==onscreen &&
- other.isBitmap()==isBitmap;
- if(res && !backgroundOpaque) {
- res = other.getTransparentRedValue()==transparentValueRed &&
- other.getTransparentGreenValue()==transparentValueGreen &&
- other.getTransparentBlueValue()==transparentValueBlue &&
- other.getTransparentAlphaValue()==transparentValueAlpha;
- }
-
- return res;
- }
-
- /**
- * Comparing RGBA values only
- **/
- @Override
- public int compareTo(final CapabilitiesImmutable caps) {
- /**
- if ( ! ( o instanceof CapabilitiesImmutable ) ) {
- Class> c = (null != o) ? o.getClass() : null ;
- throw new ClassCastException("Not a CapabilitiesImmutable object, but " + c);
- }
- final CapabilitiesImmutable caps = (CapabilitiesImmutable) o; */
-
- final int rgba = redBits * greenBits * blueBits * ( alphaBits + 1 );
-
- final int xrgba = caps.getRedBits() * caps.getGreenBits() * caps.getBlueBits() * ( caps.getAlphaBits() + 1 );
-
- if(rgba > xrgba) {
- return 1;
- } else if(rgba < xrgba) {
- return -1;
- }
-
- return 0; // they are equal: RGBA
- }
-
- @Override
- public int getVisualID(final VIDType type) throws NativeWindowException {
- switch(type) {
- case INTRINSIC:
- case NATIVE:
- return VisualIDHolder.VID_UNDEFINED;
- default:
- throw new NativeWindowException("Invalid type <"+type+">");
- }
- }
-
- @Override
- public final int getRedBits() {
- return redBits;
- }
-
- /** Sets the number of bits requested for the color buffer's red
- component. On some systems only the color depth, which is the
- sum of the red, green, and blue bits, is considered. */
- public void setRedBits(final int redBits) {
- this.redBits = redBits;
- }
-
- @Override
- public final int getGreenBits() {
- return greenBits;
- }
-
- /** Sets the number of bits requested for the color buffer's green
- component. On some systems only the color depth, which is the
- sum of the red, green, and blue bits, is considered. */
- public void setGreenBits(final int greenBits) {
- this.greenBits = greenBits;
- }
-
- @Override
- public final int getBlueBits() {
- return blueBits;
- }
-
- /** Sets the number of bits requested for the color buffer's blue
- component. On some systems only the color depth, which is the
- sum of the red, green, and blue bits, is considered. */
- public void setBlueBits(final int blueBits) {
- this.blueBits = blueBits;
- }
-
- @Override
- public final int getAlphaBits() {
- return alphaBits;
- }
-
- /**
- * Sets the number of bits requested for the color buffer's alpha
- * component. On some systems only the color depth, which is the
- * sum of the red, green, and blue bits, is considered.
- *
- * Note: If alpha bits are zero, they are set to one
- * by {@link #setBackgroundOpaque(boolean)} and it's OpenGL specialization GLCapabilities::setSampleBuffers(boolean).
- * Ensure to call this method after the above to ensure a zero value.
- * The above automated settings takes into account, that the user calls this method to request alpha bits,
- * not to reflect a current state. Nevertheless if this is the case - call it at last.
- *
- */
- public void setAlphaBits(final int alphaBits) {
- this.alphaBits = alphaBits;
- }
-
- /**
- * Sets whether the surface shall be opaque or translucent.
- *
- * Platform implementations may need an alpha component in the surface (eg. Windows),
- * or expect pre-multiplied alpha values (eg. X11/XRender).
- * To unify the experience, this method also invokes {@link #setAlphaBits(int) setAlphaBits(1)}
- * if {@link #getAlphaBits()} == 0.
- * Please note that in case alpha is required on the platform the
- * clear color shall have an alpha lower than 1.0 to allow anything shining through.
- *
- *
- * Mind that translucency may cause a performance penalty
- * due to the composite work required by the window manager.
- *
- */
- public void setBackgroundOpaque(final boolean opaque) {
- backgroundOpaque = opaque;
- if(!opaque && getAlphaBits()==0) {
- setAlphaBits(1);
- }
- }
-
- @Override
- public final boolean isBackgroundOpaque() {
- return backgroundOpaque;
- }
-
- /**
- * Sets whether the surface shall be on- or offscreen.
- *
- * Defaults to true.
- *
- *
- * If requesting an offscreen surface without further selection of it's mode,
- * e.g. FBO, Pbuffer or {@link #setBitmap(boolean) bitmap},
- * the implementation will choose the best available offscreen mode.
- *
- * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)}.
- *
- *
- * Defaults to false.
- *
- *
- * Requesting offscreen bitmap mode disables the offscreen auto selection.
- *
- */
- public void setBitmap(final boolean enable) {
- if(enable) {
- setOnscreen(false);
- }
- isBitmap = enable;
- }
-
- @Override
- public boolean isBitmap() {
- return isBitmap;
- }
-
- @Override
- public final int getTransparentRedValue() { return transparentValueRed; }
-
- @Override
- public final int getTransparentGreenValue() { return transparentValueGreen; }
-
- @Override
- public final int getTransparentBlueValue() { return transparentValueBlue; }
-
- @Override
- public final int getTransparentAlphaValue() { return transparentValueAlpha; }
-
- /** Sets the transparent red value for the frame buffer configuration,
- ranging from 0 to the maximum frame buffer value for red.
- This value is ignored if {@link #isBackgroundOpaque()} equals true.
- It defaults to half of the frambuffer value for red.
- A value of -1 is interpreted as any value. */
- public void setTransparentRedValue(final int transValueRed) { transparentValueRed=transValueRed; }
-
- /** Sets the transparent green value for the frame buffer configuration,
- ranging from 0 to the maximum frame buffer value for green.
- This value is ignored if {@link #isBackgroundOpaque()} equals true.
- It defaults to half of the frambuffer value for green.
- A value of -1 is interpreted as any value. */
- public void setTransparentGreenValue(final int transValueGreen) { transparentValueGreen=transValueGreen; }
-
- /** Sets the transparent blue value for the frame buffer configuration,
- ranging from 0 to the maximum frame buffer value for blue.
- This value is ignored if {@link #isBackgroundOpaque()} equals true.
- It defaults to half of the frambuffer value for blue.
- A value of -1 is interpreted as any value. */
- public void setTransparentBlueValue(final int transValueBlue) { transparentValueBlue=transValueBlue; }
-
- /** Sets the transparent alpha value for the frame buffer configuration,
- ranging from 0 to the maximum frame buffer value for alpha.
- This value is ignored if {@link #isBackgroundOpaque()} equals true.
- It defaults to half of the frambuffer value for alpha.
- A value of -1 is interpreted as any value. */
- public void setTransparentAlphaValue(final int transValueAlpha) { transparentValueAlpha=transValueAlpha; }
-
- @Override
- public StringBuilder toString(final StringBuilder sink) {
- return toString(sink, true);
- }
-
- /** Returns a textual representation of this Capabilities
- object. */
- @Override
- public String toString() {
- final StringBuilder msg = new StringBuilder();
- msg.append("Caps[");
- toString(msg);
- msg.append("]");
- return msg.toString();
- }
-
- /** Return a textual representation of this object's on/off screen state. Use the given StringBuilder [optional]. */
- protected StringBuilder onoffScreenToString(StringBuilder sink) {
- if(null == sink) {
- sink = new StringBuilder();
- }
- if(onscreen) {
- sink.append("on-scr");
- } else {
- sink.append("offscr[");
- }
- if(isBitmap) {
- sink.append("bitmap");
- } else if(onscreen) {
- sink.append("."); // no additional off-screen modes besides on-screen
- } else {
- sink.append("auto-cfg"); // auto-config off-screen mode
- }
- sink.append("]");
-
- return sink;
- }
-
- /** Element separator */
- protected static final String ESEP = "/";
- /** Component separator */
- protected static final String CSEP = ", ";
-
- protected StringBuilder toString(StringBuilder sink, final boolean withOnOffScreen) {
- if(null == sink) {
- sink = new StringBuilder();
- }
- sink.append("rgba ").append(redBits).append(ESEP).append(greenBits).append(ESEP).append(blueBits).append(ESEP).append(alphaBits);
- if(backgroundOpaque) {
- sink.append(", opaque");
- } else {
- sink.append(", trans-rgba 0x").append(toHexString(transparentValueRed)).append(ESEP).append(toHexString(transparentValueGreen)).append(ESEP).append(toHexString(transparentValueBlue)).append(ESEP).append(toHexString(transparentValueAlpha));
- }
- if(withOnOffScreen) {
- sink.append(CSEP);
- onoffScreenToString(sink);
- }
- return sink;
- }
-
- protected final String toHexString(final int val) { return Integer.toHexString(val); }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
deleted file mode 100644
index c33ff5a3f..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.nativewindow;
-
-import java.util.List;
-
-/** Provides a mechanism by which applications can customize the
- window type selection for a given {@link Capabilities}.
- Developers can implement this interface and pass an instance into
- the method {@link GraphicsConfigurationFactory#chooseGraphicsConfiguration}; the chooser
- will be called at window creation time. */
-
-public interface CapabilitiesChooser {
- /** Chooses the index (0..available.length - 1) of the {@link
- Capabilities} most closely matching the desired one from the
- list of all supported. Some of the entries in the
- available array may be null; the chooser must
- ignore these. The windowSystemRecommendedChoice
- parameter may be provided to the chooser by the underlying
- window system; if this index is valid, it is recommended, but
- not necessarily required, that the chooser select that entry.
-
-
Note: this method is called automatically by the
- {@link GraphicsConfigurationFactory#chooseGraphicsConfiguration} method
- when an instance of this class is passed in to it.
- It should generally not be
- invoked by users directly, unless it is desired to delegate the
- choice to some other CapabilitiesChooser object.
- */
- public int chooseCapabilities(CapabilitiesImmutable desired,
- List extends CapabilitiesImmutable> available,
- int windowSystemRecommendedChoice);
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
deleted file mode 100644
index 780d537b8..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow;
-
-import com.jogamp.common.type.WriteCloneable;
-
-/**
- * Specifies an immutable set of capabilities that a window's rendering context
- * must support, such as color depth per channel.
- *
- * @see com.jogamp.nativewindow.Capabilities
- */
-public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, Comparable {
-
- /**
- * Returns the number of bits for the color buffer's red
- * component. On some systems only the color depth, which is the sum of the
- * red, green, and blue bits, is considered.
- */
- int getRedBits();
-
- /**
- * Returns the number of bits for the color buffer's green
- * component. On some systems only the color depth, which is the sum of the
- * red, green, and blue bits, is considered.
- */
- int getGreenBits();
-
- /**
- * Returns the number of bits for the color buffer's blue
- * component. On some systems only the color depth, which is the sum of the
- * red, green, and blue bits, is considered.
- */
- int getBlueBits();
-
- /**
- * Returns the number of bits for the color buffer's alpha
- * component. On some systems only the color depth, which is the sum of the
- * red, green, and blue bits, is considered.
- */
- int getAlphaBits();
-
- /**
- * Returns whether an opaque or translucent surface is requested, supported or chosen.
- *
- * Default is true, i.e. opaque.
- *
- */
- boolean isBackgroundOpaque();
-
- /**
- * Returns whether an on- or offscreen surface is requested, available or chosen.
- *
- * Default is true, i.e. onscreen.
- *
- *
- * Mind that an capabilities intance w/ available semantics
- * may show onscreen, but also the offscreen modes FBO, Pbuffer or {@link #setBitmap(boolean) bitmap}.
- * This is valid, since one native configuration maybe used for either functionality.
- *
- */
- boolean isOnscreen();
-
- /**
- * Returns whether bitmap offscreen mode is requested, available or chosen.
- *
- * Default is false.
- *
- *
- * For chosen capabilities, only the selected offscreen surface is set to true.
- *
- */
- boolean isBitmap();
-
- /**
- * Gets the transparent red value for the frame buffer configuration. This
- * value is undefined if; equals true.
- */
- int getTransparentRedValue();
-
- /**
- * Gets the transparent green value for the frame buffer configuration. This
- * value is undefined if; equals true.
- */
- int getTransparentGreenValue();
-
- /**
- * Gets the transparent blue value for the frame buffer configuration. This
- * value is undefined if; equals true.
- */
- int getTransparentBlueValue();
-
- /**
- * Gets the transparent alpha value for the frame buffer configuration. This
- * value is undefined if; equals true.
- */
- int getTransparentAlphaValue();
-
- /** Equality over the immutable attributes of both objects */
- @Override
- boolean equals(Object obj);
-
- /** hash code over the immutable attributes of both objects */
- @Override
- int hashCode();
-
- /** Return a textual representation of this object. Use the given StringBuilder [optional]. */
- StringBuilder toString(StringBuilder sink);
-
- /** Returns a textual representation of this object. */
- @Override
- String toString();
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
deleted file mode 100644
index 33c3f8458..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.nativewindow;
-
-import java.util.List;
-
-import com.jogamp.common.util.PropertyAccess;
-
-import jogamp.nativewindow.Debug;
-
-/**
The default implementation of the {@link
- CapabilitiesChooser} interface, which provides consistent visual
- selection behavior across platforms. The precise algorithm is
- deliberately left loosely specified. Some properties are:
-
-
Attempts to match as closely as possible the given
- Capabilities, but will select one with fewer capabilities (i.e.,
- lower color depth) if necessary.
-
-
If there is no exact match, prefers a more-capable visual to
- a less-capable one.
-
-
If there is more than one exact match, chooses an arbitrary
- one.
-
-
If a valid windowSystemRecommendedChoice parameter is
- supplied, chooses that instead of using the cross-platform code.
-
-
-*/
-
-public class DefaultCapabilitiesChooser implements CapabilitiesChooser {
- private static final boolean DEBUG;
-
- static {
- Debug.initSingleton();
- DEBUG = PropertyAccess.isPropertyDefined("nativewindow.debug.CapabilitiesChooser", true);
- }
-
- private final static int NO_SCORE = -9999999;
- private final static int COLOR_MISMATCH_PENALTY_SCALE = 36;
-
- @Override
- public int chooseCapabilities(final CapabilitiesImmutable desired,
- final List extends CapabilitiesImmutable> available,
- final int windowSystemRecommendedChoice) {
- if (DEBUG) {
- System.err.println("Desired: " + desired);
- for (int i = 0; i < available.size(); i++) {
- System.err.println("Available " + i + ": " + available.get(i));
- }
- System.err.println("Window system's recommended choice: " + windowSystemRecommendedChoice);
- }
- final int availnum = available.size();
-
- if (windowSystemRecommendedChoice >= 0 &&
- windowSystemRecommendedChoice < availnum &&
- null != available.get(windowSystemRecommendedChoice)) {
- if (DEBUG) {
- System.err.println("Choosing window system's recommended choice of " + windowSystemRecommendedChoice);
- System.err.println(available.get(windowSystemRecommendedChoice));
- }
- return windowSystemRecommendedChoice;
- }
-
- // Create score array
- final int[] scores = new int[availnum];
- for (int i = 0; i < availnum; i++) {
- scores[i] = NO_SCORE;
- }
- // Compute score for each
- for (int i = 0; i < availnum; i++) {
- final CapabilitiesImmutable cur = available.get(i);
- if (cur == null) {
- continue;
- }
- if (desired.isOnscreen() && !cur.isOnscreen()) {
- continue; // requested onscreen, but n/a
- }
-
- int score = 0;
- // Compute difference in color depth
- score += (COLOR_MISMATCH_PENALTY_SCALE *
- ((cur.getRedBits() + cur.getGreenBits() + cur.getBlueBits() + cur.getAlphaBits()) -
- (desired.getRedBits() + desired.getGreenBits() + desired.getBlueBits() + desired.getAlphaBits())));
- scores[i] = score;
- }
-
- if (DEBUG) {
- System.err.print("Scores: [");
- for (int i = 0; i < availnum; i++) {
- if (i > 0) {
- System.err.print(",");
- }
- System.err.print(" " + scores[i]);
- }
- System.err.println(" ]");
- }
-
- // Ready to select. Choose score closest to 0.
- int scoreClosestToZero = NO_SCORE;
- int chosenIndex = -1;
- for (int i = 0; i < availnum; i++) {
- final int score = scores[i];
- if (score == NO_SCORE) {
- continue;
- }
- // Don't substitute a positive score for a smaller negative score
- if ((scoreClosestToZero == NO_SCORE) ||
- (Math.abs(score) < Math.abs(scoreClosestToZero) &&
- ((sign(scoreClosestToZero) < 0) || (sign(score) > 0)))) {
- scoreClosestToZero = score;
- chosenIndex = i;
- }
- }
- if (chosenIndex < 0) {
- throw new NativeWindowException("Unable to select one of the provided Capabilities");
- }
- if (DEBUG) {
- System.err.println("Chosen index: " + chosenIndex);
- System.err.println("Chosen capabilities:");
- System.err.println(available.get(chosenIndex));
- }
-
- return chosenIndex;
- }
-
- private static int sign(final int score) {
- if (score < 0) {
- return -1;
- }
- return 1;
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
deleted file mode 100644
index d20a6824d..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package com.jogamp.nativewindow;
-
-import jogamp.nativewindow.Debug;
-
-public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphicsConfiguration {
- protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
-
- private AbstractGraphicsScreen screen;
- protected CapabilitiesImmutable capabilitiesChosen;
- protected CapabilitiesImmutable capabilitiesRequested;
-
- public DefaultGraphicsConfiguration(final AbstractGraphicsScreen screen,
- final CapabilitiesImmutable capsChosen, final CapabilitiesImmutable capsRequested) {
- if(null == screen) {
- throw new IllegalArgumentException("Null screen");
- }
- if(null == capsChosen) {
- throw new IllegalArgumentException("Null chosen caps");
- }
- if(null == capsRequested) {
- throw new IllegalArgumentException("Null requested caps");
- }
- this.screen = screen;
- this.capabilitiesChosen = capsChosen;
- this.capabilitiesRequested = capsRequested;
- }
-
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (final CloneNotSupportedException e) {
- throw new NativeWindowException(e);
- }
- }
-
- @Override
- final public AbstractGraphicsScreen getScreen() {
- return screen;
- }
-
- @Override
- final public CapabilitiesImmutable getChosenCapabilities() {
- return capabilitiesChosen;
- }
-
- @Override
- final public CapabilitiesImmutable getRequestedCapabilities() {
- return capabilitiesRequested;
- }
-
- @Override
- public AbstractGraphicsConfiguration getNativeGraphicsConfiguration() {
- return this;
- }
-
- @Override
- final public int getVisualID(final VIDType type) throws NativeWindowException {
- return capabilitiesChosen.getVisualID(type);
- }
-
- /**
- * Set the capabilities to a new value.
- *
- *
- * The use case for setting the Capabilities at a later time is
- * a change or re-validation of capabilities.
- *
- * the use case for setting a new screen at a later time is
- * a change of the graphics device in a multi-screen environment.
- *
- */
- protected void setScreen(final AbstractGraphicsScreen screen) {
- this.screen = screen;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName()+"[" + screen +
- ",\n\tchosen " + capabilitiesChosen+
- ",\n\trequested " + capabilitiesRequested+
- "]";
- }
-
- public static String toHexString(final int val) {
- return "0x"+Integer.toHexString(val);
- }
-
- public static String toHexString(final long val) {
- return "0x"+Long.toHexString(val);
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java
deleted file mode 100644
index 070b6bb28..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package com.jogamp.nativewindow;
-
-import jogamp.nativewindow.NativeWindowFactoryImpl;
-
-public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice {
- private static final String separator = "_";
- private final String type;
- protected final String connection;
- protected final int unitID;
- protected final String uniqueID;
- protected long handle;
- protected ToolkitLock toolkitLock;
-
- /**
- * Create an instance with the system default {@link ToolkitLock},
- * gathered via {@link NativeWindowFactory#getDefaultToolkitLock(String)}.
- * @param type
- */
- public DefaultGraphicsDevice(final String type, final String connection, final int unitID) {
- this(type, connection, unitID, 0, NativeWindowFactory.getDefaultToolkitLock(type));
- }
-
- /**
- * Create an instance with the system default {@link ToolkitLock}.
- * gathered via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}.
- * @param type
- * @param handle
- */
- public DefaultGraphicsDevice(final String type, final String connection, final int unitID, final long handle) {
- this(type, connection, unitID, handle, NativeWindowFactory.getDefaultToolkitLock(type, handle));
- }
-
- /**
- * Create an instance with the given {@link ToolkitLock} instance, or null {@link ToolkitLock} if null.
- * @param type
- * @param handle
- * @param locker if null, a non blocking null lock is used.
- */
- public DefaultGraphicsDevice(final String type, final String connection, final int unitID, final long handle, final ToolkitLock locker) {
- this.type = type;
- this.connection = connection;
- this.unitID = unitID;
- this.uniqueID = getUniqueID(type, connection, unitID);
- this.handle = handle;
- this.toolkitLock = null != locker ? locker : NativeWindowFactoryImpl.getNullToolkitLock();
- }
-
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (final CloneNotSupportedException e) {
- throw new NativeWindowException(e);
- }
- }
-
- @Override
- public final String getType() {
- return type;
- }
-
- @Override
- public final String getConnection() {
- return connection;
- }
-
- @Override
- public final int getUnitID() {
- return unitID;
- }
-
- @Override
- public final String getUniqueID() {
- return uniqueID;
- }
-
- @Override
- public final long getHandle() {
- return handle;
- }
-
- /**
- * {@inheritDoc}
- *
- * Locking is perfomed via delegation to {@link ToolkitLock#lock()}, {@link ToolkitLock#unlock()}.
- *
- * Locking is perfomed via delegation to {@link ToolkitLock#lock()}, {@link ToolkitLock#unlock()}.
- *
- *
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
- */
- @Override
- public final void unlock() {
- toolkitLock.unlock();
- }
-
- @Override
- public boolean open() {
- return false;
- }
-
- @Override
- public boolean close() {
- toolkitLock.dispose();
- if(0 != handle) {
- handle = 0;
- return true;
- }
- return false;
- }
-
- @Override
- public boolean isHandleOwner() {
- return false;
- }
-
- @Override
- public void clearHandleOwner() {
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", owner "+isHandleOwner()+", "+toolkitLock+"]";
- }
-
- /**
- * Set the native handle of the underlying native device
- * and return the previous one.
- */
- protected final long setHandle(final long newHandle) {
- final long oldHandle = handle;
- handle = newHandle;
- return oldHandle;
- }
-
- protected Object getHandleOwnership() {
- return null;
- }
- protected Object setHandleOwnership(final Object newOwnership) {
- return null;
- }
-
- public static final void swapDeviceHandleAndOwnership(final DefaultGraphicsDevice aDevice1, final DefaultGraphicsDevice aDevice2) {
- aDevice1.lock();
- try {
- aDevice2.lock();
- try {
- final long aDevice1Handle = aDevice1.getHandle();
- final long aDevice2Handle = aDevice2.setHandle(aDevice1Handle);
- aDevice1.setHandle(aDevice2Handle);
- final Object aOwnership1 = aDevice1.getHandleOwnership();
- final Object aOwnership2 = aDevice2.setHandleOwnership(aOwnership1);
- aDevice1.setHandleOwnership(aOwnership2);
- } finally {
- aDevice2.unlock();
- }
- } finally {
- aDevice1.unlock();
- }
- }
-
- /**
- * Set the internal ToolkitLock, which is used within the
- * {@link #lock()} and {@link #unlock()} implementation.
- *
- *
- * The current ToolkitLock is being locked/unlocked while swapping the reference,
- * ensuring no concurrent access can occur during the swap.
- *
- *
- * @param locker the ToolkitLock, if null, {@link jogamp.nativewindow.NullToolkitLock} is being used
- * @return the previous ToolkitLock instance
- */
- protected ToolkitLock setToolkitLock(final ToolkitLock locker) {
- final ToolkitLock _toolkitLock = toolkitLock;
- _toolkitLock.lock();
- try {
- toolkitLock = ( null == locker ) ? NativeWindowFactoryImpl.getNullToolkitLock() : locker ;
- } finally {
- _toolkitLock.unlock();
- }
- return _toolkitLock;
- }
-
- /**
- * @return the used ToolkitLock
- *
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long)
- * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, com.jogamp.nativewindow.ToolkitLock)
- */
- public final ToolkitLock getToolkitLock() {
- return toolkitLock;
- }
-
- /**
- * Returns a unique String object using {@link String#intern()} for the given arguments,
- * which object reference itself can be used as a key.
- */
- private static String getUniqueID(final String type, final String connection, final int unitID) {
- return (type + separator + connection + separator + unitID).intern();
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java
deleted file mode 100644
index 63c79af55..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package com.jogamp.nativewindow;
-
-public class DefaultGraphicsScreen implements Cloneable, AbstractGraphicsScreen {
- private final AbstractGraphicsDevice device;
- private final int idx;
-
- public DefaultGraphicsScreen(final AbstractGraphicsDevice device, final int idx) {
- this.device = device;
- this.idx = idx;
- }
-
- public static AbstractGraphicsScreen createDefault(final String type) {
- return new DefaultGraphicsScreen(new DefaultGraphicsDevice(type, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT), 0);
- }
-
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (final CloneNotSupportedException e) {
- throw new NativeWindowException(e);
- }
- }
-
- @Override
- public AbstractGraphicsDevice getDevice() {
- return device;
- }
-
- @Override
- public int getIndex() {
- return idx;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName()+"["+device+", idx "+idx+"]";
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
deleted file mode 100644
index 929af054e..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Copyright (c) 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package com.jogamp.nativewindow;
-
-import com.jogamp.common.ExceptionUtils;
-import com.jogamp.common.util.ReflectionUtil;
-
-import jogamp.nativewindow.Debug;
-import jogamp.nativewindow.DefaultGraphicsConfigurationFactoryImpl;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Provides the mechanism by which the graphics configuration for a
- * window can be chosen before the window is created. The graphics
- * configuration decides parameters related to hardware accelerated rendering such
- * as the OpenGL pixel format.
- * On some window systems (EGL/OpenKODE and X11 in particular) it is necessary to
- * choose the graphics configuration early at window creation time.
- * Note that the selection of the graphics configuration is an algorithm which does not have
- * strong dependencies on the particular Java window toolkit in use
- * (e.g., AWT) and therefore it is strongly desirable to factor this
- * functionality out of the core {@link NativeWindowFactory} so that
- * new window toolkits can replace just the {@link
- * NativeWindowFactory} and reuse the graphics configuration selection
- * algorithm provided by, for example, an OpenGL binding.
- */
-
-public abstract class GraphicsConfigurationFactory {
- protected static final boolean DEBUG;
-
- private static class DeviceCapsType {
- public final Class> deviceType;
- public final Class> capsType;
- private final int hash32;
-
- public DeviceCapsType(final Class> deviceType, final Class> capsType) {
- this.deviceType = deviceType;
- this.capsType = capsType;
-
- // 31 * x == (x << 5) - x
- int hash32 = 31 + deviceType.hashCode();
- hash32 = ((hash32 << 5) - hash32) + capsType.hashCode();
- this.hash32 = hash32;
- }
-
- @Override
- public final int hashCode() {
- return hash32;
- }
-
- @Override
- public final boolean equals(final Object obj) {
- if(this == obj) { return true; }
- if (obj instanceof DeviceCapsType) {
- final DeviceCapsType dct = (DeviceCapsType)obj;
- return deviceType == dct.deviceType && capsType == dct.capsType;
- }
- return false;
- }
-
- @Override
- public final String toString() {
- return "DeviceCapsType["+deviceType.getName()+", "+capsType.getName()+"]";
- }
-
- }
-
- private static final Map registeredFactories;
- private static final DeviceCapsType defaultDeviceCapsType;
- static boolean initialized = false;
-
- static {
- DEBUG = Debug.debug("GraphicsConfiguration");
- if(DEBUG) {
- System.err.println(Thread.currentThread().getName()+" - Info: GraphicsConfigurationFactory.");
- // Thread.dumpStack();
- }
- registeredFactories = Collections.synchronizedMap(new HashMap());
- defaultDeviceCapsType = new DeviceCapsType(AbstractGraphicsDevice.class, CapabilitiesImmutable.class);
- }
-
- public static synchronized void initSingleton() {
- if(!initialized) {
- initialized = true;
-
- if(DEBUG) {
- System.err.println(Thread.currentThread().getName()+" - GraphicsConfigurationFactory.initSingleton()");
- }
-
- // Register the default no-op factory for arbitrary
- // AbstractGraphicsDevice implementations, including
- // AWTGraphicsDevice instances -- the OpenGL binding will take
- // care of handling AWTGraphicsDevices on X11 platforms (as
- // well as X11GraphicsDevices in non-AWT situations)
- registerFactory(defaultDeviceCapsType.deviceType, defaultDeviceCapsType.capsType, new DefaultGraphicsConfigurationFactoryImpl());
-
- if (NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true)) {
- try {
- ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.X11GraphicsConfigurationFactory",
- "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader());
- } catch (final Exception e) {
- throw new RuntimeException(e);
- }
- if(NativeWindowFactory.isAWTAvailable()) {
- try {
- ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.awt.X11AWTGraphicsConfigurationFactory",
- "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader());
- } catch (final Exception e) { /* n/a */ }
- }
- }
- }
- }
-
- public static synchronized void shutdown() {
- if(initialized) {
- initialized = false;
- if(DEBUG) {
- System.err.println(Thread.currentThread().getName()+" - GraphicsConfigurationFactory.shutdown()");
- }
- registeredFactories.clear();
- }
- }
-
- protected static String getThreadName() {
- return Thread.currentThread().getName();
- }
-
- protected static String toHexString(final int val) {
- return "0x" + Integer.toHexString(val);
- }
-
- protected static String toHexString(final long val) {
- return "0x" + Long.toHexString(val);
- }
-
- /** Creates a new NativeWindowFactory instance. End users do not
- need to call this method. */
- protected GraphicsConfigurationFactory() {
- }
-
- /**
- * Returns the graphics configuration factory for use with the
- * given device and capability.
- *
- * @see #getFactory(Class, Class)
- */
- public static GraphicsConfigurationFactory getFactory(final AbstractGraphicsDevice device, final CapabilitiesImmutable caps) {
- if (device == null) {
- throw new IllegalArgumentException("null device");
- }
- if (caps == null) {
- throw new IllegalArgumentException("null caps");
- }
- return getFactory(device.getClass(), caps.getClass());
- }
-
- /**
- * Returns the graphics configuration factory for use with the
- * given device and capability class.
- *
- * Note: Registered device types maybe classes or interfaces, where capabilities types are interfaces only.
- *
- *
- *
- * Pseudo code for finding a suitable factory is:
- *
- For-All devT := getTopDownDeviceTypes(deviceType)
- For-All capsT := getTopDownCapabilitiesTypes(capabilitiesType)
- f = factory.get(devT, capsT);
- if(f) { return f; }
- end
- end
- *
- *
- *
- * @param deviceType the minimum capabilities class type accepted, must implement or extend {@link AbstractGraphicsDevice}
- * @param capabilitiesType the minimum capabilities class type accepted, must implement or extend {@link CapabilitiesImmutable}
- *
- * @throws IllegalArgumentException if the deviceType does not implement {@link AbstractGraphicsDevice} or
- * capabilitiesType does not implement {@link CapabilitiesImmutable}
- */
- public static GraphicsConfigurationFactory getFactory(final Class> deviceType, final Class> capabilitiesType)
- throws IllegalArgumentException, NativeWindowException
- {
- if (!(defaultDeviceCapsType.deviceType.isAssignableFrom(deviceType))) {
- throw new IllegalArgumentException("Given class must implement AbstractGraphicsDevice");
- }
- if (!(defaultDeviceCapsType.capsType.isAssignableFrom(capabilitiesType))) {
- throw new IllegalArgumentException("Given capabilities class must implement CapabilitiesImmutable");
- }
- if(DEBUG) {
- ExceptionUtils.dumpStack(System.err);
- System.err.println("GraphicsConfigurationFactory.getFactory: "+deviceType.getName()+", "+capabilitiesType.getName());
- dumpFactories();
- }
-
- final List> deviceTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.deviceType, deviceType, false);
- if(DEBUG) {
- System.err.println("GraphicsConfigurationFactory.getFactory() deviceTypes: " + deviceTypes);
- }
- final List> capabilitiesTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.capsType, capabilitiesType, true);
- if(DEBUG) {
- System.err.println("GraphicsConfigurationFactory.getFactory() capabilitiesTypes: " + capabilitiesTypes);
- }
- for(int j=0; j interfaceDevice = deviceTypes.get(j);
- for(int i=0; i interfaceCaps = capabilitiesTypes.get(i);
- final DeviceCapsType dct = new DeviceCapsType(interfaceDevice, interfaceCaps);
- final GraphicsConfigurationFactory factory = registeredFactories.get(dct);
- if (factory != null) {
- if(DEBUG) {
- System.err.println("GraphicsConfigurationFactory.getFactory() found "+dct+" -> "+factory);
- }
- return factory;
- }
- }
- }
- // Return the default
- final GraphicsConfigurationFactory factory = registeredFactories.get(defaultDeviceCapsType);
- if(DEBUG) {
- System.err.println("GraphicsConfigurationFactory.getFactory() DEFAULT "+defaultDeviceCapsType+" -> "+factory);
- }
- return factory;
- }
- private static ArrayList> getAllAssignableClassesFrom(final Class> superClassOrInterface, final Class> fromClass, final boolean interfacesOnly) {
- // Using a todo list avoiding a recursive loop!
- final ArrayList> inspectClasses = new ArrayList>();
- final ArrayList> resolvedInterfaces = new ArrayList>();
- inspectClasses.add(fromClass);
- for(int j=0; j clazz = inspectClasses.get(j);
- getAllAssignableClassesFrom(superClassOrInterface, clazz, interfacesOnly, resolvedInterfaces, inspectClasses);
- }
- return resolvedInterfaces;
- }
- private static void getAllAssignableClassesFrom(final Class> superClassOrInterface, final Class> fromClass, final boolean interfacesOnly, final List> resolvedInterfaces, final List> inspectClasses) {
- final ArrayList> types = new ArrayList>();
- if( superClassOrInterface.isAssignableFrom(fromClass) && !resolvedInterfaces.contains(fromClass)) {
- if( !interfacesOnly || fromClass.isInterface() ) {
- types.add(fromClass);
- }
- }
- types.addAll(Arrays.asList(fromClass.getInterfaces()));
-
- for(int i=0; i iface = types.get(i);
- if( superClassOrInterface.isAssignableFrom(iface) && !resolvedInterfaces.contains(iface) ) {
- resolvedInterfaces.add(iface);
- if( !superClassOrInterface.equals(iface) && !inspectClasses.contains(iface) ) {
- inspectClasses.add(iface); // safe add to todo list, avoiding a recursive nature
- }
- }
- }
- final Class> parentClass = fromClass.getSuperclass();
- if( null != parentClass && superClassOrInterface.isAssignableFrom(parentClass) && !inspectClasses.contains(parentClass) ) {
- inspectClasses.add(parentClass); // safe add to todo list, avoiding a recursive nature
- }
- }
- private static void dumpFactories() {
- final Set dcts = registeredFactories.keySet();
- int i=0;
- for(final Iterator iter = dcts.iterator(); iter.hasNext(); ) {
- final DeviceCapsType dct = iter.next();
- System.err.println("Factory #"+i+": "+dct+" -> "+registeredFactories.get(dct));
- i++;
- }
- }
-
- /**
- * Registers a GraphicsConfigurationFactory handling
- * the given graphics device and capability class.
- *
- * This does not need to be called by end users, only implementors of new
- * GraphicsConfigurationFactory subclasses.
- *
- *
- *
- * Note: Registered device types maybe classes or interfaces, where capabilities types are interfaces only.
- *
- *
- *
See {@link #getFactory(Class, Class)} for a description of the find algorithm.
- *
- * @param deviceType the minimum capabilities class type accepted, must implement or extend interface {@link AbstractGraphicsDevice}
- * @param capabilitiesType the minimum capabilities class type accepted, must extend interface {@link CapabilitiesImmutable}
- * @return the previous registered factory, or null if none
- * @throws IllegalArgumentException if the given class does not implement AbstractGraphicsDevice
- */
- protected static GraphicsConfigurationFactory registerFactory(final Class> abstractGraphicsDeviceImplementor, final Class> capabilitiesType, final GraphicsConfigurationFactory factory)
- throws IllegalArgumentException
- {
- if (!(defaultDeviceCapsType.deviceType.isAssignableFrom(abstractGraphicsDeviceImplementor))) {
- throw new IllegalArgumentException("Given device class must implement AbstractGraphicsDevice");
- }
- if (!(defaultDeviceCapsType.capsType.isAssignableFrom(capabilitiesType))) {
- throw new IllegalArgumentException("Given capabilities class must implement CapabilitiesImmutable");
- }
- final DeviceCapsType dct = new DeviceCapsType(abstractGraphicsDeviceImplementor, capabilitiesType);
- final GraphicsConfigurationFactory prevFactory;
- if(null == factory) {
- prevFactory = registeredFactories.remove(dct);
- if(DEBUG) {
- System.err.println("GraphicsConfigurationFactory.registerFactory() remove "+dct+
- ", deleting: "+prevFactory);
- }
- } else {
- prevFactory = registeredFactories.put(dct, factory);
- if(DEBUG) {
- System.err.println("GraphicsConfigurationFactory.registerFactory() put "+dct+" -> "+factory+
- ", overridding: "+prevFactory);
- }
- }
- return prevFactory;
- }
-
- /**
- *
Selects a graphics configuration on the specified graphics
- * device compatible with the supplied {@link Capabilities}. Some
- * platforms (e.g.: X11, EGL, KD) require the graphics configuration
- * to be specified when the native window is created.
- * These architectures have seperated their device, screen, window and drawable
- * context and hence are capable of quering the capabilities for each screen.
- * A fully established window is not required.
- *
- *
Other platforms (e.g. Windows, MacOSX) don't offer the mentioned seperation
- * and hence need a fully established window and it's drawable.
- * Here the validation of the capabilities is performed later.
- * In this case, the AbstractGraphicsConfiguration implementation
- * must allow an overwrite of the Capabilites, for example
- * {@link DefaultGraphicsConfiguration#setChosenCapabilities DefaultGraphicsConfiguration.setChosenCapabilities(..)}.
- *
- *
- *
- * This method is mainly intended to be both used and implemented by the
- * OpenGL binding.
- *
- *
The concrete data type of the passed graphics device and
- * returned graphics configuration must be specified in the
- * documentation binding this particular API to the underlying
- * window toolkit. The Reference Implementation accepts {@link
- * com.jogamp.nativewindow.awt.AWTGraphicsDevice AWTGraphicsDevice} objects and returns {@link
- * com.jogamp.nativewindow.awt.AWTGraphicsConfiguration AWTGraphicsConfiguration} objects. On
- * X11 platforms where the AWT is not in use, it also accepts
- * {@link com.jogamp.nativewindow.x11.X11GraphicsDevice
- * X11GraphicsDevice} objects and returns {@link
- * com.jogamp.nativewindow.x11.X11GraphicsConfiguration
- * X11GraphicsConfiguration} objects.
- *
- * @param capsChosen the intermediate chosen capabilities to be refined by this implementation, may be equal to capsRequested
- * @param capsRequested the original requested capabilities
- * @param chooser the choosing implementation
- * @param screen the referring Screen
- * @param nativeVisualID if not {@link VisualIDHolder#VID_UNDEFINED} it reflects a pre-chosen visualID of the native platform's windowing system.
- * @return the complete GraphicsConfiguration
- *
- * @throws IllegalArgumentException if the data type of the passed
- * AbstractGraphicsDevice is not supported by this
- * NativeWindowFactory.
- * @throws NativeWindowException if any window system-specific errors caused
- * the selection of the graphics configuration to fail.
- *
- * @see com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
- * @see com.jogamp.nativewindow.DefaultGraphicsConfiguration#setChosenCapabilities(Capabilities caps)
- */
- public final AbstractGraphicsConfiguration
- chooseGraphicsConfiguration(final CapabilitiesImmutable capsChosen, final CapabilitiesImmutable capsRequested,
- final CapabilitiesChooser chooser,
- final AbstractGraphicsScreen screen, final int nativeVisualID)
- throws IllegalArgumentException, NativeWindowException {
- if(null==capsChosen) {
- throw new NativeWindowException("Chosen Capabilities are null");
- }
- if(null==capsRequested) {
- throw new NativeWindowException("Requested Capabilities are null");
- }
- if(null==screen) {
- throw new NativeWindowException("Screen is null");
- }
- final AbstractGraphicsDevice device = screen.getDevice();
- if(null==device) {
- throw new NativeWindowException("Screen's Device is null");
- }
- device.lock();
- try {
- return chooseGraphicsConfigurationImpl(capsChosen, capsRequested, chooser, screen, nativeVisualID);
- } finally {
- device.unlock();
- }
- }
-
- protected abstract AbstractGraphicsConfiguration
- chooseGraphicsConfigurationImpl(CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested,
- CapabilitiesChooser chooser, AbstractGraphicsScreen screen, int nativeVisualID)
- throws IllegalArgumentException, NativeWindowException;
-
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java b/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java
deleted file mode 100644
index 7686f270b..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright 2012 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow;
-
-/**
- * Provides a {@link NativeSurface} with a mutable surfaceHandle
- * via {@link #setSurfaceHandle(long)}.
- *
- * @see NativeSurface
- */
-public interface MutableSurface extends NativeSurface {
-
- /**
- * Sets the surface handle which is created outside of this implementation.
- */
- public void setSurfaceHandle(long surfaceHandle);
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
deleted file mode 100644
index ce0699c56..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow;
-
-/**
- * Provides low-level information required for
- * hardware-accelerated rendering using a surface in a platform-independent manner.
- *
- * All values of this interface are represented in pixel units, if not stated otherwise.
- * See {@link NativeWindow}.
- *
- *
- * A NativeSurface created for a particular on- or offscreen component is
- * expected to have the same lifetime as that component. As long as
- * the component is alive and realized/visible, NativeSurface must be able
- * provide information such as the surface handle while it is locked.
- *
- */
-public interface NativeSurface extends SurfaceUpdatedListener {
- /** Unlocked state, {@value}. */
- public static final int LOCK_SURFACE_UNLOCKED = 0;
-
- /** Returned by {@link #lockSurface()} if the surface is not ready to be locked, {@value}. */
- public static final int LOCK_SURFACE_NOT_READY = 1;
-
- /** Returned by {@link #lockSurface()} if the surface is locked, but has changed, {@value}. */
- public static final int LOCK_SURFACE_CHANGED = 2;
-
- /** Returned by {@link #lockSurface()} if the surface is locked, and is unchanged, {@value}. */
- public static final int LOCK_SUCCESS = 3;
-
- /**
- * Lock the surface of this native window.
- *
- * The surface handle shall be valid after a successfull call,
- * ie return a value other than {@link #LOCK_SURFACE_UNLOCKED} and {@link #LOCK_SURFACE_NOT_READY},
- * which is
- *
- * boolean ok = LOCK_SURFACE_NOT_READY < lockSurface();
- *
- *
- *
- * The caller may need to take care of the result {@link #LOCK_SURFACE_CHANGED},
- * where the surface handle is valid but has changed.
- *
- *
- * This call is blocking until the surface has been locked
- * or a timeout is reached. The latter will throw a runtime exception.
- *
- *
- * This call allows recursion from the same thread.
- *
- *
- * The implementation may want to aquire the
- * application level {@link com.jogamp.common.util.locks.RecursiveLock}
- * first before proceeding with a native surface lock.
- *
- *
- * The implementation shall also invoke {@link AbstractGraphicsDevice#lock()}
- * for the initial lock (recursive count zero).
- *
- *
- * @return {@link #LOCK_SUCCESS}, {@link #LOCK_SURFACE_CHANGED} or {@link #LOCK_SURFACE_NOT_READY}.
- *
- * @throws RuntimeException after timeout when waiting for the surface lock
- * @throws NativeWindowException if native locking failed, maybe platform related
- *
- * @see com.jogamp.common.util.locks.RecursiveLock
- */
- public int lockSurface() throws NativeWindowException, RuntimeException;
-
- /**
- * Unlock the surface of this native window
- *
- * Shall not modify the surface handle, see {@link #lockSurface()}
- *
- * The implementation shall also invoke {@link AbstractGraphicsDevice#unlock()}
- * for the final unlock (recursive count zero).
- *
- * The implementation shall be fail safe, i.e. tolerant in case the native resources
- * are already released / unlocked. In this case the implementation shall simply ignore the call.
- *
- * @see #lockSurface
- * @see com.jogamp.common.util.locks.RecursiveLock
- */
- public void unlockSurface();
-
- /**
- * Query if surface is locked by another thread, i.e. not the current one.
- *
- * Convenient shortcut for:
- *
- * final Thread o = getSurfaceLockOwner();
- * if( null != o && Thread.currentThread() != o ) { .. }
- *
- */
- public boolean isSurfaceLockedByOtherThread();
-
- /**
- * Return the locking owner's Thread, or null if not locked.
- */
- public Thread getSurfaceLockOwner();
-
- /**
- * Provide a mechanism to utilize custom (pre-) swap surface
- * code. This method is called before the render toolkit (e.g. JOGL)
- * swaps the buffer/surface if double buffering is enabled.
- *
- * The implementation may itself apply the swapping,
- * in which case true shall be returned.
- *
- *
- * @return true if this method completed swapping the surface,
- * otherwise false, in which case eg the GLDrawable
- * implementation has to swap the code.
- */
- public boolean surfaceSwap();
-
- /** Appends the given {@link SurfaceUpdatedListener} to the end of the list. */
- public void addSurfaceUpdatedListener(SurfaceUpdatedListener l);
-
- /**
- * Inserts the given {@link SurfaceUpdatedListener} at the
- * specified position in the list.
- *
- * @param index Position where the listener will be inserted.
- * Should be within (0 <= index && index <= size()).
- * An index value of -1 is interpreted as the end of the list, size().
- * @param l The listener object to be inserted
- * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index <= size()), or -1
- */
- public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException;
-
- /** Remove the specified {@link SurfaceUpdatedListener} from the list. */
- public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l);
-
- /**
- * Returns the handle to the surface for this NativeSurface.
- *
- * The surface handle should be set/update by {@link #lockSurface()},
- * where {@link #unlockSurface()} is not allowed to modify it.
- * After {@link #unlockSurface()} it is no more guaranteed
- * that the surface handle is still valid.
- *
- * The surface handle shall reflect the platform one
- * for all drawable surface operations, e.g. opengl, swap-buffer.
- *
- * On X11 this returns an entity of type Window,
- * since there is no differentiation of surface and window there.
- * On Microsoft Windows this returns an entity of type HDC.
- */
- public long getSurfaceHandle();
-
- /**
- * Returns the width of the client area excluding insets (window decorations) in pixel units.
- * @return width of the client area in pixel units
- * @see NativeWindow#getWidth()
- * @see #convertToWindowUnits(int[])
- */
- public int getSurfaceWidth();
-
- /**
- * Returns the height of the client area excluding insets (window decorations) in pixel units.
- * @return height of the client area in pixel units
- * @see NativeWindow#getHeight()
- * @see #convertToWindowUnits(int[])
- */
- public int getSurfaceHeight();
-
- /**
- * Converts the given pixel units into window units in place.
- * @param pixelUnitsAndResult int[2] storage holding the pixel units for the x- and y-coord to convert
- * and the resulting values.
- * @return result int[2] storage pixelUnitsAndResult for chaining holding the converted values
- * @see ScalableSurface
- */
- public int[] convertToWindowUnits(final int[] pixelUnitsAndResult);
-
- /**
- * Converts the given window units into pixel units in place.
- * @param windowUnitsAndResult int[2] storage holding the window units for the x- and y-coord to convert
- * and the resulting values.
- * @return result int[2] storage windowUnitsAndResult for chaining holding the converted values
- * @see ScalableSurface
- */
- public int[] convertToPixelUnits(final int[] windowUnitsAndResult);
-
- /**
- * Returns the graphics configuration corresponding to this window.
- *
- * In case the implementation utilizes a delegation pattern to wrap abstract toolkits,
- * this method shall return the native {@link AbstractGraphicsConfiguration} via {@link AbstractGraphicsConfiguration#getNativeGraphicsConfiguration()}.
- *
- * @see AbstractGraphicsConfiguration#getNativeGraphicsConfiguration()
- * @see com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
- */
- public AbstractGraphicsConfiguration getGraphicsConfiguration();
-
- /**
- * Convenience: Get display handle from
- * AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice
- */
- public long getDisplayHandle();
-
- /**
- * Convenience: Get display handle from
- * AbstractGraphicsConfiguration . AbstractGraphicsScreen
- */
- public int getScreenIndex();
-
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurfaceHolder.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurfaceHolder.java
deleted file mode 100644
index 667f5d8af..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurfaceHolder.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright 2014 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow;
-
-/**
- * Accessor interface for implementing classes with ownership of a {@link NativeSurface}
- * via an is-a or has-a relation.
- */
-public interface NativeSurfaceHolder {
- /**
- * Returns the associated {@link NativeSurface} of this {@link NativeSurfaceHolder}.
- */
- public NativeSurface getNativeSurface();
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
deleted file mode 100644
index 1a2d212da..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.nativewindow;
-
-import com.jogamp.nativewindow.util.InsetsImmutable;
-import com.jogamp.nativewindow.util.Point;
-
-/**
- * Extend the {@link NativeSurface} interface with windowing
- * information such as {@link #getWindowHandle() window-handle},
- * {@link #getWidth() window-size} and {@link #getX() window-position}.
- *
- * All values of this interface are represented in window units, if not stated otherwise.
- * See {@link NativeSurface}.
- *
Abstract screen space has it's origin in the top-left corner, and may not be at 0/0.
- *
Window origin is in it's top-left corner, see {@link #getX()} and {@link #getY()}.
- *
Window client-area excludes {@link #getInsets() insets}, i.e. window decoration.
- *
Window origin is relative to it's parent window if exist, or the screen position (top-level).
- *
- *
- *
- * A window toolkit such as the AWT may either implement this interface
- * directly with one of its components, or provide and register an
- * implementation of {@link NativeWindowFactory NativeWindowFactory}
- * which can create NativeWindow objects for its components.
- *
- * Returns this instance, which is-a {@link NativeSurface}.
- *
- */
- @Override
- public NativeSurface getNativeSurface();
-
- /**
- * Destroys this window incl. releasing all related resources.
- */
- public void destroy();
-
- /**
- * @return The parent NativeWindow, or null if this NativeWindow is top level.
- */
- public NativeWindow getParent();
-
- /**
- * Returns the window handle for this NativeWindow.
- *
- * The window handle shall reflect the platform one
- * for all window related operations, e.g. open, close, resize.
- *
- * On X11 this returns an entity of type Window.
- * On Microsoft Windows this returns an entity of type HWND.
- */
- public long getWindowHandle();
-
- /**
- * Returns the insets defined as the width and height of the window decoration
- * on the left, right, top and bottom in window units.
- *
- * Insets are zero if the window is undecorated, including child windows.
- *
- *
- *
- * Insets are available only after the native window has been created,
- * ie. the native window has been made visible.
- *
- * The top-level window area's top-left corner is located at
- *
- *
- * @return insets
- */
- public InsetsImmutable getInsets();
-
- /** Returns the current x position of this window, relative to it's parent. */
-
- /**
- * Returns the x position of the top-left corner
- * of the client area relative to it's parent in window units.
- *
- * If no parent exist (top-level window), this coordinate equals the screen coordinate.
- *
- *
- * Since the position reflects the client area, it does not include the insets.
- *
- * @see #getInsets()
- * @see #getLocationOnScreen(Point)
- */
- public int getX();
-
- /**
- * Returns the current y position of the top-left corner
- * of the client area relative to it's parent in window units.
- *
- * If no parent exist (top-level window), this coordinate equals the screen coordinate.
- *
- *
- * Since the position reflects the client area, it does not include the insets.
- *
- * @see #getInsets()
- * @see #getLocationOnScreen(Point)
- */
- public int getY();
-
- /**
- * Returns the width of the client area excluding insets (window decorations) in window units.
- * @return width of the client area in window units
- * @see NativeSurface#getSurfaceWidth()
- */
- public int getWidth();
-
- /**
- * Returns the height of the client area excluding insets (window decorations) in window units.
- * @return height of the client area in window units
- * @see NativeSurface#getSurfaceHeight()
- */
- public int getHeight();
-
- /**
- * Returns the window's top-left client-area position in the screen.
- *
- * If {@link Point} is not null, it is translated about the resulting screen position
- * and returned.
- *
- * Since the position reflects the client area, it does not include the insets.
- *
- * @param point Optional {@link Point} storage.
- * If not null, null, it is translated about the resulting screen position
- * and returned.
- * @see #getX()
- * @see #getY()
- * @see #getInsets()
- */
- public Point getLocationOnScreen(Point point);
-
- /** Returns true if this native window owns the focus, otherwise false. */
- boolean hasFocus();
-
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java
deleted file mode 100644
index 8f841e7ea..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.nativewindow;
-
-/** A generic exception for OpenGL errors used throughout the binding
- as a substitute for {@link RuntimeException}. */
-
-public class NativeWindowException extends RuntimeException {
- /** Constructs a NativeWindowException object. */
- public NativeWindowException() {
- super();
- }
-
- /** Constructs a NativeWindowException object with the specified detail
- message. */
- public NativeWindowException(final String message) {
- super(message);
- }
-
- /** Constructs a NativeWindowException object with the specified detail
- message and root cause. */
- public NativeWindowException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- /** Constructs a NativeWindowException object with the specified root
- cause. */
- public NativeWindowException(final Throwable cause) {
- super(cause);
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
deleted file mode 100644
index cba3a9214..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
+++ /dev/null
@@ -1,716 +0,0 @@
-/*
- * Copyright (c) 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-
-package com.jogamp.nativewindow;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.jogamp.nativewindow.util.PointImmutable;
-
-import jogamp.common.os.PlatformPropsImpl;
-import jogamp.nativewindow.Debug;
-import jogamp.nativewindow.NativeWindowFactoryImpl;
-import jogamp.nativewindow.ToolkitProperties;
-import jogamp.nativewindow.ResourceToolkitLock;
-import jogamp.nativewindow.WrappedWindow;
-import jogamp.nativewindow.macosx.OSXUtil;
-import jogamp.nativewindow.windows.GDIUtil;
-import jogamp.nativewindow.x11.X11Lib;
-
-import com.jogamp.common.os.Platform;
-import com.jogamp.common.util.PropertyAccess;
-import com.jogamp.common.util.ReflectionUtil;
-import com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos;
-import com.jogamp.nativewindow.awt.AWTGraphicsDevice;
-import com.jogamp.nativewindow.awt.AWTGraphicsScreen;
-import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice;
-import com.jogamp.nativewindow.windows.WindowsGraphicsDevice;
-import com.jogamp.nativewindow.x11.X11GraphicsDevice;
-import com.jogamp.nativewindow.x11.X11GraphicsScreen;
-
-/** Provides a pluggable mechanism for arbitrary window toolkits to
- adapt their components to the {@link NativeWindow} interface,
- which provides a platform-independent mechanism of accessing the
- information required to perform operations like
- hardware-accelerated rendering using the OpenGL API. */
-
-public abstract class NativeWindowFactory {
- protected static final boolean DEBUG;
-
- /** OpenKODE/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/
- public static final String TYPE_EGL = ".egl".intern();
-
- /** Microsoft Windows type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
- public static final String TYPE_WINDOWS = ".windows".intern();
-
- /** X11 type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
- public static final String TYPE_X11 = ".x11".intern();
-
- /** Broadcom VC IV/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
- public static final String TYPE_BCM_VC_IV = ".bcm.vc.iv".intern();
-
- /** Android/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/
- public static final String TYPE_ANDROID = ".android".intern();
-
- /** Mac OS X type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
- public static final String TYPE_MACOSX = ".macosx".intern();
-
- /** Generic AWT type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
- public static final String TYPE_AWT = ".awt".intern();
-
- /** Generic DEFAULT type, where platform implementation don't care, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */
- public static final String TYPE_DEFAULT = ".default".intern();
-
- private static final String nativeWindowingTypePure; // canonical String via String.intern()
- private static final String nativeWindowingTypeCustom; // canonical String via String.intern()
-
- private static NativeWindowFactory defaultFactory;
- private static Map, NativeWindowFactory> registeredFactories;
-
- private static Class> nativeWindowClass;
- private static boolean isAWTAvailable;
-
- private static final String JAWTUtilClassName = "jogamp.nativewindow.jawt.JAWTUtil" ;
- /** {@link jogamp.nativewindow.x11.X11Util} implements {@link ToolkitProperties}. */
- private static final String X11UtilClassName = "jogamp.nativewindow.x11.X11Util";
- /** {@link jogamp.nativewindow.macosx.OSXUtil} implements {@link ToolkitProperties}. */
- private static final String OSXUtilClassName = "jogamp.nativewindow.macosx.OSXUtil";
- /** {@link jogamp.nativewindow.windows.GDIUtil} implements {@link ToolkitProperties}. */
- private static final String GDIClassName = "jogamp.nativewindow.windows.GDIUtil";
-
- private static ToolkitLock jawtUtilJAWTToolkitLock;
-
- private static boolean requiresToolkitLock;
- private static boolean desktopHasThreadingIssues;
-
- // Shutdown hook mechanism for the factory
- private static volatile boolean isJVMShuttingDown = false;
- private static final List customShutdownHooks = new ArrayList();
-
- /** Creates a new NativeWindowFactory instance. End users do not
- need to call this method. */
- protected NativeWindowFactory() {
- }
-
- private static final boolean guessBroadcomVCIV() {
- return AccessController.doPrivileged(new PrivilegedAction() {
- private final File vcliblocation = new File(
- "/opt/vc/lib/libbcm_host.so");
- @Override
- public Boolean run() {
- if ( vcliblocation.isFile() ) {
- return Boolean.TRUE;
- }
- return Boolean.FALSE;
- }
- } ).booleanValue();
- }
-
- private static String _getNativeWindowingType() {
- switch(PlatformPropsImpl.OS_TYPE) {
- case ANDROID:
- return TYPE_ANDROID;
- case MACOS:
- return TYPE_MACOSX;
- case WINDOWS:
- return TYPE_WINDOWS;
- case OPENKODE:
- return TYPE_EGL;
-
- case LINUX:
- case FREEBSD:
- case SUNOS:
- case HPUX:
- default:
- if( guessBroadcomVCIV() ) {
- return TYPE_BCM_VC_IV;
- }
- return TYPE_X11;
- }
- }
-
- static {
- final boolean[] _DEBUG = new boolean[] { false };
- final String[] _tmp = new String[] { null };
-
- AccessController.doPrivileged(new PrivilegedAction() {
- @Override
- public Object run() {
- Platform.initSingleton(); // last resort ..
- _DEBUG[0] = Debug.debug("NativeWindow");
- _tmp[0] = PropertyAccess.getProperty("nativewindow.ws.name", true);
- Runtime.getRuntime().addShutdownHook(
- new Thread(new Runnable() {
- @Override
- public void run() {
- NativeWindowFactory.shutdown(true);
- } }, "NativeWindowFactory_ShutdownHook" ) ) ;
- return null;
- } } ) ;
-
- DEBUG = _DEBUG[0];
- if(DEBUG) {
- System.err.println(Thread.currentThread().getName()+" - Info: NativeWindowFactory.");
- // Thread.dumpStack();
- }
-
- // Gather the windowing TK first
- nativeWindowingTypePure = _getNativeWindowingType();
- if(null==_tmp[0] || _tmp[0].length()==0) {
- nativeWindowingTypeCustom = nativeWindowingTypePure;
- } else {
- nativeWindowingTypeCustom = _tmp[0].intern(); // canonical representation
- }
- }
-
- private static boolean initialized = false;
-
- private static void initSingletonNativeImpl(final ClassLoader cl) {
- final String clazzName;
- if( TYPE_X11 == nativeWindowingTypePure ) {
- clazzName = X11UtilClassName;
- } else if( TYPE_WINDOWS == nativeWindowingTypePure ) {
- clazzName = GDIClassName;
- } else if( TYPE_MACOSX == nativeWindowingTypePure ) {
- clazzName = OSXUtilClassName;
- } else {
- clazzName = null;
- }
- if( null != clazzName ) {
- ReflectionUtil.callStaticMethod(clazzName, "initSingleton", null, null, cl );
-
- final Boolean res1 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresToolkitLock", null, null, cl);
- requiresToolkitLock = res1.booleanValue();
- final Boolean res2 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "hasThreadingIssues", null, null, cl);
- desktopHasThreadingIssues = res2.booleanValue();
- } else {
- requiresToolkitLock = false;
- desktopHasThreadingIssues = false;
- }
- }
-
- /** Returns true if the JVM is shutting down, otherwise false. */
- public static final boolean isJVMShuttingDown() { return isJVMShuttingDown; }
-
- /**
- * Add a custom shutdown hook to be performed at JVM shutdown before shutting down NativeWindowFactory instance.
- *
- * @param head if true add runnable at the start, otherwise at the end
- * @param runnable runnable to be added.
- */
- public static void addCustomShutdownHook(final boolean head, final Runnable runnable) {
- synchronized( customShutdownHooks ) {
- if( !customShutdownHooks.contains( runnable ) ) {
- if( head ) {
- customShutdownHooks.add(0, runnable);
- } else {
- customShutdownHooks.add( runnable );
- }
- }
- }
- }
-
- /**
- * Cleanup resources at JVM shutdown
- */
- public static synchronized void shutdown(final boolean _isJVMShuttingDown) {
- isJVMShuttingDown = _isJVMShuttingDown;
- if(DEBUG) {
- System.err.println("NativeWindowFactory.shutdown() START: JVM Shutdown "+isJVMShuttingDown+", on thread "+Thread.currentThread().getName());
- }
- synchronized(customShutdownHooks) {
- final int cshCount = customShutdownHooks.size();
- for(int i=0; i < cshCount; i++) {
- try {
- if( DEBUG ) {
- System.err.println("NativeWindowFactory.shutdown - customShutdownHook #"+(i+1)+"/"+cshCount);
- }
- customShutdownHooks.get(i).run();
- } catch(final Throwable t) {
- System.err.println("NativeWindowFactory.shutdown: Caught "+t.getClass().getName()+" during customShutdownHook #"+(i+1)+"/"+cshCount);
- if( DEBUG ) {
- t.printStackTrace();
- }
- }
- }
- customShutdownHooks.clear();
- }
- if(DEBUG) {
- System.err.println("NativeWindowFactory.shutdown(): Post customShutdownHook");
- }
-
- if(initialized) {
- initialized = false;
- if(null != registeredFactories) {
- registeredFactories.clear();
- registeredFactories = null;
- }
- GraphicsConfigurationFactory.shutdown();
- }
-
- shutdownNativeImpl(NativeWindowFactory.class.getClassLoader()); // always re-shutdown
- // SharedResourceToolkitLock.shutdown(DEBUG); // not used yet
- if(DEBUG) {
- System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() END JVM Shutdown "+isJVMShuttingDown);
- }
- }
-
- private static void shutdownNativeImpl(final ClassLoader cl) {
- final String clazzName;
- if( TYPE_X11 == nativeWindowingTypePure ) {
- clazzName = X11UtilClassName;
- } else if( TYPE_WINDOWS == nativeWindowingTypePure ) {
- clazzName = GDIClassName;
- } else if( TYPE_MACOSX == nativeWindowingTypePure ) {
- clazzName = OSXUtilClassName;
- } else {
- clazzName = null;
- }
- if( null != clazzName ) {
- ReflectionUtil.callStaticMethod(clazzName, "shutdown", null, null, cl );
- }
- }
-
- /** Returns true if {@link #initSingleton()} has been called w/o subsequent {@link #shutdown(boolean)}. */
- public static synchronized boolean isInitialized() { return initialized; }
-
- /**
- * Static one time initialization of this factory.
- * This initialization method must be called once by the program or utilizing modules!
- */
- public static synchronized void initSingleton() {
- if(!initialized) {
- initialized = true;
-
- if(DEBUG) {
- System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.initSingleton()");
- }
-
- final ClassLoader cl = NativeWindowFactory.class.getClassLoader();
-
- isAWTAvailable = false; // may be set to true below
-
- if( Platform.AWT_AVAILABLE &&
- ReflectionUtil.isClassAvailable("com.jogamp.nativewindow.awt.AWTGraphicsDevice", cl) ) {
-
- final Method[] jawtUtilMethods = AccessController.doPrivileged(new PrivilegedAction() {
- @Override
- public Method[] run() {
- try {
- final Class> _jawtUtilClass = Class.forName(JAWTUtilClassName, true, NativeWindowFactory.class.getClassLoader());
- final Method jawtUtilIsHeadlessMethod = _jawtUtilClass.getDeclaredMethod("isHeadlessMode", (Class[])null);
- jawtUtilIsHeadlessMethod.setAccessible(true);
- final Method jawtUtilInitMethod = _jawtUtilClass.getDeclaredMethod("initSingleton", (Class[])null);
- jawtUtilInitMethod.setAccessible(true);
- final Method jawtUtilGetJAWTToolkitLockMethod = _jawtUtilClass.getDeclaredMethod("getJAWTToolkitLock", new Class[]{});
- jawtUtilGetJAWTToolkitLockMethod.setAccessible(true);
- return new Method[] { jawtUtilInitMethod, jawtUtilIsHeadlessMethod, jawtUtilGetJAWTToolkitLockMethod };
- } catch (final Exception e) {
- if(DEBUG) {
- e.printStackTrace();
- }
- }
- return null;
- }
- });
- if(null != jawtUtilMethods) {
- final Method jawtUtilInitMethod = jawtUtilMethods[0];
- final Method jawtUtilIsHeadlessMethod = jawtUtilMethods[1];
- final Method jawtUtilGetJAWTToolkitLockMethod = jawtUtilMethods[2];
-
- ReflectionUtil.callMethod(null, jawtUtilInitMethod);
-
- Object resO = ReflectionUtil.callMethod(null, jawtUtilIsHeadlessMethod);
- if(resO instanceof Boolean) {
- // AWT is only available in case all above classes are available
- // and AWT is not int headless mode
- isAWTAvailable = ((Boolean)resO).equals(Boolean.FALSE);
- } else {
- throw new RuntimeException("JAWTUtil.isHeadlessMode() didn't return a Boolean");
- }
- resO = ReflectionUtil.callMethod(null, jawtUtilGetJAWTToolkitLockMethod);
- if(resO instanceof ToolkitLock) {
- jawtUtilJAWTToolkitLock = (ToolkitLock) resO;
- } else {
- throw new RuntimeException("JAWTUtil.getJAWTToolkitLock() didn't return a ToolkitLock");
- }
- }
- }
-
- // X11 initialization after possible AWT initialization
- // This is performed post AWT initialization, allowing AWT to complete the same,
- // which may have been triggered before NativeWindow initialization.
- // This way behavior is more uniforms across configurations (Applet/RCP, applications, ..).
- initSingletonNativeImpl(cl);
-
- registeredFactories = Collections.synchronizedMap(new HashMap, NativeWindowFactory>());
-
- // register our default factory -> NativeWindow
- final NativeWindowFactory factory = new NativeWindowFactoryImpl();
- nativeWindowClass = com.jogamp.nativewindow.NativeWindow.class;
- registerFactory(nativeWindowClass, factory);
- defaultFactory = factory;
-
- if ( isAWTAvailable ) {
- // register either our default factory or (if exist) the X11/AWT one -> AWT Component
- registerFactory(ReflectionUtil.getClass(ReflectionUtil.AWTNames.ComponentClass, false, cl), factory);
- }
-
- if(DEBUG) {
- System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock+", desktopHasThreadingIssues "+desktopHasThreadingIssues);
- System.err.println("NativeWindowFactory isAWTAvailable "+isAWTAvailable+", defaultFactory "+factory);
- }
-
- GraphicsConfigurationFactory.initSingleton();
- }
- }
-
- /** @return true if the underlying toolkit requires locking, otherwise false. */
- public static boolean requiresToolkitLock() {
- return requiresToolkitLock;
- }
-
- /** @return true if not headless, AWT Component and NativeWindow's AWT part available */
- public static boolean isAWTAvailable() { return isAWTAvailable; }
-
- /**
- * @param useCustom if false return the native value, if true return a custom value if set, otherwise fallback to the native value.
- * @return the native window type, e.g. {@link #TYPE_X11}, which is canonical via {@link String#intern()}.
- * Hence {@link String#equals(Object)} and == produce the same result.
- */
- public static String getNativeWindowType(final boolean useCustom) {
- return useCustom?nativeWindowingTypeCustom:nativeWindowingTypePure;
- }
-
- /** Don't know if we shall add this factory here ..
- public static AbstractGraphicsDevice createGraphicsDevice(String type, String connection, int unitID, long handle, ToolkitLock locker) {
- if(TYPE_EGL == type) {
- return new
- } else if(TYPE_X11 == type) {
- } else if(TYPE_WINDOWS == type) {
- } else if(TYPE_MACOSX == type)) {
- } else if(TYPE_AWT == type) {
- } else if(TYPE_DEFAULT == type) {
- }
- } */
-
- /** Sets the default NativeWindowFactory. */
- public static void setDefaultFactory(final NativeWindowFactory factory) {
- defaultFactory = factory;
- }
-
- /** Gets the default NativeWindowFactory. */
- public static NativeWindowFactory getDefaultFactory() {
- return defaultFactory;
- }
-
- /**
- * Returns the AWT {@link ToolkitLock} (JAWT based) if {@link #isAWTAvailable}, otherwise null.
- *
- * The JAWT based {@link ToolkitLock} also locks the global lock,
- * which matters if the latter is required.
- *
- */
- public static ToolkitLock getAWTToolkitLock() {
- return jawtUtilJAWTToolkitLock;
- }
-
- public static ToolkitLock getNullToolkitLock() {
- return NativeWindowFactoryImpl.getNullToolkitLock();
- }
-
- /**
- * Provides the system default {@link ToolkitLock} for the default system windowing type.
- * @see #getNativeWindowType(boolean)
- * @see #getDefaultToolkitLock(java.lang.String)
- */
- public static ToolkitLock getDefaultToolkitLock() {
- return getDefaultToolkitLock(nativeWindowingTypePure);
- }
-
- /**
- * Provides the default {@link ToolkitLock} for type.
- *
- *
JAWT {@link ToolkitLock} if required and type is of {@link #TYPE_AWT} and AWT available,
- *
{@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
- *
{@link jogamp.nativewindow.NullToolkitLock}
- *
- */
- public static ToolkitLock getDefaultToolkitLock(final String type) {
- if( requiresToolkitLock ) {
- if( TYPE_AWT == type && isAWTAvailable() ) { // uses .intern()!
- return getAWTToolkitLock();
- }
- return ResourceToolkitLock.create();
- }
- return NativeWindowFactoryImpl.getNullToolkitLock();
- }
-
- /**
- * Provides the default {@link ToolkitLock} for type and deviceHandle.
- *
- *
JAWT {@link ToolkitLock} if required and type is of {@link #TYPE_AWT} and AWT available,
- *
{@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
- *
{@link jogamp.nativewindow.NullToolkitLock}
- *
- */
- public static ToolkitLock getDefaultToolkitLock(final String type, final long deviceHandle) {
- if( requiresToolkitLock ) {
- if( TYPE_AWT == type && isAWTAvailable() ) { // uses .intern()!
- return getAWTToolkitLock();
- }
- return ResourceToolkitLock.create();
- }
- return NativeWindowFactoryImpl.getNullToolkitLock();
- }
-
- /**
- * @param device
- * @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen
- * @return newly created AbstractGraphicsScreen matching device's native type
- */
- public static AbstractGraphicsScreen createScreen(final AbstractGraphicsDevice device, int screen) {
- final String type = device.getType();
- if( TYPE_X11 == type ) {
- final X11GraphicsDevice x11Device = (X11GraphicsDevice)device;
- if(0 > screen) {
- screen = x11Device.getDefaultScreen();
- }
- return new X11GraphicsScreen(x11Device, screen);
- }
- if(0 > screen) {
- screen = 0; // FIXME: Needs native API utilization
- }
- if( TYPE_AWT == type ) {
- final AWTGraphicsDevice awtDevice = (AWTGraphicsDevice) device;
- return new AWTGraphicsScreen(awtDevice);
- }
- return new DefaultGraphicsScreen(device, screen);
- }
-
- /** Returns the appropriate NativeWindowFactory to handle window
- objects of the given type. The windowClass might be {@link
- NativeWindow NativeWindow}, in which case the client has
- already assumed the responsibility of creating a compatible
- NativeWindow implementation, or it might be that of a toolkit
- class like {@link java.awt.Component Component}. */
- public static NativeWindowFactory getFactory(final Class> windowClass) throws IllegalArgumentException {
- if (nativeWindowClass.isAssignableFrom(windowClass)) {
- return registeredFactories.get(nativeWindowClass);
- }
- Class> clazz = windowClass;
- while (clazz != null) {
- final NativeWindowFactory factory = registeredFactories.get(clazz);
- if (factory != null) {
- return factory;
- }
- clazz = clazz.getSuperclass();
- }
- throw new IllegalArgumentException("No registered NativeWindowFactory for class " + windowClass.getName());
- }
-
- /** Registers a NativeWindowFactory handling window objects of the
- given class. This does not need to be called by end users,
- only implementors of new NativeWindowFactory subclasses. */
- protected static void registerFactory(final Class> windowClass, final NativeWindowFactory factory) {
- if(DEBUG) {
- System.err.println("NativeWindowFactory.registerFactory() "+windowClass+" -> "+factory);
- }
- registeredFactories.put(windowClass, factory);
- }
-
- /** Converts the given window object and it's
- {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration} into a
- {@link NativeWindow NativeWindow} which can be operated upon by a custom
- toolkit, e.g. {@link com.jogamp.opengl.GLDrawableFactory com.jogamp.opengl.GLDrawableFactory}.
- The object may be a component for a particular window toolkit, such as an AWT
- Canvas. It may also be a NativeWindow object itself.
- You shall utilize {@link com.jogamp.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}
- to construct a proper {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration}.
- The particular implementation of the
- NativeWindowFactory is responsible for handling objects from a
- particular window toolkit. The built-in NativeWindowFactory
- handles NativeWindow instances as well as AWT Components.
-
- @throws IllegalArgumentException if the given window object
- could not be handled by any of the registered
- NativeWindowFactory instances
-
- @see com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
- */
- public static NativeWindow getNativeWindow(final Object winObj, final AbstractGraphicsConfiguration config) throws IllegalArgumentException, NativeWindowException {
- if (winObj == null) {
- throw new IllegalArgumentException("Null window object");
- }
-
- return getFactory(winObj.getClass()).getNativeWindowImpl(winObj, config);
- }
-
- /** Performs the conversion from a toolkit's window object to a
- NativeWindow. Implementors of concrete NativeWindowFactory
- subclasses should override this method. */
- protected abstract NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException;
-
- /**
- * Returns the {@link OffscreenLayerSurface} instance of this {@link NativeSurface}.
- *
- * In case this surface is a {@link NativeWindow}, we traverse from the given surface
- * up to root until an implementation of {@link OffscreenLayerSurface} is found.
- * In case ifEnabled is true, the surface must also implement {@link OffscreenLayerOption}
- * where {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()} is true.
- *
- *
- * @param surface The surface to query.
- * @param ifEnabled If true, only return the enabled {@link OffscreenLayerSurface}, see {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()}.
- * @return
- */
- public static OffscreenLayerSurface getOffscreenLayerSurface(final NativeSurface surface, final boolean ifEnabled) {
- if(surface instanceof OffscreenLayerSurface &&
- ( !ifEnabled || surface instanceof OffscreenLayerOption ) ) {
- final OffscreenLayerSurface ols = (OffscreenLayerSurface) surface;
- return ( !ifEnabled || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null;
- }
- if(surface instanceof NativeWindow) {
- NativeWindow nw = ((NativeWindow) surface).getParent();
- while(null != nw) {
- if(nw instanceof OffscreenLayerSurface &&
- ( !ifEnabled || nw instanceof OffscreenLayerOption ) ) {
- final OffscreenLayerSurface ols = (OffscreenLayerSurface) nw;
- return ( !ifEnabled || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null;
- }
- nw = nw.getParent();
- }
- }
- return null;
- }
-
- /**
- * Returns true if the given visualID is valid for further processing, i.e. OpenGL usage,
- * otherwise return false.
- *
- * On certain platforms, i.e. X11, a valid visualID is required at window creation.
- * Other platforms may determine it later on, e.g. OSX and Windows.
- *
- * If the visualID is {@link VisualIDHolder#VID_UNDEFINED} and the platform requires it
- * at creation time (see above), it is not valid for further processing.
- *
- */
- public static boolean isNativeVisualIDValidForProcessing(final int visualID) {
- return NativeWindowFactory.TYPE_X11 != NativeWindowFactory.getNativeWindowType(false) ||
- VisualIDHolder.VID_UNDEFINED != visualID ;
- }
-
- /**
- * Creates a native device type, following {@link #getNativeWindowType(boolean) getNativeWindowType(true)}.
- *
- * The device will be opened if own is true, otherwise no native handle will ever be acquired.
- *
- * The given {@link UpstreamWindowHookMutableSizePos} maybe used to reflect resizes and repositioning of the native window.
- *
- *
- * The {@link AbstractGraphicsScreen} may be created via {@link #createScreen(AbstractGraphicsDevice, int)}.
- *
- *
- * The {@link AbstractGraphicsScreen} may have an underlying open {@link AbstractGraphicsDevice}
- * or a simple dummy instance, see {@link #createDevice(String, boolean)}.
- *
- */
- public static NativeWindow createWrappedWindow(final AbstractGraphicsScreen aScreen, final long surfaceHandle, final long windowHandle,
- final UpstreamWindowHookMutableSizePos hook) {
- final CapabilitiesImmutable caps = new Capabilities();
- final AbstractGraphicsConfiguration config = new DefaultGraphicsConfiguration(aScreen, caps, caps);
- return new WrappedWindow(config, surfaceHandle, hook, true, windowHandle);
- }
-
- /**
- * @param nw
- * @return top-left client-area position in window units
- */
- public static PointImmutable getLocationOnScreen(final NativeWindow nw) {
- final String nwt = NativeWindowFactory.getNativeWindowType(true);
- if( NativeWindowFactory.TYPE_X11 == nwt ) {
- return X11Lib.GetRelativeLocation(nw.getDisplayHandle(), nw.getScreenIndex(), nw.getWindowHandle(), 0, 0, 0);
- } else if( NativeWindowFactory.TYPE_WINDOWS == nwt ) {
- return GDIUtil.GetRelativeLocation(nw.getWindowHandle(), 0, 0, 0);
- } else if( NativeWindowFactory.TYPE_MACOSX == nwt ) {
- return OSXUtil.GetLocationOnScreen(nw.getWindowHandle(), 0, 0);
- /**
- * FIXME: Needs service provider interface (SPI) for TK dependent implementation
- } else if( NativeWindowFactory.TYPE_BCM_VC_IV == nwt ) {
- } else if( NativeWindowFactory.TYPE_ANDROID== nwt ) {
- } else if( NativeWindowFactory.TYPE_EGL == nwt ) {
- } else if( NativeWindowFactory.TYPE_BCM_VC_IV == nwt ) {
- } else if( NativeWindowFactory.TYPE_AWT == nwt ) {
- */
- }
- throw new UnsupportedOperationException("n/a for windowing system: "+nwt);
- }
-
-
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java
deleted file mode 100644
index 2e9f2c172..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package com.jogamp.nativewindow;
-
-/**
- * Handling requests for using an {@link OffscreenLayerSurface}
- * within the implementation.
- */
-public interface OffscreenLayerOption {
- /**
- * Request an offscreen layer, if supported.
- *
- * Shall be called before the first {@link NativeWindow#lockSurface()},
- * and hence before realization.
- *
- *
- * @see #getShallUseOffscreenLayer()
- * @see #isOffscreenLayerSurfaceEnabled()
- */
- public void setShallUseOffscreenLayer(boolean v);
-
- /** Returns the property set by {@link #setShallUseOffscreenLayer(boolean)}. */
- public boolean getShallUseOffscreenLayer();
-
- /**
- * Returns true if this instance uses an offscreen layer, otherwise false.
- *
- * This instance is an offscreen layer, if {@link #setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)}
- * has been called before it's realization and first lock and the underlying implementation supports it.
- *
- * The return value is undefined before issuing the first {@link NativeWindow#lockSurface()}.
- *
- * @see #setShallUseOffscreenLayer(boolean)
- */
- public boolean isOffscreenLayerSurfaceEnabled();
-}
\ No newline at end of file
diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
deleted file mode 100644
index abba2c126..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package com.jogamp.nativewindow;
-
-import com.jogamp.nativewindow.util.PixelRectangle;
-import com.jogamp.nativewindow.util.PointImmutable;
-
-import com.jogamp.common.util.locks.RecursiveLock;
-
-/**
- * Interface specifying the offscreen layer surface protocol.
- */
-public interface OffscreenLayerSurface {
- /**
- * Attach the offscreen layer to this offscreen layer surface.
- *
- * Implementation may realize all required resources at this point.
- *
- *
- * @see #isOffscreenLayerSurfaceEnabled()
- * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
- */
- public void attachSurfaceLayer(final long layerHandle) throws NativeWindowException;
-
- /**
- * Detaches a previously attached offscreen layer from this offscreen layer surface.
- * @see #attachSurfaceLayer(long)
- * @see #isOffscreenLayerSurfaceEnabled()
- * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false
- * or no surface layer is attached.
- */
- public void detachSurfaceLayer() throws NativeWindowException;
-
- /** Returns the attached surface layer or null if none is attached. */
- public long getAttachedSurfaceLayer();
-
- /** Returns true if a surface layer is attached, otherwise false. */
- public boolean isSurfaceLayerAttached();
-
- /** Sets the capabilities of this instance, allowing upstream API's to refine it, i.e. OpenGL related settings. */
- public void setChosenCapabilities(CapabilitiesImmutable caps);
-
- /** Returns the recursive lock object of this surface, which synchronizes multithreaded access. */
- public RecursiveLock getLock();
-
- /**
- * Optional method setting cursor in the corresponding on-screen surface/window, if exists.
- *
- * @param pixelrect cursor pixels, maybe null for default cursor
- * @param hotSpot maybe null for default cursor
- * @return true if successful, i.e. on-screen surface/window w/ cursor capabilities exists. Otherwise false.
- */
- public boolean setCursor(PixelRectangle pixelrect, PointImmutable hotSpot);
-
- /**
- * Optional method hiding the cursor in the corresponding on-screen surface/window, if exists.
- *
- * @return true if successful, i.e. on-screen surface/window w/ cursor capabilities exists. Otherwise false.
- */
- public boolean hideCursor();
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
deleted file mode 100644
index 7b36531dc..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * Copyright 2012 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow;
-
-import jogamp.nativewindow.Debug;
-
-/**
- * Provides a mutable {@link NativeSurface}, i.e. {@link MutableSurface}, while allowing an
- * {@link UpstreamSurfaceHook} to influence the lifecycle and information.
- *
- * @see UpstreamSurfaceHook
- * @see MutableSurface
- * @see NativeSurface
- */
-public interface ProxySurface extends MutableSurface {
- public static final boolean DEBUG = Debug.debug("ProxySurface");
-
- /**
- * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's surface handle
- * @see #addUpstreamOptionBits(int)
- * @see #clearUpstreamOptionBits(int)
- * @see #getUpstreamOptionBits()
- */
- public static final int OPT_PROXY_OWNS_UPSTREAM_SURFACE = 1 << 6;
-
- /**
- * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's {@link AbstractGraphicsDevice}.
- * @see #addUpstreamOptionBits(int)
- * @see #clearUpstreamOptionBits(int)
- * @see #getUpstreamOptionBits()
- */
- public static final int OPT_PROXY_OWNS_UPSTREAM_DEVICE = 1 << 7;
-
- /**
- * Implementation specific bitvalue stating the upstream's {@link NativeSurface} is an invisible window, i.e. maybe incomplete.
- * @see #addUpstreamOptionBits(int)
- * @see #clearUpstreamOptionBits(int)
- * @see #getUpstreamOptionBits()
- */
- public static final int OPT_UPSTREAM_WINDOW_INVISIBLE = 1 << 8;
-
- /**
- * Implementation specific bitvalue stating the upstream's {@link NativeSurface}'s zero handle is valid.
- * @see #addUpstreamOptionBits(int)
- * @see #clearUpstreamOptionBits(int)
- * @see #getUpstreamOptionBits()
- */
- public static final int OPT_UPSTREAM_SURFACELESS = 1 << 9;
-
- /** Allow redefining the AbstractGraphicsConfiguration */
- public void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg);
-
- /**
- * Returns the optional upstream {@link NativeSurface} if used by implementation, otherwise null.
- *
- * The upstream {@link NativeSurface} is retrieved via {@link #getUpstreamSurfaceHook() the UpstreamSurfaceHook},
- * i.e. {@link UpstreamSurfaceHook#getUpstreamSurface()}.
- *
- *
- * One example is the JOGL EGLWrappedSurface, which might be backed up by a
- * native platform NativeSurface (X11, WGL, CGL, ..).
- *
- */
- public NativeSurface getUpstreamSurface();
-
- /** Returns the {@link UpstreamSurfaceHook} if {@link #setUpstreamSurfaceHook(UpstreamSurfaceHook) set}, otherwise null. */
- public UpstreamSurfaceHook getUpstreamSurfaceHook();
-
- /**
- * Overrides the {@link UpstreamSurfaceHook}.
- */
- public void setUpstreamSurfaceHook(UpstreamSurfaceHook hook);
-
- /**
- * Enables or disables the {@link UpstreamSurfaceHook} lifecycle functions
- * {@link UpstreamSurfaceHook#create(ProxySurface)} and {@link UpstreamSurfaceHook#destroy(ProxySurface)}.
- *
- * Use this for small code blocks where the native resources shall not change,
- * i.e. resizing a derived (OpenGL) drawable.
- *
- */
- public void enableUpstreamSurfaceHookLifecycle(boolean enable);
-
- /**
- * {@link UpstreamSurfaceHook#create(ProxySurface)} is being issued and the proxy surface/window handles shall be set.
- */
- public void createNotify();
-
- /**
- * {@link UpstreamSurfaceHook#destroy(ProxySurface)} is being issued and all proxy surface/window handles shall be cleared.
- */
- public void destroyNotify();
-
- public StringBuilder getUpstreamOptionBits(StringBuilder sink);
- public int getUpstreamOptionBits();
-
- /** Returns true if the give bit-mask v is set in this instance upstream-option-bits, otherwise false.*/
- public boolean containsUpstreamOptionBits(int v);
-
- /** Add the given bit-mask to this instance upstream-option-bits using bit-or w/ v.*/
- public void addUpstreamOptionBits(int v);
-
- /** Clear the given bit-mask from this instance upstream-option-bits using bit-and w/ ~v*/
- public void clearUpstreamOptionBits(int v);
-
- public StringBuilder toString(StringBuilder sink);
- @Override
- public String toString();
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java b/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java
deleted file mode 100644
index eea9e4bed..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/ScalableSurface.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * Copyright 2014 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow;
-
-/**
- * Adding mutable surface pixel scale property to implementing class, usually to a {@link NativeSurface} implementation,
- * see {@link #setSurfaceScale(float[])}.
- */
-public interface ScalableSurface {
- /** Setting surface-pixel-scale of {@value}, results in same pixel- and window-units. */
- public static final float IDENTITY_PIXELSCALE = 1f;
- /** Setting surface-pixel-scale of {@value}, results in maximum platform dependent pixel-scale, i.e. pixel-units >> window-units where available. */
- public static final float AUTOMAX_PIXELSCALE = 0f;
-
- /**
- * Request a pixel scale in x- and y-direction for the associated {@link NativeSurface},
- * where {@code size_in_pixel_units = pixel_scale * size_in_window_units}.
- *
- * Default pixel scale request for both directions is {@link #AUTOMAX_PIXELSCALE}.
- *
- *
- * In case platform only supports uniform pixel scale, i.e. one scale for both directions,
- * either {@link #AUTOMAX_PIXELSCALE} or the maximum requested pixel scale component is used.
- *
- *
- * The requested pixel scale will be validated against platform limits before native scale-setup,
- * i.e. clipped to {@link #IDENTITY_PIXELSCALE} if not supported or clipped to the platform maximum.
- * It can be queried via {@link #getRequestedSurfaceScale(float[])}.
- *
- *
- * The actual realized pixel scale values of the {@link NativeSurface}
- * can be queried via {@link #getCurrentSurfaceScale(float[])} or
- * computed via surface.{@link NativeSurface#convertToPixelUnits(int[]) convertToPixelUnits}(new int[] { 1, 1 })
- *
- * @param pixelScale requested surface pixel scale float[2] values for x- and y-direction.
- * @return {@code true} if the {@link #getCurrentSurfaceScale(float[]) current pixel scale} has changed, otherwise {@code false}.
- * @see #getRequestedSurfaceScale(float[])
- */
- public boolean setSurfaceScale(final float[] pixelScale);
-
- /**
- * Returns the {@link #setSurfaceScale(float[]) requested} pixel scale of the associated {@link NativeSurface}.
- *
- * @param result float[2] storage for the result
- * @return the passed storage containing the current pixelScale for chaining
- * @see #setSurfaceScale(float[])
- */
- public float[] getRequestedSurfaceScale(final float[] result);
-
- /**
- * Returns the current pixel scale of the associated {@link NativeSurface}.
- *
- * @param result float[2] storage for the result
- * @return the passed storage containing the current pixelScale for chaining
- */
- public float[] getCurrentSurfaceScale(final float[] result);
-
- /**
- * Returns the minimum pixel scale of the associated {@link NativeSurface}.
- * @param result float[2] storage for the result
- * @return the passed storage containing the minimum pixelScale for chaining
- */
- public float[] getMinimumSurfaceScale(final float[] result);
-
- /**
- * Returns the maximum pixel scale of the associated {@link NativeSurface}.
- *
- * The maximum pixel scale maybe used to determine the proper dpi
- * value of the monitor displaying this {@link NativeSurface}.
- *
- * surfacePpMM = monitorPpMM * currentSurfaceScale / nativeSurfaceScale,
- * with PpMM == pixel per millimeter
- *
- *
- *
- * @param result float[2] storage for the result
- * @return the passed storage containing the maximum pixelScale for chaining
- */
- public float[] getMaximumSurfaceScale(final float[] result);
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java b/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java
deleted file mode 100644
index 37e4bd0c9..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-package com.jogamp.nativewindow;
-
-/**
- * Clients may add their SurfaceUpdateListener implementation to a {@link com.jogamp.nativewindow.NativeSurface}
- * allowing to get notified after the surface has been updated, eg. after a swap buffer operation.
- */
-public interface SurfaceUpdatedListener {
- /** Notification of a surface update event, eg. after a swap buffer operation.
- *
- * @param updater is the caller object who updated the surface,
- * e.g. a JOGL GLDrawable.
- * @param ns the updated NativeSurface
- * @param when the time in ms, when the surface was updated
- */
- public void surfaceUpdated(Object updater, NativeSurface ns, long when) ;
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java
deleted file mode 100644
index eef11adb7..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow;
-
-import jogamp.nativewindow.Debug;
-
-/**
- * Marker for a singleton global recursive blocking lock implementation,
- * optionally locking a native windowing toolkit as well.
- *
- * Toolkit locks are created solely via {@link NativeWindowFactory}.
- *
- *
- * One use case is the AWT locking on X11, see {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}.
- *
- */
-public interface ToolkitLock {
- public static final boolean DEBUG = Debug.debug("ToolkitLock");
- public static final boolean TRACE_LOCK = Debug.isPropertyDefined("nativewindow.debug.ToolkitLock.TraceLock", true);
-
- /**
- * Blocking until the lock is acquired by this Thread or a timeout is reached.
- *
- * Timeout is implementation specific, if used at all.
- *
- *
- * @throws RuntimeException in case of a timeout
- */
- public void lock();
-
- /**
- * Release the lock.
- *
- * @throws RuntimeException in case the lock is not acquired by this thread.
- */
- public void unlock();
-
- /**
- * @throws RuntimeException if current thread does not hold the lock
- */
- public void validateLocked() throws RuntimeException;
-
- /**
- * Dispose this instance.
- *
- * Shall be called when instance is no more required.
- *
- * This allows implementations sharing a lock via resources
- * to decrease the reference counter.
- */
- public void dispose();
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java b/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java
deleted file mode 100644
index 5e9b8d293..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright 2012 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow;
-
-/**
- * Interface allowing upstream caller to pass lifecycle actions and size info
- * to a {@link ProxySurface} instance.
- */
-public interface UpstreamSurfaceHook {
- /** called within {@link ProxySurface#createNotify()} within lock, before using surface. */
- public void create(ProxySurface s);
- /** called within {@link ProxySurface#destroyNotify()} within lock, before clearing fields. */
- public void destroy(ProxySurface s);
-
- /**
- * Returns the optional upstream {@link NativeSurface} if used by implementation, otherwise null.
- *
- * One example is the JOGL EGLWrappedSurface, which might be backed up by a
- * native platform NativeSurface (X11, WGL, CGL, ..).
- *
- */
- public NativeSurface getUpstreamSurface();
-
- /** Returns the width of the upstream surface in pixels, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */
- public int getSurfaceWidth(ProxySurface s);
- /** Returns the height of the upstream surface in pixels, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */
- public int getSurfaceHeight(ProxySurface s);
-
- /**
- * {@link UpstreamSurfaceHook} w/ mutable size, allowing it's {@link ProxySurface} user to resize.
- */
- public interface MutableSize extends UpstreamSurfaceHook {
- /**
- * Resizes the upstream surface.
- * @param width new width in pixel units
- * @param height new height in pixel units
- */
- public void setSurfaceSize(int width, int height);
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java
deleted file mode 100644
index 69bfe50f8..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * Copyright 2012 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow;
-
-import java.util.Comparator;
-
-/**
- * Visual ID holder interface.
- *
- * Allows queries of different types of native visual IDs,
- * see {@link #getVisualID(int)}.
- *
- */
-public interface VisualIDHolder {
-
- public enum VIDType {
- // Generic Values
- INTRINSIC(0), NATIVE(1),
- // EGL Values
- EGL_CONFIG(10),
- // X11 Values
- X11_XVISUAL(20), X11_FBCONFIG(21),
- // Windows Values
- WIN32_PFD(30);
-
- public final int id;
-
- VIDType(final int id){
- this.id = id;
- }
- }
-
- /**
- * Returns the native visual ID of the given type
- * if supported, or {@link #VID_UNDEFINED} if not supported.
- *
- * Depending on the native windowing system, type is handled as follows:
- *
- *
X11 throws NativeWindowException on EGL_CONFIG, WIN32_PFD
- *
- *
INTRINSIC: X11 XVisual ID
- *
NATIVE: X11 XVisual ID
- *
X11_XVISUAL: X11 XVisual ID
- *
X11_FBCONFIG: VID_UNDEFINED
- *
- *
X11/GL throws NativeWindowException on EGL_CONFIG, WIN32_PFD
- *
- *
INTRINSIC: X11 XVisual ID
- *
NATIVE: X11 XVisual ID
- *
X11_XVISUAL: X11 XVisual ID
- *
X11_FBCONFIG: X11 FBConfig ID or VID_UNDEFINED
- *
- *
Windows/GL throws NativeWindowException on EGL_CONFIG, X11_XVISUAL, X11_FBCONFIG
- *
- *
INTRINSIC: Win32 PIXELFORMATDESCRIPTOR ID
- *
NATIVE: Win32 PIXELFORMATDESCRIPTOR ID
- *
WIN32_PFD: Win32 PIXELFORMATDESCRIPTOR ID
- *
- *
EGL/GL throws NativeWindowException on X11_XVISUAL, X11_FBCONFIG, WIN32_PFD
- *
- *
- * Note: INTRINSIC and NATIVE are always handled,
- * but may result in {@link #VID_UNDEFINED}. The latter is true if
- * the native value are actually undefined or the corresponding object is not
- * mapped to a native visual object.
- *
- * @throws NativeWindowException if type is neither
- * INTRINSIC nor NATIVE
- * and does not match the native implementation.
- */
- int getVisualID(VIDType type) throws NativeWindowException ;
-
- /**
- * {@link #getVisualID(VIDType)} result indicating an undefined value,
- * which could be cause by an unsupported query.
- *
- * We assume the const value 0 doesn't reflect a valid native visual ID
- * and is interpreted as no value on all platforms.
- * This is currently true for Android, X11 and Windows.
- *
- */
- static final int VID_UNDEFINED = 0;
-
- /** Comparing {@link VIDType#NATIVE} */
- public static class VIDComparator implements Comparator {
- private final VIDType type;
-
- public VIDComparator(final VIDType type) {
- this.type = type;
- }
-
- @Override
- public int compare(final VisualIDHolder vid1, final VisualIDHolder vid2) {
- final int id1 = vid1.getVisualID(type);
- final int id2 = vid2.getVisualID(type);
-
- if(id1 > id2) {
- return 1;
- } else if(id1 < id2) {
- return -1;
- }
- return 0;
- }
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java b/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java
deleted file mode 100644
index f4f8a02e1..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow;
-
-/**
- * Protocol for handling window closing events.
- *
- * The implementation shall obey either the user value set by this interface,
- * an underlying toolkit set user value or it's default, eg. {@link WindowClosingMode#DO_NOTHING_ON_CLOSE DO_NOTHING_ON_CLOSE} within an AWT environment.
- * If none of the above determines the operation,
- * this protocol default behavior {@link WindowClosingMode#DISPOSE_ON_CLOSE DISPOSE_ON_CLOSE} shall be used.
- */
-public interface WindowClosingProtocol {
-
- /**
- * Window closing mode if triggered by toolkit close operation.
- */
- public enum WindowClosingMode {
- /**
- * Do nothing on native window close operation.
- * This is the default behavior within an AWT environment.
- */
- DO_NOTHING_ON_CLOSE,
-
- /**
- * Dispose resources on native window close operation.
- * This is the default behavior in case no underlying toolkit defines otherwise.
- */
- DISPOSE_ON_CLOSE;
- }
-
-
- /**
- * @return the current close operation value
- * @see WindowClosingMode#DISPOSE_ON_CLOSE
- * @see WindowClosingMode#DO_NOTHING_ON_CLOSE
- */
- WindowClosingMode getDefaultCloseOperation();
-
- /**
- * @param op the new close operation value
- * @return the previous close operation value
- * @see WindowClosingMode#DISPOSE_ON_CLOSE
- * @see WindowClosingMode#DO_NOTHING_ON_CLOSE
- */
- WindowClosingMode setDefaultCloseOperation(WindowClosingMode op);
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/package.html b/src/nativewindow/classes/javax/media/nativewindow/package.html
deleted file mode 100644
index 1fe52eea4..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/package.html
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
-
- NativeWindow Specification Overview
-
-
-
-
NativeWindow Protocol Specification Overview
-
-
Preface
- This specification, an optional set of packages, describing a protocol for a
- native windowing interface binding to Java(TM).
- Currently specified native windowing systems are:
-
-
EGL/OpenKODE Windowing System
-
X11 Windowing System
-
Microsoft Windows
-
Apple MacOSX
-
Java's AWT
-
-
- However, any other native windowing system may be added to the implementation,
- using a generic string identifier and an optional specialisation of:
-
The specialisation of the abstract class {@link com.jogamp.nativewindow.NativeWindowFactory NativeWindowFactory}
-
shall be registered with {@link com.jogamp.nativewindow.NativeWindowFactory#registerFactory NativeWindowFactory.registerFactory(..)}.
-
-
The specialisation of the abstract class {@link com.jogamp.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}
-
shall be registered with {@link com.jogamp.nativewindow.GraphicsConfigurationFactory#registerFactory GraphicsConfigurationFactory.registerFactory(..)}.
-
-
This protocol does not describe how to create native windows, but how to bind a native surface to an implementation of
- and window to an implementation of {@link com.jogamp.nativewindow.NativeSurface NativeSurface}.
-
{@link com.jogamp.nativewindow.NativeWindow NativeWindow} specializes the NativeSurface.
-
However, an implementation of this protocol (e.g. {@link com.jogamp.newt}) may support the creation.
-
-
Dependencies
- This binding has dependencies to the following:
-
- The packages defined by this specification include:
-
-
The com.jogamp.nativewindow package
-
This package contains Java bindings for a native windowing system.
-
Subsequent packages contain marker type classes, containing native characteristics of the windowing system.
-
-
The com.jogamp.nativewindow.awt package
-
This sub package contains classes to cover the native characteristics of the AWT windowing system.
-
-
The com.jogamp.nativewindow.x11 package
-
This sub package contains classes to cover the native characteristics of the X11 windowing system.
-
-
The com.jogamp.nativewindow.windows package
-
This sub package contains classes to cover the native characteristics of the Windows windowing system.
-
-
The com.jogamp.nativewindow.macosx package
-
This sub package contains classes to cover the native characteristics of the MacOSX windowing system.
-
-
The com.jogamp.nativewindow.egl package
-
This sub package contains classes to cover the native characteristics of the EGL/OpenKODE windowing system.
-
-
-
-
Factory Model
-
Running on a platform with a supported windowing system, the factory model shall be used
-to instantiate a native window, see {@link com.jogamp.nativewindow.NativeWindowFactory NativeWindowFactory}.
-
-
Revision History
-
-
-
Early Draft Review, June 2009
-
2.0.0 Maintenance Release, February 2011
-
2.0.2 Major Release, July 18th 2013
-
-
-
-
-
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java
deleted file mode 100644
index 28c5dd90e..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow.util;
-
-public class Dimension implements Cloneable, DimensionImmutable {
- int width;
- int height;
-
- public Dimension() {
- this(0, 0);
- }
-
- public Dimension(final int[] size) {
- this(size[0], size[1]);
- }
-
- public Dimension(final int width, final int height) {
- if(width<0 || height<0) {
- throw new IllegalArgumentException("width and height must be within: ["+0+".."+Integer.MAX_VALUE+"]");
- }
- this.width=width;
- this.height=height;
- }
-
- @Override
- public Object cloneMutable() {
- return clone();
- }
-
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (final CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public final int getWidth() { return width; }
- @Override
- public final int getHeight() { return height; }
-
- public final void set(final int width, final int height) {
- this.width = width;
- this.height = height;
- }
- public final void setWidth(final int width) {
- this.width = width;
- }
- public final void setHeight(final int height) {
- this.height = height;
- }
- public final Dimension scale(final int s) {
- width *= s;
- height *= s;
- return this;
- }
- public final Dimension add(final Dimension pd) {
- width += pd.width ;
- height += pd.height ;
- return this;
- }
-
- @Override
- public String toString() {
- return width + " x " + height;
- }
-
- @Override
- public int compareTo(final DimensionImmutable d) {
- final int tsq = width*height;
- final int xsq = d.getWidth()*d.getHeight();
-
- if(tsq > xsq) {
- return 1;
- } else if(tsq < xsq) {
- return -1;
- }
- return 0;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if(this == obj) { return true; }
- if (obj instanceof Dimension) {
- final Dimension p = (Dimension)obj;
- return height == p.height &&
- width == p.width ;
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- // 31 * x == (x << 5) - x
- final int hash = 31 + width;
- return ((hash << 5) - hash) + height;
- }
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java
deleted file mode 100644
index 6de77a716..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow.util;
-
-import com.jogamp.common.type.WriteCloneable;
-
-/** Immutable Dimension Interface, consisting of it's read only components:
- *
- * {@inheritDoc}
- */
- @Override
- public int compareTo(final DimensionImmutable d);
-
- /**
- * Checks whether two dimensions objects are equal. Two instances
- * of DimensionReadOnly are equal if two components
- * height and width are equal.
- * @return true if the two dimensions are equal;
- * otherwise false.
- */
- @Override
- boolean equals(Object obj);
-
- @Override
- int hashCode();
-
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java
deleted file mode 100644
index 205e18346..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow.util;
-
-/**
- * Mutable insets representing rectangular window decoration insets on all four edges
- * in window units.
- */
-public class Insets implements Cloneable, InsetsImmutable {
- static final InsetsImmutable zeroInsets = new Insets();
- public static final InsetsImmutable getZero() { return zeroInsets; }
-
- private int l, r, t, b;
-
- public Insets() {
- this(0, 0, 0, 0);
- }
-
- public Insets(final int left, final int right, final int top, final int bottom) {
- this.l=left;
- this.r=right;
- this.t=top;
- this.b=bottom;
- }
-
- @Override
- public Object cloneMutable() {
- return clone();
- }
-
- @Override
- protected Object clone() {
- try {
- return super.clone();
- } catch (final CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public final int getLeftWidth() { return l; }
- @Override
- public final int getRightWidth() { return r; }
- @Override
- public final int getTotalWidth() { return l + r; }
- @Override
- public final int getTopHeight() { return t; }
- @Override
- public final int getBottomHeight() { return b; }
- @Override
- public final int getTotalHeight() { return t + b; }
-
- /**
- * Set the inset values of this instance in window units.
- * @param left left inset width in window units.
- * @param right right inset width in window units.
- * @param top top inset width in window units.
- * @param bottom bottom inset width in window units.
- */
- public final void set(final int left, final int right, final int top, final int bottom) {
- l = left; r = right; t = top; b = bottom;
- }
- /**
- * Set the left inset value of this instance in window units.
- * @param left left inset width in window units.
- */
- public final void setLeftWidth(final int left) { l = left; }
- /**
- * Set the right inset value of this instance in window units.
- * @param right right inset width in window units.
- */
- public final void setRightWidth(final int right) { r = right; }
- /**
- * Set the top inset value of this instance in window units.
- * @param top top inset width in window units.
- */
- public final void setTopHeight(final int top) { t = top; }
- /**
- * Set the bottom inset value of this instance in window units.
- * @param bottom bottom inset width in window units.
- */
- public final void setBottomHeight(final int bottom) { b = bottom; }
-
- @Override
- public boolean equals(final Object obj) {
- if(this == obj) { return true; }
- if (obj instanceof Insets) {
- final Insets insets = (Insets)obj;
- return (r == insets.r) && (l == insets.l) &&
- (b == insets.b) && (t == insets.t);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- final int sum1 = l + b;
- final int sum2 = t + r;
- final int val1 = sum1 * (sum1 + 1)/2 + l;
- final int val2 = sum2 * (sum2 + 1)/2 + r;
- final int sum3 = val1 + val2;
- return sum3 * (sum3 + 1)/2 + val2;
- }
-
- @Override
- public String toString() {
- return "[ l "+l+", r "+r+" - t "+t+", b "+b+" - "+getTotalWidth()+"x"+getTotalHeight()+"]";
- }
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java
deleted file mode 100644
index e626a507e..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow.util;
-
-import com.jogamp.common.type.WriteCloneable;
-
-/**
- * Immutable insets representing rectangular window decoration insets on all four edges
- * in window units.
- */
-public interface InsetsImmutable extends WriteCloneable {
-
- /** @return left inset width in window units. */
- int getLeftWidth();
-
- /** @return right inset width in window units. */
- int getRightWidth();
-
- /** @return total width in window units, ie. left_width + right_width */
- int getTotalWidth();
-
- /** @return top inset height in window units. */
- int getTopHeight();
-
- /** @return bottom inset height in window units. */
- int getBottomHeight();
-
- /** @return total height in window units, ie. top_height + bottom_height */
- int getTotalHeight();
-
- /**
- * Checks whether two rect objects are equal. Two instances
- * of Insets are equal if the four integer values
- * of the fields left, right,
- * top, and bottom are all equal.
- * @return true if the two Insets are equal;
- * otherwise false.
- */
- @Override
- boolean equals(Object obj);
-
- @Override
- int hashCode();
-
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormat.java b/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormat.java
deleted file mode 100644
index 8b1e91564..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormat.java
+++ /dev/null
@@ -1,739 +0,0 @@
-/**
- * Copyright (c) 2014 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow.util;
-
-import java.util.Arrays;
-
-import com.jogamp.common.util.IntBitfield;
-
-/**
- * Basic pixel formats
- *
- * Notation follows OpenGL notation, i.e.
- * name consist of all it's component names
- * followed by their bit size.
- *
- *
- * Order of component names is from lowest-bit to highest-bit.
- *
- *
- * In case component-size is 1 byte (e.g. OpenGL data-type GL_UNSIGNED_BYTE),
- * component names are ordered from lowest-byte to highest-byte.
- * Note that OpenGL applies special interpretation if
- * data-type is e.g. GL_UNSIGNED_8_8_8_8_REV or GL_UNSIGNED_8_8_8_8_REV.
- *
- *
- * PixelFormat can be converted to OpenGL GLPixelAttributes
- * via
- *
- *
- */
- BGRA8888(new CType[]{ CType.B, CType.G, CType.R, CType.A }, 4, 8, 32);
-
- /** Unique {@link Composition Pixel Composition}, i.e. layout of its components. */
- public final Composition comp;
-
- /**
- * @param componentOrder {@link CType Component type} order of all components, see {@link Composition#componentBitMask()}.
- * @param componentCount number of components
- * @param bpc bits per component
- * @param bitStride stride bits to next pixel
- */
- private PixelFormat(final CType[] componentOrder, final int componentCount, final int bpc, final int bitStride) {
- this.comp = new PackedComposition(componentOrder, componentCount, bpc, bitStride);
- }
-
- /**
- * @param componentOrder {@link CType Component type} order of all components, see {@link Composition#componentBitMask()}.
- * @param componentMask bit-mask of of all components, see {@link Composition##componentBitMask()}.
- * @param componentBitShift bit-shift of all components, see {@link Composition##componentBitMask()}.
- * @param bitStride stride bits to next pixel
- */
- private PixelFormat(final CType[] componentOrder, final int[] componentMask, final int[] componentBitShift, final int bitStride) {
- this.comp = new PackedComposition(componentOrder, componentMask, componentBitShift, bitStride);
- }
-
- /**
- * Returns the unique matching {@link PixelFormat} of the given {@link Composition}
- * or {@code null} if none is available.
- */
- public static PixelFormat valueOf(final Composition comp) {
- final PixelFormat[] all = PixelFormat.values();
- for(int i=all.length-1; i>=0; i--) {
- final PixelFormat pf = all[i];
- if( comp.hashCode() == pf.comp.hashCode() && comp.equals(pf.comp) ) {
- return pf;
- }
- }
- return null;
- }
-
- /** Component types */
- public static enum CType {
- /** Red component */
- R,
- /** Green component */
- G,
- /** Blue component */
- B,
- /** Alpha component */
- A,
- /** Luminance component, e.g. grayscale or Y of YUV */
- Y,
- /** U component of YUV */
- U,
- /** V component of YUV */
- V;
- }
-
- /**
- * Pixel composition, i.e. layout of its components.
- */
- public static interface Composition {
- /** {@value} */
- public static final int UNDEF = -1;
-
- /**
- * Returns {@code true} if all components are of same bit-size, e.g. {@link PixelFormat#RGBA8888 RGBA8888},
- * otherwise {@code false}, e.g. {@link PixelFormat#RGBA5551 RGBA5551}
- */
- boolean isUniform();
-
- /**
- * Returns {@code true} if all components are packed, i.e. interleaved, e.g. {@link PixelFormat#RGBA8888 RGBA8888},
- * otherwise {@code false}.
- */
- boolean isInterleaved();
-
- /** Number of components per pixel, e.g. 3 for {@link PixelFormat#RGBx8888 RGBx8888}. */
- int componenCount();
- /** Number of bits per pixel, e.g. 24 bits for {@link PixelFormat#RGBx8888 RGBx8888}. */
- int bitsPerPixel();
- /**
- * Bit distance between pixels.
- *
- * For packed pixels e.g. 32 bits for {@link PixelFormat#RGBx8888 RGBx8888}.
- *
- */
- int bitStride();
- /** Number of bytes per pixel, i.e. packed {@link #bitStride()} in bytes, e.g. 4 for {@link PixelFormat#RGBx8888 RGBx8888}. */
- int bytesPerPixel();
- /**
- * Returns the {@link CType Component type} order of all components, see {@link #componentBitMask()}.
- */
- CType[] componentOrder();
- /**
- * Returns the index of given {@link CType} within {@link #componentOrder()}, -1 if not exists.
- */
- int find(final PixelFormat.CType s);
- /**
- * Returns the un-shifted bit-mask of all components.
- *
- * Components mask is returned in the order Low-Index to High-Index, e.g.:
- *
- *
{@link PixelFormat#RGB565 RGB565}: 0: R 0x1F, 1: G 0x3F, 2: B 0x1F
- *
{@link PixelFormat#RGBA5551 RGBA5551}: 0: R 0x1F, 1: G 0x1F, 2: B 0x1F, 3: A 0x01
- *
{@link PixelFormat#RGBA8888 RGBA8888}: 0: R 0xFF, 1: G 0xFF, 2: B 0xFF, 3: A 0xFF
- *
- *
- *
- */
- int[] componentBitMask();
- /**
- * Returns the number of bits of all components, see {@link #componentBitMask()}.
- */
- int[] componentBitCount();
- /**
- * Returns the bit-shift of all components, see {@link #componentBitMask()}.
- */
- int[] componentBitShift();
-
- /**
- * Decodes a component from the shifted pixel data with a {@link #bytesPerPixel()} of up to 32bit.
- * @param shifted complete pixel encoded into on 32bit integer
- * @param cIdx the desired component index
- * @return the decoded component value
- */
- int decodeSingleI32(final int shifted, final int cIdx);
- /**
- * Decodes a component from the shifted pixel data with a {@link #bytesPerPixel()} of up to 64bit.
- * @param shifted complete pixel encoded into on 64bit integer
- * @param cIdx the desired component index
- * @return the decoded component value
- */
- int decodeSingleI64(final long shifted, final int cIdx);
-
- int encodeSingleI32(final int norm, final int cIdx);
- long encodeSingleI64(final int norm, final int cIdx);
-
- int encode3CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32);
- int encode4CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32, final int c4NormI32);
-
- int encodeSingleI8(final byte normalI8, final int cIdx);
- int encode3CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8);
- int encode4CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8, final byte c4NormI8);
-
- float toFloat(final int i32, final int cIdx, final boolean i32Shifted);
- int fromFloat(final float f, final int cIdx, final boolean shiftResult);
-
- int defaultValue(final int cIdx, final boolean shiftResult);
-
- /**
- * Returns cached immutable hash value, see {@link Object#hashCode()}.
- */
- int hashCode();
- /**
- * Returns {@link Object#equals(Object)}
- */
- boolean equals(final Object o);
-
- /**
- * Returns {@link Object#toString()}.
- */
- String toString();
- }
-
- /**
- * Packed pixel composition, see {@link Composition}.
- *
- * Components are interleaved, i.e. packed.
- *
- */
- public static class PackedComposition implements Composition {
- private final CType[] compOrder;
- private final int[] compMask;
- private final int[] compBitCount;
- private final int[] compBitShift;
- private final int bitsPerPixel;
- private final int bitStride;
- private final boolean uniform;
- private final int hashCode;
-
- public final String toString() {
- return String.format("PackedComp[order %s, stride %d, bpp %d, uni %b, comp %d: %s]",
- Arrays.toString(compOrder), bitStride, bitsPerPixel, uniform,
- compMask.length, toHexString(compBitCount, compMask, compBitShift));
- }
-
- /**
- * @param componentOrder {@link CType Component type} order of all components, see {@link #componentBitMask()}.
- * @param componentCount number of components
- * @param bpc bits per component
- * @param bitStride stride bits to next pixel
- */
- public PackedComposition(final CType[] componentOrder, final int componentCount, final int bpc, final int bitStride) {
- this.compOrder = componentOrder;
- this.compMask = new int[componentCount];
- this.compBitShift = new int[componentCount];
- this.compBitCount = new int[componentCount];
- final int compMask = ( 1 << bpc ) - 1;
- for(int i=0; i=0; i--) {
- final int cmask = componentMask[i];
- final int bitCount = IntBitfield.getBitCount(cmask);
- bpp += bitCount;
- this.compBitCount[i] = bitCount;
- if( i > 0 && uniform ) {
- uniform = componentMask[i-1] == cmask;
- }
- }
- this.uniform = uniform;
- this.bitsPerPixel = bpp;
- this.bitStride = bitStride;
- if( this.bitStride < this.bitsPerPixel ) {
- throw new IllegalArgumentException(String.format("bit-stride %d < bitsPerPixel %d", this.bitStride, this.bitsPerPixel));
- }
- this.hashCode = hashCodeImpl();
- }
-
- @Override
- public final boolean isUniform() { return uniform; }
- /**
- * {@inheritDoc}
- *
- */
- @Override
- public final boolean isInterleaved() { return true; }
- @Override
- public final int componenCount() { return compMask.length; }
- @Override
- public final int bitsPerPixel() { return bitsPerPixel; }
- @Override
- public final int bitStride() { return bitStride; }
- @Override
- public final int bytesPerPixel() { return (7+bitStride)/8; }
- @Override
- public final CType[] componentOrder() { return compOrder; }
- @Override
- public final int find(final PixelFormat.CType s) { return PixelFormatUtil.find(s, compOrder, false /* mapRGB2Y */); }
- @Override
- public final int[] componentBitMask() { return compMask; }
- @Override
- public final int[] componentBitCount() { return compBitCount; }
- @Override
- public final int[] componentBitShift() { return compBitShift; }
-
- @Override
- public final int decodeSingleI32(final int shifted, final int cIdx) {
- return ( shifted >>> compBitShift[cIdx] ) & compMask[cIdx];
- }
- @Override
- public final int decodeSingleI64(final long shifted, final int cIdx) {
- return ( (int)( 0xffffffffL & ( shifted >>> compBitShift[cIdx] ) ) ) & compMask[cIdx];
- }
- @Override
- public final int encodeSingleI32(final int norm, final int cIdx) {
- return ( norm & compMask[cIdx] ) << compBitShift[cIdx] ;
- }
- @Override
- public final long encodeSingleI64(final int norm, final int cIdx) {
- return ( 0xffffffffL & ( norm & compMask[cIdx] ) ) << compBitShift[cIdx] ;
- }
- @Override
- public final int encode3CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32) {
- return ( c1NormI32 & compMask[0] ) << compBitShift[0] |
- ( c2NormI32 & compMask[1] ) << compBitShift[1] |
- ( c3NormI32 & compMask[2] ) << compBitShift[2] ;
- }
- @Override
- public final int encode4CompI32(final int c1NormI32, final int c2NormI32, final int c3NormI32, final int c4NormI32) {
- return ( c1NormI32 & compMask[0] ) << compBitShift[0] |
- ( c2NormI32 & compMask[1] ) << compBitShift[1] |
- ( c3NormI32 & compMask[2] ) << compBitShift[2] |
- ( c4NormI32 & compMask[3] ) << compBitShift[3] ;
- }
- @Override
- public final int encodeSingleI8(final byte normI8, final int cIdx) {
- return ( normI8 & compMask[cIdx] ) << compBitShift[cIdx] ;
- }
- @Override
- public final int encode3CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8) {
- return ( c1NormI8 & compMask[0] ) << compBitShift[0] |
- ( c2NormI8 & compMask[1] ) << compBitShift[1] |
- ( c3NormI8 & compMask[2] ) << compBitShift[2] ;
- }
- @Override
- public final int encode4CompI8(final byte c1NormI8, final byte c2NormI8, final byte c3NormI8, final byte c4NormI8) {
- return ( c1NormI8 & compMask[0] ) << compBitShift[0] |
- ( c2NormI8 & compMask[1] ) << compBitShift[1] |
- ( c3NormI8 & compMask[2] ) << compBitShift[2] |
- ( c4NormI8 & compMask[3] ) << compBitShift[3] ;
- }
-
- @Override
- public final float toFloat(final int i32, final int cIdx, final boolean i32Shifted) {
- if( i32Shifted ) {
- return ( ( i32 >>> compBitShift[cIdx] ) & compMask[cIdx] ) / (float)( compMask[cIdx] ) ;
- } else {
- return ( i32 & compMask[cIdx] ) / (float)( compMask[cIdx] ) ;
- }
- }
- @Override
- public final int fromFloat(final float f, final int cIdx, final boolean shiftResult) {
- final int v = (int)(f * compMask[cIdx] + 0.5f);
- return shiftResult ? v << compBitShift[cIdx] : v;
- }
-
- @Override
- public final int defaultValue(final int cIdx, final boolean shiftResult) {
- final int v = ( CType.A == compOrder[cIdx] || CType.Y == compOrder[cIdx] )
- ? compMask[cIdx] : 0;
- return shiftResult ? v << compBitShift[cIdx] : v;
- }
-
- @Override
- public final int hashCode() { return hashCode; }
- private final int hashCodeImpl() {
- // 31 * x == (x << 5) - x
- int hash = 31 + bitStride;
- hash = ((hash << 5) - hash) + bitsPerPixel;
- hash = ((hash << 5) - hash) + compMask.length;
- for(int i=compOrder.length-1; i>=0; i--) {
- hash = ((hash << 5) - hash) + compOrder[i].ordinal();
- }
- for(int i=compMask.length-1; i>=0; i--) {
- hash = ((hash << 5) - hash) + compMask[i];
- }
- for(int i=compBitShift.length-1; i>=0; i--) {
- hash = ((hash << 5) - hash) + compBitShift[i];
- }
- return hash;
- }
-
- @Override
- public final boolean equals(final Object obj) {
- if(this == obj) { return true; }
- if( obj instanceof PackedComposition ) {
- final PackedComposition other = (PackedComposition) obj;
- return bitStride == other.bitStride &&
- bitsPerPixel == other.bitsPerPixel &&
- Arrays.equals(compOrder, other.compOrder) &&
- Arrays.equals(compMask, other.compMask) &&
- Arrays.equals(compBitShift, other.compBitShift);
- } else {
- return false;
- }
- }
- }
-
- private static String toHexString(final int[] bitCount, final int[] mask, final int[] shift) {
- final StringBuilder sb = new StringBuilder();
- sb.append("[");
- final int l = mask.length;
- for(int i=0; i < l; i++) {
- if(i > 0) {
- sb.append(", ");
- }
- sb.append(bitCount[i]).append(": ").
- append("0x").append(Integer.toHexString(mask[i])).append(" << ").append(shift[i]);
- }
- return sb.append("]").toString();
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormatUtil.java b/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormatUtil.java
deleted file mode 100644
index 180f02d72..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormatUtil.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/**
- * Copyright (c) 2014 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package com.jogamp.nativewindow.util;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
-import com.jogamp.common.nio.Buffers;
-import com.jogamp.common.util.Bitstream;
-
-/**
- * Pixel Rectangle Utilities.
- *
- * All conversion methods are endian independent.
- *
- */
-public class PixelFormatUtil {
- private static boolean DEBUG = false;
-
- public static class ComponentMap {
- /**
- * Contains the source index for each destination index,
- * length is {@link Composition#componenCount()} of destination.
- */
- final int[] dst2src;
- /**
- * Contains the destination index for each source index,
- * length is {@link Composition#componenCount()} of source.
- */
- final int[] src2dst;
-
- /**
- * Contains the source index of RGBA components.
- */
- final int[] srcRGBA;
- final boolean hasSrcRGB;
-
- public ComponentMap(final PixelFormat.Composition src, final PixelFormat.Composition dst) {
- final int sCompCount = src.componenCount();
- final int dCompCount = dst.componenCount();
- final PixelFormat.CType[] sCompOrder = src.componentOrder();
- final PixelFormat.CType[] dCompOrder = dst.componentOrder();
-
- dst2src = new int[dCompCount];
- for(int dIdx=0; dIdx= 0 && pool[i] != s) { i--; }
-
- if( 0 > i && mapRGB2Y && 1 == pool.length && pool[0] == PixelFormat.CType.Y &&
- ( PixelFormat.CType.R == s ||
- PixelFormat.CType.G == s ||
- PixelFormat.CType.B == s ) )
- {
- // Special case, fallback for RGB mapping -> LUMINANCE/Y
- return 0;
- } else {
- return i;
- }
- }
-
- /**
- * Returns shifted bytes from the given {@code data} at given {@code offset}
- * of maximal 4 {@code bytesPerPixel}.
- * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
- * @param data byte buffer covering complete pixel at position {@code offset}
- * @param offset byte offset of pixel {@code data} start
- * @return the shifted 32bit integer value of the pixel
- */
- public static int getShiftedI32(final int bytesPerPixel, final byte[] data, final int offset) {
- if( bytesPerPixel <= 4 ) {
- int shiftedI32 = 0;
- for(int i=0; i 4");
- }
- }
- /**
- * Returns shifted bytes from the given {@code data} at given {@code offset}
- * of maximal 8 {@code bytesPerPixel}.
- * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
- * @param data byte buffer covering complete pixel at position {@code offset}
- * @param offset byte offset of pixel {@code data} start
- * @return the shifted 64bit integer value of the pixel
- */
- public static long getShiftedI64(final int bytesPerPixel, final byte[] data, final int offset) {
- if( bytesPerPixel <= 8 ) {
- long shiftedI64 = 0;
- for(int i=0; i 8");
- }
- }
- /**
- * Returns shifted bytes from the given {@code data} at current position
- * of maximal 4 {@code bytesPerPixel}.
- * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
- * @param data byte buffer covering complete pixel at position {@code offset}
- * @param retainDataPos if true, absolute {@link ByteBuffer#get(int)} is used and the {@code data} position stays unchanged.
- * Otherwise relative {@link ByteBuffer#get()} is used and the {@code data} position changes.
- * @return the shifted 32bit integer value of the pixel
- */
- public static int getShiftedI32(final int bytesPerPixel, final ByteBuffer data, final boolean retainDataPos) {
- if( bytesPerPixel <= 4 ) {
- int shiftedI32 = 0;
- if( retainDataPos ) {
- final int offset = data.position();
- for(int i=0; i 4");
- }
- }
- /**
- * Returns shifted bytes from the given {@code data} at current position
- * of maximal 8 {@code bytesPerPixel}.
- * @param bytesPerPixel number of bytes per pixel to fetch, a maximum of 4 are allowed
- * @param data byte buffer covering complete pixel at position {@code offset}
- * @param retainDataPos if true, absolute {@link ByteBuffer#get(int)} is used and the {@code data} position stays unchanged.
- * Otherwise relative {@link ByteBuffer#get()} is used and the {@code data} position changes.
- * @return the shifted 64bit integer value of the pixel
- */
- public static long getShiftedI64(final int bytesPerPixel, final ByteBuffer data, final boolean retainDataPos) {
- if( bytesPerPixel <= 8 ) {
- long shiftedI64 = 0;
- if( retainDataPos ) {
- final int offset = data.position();
- for(int i=0; i 8");
- }
- }
-
- /**
- * Returns the {@link PixelFormat} with reversed components of fmt.
- * If no reversed {@link PixelFormat} is available, returns fmt.
- */
- public static PixelFormat getReversed(final PixelFormat fmt) {
- switch(fmt) {
- case RGB565:
- return PixelFormat.BGR565;
- case BGR565:
- return PixelFormat.RGB565;
- case RGBA5551:
- return PixelFormat.ABGR1555;
- case ABGR1555:
- return PixelFormat.RGBA5551;
- case RGB888:
- return PixelFormat.BGR888;
- case BGR888:
- return PixelFormat.RGB888;
- case RGBA8888:
- return PixelFormat.ABGR8888;
- case ABGR8888:
- return PixelFormat.RGBA8888;
- case ARGB8888:
- return PixelFormat.BGRA8888;
- case BGRA8888:
- return PixelFormat.ABGR8888;
- default:
- return fmt;
- }
- }
-
- public static int convertToInt32(final PixelFormat dst_fmt, final byte r, final byte g, final byte b, final byte a) {
- switch(dst_fmt) {
- case LUMINANCE: {
- final byte l = ( byte) ( ( ( ( 0xff & r ) + ( 0xff & g ) + ( 0xff & b ) ) / 3 ) * a );
- return ( 0xff ) << 24 | ( 0xff & l ) << 16 | ( 0xff & l ) << 8 | ( 0xff & l );
- }
- case RGB888:
- return ( 0xff ) << 24 | ( 0xff & b ) << 16 | ( 0xff & g ) << 8 | ( 0xff & r );
- case BGR888:
- return ( 0xff ) << 24 | ( 0xff & r ) << 16 | ( 0xff & g ) << 8 | ( 0xff & b );
- case RGBA8888:
- return ( 0xff & a ) << 24 | ( 0xff & b ) << 16 | ( 0xff & g ) << 8 | ( 0xff & r );
- case ABGR8888:
- return ( 0xff & r ) << 24 | ( 0xff & g ) << 16 | ( 0xff & b ) << 8 | ( 0xff & a );
- case ARGB8888:
- return ( 0xff & b ) << 24 | ( 0xff & g ) << 16 | ( 0xff & r ) << 8 | ( 0xff & a );
- case BGRA8888:
- return ( 0xff & a ) << 24 | ( 0xff & r ) << 16 | ( 0xff & g ) << 8 | ( 0xff & b );
- default:
- throw new InternalError("Unhandled format "+dst_fmt);
- }
- }
-
- public static int convertToInt32(final PixelFormat dst_fmt, final PixelFormat src_fmt, final ByteBuffer src, int srcOff) {
- final byte r, g, b, a;
- switch(src_fmt) {
- case LUMINANCE:
- r = src.get(srcOff++); // R
- g = r; // G
- b = r; // B
- a = (byte) 0xff; // A
- break;
- case RGB888:
- r = src.get(srcOff++); // R
- g = src.get(srcOff++); // G
- b = src.get(srcOff++); // B
- a = (byte) 0xff; // A
- break;
- case BGR888:
- b = src.get(srcOff++); // B
- g = src.get(srcOff++); // G
- r = src.get(srcOff++); // R
- a = (byte) 0xff; // A
- break;
- case RGBA8888:
- r = src.get(srcOff++); // R
- g = src.get(srcOff++); // G
- b = src.get(srcOff++); // B
- a = src.get(srcOff++); // A
- break;
- case ABGR8888:
- a = src.get(srcOff++); // A
- b = src.get(srcOff++); // B
- g = src.get(srcOff++); // G
- r = src.get(srcOff++); // R
- break;
- case ARGB8888:
- a = src.get(srcOff++); // A
- r = src.get(srcOff++); // R
- g = src.get(srcOff++); // G
- b = src.get(srcOff++); // B
- break;
- case BGRA8888:
- b = src.get(srcOff++); // B
- g = src.get(srcOff++); // G
- r = src.get(srcOff++); // R
- a = src.get(srcOff++); // A
- break;
- default:
- throw new InternalError("Unhandled format "+src_fmt);
- }
- return convertToInt32(dst_fmt, r, g, b, a);
- }
-
- public static int convertToInt32(final PixelFormat dest_fmt, final PixelFormat src_fmt, final int src_pixel) {
- final byte r, g, b, a;
- switch(src_fmt) {
- case LUMINANCE:
- r = (byte) ( src_pixel ); // R
- g = r; // G
- b = r; // B
- a = (byte) 0xff; // A
- break;
- case RGB888:
- r = (byte) ( src_pixel ); // R
- g = (byte) ( src_pixel >>> 8 ); // G
- b = (byte) ( src_pixel >>> 16 ); // B
- a = (byte) 0xff; // A
- break;
- case BGR888:
- b = (byte) ( src_pixel ); // B
- g = (byte) ( src_pixel >>> 8 ); // G
- r = (byte) ( src_pixel >>> 16 ); // R
- a = (byte) 0xff; // A
- break;
- case RGBA8888:
- r = (byte) ( src_pixel ); // R
- g = (byte) ( src_pixel >>> 8 ); // G
- b = (byte) ( src_pixel >>> 16 ); // B
- a = (byte) ( src_pixel >>> 24 ); // A
- break;
- case ABGR8888:
- a = (byte) ( src_pixel ); // A
- b = (byte) ( src_pixel >>> 8 ); // B
- g = (byte) ( src_pixel >>> 16 ); // G
- r = (byte) ( src_pixel >>> 24 ); // R
- break;
- case ARGB8888:
- a = (byte) ( src_pixel ); // A
- r = (byte) ( src_pixel >>> 8 ); // R
- g = (byte) ( src_pixel >>> 16 ); // G
- b = (byte) ( src_pixel >>> 24 ); // B
- break;
- case BGRA8888:
- b = (byte) ( src_pixel ); // B
- g = (byte) ( src_pixel >>> 8 ); // G
- r = (byte) ( src_pixel >>> 16 ); // R
- a = (byte) ( src_pixel >>> 24 ); // A
- break;
- default:
- throw new InternalError("Unhandled format "+src_fmt);
- }
- return convertToInt32(dest_fmt, r, g, b, a);
- }
-
- public static PixelRectangle convert(final PixelRectangle src,
- final PixelFormat destFmt, final int ddestStride, final boolean isGLOriented,
- final boolean destIsDirect) {
- final int width = src.getSize().getWidth();
- final int height = src.getSize().getHeight();
- final int bpp = destFmt.comp.bytesPerPixel();
- final int destStride;
- if( 0 != ddestStride ) {
- destStride = ddestStride;
- } else {
- destStride = bpp * width;
- }
- final int capacity = destStride*height;
- final ByteBuffer destBB = destIsDirect ? Buffers.newDirectByteBuffer(capacity) : ByteBuffer.allocate(capacity).order(src.getPixels().order());
- convert(src, destBB, destFmt, isGLOriented, destStride);
- return new PixelRectangle.GenericPixelRect(destFmt, src.getSize(), destStride, isGLOriented, destBB);
- }
-
- /**
- * @param src
- * @param dst_bb {@link ByteBuffer} sink
- * @param dst_fmt destination {@link PixelFormat}
- * @param dst_glOriented if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left,
- * otherwise origin at top left.
- * @param dst_lineStride line stride in byte-size for destination, i.e. byte count from one line to the next.
- * Must be >= {@link PixelFormat.Composition#bytesPerPixel() dst_fmt.comp.bytesPerPixel()} * width
- * or {@code zero} for default stride.
- *
- * @throws IllegalStateException
- * @throws IllegalArgumentException if {@code src_lineStride} or {@code dst_lineStride} is invalid
- */
- public static void convert(final PixelRectangle src,
- final ByteBuffer dst_bb, final PixelFormat dst_fmt, final boolean dst_glOriented, final int dst_lineStride)
- throws IllegalStateException
- {
- convert(src.getSize().getWidth(), src.getSize().getHeight(),
- src.getPixels(), src.getPixelformat(), src.isGLOriented(), src.getStride(),
- dst_bb, dst_fmt, dst_glOriented, dst_lineStride);
- }
-
-
- /**
- * @param width width of the to be converted pixel rectangle
- * @param height height of the to be converted pixel rectangle
- * @param src_bb {@link ByteBuffer} source
- * @param src_fmt source {@link PixelFormat}
- * @param src_glOriented if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left,
- * otherwise origin at top left.
- * @param src_lineStride line stride in byte-size for source, i.e. byte count from one line to the next.
- * Must be >= {@link PixelFormat.Composition#bytesPerPixel() src_fmt.comp.bytesPerPixel()} * width
- * or {@code zero} for default stride.
- * @param dst_bb {@link ByteBuffer} sink
- * @param dst_fmt destination {@link PixelFormat}
- * @param dst_glOriented if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left,
- * otherwise origin at top left.
- * @param dst_lineStride line stride in byte-size for destination, i.e. byte count from one line to the next.
- * Must be >= {@link PixelFormat.Composition#bytesPerPixel() dst_fmt.comp.bytesPerPixel()} * width
- * or {@code zero} for default stride.
- *
- * @throws IllegalStateException
- * @throws IllegalArgumentException if {@code src_lineStride} or {@code dst_lineStride} is invalid
- */
- public static void convert(final int width, final int height,
- final ByteBuffer src_bb, final PixelFormat src_fmt, final boolean src_glOriented, int src_lineStride,
- final ByteBuffer dst_bb, final PixelFormat dst_fmt, final boolean dst_glOriented, int dst_lineStride
- ) throws IllegalStateException, IllegalArgumentException {
- final PixelFormat.Composition src_comp = src_fmt.comp;
- final PixelFormat.Composition dst_comp = dst_fmt.comp;
- final int src_bpp = src_comp.bytesPerPixel();
- final int dst_bpp = dst_comp.bytesPerPixel();
-
- if( 0 != src_lineStride ) {
- if( src_lineStride < src_bpp * width ) {
- throw new IllegalArgumentException(String.format("Invalid %s stride %d, must be greater than bytesPerPixel %d * width %d",
- "source", src_lineStride, src_bpp, width));
- }
- } else {
- src_lineStride = src_bpp * width;
- }
- if( 0 != dst_lineStride ) {
- if( dst_lineStride < dst_bpp * width ) {
- throw new IllegalArgumentException(String.format("Invalid %s stride %d, must be greater than bytesPerPixel %d * width %d",
- "destination", dst_lineStride, dst_bpp, width));
- }
- } else {
- dst_lineStride = dst_bpp * width;
- }
-
- // final int src_comp_bitStride = src_comp.bitStride();
- final int dst_comp_bitStride = dst_comp.bitStride();
- final boolean vert_flip = src_glOriented != dst_glOriented;
- final boolean fast_copy = src_comp.equals(dst_comp) && 0 == dst_comp_bitStride%8;
- if( DEBUG ) {
- System.err.println("XXX: size "+width+"x"+height+", fast_copy "+fast_copy);
- System.err.println("XXX: SRC fmt "+src_fmt+", "+src_comp+", stride "+src_lineStride+", isGLOrient "+src_glOriented);
- System.err.println("XXX: DST fmt "+dst_fmt+", "+dst_comp+", stride "+dst_lineStride+", isGLOrient "+dst_glOriented);
- }
-
- if( fast_copy ) {
- // Fast copy
- for(int y=0; y srcBitStream = new Bitstream(srcBBS, false /* outputMode */);
- srcBitStream.setThrowIOExceptionOnEOF(true);
-
- final Bitstream.ByteBufferStream dstBBS = new Bitstream.ByteBufferStream(dst_bb);
- final Bitstream dstBitStream = new Bitstream(dstBBS, true /* outputMode */);
- dstBitStream.setThrowIOExceptionOnEOF(true);
-
- if( DEBUG ) {
- System.err.println("XXX: cmap.dst2src "+Arrays.toString(cmap.dst2src));
- System.err.println("XXX: cmap.src2dst "+Arrays.toString(cmap.src2dst));
- System.err.println("XXX: cmap.srcRGBA "+Arrays.toString(cmap.srcRGBA));
- System.err.println("XXX: srcBitStream "+srcBitStream);
- System.err.println("XXX: dstBitStream "+dstBitStream);
- }
- try {
- for(int y=0; y dstBitStream,
- final PixelFormat.Composition srcComp,
- final Bitstream srcBitStream) throws IllegalStateException, IOException {
- final int sCompCount = srcComp.componenCount();
- final int dCompCount = dstComp.componenCount();
- final int[] sc = new int[sCompCount];
- final int[] dcDef = new int[dCompCount];
- final int[] srcCompBitCount = srcComp.componentBitCount();
- final int[] srcCompBitMask = srcComp.componentBitMask();
- final int[] dstCompBitCount = dstComp.componentBitCount();
-
- // Fill w/ source values
- for(int sIdx=0; sIdx Y conversion
- final int r = sc[cmap.srcRGBA[0]];
- final int g = sc[cmap.srcRGBA[1]];
- final int b = sc[cmap.srcRGBA[2]];
- final float rF = srcComp.toFloat(r, cmap.srcRGBA[0], false);
- final float gF = srcComp.toFloat(g, cmap.srcRGBA[1], false);
- final float bF = srcComp.toFloat(b, cmap.srcRGBA[2], false);
- final int a;
- final float aF;
- /** if( 0 <= cmap.srcRGBA[3] ) { // disable premultiplied-alpha
- a = sc[cmap.srcRGBA[3]];
- aF = srcComp.toFloat(a, false, cmap.srcRGBA[3]);
- } else */ {
- a = 1;
- aF = 1f;
- }
- final float lF = ( rF + gF + bF ) * aF / 3f;
- final int v = dstComp.fromFloat(lF, 0, false);
-
- dstBitStream.writeBits31(dstCompBitCount[0], v);
- dstBitStream.skip(dstComp.bitStride() - dstComp.bitsPerPixel());
- if( DEBUG ) {
- if( srcBitStream.position() <= 8*4 ) {
- System.err.printf("convert: rgb[a] -> Y: rgb 0x%02X 0x%02X 0x%02X 0x%02X -> %f %f %f %f"+
- " -> %f -> dstC 0 0x%08X (%d bits: %s)%n",
- r, g, b, a,
- rF, gF, bF, aF,
- lF, v, dstCompBitCount[0], Bitstream.toBinString(true, v, dstCompBitCount[0])
- );
- }
- }
- return;
- }
-
- for(int dIdx=0; dIdx %f -> dstC %d 0x%08X (%d bits: %s)%n",
- sIdx, sc[sIdx], f, dIdx, v, dstCompBitCount[dIdx], Bitstream.toBinString(true, v, dstCompBitCount[dIdx]));
- }
- }
- } else {
- dstBitStream.writeBits31(dstCompBitCount[dIdx], dcDef[dIdx]);
- if( DEBUG ) {
- if( srcBitStream.position() <= 8*4 ) {
- System.err.printf("convert: srcC %d: undef -> dstC %d 0x%08X (%d bits: %s)%n",
- sIdx, dIdx, dcDef[dIdx], dstCompBitCount[dIdx], Bitstream.toBinString(true, dcDef[dIdx], dstCompBitCount[dIdx]));
- }
- }
- }
- }
- dstBitStream.skip(dstComp.bitStride() - dstComp.bitsPerPixel());
- return;
- }
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PixelRectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/PixelRectangle.java
deleted file mode 100644
index f58ba0ce2..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/PixelRectangle.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * Copyright (c) 2014 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package com.jogamp.nativewindow.util;
-
-import java.nio.ByteBuffer;
-
-/**
- * Pixel Rectangle identified by it's {@link #hashCode()}.
- *
- * The {@link #getPixels()} are assumed to be immutable.
- *
- */
-public interface PixelRectangle {
- /**
- *
- * Computes a hash code over:
- *
- *
pixelformat
- *
size
- *
stride
- *
isGLOriented
- *
pixels
- *
- *
- *
- * The hashCode shall be computed only once with first call
- * and stored for later retrieval to enhance performance.
- *
- *
- * {@inheritDoc}
- *
- */
- @Override
- int hashCode();
-
- /** Returns the {@link PixelFormat}. */
- PixelFormat getPixelformat();
-
- /** Returns the size, i.e. width and height. */
- DimensionImmutable getSize();
-
- /**
- * Returns stride in byte-size, i.e. byte count from one line to the next.
- *
- * Must be >= {@link #getPixelformat()}.{@link PixelFormat#bytesPerPixel() bytesPerPixel()} * {@link #getSize()}.{@link DimensionImmutable#getWidth() getWidth()}.
- *
- */
- int getStride();
-
- /**
- * Returns true if the memory is laid out in
- * OpenGL's coordinate system, origin at bottom left.
- * Otherwise returns false, i.e. origin at top left.
- */
- public boolean isGLOriented();
-
- /** Returns the pixels. */
- ByteBuffer getPixels();
-
- @Override
- String toString();
-
- /**
- * Generic PixelRectangle implementation
- */
- public static class GenericPixelRect implements PixelRectangle {
- protected final PixelFormat pixelformat;
- protected final DimensionImmutable size;
- protected final int strideInBytes;
- protected final boolean isGLOriented;
- protected final ByteBuffer pixels;
- private int hashCode = 0;
- private volatile boolean hashCodeComputed = false;
-
- /**
- *
- * @param pixelformat
- * @param size
- * @param strideInBytes stride in byte-size, i.e. byte count from one line to the next.
- * If not zero, value must be >= width * bytes-per-pixel.
- * If zero, stride is set to width * bytes-per-pixel.
- * @param isGLOriented
- * @param pixels
- * @throws IllegalArgumentException if strideInBytes is invalid.
- * @throws IndexOutOfBoundsException if pixels has insufficient bytes left
- */
- public GenericPixelRect(final PixelFormat pixelformat, final DimensionImmutable size, int strideInBytes, final boolean isGLOriented, final ByteBuffer pixels)
- throws IllegalArgumentException, IndexOutOfBoundsException
- {
- if( 0 != strideInBytes ) {
- if( strideInBytes < pixelformat.comp.bytesPerPixel() * size.getWidth()) {
- throw new IllegalArgumentException("Invalid stride "+strideInBytes+", must be greater than bytesPerPixel "+pixelformat.comp.bytesPerPixel()+" * width "+size.getWidth());
- }
- } else {
- strideInBytes = pixelformat.comp.bytesPerPixel() * size.getWidth();
- }
- final int reqBytes = strideInBytes * size.getHeight();
- if( pixels.limit() < reqBytes ) {
- throw new IndexOutOfBoundsException("Dest buffer has insufficient bytes left, needs "+reqBytes+": "+pixels);
- }
- this.pixelformat = pixelformat;
- this.size = size;
- this.strideInBytes = strideInBytes;
- this.isGLOriented = isGLOriented;
- this.pixels = pixels;
- }
-
- /**
- * Copy ctor validating src.
- * @param src
- * @throws IllegalArgumentException if strideInBytes is invalid.
- * @throws IndexOutOfBoundsException if pixels has insufficient bytes left
- */
- public GenericPixelRect(final PixelRectangle src)
- throws IllegalArgumentException, IndexOutOfBoundsException
- {
- this(src.getPixelformat(), src.getSize(), src.getStride(), src.isGLOriented(), src.getPixels());
- }
-
- @Override
- public int hashCode() {
- if( !hashCodeComputed ) { // DBL CHECKED OK VOLATILE
- synchronized (this) {
- if( !hashCodeComputed ) {
- // 31 * x == (x << 5) - x
- int hash = pixelformat.comp.hashCode();
- hash = ((hash << 5) - hash) + size.hashCode();
- hash = ((hash << 5) - hash) + strideInBytes;
- hash = ((hash << 5) - hash) + ( isGLOriented ? 1 : 0);
- hashCode = ((hash << 5) - hash) + pixels.hashCode();
- hashCodeComputed = true;
- }
- }
- }
- return hashCode;
- }
-
- @Override
- public PixelFormat getPixelformat() {
- return pixelformat;
- }
-
- @Override
- public DimensionImmutable getSize() {
- return size;
- }
-
- @Override
- public int getStride() {
- return strideInBytes;
- }
-
- @Override
- public boolean isGLOriented() {
- return isGLOriented;
- }
-
- @Override
- public ByteBuffer getPixels() {
- return pixels;
- }
-
- @Override
- public final String toString() {
- return "PixelRect[obj 0x"+Integer.toHexString(super.hashCode())+", "+pixelformat+", "+size+", stride "+strideInBytes+", isGLOrient "+isGLOriented+", pixels "+pixels+"]";
- }
- }
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java
deleted file mode 100644
index fc5465bbf..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow.util;
-
-public class Point implements Cloneable, PointImmutable {
- int x;
- int y;
-
- public Point(final int x, final int y) {
- this.x=x;
- this.y=y;
- }
-
- public Point() {
- this(0, 0);
- }
-
- @Override
- public Object cloneMutable() {
- return clone();
- }
-
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (final CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public int compareTo(final PointImmutable d) {
- final int sq = x*y;
- final int xsq = d.getX()*d.getY();
-
- if(sq > xsq) {
- return 1;
- } else if(sq < xsq) {
- return -1;
- }
- return 0;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if(this == obj) { return true; }
- if (obj instanceof Point) {
- final Point p = (Point)obj;
- return y == p.y && x == p.x;
- }
- return false;
- }
-
- @Override
- public final int getX() {
- return x;
- }
-
- @Override
- public final int getY() {
- return y;
- }
-
- @Override
- public int hashCode() {
- // 31 * x == (x << 5) - x
- int hash = 31 + x;
- hash = ((hash << 5) - hash) + y;
- return hash;
- }
-
- @Override
- public String toString() {
- return x + " / " + y;
- }
-
- public final void set(final int x, final int y) { this.x = x; this.y = y; }
- public final void setX(final int x) { this.x = x; }
- public final void setY(final int y) { this.y = y; }
-
- /**
- * Translate this instance's x- and y-components,
- * i.e. add the values of the given delta point to them.
- * @param pd delta point
- * @return this instance for scaling
- */
- public final Point translate(final Point pd) {
- x += pd.x ;
- y += pd.y ;
- return this;
- }
-
- /**
- * Translate this instance's x- and y-components,
- * i.e. add the given deltas to them.
- * @param dx delta for x
- * @param dy delta for y
- * @return this instance for scaling
- */
- public final Point translate(final int dx, final int dy) {
- x += dx ;
- y += dy ;
- return this;
- }
-
- /**
- * Scale this instance's x- and y-components,
- * i.e. multiply them by the given scale factors.
- * @param sx scale factor for x
- * @param sy scale factor for y
- * @return this instance for scaling
- */
- public final Point scale(final int sx, final int sy) {
- x *= sx ;
- y *= sy ;
- return this;
- }
-
- /**
- * Scale this instance's x- and y-components,
- * i.e. multiply them by the given scale factors.
- *
- * The product is rounded back to integer.
- *
- * @param sx scale factor for x
- * @param sy scale factor for y
- * @return this instance for scaling
- */
- public final Point scale(final float sx, final float sy) {
- x = (int)(x * sx + 0.5f);
- y = (int)(y * sy + 0.5f);
- return this;
- }
-
- /**
- * Inverse scale this instance's x- and y-components,
- * i.e. divide them by the given scale factors.
- * @param sx inverse scale factor for x
- * @param sy inverse scale factor for y
- * @return this instance for scaling
- */
- public final Point scaleInv(final int sx, final int sy) {
- x /= sx ;
- y /= sy ;
- return this;
- }
- /**
- * Inverse scale this instance's x- and y-components,
- * i.e. divide them by the given scale factors.
- *
- * The product is rounded back to integer.
- *
- * @param sx inverse scale factor for x
- * @param sy inverse scale factor for y
- * @return this instance for scaling
- */
- public final Point scaleInv(final float sx, final float sy) {
- x = (int)(x / sx + 0.5f);
- y = (int)(y / sy + 0.5f);
- return this;
- }
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java
deleted file mode 100644
index 59372f67d..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow.util;
-
-import com.jogamp.common.type.WriteCloneable;
-
-/** Immutable Point interface */
-public interface PointImmutable extends WriteCloneable, Comparable {
-
- int getX();
-
- int getY();
-
- /**
- *
- * Compares the square of the position.
- *
- * {@inheritDoc}
- */
- @Override
- public int compareTo(final PointImmutable d);
-
- /**
- * Checks whether two points objects are equal. Two instances
- * of PointReadOnly are equal if the two components
- * y and x are equal.
- * @return true if the two points are equal;
- * otherwise false.
- */
- @Override
- public boolean equals(Object obj);
-
- @Override
- public int hashCode();
-
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
deleted file mode 100644
index 33a1955e8..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow.util;
-
-import java.util.List;
-
-public class Rectangle implements Cloneable, RectangleImmutable {
- int x;
- int y;
- int width;
- int height;
-
- public Rectangle() {
- this(0, 0, 0, 0);
- }
-
- public Rectangle(final int x, final int y, final int width, final int height) {
- this.x=x;
- this.y=y;
- this.width=width;
- this.height=height;
- }
-
- @Override
- public Object cloneMutable() {
- return clone();
- }
-
- @Override
- protected Object clone() {
- try {
- return super.clone();
- } catch (final CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public final int getX() { return x; }
- @Override
- public final int getY() { return y; }
- @Override
- public final int getWidth() { return width; }
- @Override
- public final int getHeight() { return height; }
-
- public final void set(final int x, final int y, final int width, final int height) {
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- }
- public final void set(final Rectangle s) {
- this.x = s.x;
- this.y = s.y;
- this.width = s.width;
- this.height = s.height;
- }
- public final void setX(final int x) { this.x = x; }
- public final void setY(final int y) { this.y = y; }
- public final void setWidth(final int width) { this.width = width; }
- public final void setHeight(final int height) { this.height = height; }
-
- @Override
- public final RectangleImmutable union(final RectangleImmutable r) {
- return union(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight());
- }
- @Override
- public final RectangleImmutable union(final int rx1, final int ry1, final int rx2, final int ry2) {
- final int x1 = Math.min(x, rx1);
- final int y1 = Math.min(y, ry1);
- final int x2 = Math.max(x + width, rx2);
- final int y2 = Math.max(y + height, ry2);
- return new Rectangle(x1, y1, x2 - x1, y2 - y1);
- }
- /**
- * Calculates the union of the given rectangles, stores it in this instance and returns this instance.
- * @param rectangles given list of rectangles
- * @return this instance holding the union of given rectangles.
- */
- public final Rectangle union(final List rectangles) {
- int x1=Integer.MAX_VALUE, y1=Integer.MAX_VALUE;
- int x2=Integer.MIN_VALUE, y2=Integer.MIN_VALUE;
- for(int i=rectangles.size()-1; i>=0; i--) {
- final RectangleImmutable vp = rectangles.get(i);
- x1 = Math.min(x1, vp.getX());
- x2 = Math.max(x2, vp.getX() + vp.getWidth());
- y1 = Math.min(y1, vp.getY());
- y2 = Math.max(y2, vp.getY() + vp.getHeight());
- }
- set(x1, y1, x2 - x1, y2 - y1);
- return this;
- }
-
- @Override
- public final RectangleImmutable intersection(final RectangleImmutable r) {
- return intersection(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight());
- }
- @Override
- public final RectangleImmutable intersection(final int rx1, final int ry1, final int rx2, final int ry2) {
- final int x1 = Math.max(x, rx1);
- final int y1 = Math.max(y, ry1);
- final int x2 = Math.min(x + width, rx2);
- final int y2 = Math.min(y + height, ry2);
- final int ix, iy, iwidth, iheight;
- if( x2 < x1 ) {
- ix = 0;
- iwidth = 0;
- } else {
- ix = x1;
- iwidth = x2 - x1;
- }
- if( y2 < y1 ) {
- iy = 0;
- iheight = 0;
- } else {
- iy = y1;
- iheight = y2 - y1;
- }
- return new Rectangle (ix, iy, iwidth, iheight);
- }
- @Override
- public final float coverage(final RectangleImmutable r) {
- final RectangleImmutable isect = intersection(r);
- final float sqI = isect.getWidth()*isect.getHeight();
- final float sqT = width*height;
- return sqI / sqT;
- }
-
- /**
- * Scale this instance's components,
- * i.e. multiply them by the given scale factors.
- * @param sx scale factor for x
- * @param sy scale factor for y
- * @return this instance for scaling
- */
- public final Rectangle scale(final int sx, final int sy) {
- x *= sx ;
- y *= sy ;
- width *= sx ;
- height *= sy ;
- return this;
- }
-
- /**
- * Inverse scale this instance's components,
- * i.e. divide them by the given scale factors.
- * @param sx inverse scale factor for x
- * @param sy inverse scale factor for y
- * @return this instance for scaling
- */
- public final Rectangle scaleInv(final int sx, final int sy) {
- x /= sx ;
- y /= sy ;
- width /= sx ;
- height /= sy ;
- return this;
- }
-
- @Override
- public int compareTo(final RectangleImmutable d) {
- {
- final int sq = width*height;
- final int xsq = d.getWidth()*d.getHeight();
-
- if(sq > xsq) {
- return 1;
- } else if(sq < xsq) {
- return -1;
- }
- }
- {
- final int sq = x*y;
- final int xsq = d.getX()*d.getY();
-
- if(sq > xsq) {
- return 1;
- } else if(sq < xsq) {
- return -1;
- }
- }
- return 0;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if(this == obj) { return true; }
- if (obj instanceof Rectangle) {
- final Rectangle rect = (Rectangle)obj;
- return (y == rect.y) && (x == rect.x) &&
- (height == rect.height) && (width == rect.width);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- final int sum1 = x + height;
- final int sum2 = width + y;
- final int val1 = sum1 * (sum1 + 1)/2 + x;
- final int val2 = sum2 * (sum2 + 1)/2 + y;
- final int sum3 = val1 + val2;
- return sum3 * (sum3 + 1)/2 + val2;
- }
-
- @Override
- public String toString() {
- return "[ "+x+" / "+y+" "+width+" x "+height+" ]";
- }
-}
-
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java
deleted file mode 100644
index ff2209598..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow.util;
-
-import com.jogamp.common.type.WriteCloneable;
-
-/** Immutable Rectangle interface */
-public interface RectangleImmutable extends WriteCloneable, Comparable {
-
- int getHeight();
-
- int getWidth();
-
- int getX();
-
- int getY();
-
- /** Returns the union of this rectangle and the given rectangle. */
- RectangleImmutable union(final RectangleImmutable r);
- /** Returns the union of this rectangleand the given coordinates. */
- RectangleImmutable union(final int rx1, final int ry1, final int rx2, final int ry2);
- /** Returns the intersection of this rectangleand the given rectangle. */
- RectangleImmutable intersection(RectangleImmutable r);
- /** Returns the intersection of this rectangleand the given coordinates. */
- RectangleImmutable intersection(final int rx1, final int ry1, final int rx2, final int ry2);
- /**
- * Returns the coverage of given rectangle w/ this this one, i.e. between 0.0 and 1.0.
- *
- * Compares square of size 1st, if equal the square of position.
- *
- * {@inheritDoc}
- */
- @Override
- public int compareTo(final RectangleImmutable d);
-
- /**
- * Checks whether two rect objects are equal. Two instances
- * of Rectangle are equal if the four integer values
- * of the fields y, x,
- * height, and width are all equal.
- * @return true if the two rectangles are equal;
- * otherwise false.
- */
- @Override
- boolean equals(Object obj);
-
- @Override
- int hashCode();
-
-}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
deleted file mode 100644
index b9e6ded95..000000000
--- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Copyright 2010 JogAmp Community. All rights reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-
-package com.jogamp.nativewindow.util;
-
-/**
- * Immutable SurfaceSize Class, consisting of it's read only components:
- *
- *
{@link com.jogamp.nativewindow.util.DimensionImmutable size in pixels}
- *
bits per pixel
- *
- */
-public class SurfaceSize implements Comparable {
- final DimensionImmutable resolution;
- final int bitsPerPixel;
-
- public SurfaceSize(final DimensionImmutable resolution, final int bitsPerPixel) {
- if(null==resolution || bitsPerPixel<=0) {
- throw new IllegalArgumentException("resolution must be set and bitsPerPixel greater 0");
- }
- this.resolution=resolution;
- this.bitsPerPixel=bitsPerPixel;
- }
-
- /** Returns the resolution in pixel units */
- public final DimensionImmutable getResolution() {
- return resolution;
- }
-
- public final int getBitsPerPixel() {
- return bitsPerPixel;
- }
-
- @Override
- public final String toString() {
- return "[ "+resolution+" pixels x "+bitsPerPixel+" bpp ]";
- }
-
- /**
- *
- * Compares {@link DimensionImmutable#compareTo(DimensionImmutable) resolution} 1st, if equal the bitsPerPixel.
- *
- * {@inheritDoc}
- */
- @Override
- public int compareTo(final SurfaceSize ssz) {
- final int rres = resolution.compareTo(ssz.getResolution());
- if( 0 != rres ) {
- return rres;
- }
- final int xbpp = ssz.getBitsPerPixel();
- if(bitsPerPixel > xbpp) {
- return 1;
- } else if(bitsPerPixel < xbpp) {
- return -1;
- }
- return 0;
- }
-
- /**
- * Checks whether two size objects are equal. Two instances
- * of SurfaceSize are equal if the two components
- * resolution and bitsPerPixel
- * are equal.
- * @return true if the two dimensions are equal;
- * otherwise false.
- */
- @Override
- public final boolean equals(final Object obj) {
- if(this == obj) { return true; }
- if (obj instanceof SurfaceSize) {
- final SurfaceSize p = (SurfaceSize)obj;
- return getResolution().equals(p.getResolution()) &&
- getBitsPerPixel() == p.getBitsPerPixel();
- }
- return false;
- }
-
- @Override
- public final int hashCode() {
- // 31 * x == (x << 5) - x
- int hash = getResolution().hashCode();
- hash = ((hash << 5) - hash) + getBitsPerPixel();
- return hash;
- }
-}
-
--
cgit v1.2.3