aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/x11
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2009-06-15 22:52:34 +0000
committerKenneth Russel <[email protected]>2009-06-15 22:52:34 +0000
commit506b634b780dcd23aa61015c2ceba3e687196abf (patch)
tree897649a36cc769351704a050828f8e0e994c5686 /src/classes/com/sun/opengl/impl/x11
parent04c0c10bfee764dbd0301ae83a0fae695dcb5b23 (diff)
Deleted obsolete source code in preparation for copying JOGL_2_SANDBOX
on to trunk git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1958 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl/x11')
-rw-r--r--src/classes/com/sun/opengl/impl/x11/DRIHack.java128
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/x11/X11ExternalGLContext.java130
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/x11/X11ExternalGLDrawable.java215
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11GLContext.java344
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11GLDrawable.java172
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java799
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11OffscreenGLContext.java83
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11OffscreenGLDrawable.java145
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java100
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java186
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11PbufferGLContext.java155
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java239
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11SunJDKReflection.java101
13 files changed, 0 insertions, 2797 deletions
diff --git a/src/classes/com/sun/opengl/impl/x11/DRIHack.java b/src/classes/com/sun/opengl/impl/x11/DRIHack.java
deleted file mode 100644
index 35a1c8fc7..000000000
--- a/src/classes/com/sun/opengl/impl/x11/DRIHack.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2006 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.sun.opengl.impl.x11;
-
-import java.io.*;
-import java.security.*;
-import com.sun.gluegen.runtime.*;
-import com.sun.opengl.impl.*;
-
-/**
- * Helper class for working around problems with open-source DRI
- * drivers. In the current DRI implementation it is required that the
- * symbols in libGL.so.1.2 be globally visible to be accessible from
- * other libraries that are dynamically loaded by the implementation.
- * Applications may typically satisfy this need either by linking
- * against libGL.so on the command line (-lGL) or by dlopen'ing
- * libGL.so.1.2 with the RTLD_GLOBAL flag. The JOGL implementation
- * links against libGL on all platforms rather than forcing all OpenGL
- * entry points to be called through a function pointer. This allows
- * the JOGL library to link directly to core 1.1 OpenGL entry points
- * like glVertex3f, while calling through function pointers for entry
- * points from later OpenGL versions as well as from
- * extensions. However, because libjogl.so (which links against
- * libGL.so) is loaded by the JVM, and because the JVM implicitly uses
- * RTLD_LOCAL in the implementation of System.loadLibrary(), this
- * means via transitivity that the symbols for libGL.so have only
- * RTLD_LOCAL visibility to the rest of the application, so the DRI
- * drivers can not find the symbols required. <P>
- *
- * There are at least two possible solutions. One would be to change
- * the JOGL implementation to call through function pointers uniformly
- * so that it does not need to link against libGL.so. This is
- * possible, but requires changes to GlueGen and also is not really
- * necessary in any other situation than with the DRI drivers. Another
- * solution is to force the first load of libGL.so.1.2 to be done
- * dynamically with RTLD_GLOBAL before libjogl.so is loaded and causes
- * libGL.so.1.2 to be loaded again. The NativeLibrary class in the
- * GlueGen runtime has this property, and we use it to implement this
- * workaround.
- */
-
-public class DRIHack {
- private static final boolean DEBUG = Debug.debug("DRIHack");
- private static boolean driHackNeeded;
- private static NativeLibrary oglLib;
-
- public static void begin() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- String os = System.getProperty("os.name").toLowerCase();
- // Do DRI hack on all Linux distributions for best robustness
- driHackNeeded =
- (os.startsWith("linux") ||
- new File("/usr/lib/dri").exists() ||
- new File("/usr/X11R6/lib/modules/dri").exists());
- // Allow manual overriding for now as a workaround for
- // problems seen in some situations -- needs more investigation
- if (System.getProperty("jogl.drihack.disable") != null) {
- driHackNeeded = false;
- }
- return null;
- }
- });
-
- if (driHackNeeded) {
- if (DEBUG) {
- System.err.println("Beginning DRI hack");
- }
-
- // Try a few different variants for best robustness
- // In theory probably only the first is necessary
- oglLib = NativeLibrary.open("libGL.so.1", null);
- if (DEBUG && oglLib != null) System.err.println(" Found libGL.so.1");
- if (oglLib == null) {
- oglLib = NativeLibrary.open("/usr/lib/libGL.so.1", null);
- if (DEBUG && oglLib != null) System.err.println(" Found /usr/lib/libGL.so.1");
- }
- }
- }
-
- public static void end() {
- if (oglLib != null) {
- if (DEBUG) {
- System.err.println("Ending DRI hack");
- }
-
- oglLib.close();
- oglLib = null;
- }
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11ExternalGLContext.java b/src/classes/com/sun/opengl/impl/x11/X11ExternalGLContext.java
deleted file mode 100755
index 89b769eee..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11ExternalGLContext.java
+++ /dev/null
@@ -1,130 +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.sun.opengl.impl.x11;
-
-import javax.media.opengl.*;
-import com.sun.opengl.impl.*;
-
-public class X11ExternalGLContext extends X11GLContext {
- private boolean firstMakeCurrent = true;
- private boolean created = true;
- private GLContext lastContext;
-
- public X11ExternalGLContext() {
- super(null, null);
- lockToolkit();
- try {
- context = GLX.glXGetCurrentContext();
- if (context == 0) {
- throw new GLException("Error: attempted to make an external GLContext without a drawable/context current");
- }
- drawable = new Drawable(GLX.glXGetCurrentDisplay());
- } finally {
- unlockToolkit();
- }
- GLContextShareSet.contextCreated(this);
- resetGLFunctionAvailability();
- }
-
- protected void create() {
- }
-
- public int makeCurrent() throws GLException {
- // Save last context if necessary to allow external GLContexts to
- // talk to other GLContexts created by this library
- GLContext cur = getCurrent();
- if (cur != null && cur != this) {
- lastContext = cur;
- setCurrent(null);
- }
- return super.makeCurrent();
- }
-
- public void release() throws GLException {
- super.release();
- setCurrent(lastContext);
- lastContext = null;
- }
-
- protected int makeCurrentImpl() throws GLException {
- mostRecentDisplay = drawable.getDisplay();
- if (firstMakeCurrent) {
- firstMakeCurrent = false;
- return CONTEXT_CURRENT_NEW;
- }
- return CONTEXT_CURRENT;
- }
-
- protected void releaseImpl() throws GLException {
- }
-
- protected void destroyImpl() throws GLException {
- created = false;
- GLContextShareSet.contextDestroyed(this);
- }
-
- public boolean isCreated() {
- return created;
- }
-
- // Need to provide the display connection to extension querying APIs
- class Drawable extends X11GLDrawable {
- Drawable(long display) {
- super(null, null);
- this.display = display;
- }
-
- public GLContext createContext(GLContext shareWith) {
- throw new GLException("Should not call this");
- }
-
- public int getWidth() {
- throw new GLException("Should not call this");
- }
-
- public int getHeight() {
- throw new GLException("Should not call this");
- }
-
- public void setSize(int width, int height) {
- throw new GLException("Should not call this");
- }
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11ExternalGLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11ExternalGLDrawable.java
deleted file mode 100755
index 10e58d3a0..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11ExternalGLDrawable.java
+++ /dev/null
@@ -1,215 +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.sun.opengl.impl.x11;
-
-import javax.media.opengl.*;
-import com.sun.opengl.impl.*;
-
-public class X11ExternalGLDrawable extends X11GLDrawable {
- private int fbConfigID;
- private int renderType;
- private int screen;
- private long readDrawable;
-
- public X11ExternalGLDrawable() {
- super(null, null);
- lockToolkit();
- try {
- display = GLX.glXGetCurrentDisplay();
- drawable = GLX.glXGetCurrentDrawable();
- readDrawable = GLX.glXGetCurrentReadDrawable();
- if (drawable == 0) {
- throw new GLException("Error: attempted to make an external GLDrawable without a drawable/context current");
- }
-
- // Need GLXFBConfig ID in order to properly create new contexts
- // on this drawable
- long context = GLX.glXGetCurrentContext();
- int[] val = new int[1];
- GLX.glXQueryContext(display, context, GLX.GLX_FBCONFIG_ID, val, 0);
- fbConfigID = val[0];
- renderType = GLX.GLX_RGBA_TYPE;
- GLX.glXQueryContext(display, context, GLX.GLX_RENDER_TYPE, val, 0);
- if ((val[0] & GLX.GLX_RGBA_BIT) == 0) {
- if (DEBUG) {
- System.err.println("X11ExternalGLDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts");
- }
- }
- GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val, 0);
- screen = val[0];
- } finally {
- unlockToolkit();
- }
- }
-
- public GLContext createContext(GLContext shareWith) {
- return new Context(shareWith);
- }
-
- public void setSize(int newWidth, int newHeight) {
- throw new GLException("Should not call this");
- }
-
- public int getWidth() {
- throw new GLException("Should not call this");
- }
-
- public int getHeight() {
- throw new GLException("Should not call this");
- }
-
- public void destroy() {
- }
-
- class Context extends X11GLContext {
- Context(GLContext shareWith) {
- super(X11ExternalGLDrawable.this, shareWith);
- this.drawable = drawable;
- }
-
- protected int makeCurrentImpl() throws GLException {
- if (drawable.getDrawable() == 0) {
- // parent drawable not properly initialized
- // FIXME: signal error?
- if (DEBUG) {
- System.err.println("parent drawable not properly initialized");
- }
- return CONTEXT_NOT_CURRENT;
- }
-
- // Note that we have to completely override makeCurrentImpl
- // because the underlying makeCurrent call differs from the norm
- lockToolkit();
- try {
- boolean created = false;
- if (context == 0) {
- create();
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created GL context for " + getClass().getName());
- }
- created = true;
- }
-
- if (!GLX.glXMakeContextCurrent(drawable.getDisplay(),
- drawable.getDrawable(),
- readDrawable,
- context)) {
- throw new GLException("Error making context current");
- } else {
- mostRecentDisplay = drawable.getDisplay();
- if (DEBUG && VERBOSE) {
- System.err.println(getThreadName() + ": glXMakeCurrent(display " + toHexString(drawable.getDisplay()) +
- ", drawable " + toHexString(drawable.getDrawable()) +
- ", context " + toHexString(context) + ") succeeded");
- }
- }
-
- if (created) {
- resetGLFunctionAvailability();
- return CONTEXT_CURRENT_NEW;
- }
- return CONTEXT_CURRENT;
- } finally {
- unlockToolkit();
- }
- }
-
- protected void releaseImpl() throws GLException {
- lockToolkit();
- try {
- if (!GLX.glXMakeContextCurrent(drawable.getDisplay(), 0, 0, 0)) {
- throw new GLException("Error freeing OpenGL context");
- }
- } finally {
- unlockToolkit();
- }
- }
-
- protected void create() {
- // We already have the GLXFBConfig ID for the context. All we
- // need to do is use it to choose the GLXFBConfig and then
- // create a context with it.
- int[] iattributes = new int[] {
- GLX.GLX_FBCONFIG_ID,
- fbConfigID,
- 0,
- 0
- };
- float[] fattributes = new float[0];
- int[] nelementsTmp = new int[1];
- GLXFBConfig[] fbConfigs = GLX.glXChooseFBConfig(display, screen, iattributes, 0, nelementsTmp, 0);
- int nelements = nelementsTmp[0];
- if (nelements <= 0) {
- throw new GLException("context creation error: couldn't find a suitable frame buffer configuration");
- }
- if (nelements != 1) {
- throw new GLException("context creation error: shouldn't get more than one GLXFBConfig");
- }
- // Note that we currently don't allow selection of anything but
- // the first GLXFBConfig in the returned list (there should be only one)
- GLXFBConfig fbConfig = fbConfigs[0];
- // Create a gl context for the drawable
- X11GLContext other = (X11GLContext) GLContextShareSet.getShareContext(this);
- long share = 0;
- if (other != null) {
- share = other.getContext();
- if (share == 0) {
- throw new GLException("GLContextShareSet returned an invalid OpenGL context");
- }
- }
- // FIXME: how to determine "direct" bit?
- context = GLX.glXCreateNewContext(display, fbConfig, renderType, share, true);
- if (context == 0) {
- String detail = " display=" + toHexString(display) +
- " fbconfig=" + fbConfig +
- " fbconfigID=" + toHexString(fbConfigID) +
- " renderType=" + toHexString(renderType) +
- " share=" + toHexString(share);
- throw new GLException("context creation error: glXCreateNewContext() failed: " + detail);
- }
- GLContextShareSet.contextCreated(this);
-
- if (DEBUG) {
- System.err.println("Created context " + toHexString(context) +
- " for GLXDrawable " + toHexString(drawable.getDrawable()));
- }
- }
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLContext.java b/src/classes/com/sun/opengl/impl/x11/X11GLContext.java
deleted file mode 100644
index 17b2cca40..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11GLContext.java
+++ /dev/null
@@ -1,344 +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.sun.opengl.impl.x11;
-
-import java.nio.*;
-import java.util.*;
-import javax.media.opengl.*;
-import com.sun.opengl.impl.*;
-
-public abstract class X11GLContext extends GLContextImpl {
- protected X11GLDrawable drawable;
- protected long context;
- private boolean glXQueryExtensionsStringInitialized;
- private boolean glXQueryExtensionsStringAvailable;
- private static final Map/*<String, String>*/ functionNameMap;
- private GLXExt glXExt;
- // Table that holds the addresses of the native C-language entry points for
- // GLX extension functions.
- private GLXExtProcAddressTable glXExtProcAddressTable;
- // Cache the most recent value of the "display" variable (which we
- // only guarantee to be valid in between makeCurrent / free pairs)
- // so that we can implement displayImpl() (which must be done when
- // the context is not current)
- protected long mostRecentDisplay;
-
- static {
- functionNameMap = new HashMap();
- functionNameMap.put("glAllocateMemoryNV", "glXAllocateMemoryNV");
- functionNameMap.put("glFreeMemoryNV", "glXFreeMemoryNV");
- }
-
- public X11GLContext(X11GLDrawable drawable,
- GLContext shareWith) {
- super(shareWith);
- this.drawable = drawable;
- }
-
- public Object getPlatformGLExtensions() {
- return getGLXExt();
- }
-
- public GLXExt getGLXExt() {
- if (glXExt == null) {
- glXExt = new GLXExtImpl(this);
- }
- return glXExt;
- }
-
- public GLDrawable getGLDrawable() {
- return drawable;
- }
-
- protected String mapToRealGLFunctionName(String glFunctionName) {
- String lookup = (String) functionNameMap.get(glFunctionName);
- if (lookup != null) {
- return lookup;
- }
- return glFunctionName;
- }
-
- protected String mapToRealGLExtensionName(String glExtensionName) {
- return glExtensionName;
- }
-
- /** Helper routine which usually just turns around and calls
- * createContext (except for pbuffers, which use a different context
- * creation mechanism). Should only be called by {@link
- * makeCurrentImpl()}.
- */
- protected abstract void create();
-
- /**
- * Creates and initializes an appropriate OpenGL context. Should only be
- * called by {@link create()}.
- */
- protected void createContext(boolean onscreen) {
- XVisualInfo vis = drawable.chooseVisual(onscreen);
- X11GLContext other = (X11GLContext) GLContextShareSet.getShareContext(this);
- long share = 0;
- if (other != null) {
- share = other.getContext();
- if (share == 0) {
- throw new GLException("GLContextShareSet returned an invalid OpenGL context");
- }
- }
- context = GLX.glXCreateContext(drawable.getDisplay(), vis, share, onscreen);
- if (context == 0) {
- throw new GLException("Unable to create OpenGL context");
- }
- GLContextShareSet.contextCreated(this);
- }
-
- protected int makeCurrentImpl() throws GLException {
- boolean created = false;
- if (context == 0) {
- create();
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created GL context for " + getClass().getName());
- }
- created = true;
- }
-
- if (!GLX.glXMakeCurrent(drawable.getDisplay(), drawable.getDrawable(), context)) {
- throw new GLException("Error making context current");
- } else {
- mostRecentDisplay = drawable.getDisplay();
- if (DEBUG && (VERBOSE || created)) {
- System.err.println(getThreadName() + ": glXMakeCurrent(display " + toHexString(drawable.getDisplay()) +
- ", drawable " + toHexString(drawable.getDrawable()) +
- ", context " + toHexString(context) + ") succeeded");
- }
- }
-
- if (created) {
- resetGLFunctionAvailability();
- return CONTEXT_CURRENT_NEW;
- }
- return CONTEXT_CURRENT;
- }
-
- protected void releaseImpl() throws GLException {
- lockToolkit();
- try {
- if (!GLX.glXMakeCurrent(mostRecentDisplay, 0, 0)) {
- throw new GLException("Error freeing OpenGL context");
- }
- } finally {
- unlockToolkit();
- }
- }
-
- protected void destroyImpl() throws GLException {
- lockToolkit();
- try {
- if (context != 0) {
- if (DEBUG) {
- System.err.println("glXDestroyContext(0x" +
- Long.toHexString(mostRecentDisplay) +
- ", 0x" +
- Long.toHexString(context) + ")");
- }
- GLX.glXDestroyContext(mostRecentDisplay, context);
- if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL context " + context);
- }
- context = 0;
- mostRecentDisplay = 0;
- GLContextShareSet.contextDestroyed(this);
- }
- } finally {
- unlockToolkit();
- }
- }
-
- public boolean isCreated() {
- return (context != 0);
- }
-
- public void copy(GLContext source, int mask) throws GLException {
- long dst = getContext();
- long src = ((X11GLContext) source).getContext();
- if (src == 0) {
- throw new GLException("Source OpenGL context has not been created");
- }
- if (dst == 0) {
- throw new GLException("Destination OpenGL context has not been created");
- }
- if (mostRecentDisplay == 0) {
- throw new GLException("Connection to X display not yet set up");
- }
- lockToolkit();
- try {
- GLX.glXCopyContext(mostRecentDisplay, src, dst, mask);
- // Should check for X errors and raise GLException
- } finally {
- unlockToolkit();
- }
- }
-
- protected void resetGLFunctionAvailability() {
- super.resetGLFunctionAvailability();
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Initializing GLX extension address table");
- }
- resetProcAddressTable(getGLXExtProcAddressTable());
- }
-
- public GLXExtProcAddressTable getGLXExtProcAddressTable() {
- if (glXExtProcAddressTable == null) {
- // FIXME: cache ProcAddressTables by capability bits so we can
- // share them among contexts with the same capabilities
- glXExtProcAddressTable = new GLXExtProcAddressTable();
- }
- return glXExtProcAddressTable;
- }
-
- public synchronized String getPlatformExtensionsString() {
- if (mostRecentDisplay == 0) {
- throw new GLException("Context not current");
- }
- if (!glXQueryExtensionsStringInitialized) {
- glXQueryExtensionsStringAvailable =
- (GLDrawableFactoryImpl.getFactoryImpl().dynamicLookupFunction("glXQueryExtensionsString") != 0);
- glXQueryExtensionsStringInitialized = true;
- }
- if (glXQueryExtensionsStringAvailable) {
- lockToolkit();
- try {
- String ret = GLX.glXQueryExtensionsString(mostRecentDisplay, GLX.DefaultScreen(mostRecentDisplay));
- if (DEBUG) {
- System.err.println("!!! GLX extensions: " + ret);
- }
- return ret;
- } finally {
- unlockToolkit();
- }
- } else {
- return "";
- }
- }
-
- protected boolean isFunctionAvailable(String glFunctionName)
- {
- boolean available = super.isFunctionAvailable(glFunctionName);
-
- // Sanity check for implementations that use proc addresses for run-time
- // linking: if the function IS available, then make sure there's a proc
- // address for it if it's an extension or not part of the OpenGL 1.1 core
- // (post GL 1.1 functions are run-time linked on windows).
- assert(!available ||
- (getGLProcAddressTable().getAddressFor(mapToRealGLFunctionName(glFunctionName)) != 0 ||
- FunctionAvailabilityCache.isPartOfGLCore("1.1", mapToRealGLFunctionName(glFunctionName)))
- );
-
- return available;
- }
-
- public boolean isExtensionAvailable(String glExtensionName) {
- if (glExtensionName.equals("GL_ARB_pbuffer") ||
- glExtensionName.equals("GL_ARB_pixel_format")) {
- return GLDrawableFactory.getFactory().canCreateGLPbuffer();
- }
- return super.isExtensionAvailable(glExtensionName);
- }
-
-
- public void setSwapInterval(int interval) {
- lockToolkit();
- try {
- // FIXME: make the context current first? Currently assumes that
- // will not be necessary. Make the caller do this?
- GLXExt glXExt = getGLXExt();
- if (glXExt.isExtensionAvailable("GLX_SGI_swap_control")) {
- glXExt.glXSwapIntervalSGI(interval);
- }
- } finally {
- unlockToolkit();
- }
- }
-
- public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
- return getGLXExt().glXAllocateMemoryNV(arg0, arg1, arg2, arg3);
- }
-
- public int getOffscreenContextPixelDataType() {
- throw new GLException("Should not call this");
- }
-
- public int getOffscreenContextReadBuffer() {
- throw new GLException("Should not call this");
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- throw new GLException("Should not call this");
- }
-
- public void bindPbufferToTexture() {
- throw new GLException("Should not call this");
- }
-
- public void releasePbufferFromTexture() {
- throw new GLException("Should not call this");
- }
-
- public boolean isOptimizable() {
- return (super.isOptimizable() &&
- !X11GLDrawableFactory.getX11Factory().isVendorATI());
- }
-
- //----------------------------------------------------------------------
- // Internals only below this point
- //
-
- public long getContext() {
- return context;
- }
-
- // These synchronization primitives prevent the AWT from making
- // requests from the X server asynchronously to this code.
- protected void lockToolkit() {
- X11GLDrawableFactory.getX11Factory().lockToolkit();
- }
-
- protected void unlockToolkit() {
- X11GLDrawableFactory.getX11Factory().unlockToolkit();
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11GLDrawable.java
deleted file mode 100644
index c11404b9f..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11GLDrawable.java
+++ /dev/null
@@ -1,172 +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.sun.opengl.impl.x11;
-
-import javax.media.opengl.*;
-import com.sun.opengl.impl.*;
-
-public abstract class X11GLDrawable extends GLDrawableImpl {
- protected static final boolean DEBUG = Debug.debug("X11GLDrawable");
-
- protected long display;
- protected long drawable;
- protected long visualID;
- protected GLCapabilities capabilities;
- protected GLCapabilitiesChooser chooser;
-
- public X11GLDrawable(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser) {
- this.capabilities = (capabilities == null) ? null :
- ((GLCapabilities) capabilities.clone());
- this.chooser = chooser;
- }
-
- public void setRealized(boolean val) {
- throw new GLException("Should not call this (should only be called for onscreen GLDrawables)");
- }
-
- public void destroy() {
- throw new GLException("Should not call this (should only be called for offscreen GLDrawables)");
- }
-
- public void swapBuffers() throws GLException {
- }
-
- public long getDisplay() {
- return display;
- }
-
- public long getDrawable() {
- return drawable;
- }
-
- //---------------------------------------------------------------------------
- // Internals only below this point
- //
-
- protected XVisualInfo chooseVisual(boolean onscreen) {
- if (display == 0) {
- throw new GLException("null display");
- }
-
- // FIXME
- if (onscreen) {
- // The visual has already been chosen by the time we get here;
- // it's specified by the GraphicsConfiguration of the
- // GLCanvas. Fortunately, the JAWT supplies the visual ID for
- // the component in a portable fashion, so all we have to do is
- // use XGetVisualInfo with a VisualIDMask to get the
- // corresponding XVisualInfo to pass into glXChooseVisual.
- int[] count = new int[1];
- XVisualInfo template = XVisualInfo.create();
- // FIXME: probably not 64-bit clean
- template.visualid((int) visualID);
- lockToolkit();
- XVisualInfo[] infos = GLX.XGetVisualInfo(display, GLX.VisualIDMask, template, count, 0);
- unlockToolkit();
- if (infos == null || infos.length == 0) {
- throw new GLException("Error while getting XVisualInfo for visual ID " + visualID);
- }
- if (DEBUG) {
- System.err.println("!!! Fetched XVisualInfo for visual ID 0x" + Long.toHexString(visualID));
- System.err.println("!!! Resulting XVisualInfo: visualid = 0x" + Long.toHexString(infos[0].visualid()));
- }
-
- // FIXME: the storage for the infos array is leaked (should
- // clean it up somehow when we're done with the visual we're
- // returning)
- return infos[0];
- } else {
- // It isn't clear to me whether we need this much code to handle
- // the offscreen case, where we're creating a pixmap into which
- // to render...this is what we (incorrectly) used to do for the
- // onscreen case
-
- int screen = 0; // FIXME: provide way to specify this?
- XVisualInfo vis = null;
- int[] count = new int[1];
- XVisualInfo template = XVisualInfo.create();
- template.screen(screen);
- XVisualInfo[] infos = null;
- GLCapabilities[] caps = null;
- lockToolkit();
- try {
- infos = GLX.XGetVisualInfo(display, GLX.VisualScreenMask, template, count, 0);
- if (infos == null) {
- throw new GLException("Error while enumerating available XVisualInfos");
- }
- caps = new GLCapabilities[infos.length];
- for (int i = 0; i < infos.length; i++) {
- caps[i] = X11GLDrawableFactory.xvi2GLCapabilities(display, infos[i]);
- }
- } finally {
- unlockToolkit();
- }
- int chosen = chooser.chooseCapabilities(capabilities, caps, -1);
- if (chosen < 0 || chosen >= caps.length) {
- throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
- }
- if (DEBUG) {
- System.err.println("Chosen visual (" + chosen + "):");
- System.err.println(caps[chosen]);
- }
- vis = infos[chosen];
- if (vis == null) {
- throw new GLException("GLCapabilitiesChooser chose an invalid visual");
- }
- // FIXME: the storage for the infos array is leaked (should
- // clean it up somehow when we're done with the visual we're
- // returning)
-
- return vis;
- }
- }
-
-
- // These synchronization primitives prevent the AWT from making
- // requests from the X server asynchronously to this code.
- protected void lockToolkit() {
- X11GLDrawableFactory.getX11Factory().lockToolkit();
- }
-
- protected void unlockToolkit() {
- X11GLDrawableFactory.getX11Factory().unlockToolkit();
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java
deleted file mode 100644
index 6ff112348..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java
+++ /dev/null
@@ -1,799 +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.sun.opengl.impl.x11;
-
-import java.awt.Component;
-import java.awt.Graphics;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
-import java.nio.*;
-import java.security.*;
-import java.util.*;
-import javax.media.opengl.*;
-import com.sun.gluegen.runtime.*;
-import com.sun.opengl.impl.*;
-
-public class X11GLDrawableFactory extends GLDrawableFactoryImpl {
- private static final boolean DEBUG = Debug.debug("X11GLDrawableFactory");
-
- // ATI's proprietary drivers apparently send GLX tokens even for
- // direct contexts, so we need to disable the context optimizations
- // in this case
- private static boolean isVendorATI;
-
- // See whether we're running in headless mode
- private static boolean isHeadless;
-
- // Map for rediscovering the GLCapabilities associated with a
- // particular screen and visualID after the fact
- private static Map visualToGLCapsMap = Collections.synchronizedMap(new HashMap());
-
- static class ScreenAndVisualIDKey {
- private int screen;
- private long visualID;
-
- ScreenAndVisualIDKey(int screen,
- long visualID) {
- this.screen = screen;
- this.visualID = visualID;
- }
-
- public int hashCode() {
- return (int) (screen + 13 * visualID);
- }
-
- public boolean equals(Object obj) {
- if ((obj == null) || (!(obj instanceof ScreenAndVisualIDKey))) {
- return false;
- }
-
- ScreenAndVisualIDKey key = (ScreenAndVisualIDKey) obj;
- return (screen == key.screen &&
- visualID == key.visualID);
- }
-
- int screen() { return screen; }
- long visualID() { return visualID; }
- }
-
- static {
- // See DRIHack.java for an explanation of why this is necessary
- DRIHack.begin();
-
- com.sun.opengl.impl.NativeLibLoader.loadCore();
-
- DRIHack.end();
-
- isHeadless = GraphicsEnvironment.isHeadless();
- }
-
- public X11GLDrawableFactory() {
- // Must initialize GLX support eagerly in case a pbuffer is the
- // first thing instantiated
- ProcAddressHelper.resetProcAddressTable(GLX.getGLXProcAddressTable(), this);
- }
-
- private static final int MAX_ATTRIBS = 128;
-
- public AbstractGraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser,
- AbstractGraphicsDevice absDevice) {
- if (capabilities == null) {
- capabilities = new GLCapabilities();
- }
- if (chooser == null) {
- chooser = new DefaultGLCapabilitiesChooser();
- }
- GraphicsDevice device = null;
- if (absDevice != null &&
- !(absDevice instanceof AWTGraphicsDevice)) {
- throw new IllegalArgumentException("This GLDrawableFactory accepts only AWTGraphicsDevice objects");
- }
-
- if ((absDevice == null) ||
- (((AWTGraphicsDevice) absDevice).getGraphicsDevice() == null)) {
- device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
- } else {
- device = ((AWTGraphicsDevice) absDevice).getGraphicsDevice();
- }
-
- int screen;
- if (isXineramaEnabled()) {
- screen = 0;
- } else {
- screen = X11SunJDKReflection.graphicsDeviceGetScreen(device);
- }
-
- // Until we have a rock-solid visual selection algorithm written
- // in pure Java, we're going to provide the underlying window
- // system's selection to the chooser as a hint
-
- int[] attribs = glCapabilities2AttribList(capabilities, isMultisampleAvailable(), false, 0, 0);
- XVisualInfo[] infos = null;
- GLCapabilities[] caps = null;
- int recommendedIndex = -1;
- lockToolkit();
- try {
- long display = getDisplayConnection();
- XVisualInfo recommendedVis = GLX.glXChooseVisual(display, screen, attribs, 0);
- if (DEBUG) {
- System.err.print("!!! glXChooseVisual recommended ");
- if (recommendedVis == null) {
- System.err.println("null visual");
- } else {
- System.err.println("visual id 0x" + Long.toHexString(recommendedVis.visualid()));
- }
- }
- int[] count = new int[1];
- XVisualInfo template = XVisualInfo.create();
- template.screen(screen);
- infos = GLX.XGetVisualInfo(display, GLX.VisualScreenMask, template, count, 0);
- if (infos == null) {
- throw new GLException("Error while enumerating available XVisualInfos");
- }
- caps = new GLCapabilities[infos.length];
- for (int i = 0; i < infos.length; i++) {
- caps[i] = xvi2GLCapabilities(display, infos[i]);
- // Attempt to find the visual chosen by glXChooseVisual
- if (recommendedVis != null && recommendedVis.visualid() == infos[i].visualid()) {
- recommendedIndex = i;
- }
- }
- } finally {
- unlockToolkit();
- }
- // Store these away for later
- for (int i = 0; i < infos.length; i++) {
- if (caps[i] != null) {
- visualToGLCapsMap.put(new ScreenAndVisualIDKey(screen, infos[i].visualid()),
- caps[i].clone());
- }
- }
- int chosen = chooser.chooseCapabilities(capabilities, caps, recommendedIndex);
- if (chosen < 0 || chosen >= caps.length) {
- throw new GLException("GLCapabilitiesChooser specified invalid index (expected 0.." + (caps.length - 1) + ")");
- }
- XVisualInfo vis = infos[chosen];
- if (vis == null) {
- throw new GLException("GLCapabilitiesChooser chose an invalid visual");
- }
- // FIXME: need to look at glue code and see type of this field
- long visualID = vis.visualid();
- // FIXME: the storage for the infos array, as well as that for the
- // recommended visual, is leaked; should free them here with XFree()
-
- // Now figure out which GraphicsConfiguration corresponds to this
- // visual by matching the visual ID
- GraphicsConfiguration[] configs = device.getConfigurations();
- for (int i = 0; i < configs.length; i++) {
- GraphicsConfiguration config = configs[i];
- if (config != null) {
- if (X11SunJDKReflection.graphicsConfigurationGetVisualID(config) == visualID) {
- return new AWTGraphicsConfiguration(config);
- }
- }
- }
-
- // Either we weren't able to reflectively introspect on the
- // X11GraphicsConfig or something went wrong in the steps above;
- // we're going to return null without signaling an error condition
- // in this case (although we should distinguish between the two
- // and possibly report more of an error in the latter case)
- return null;
- }
-
- public GLDrawable getGLDrawable(Object target,
- GLCapabilities capabilities,
- GLCapabilitiesChooser chooser) {
- if (target == null) {
- throw new IllegalArgumentException("Null target");
- }
- if (!(target instanceof Component)) {
- throw new IllegalArgumentException("GLDrawables not supported for objects of type " +
- target.getClass().getName() + " (only Components are supported in this implementation)");
- }
- Component comp = (Component) target;
- X11OnscreenGLDrawable drawable = new X11OnscreenGLDrawable(comp);
- // Figure out the GLCapabilities of this component
- GraphicsConfiguration config = comp.getGraphicsConfiguration();
- if (config == null) {
- throw new IllegalArgumentException("GLDrawableFactory.chooseGraphicsConfiguration() was not used when creating this Component");
- }
- int visualID = X11SunJDKReflection.graphicsConfigurationGetVisualID(config);
- int screen;
- if (isXineramaEnabled()) {
- screen = 0;
- } else {
- screen = X11SunJDKReflection.graphicsDeviceGetScreen(config.getDevice());
- }
- drawable.setChosenGLCapabilities((GLCapabilities) visualToGLCapsMap.get(new ScreenAndVisualIDKey(screen, visualID)));
- return drawable;
- }
-
- public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser) {
- return new X11OffscreenGLDrawable(capabilities, chooser);
- }
-
- private boolean pbufferSupportInitialized = false;
- private boolean canCreateGLPbuffer = false;
- public boolean canCreateGLPbuffer() {
- if (!pbufferSupportInitialized) {
- Runnable r = new Runnable() {
- public void run() {
- long display = getDisplayConnection();
- lockToolkit();
- try {
- int[] major = new int[1];
- int[] minor = new int[1];
- int screen = 0; // FIXME: provide way to specify this?
-
- if (!GLX.glXQueryVersion(display, major, 0, minor, 0)) {
- throw new GLException("glXQueryVersion failed");
- }
- if (DEBUG) {
- System.err.println("!!! GLX version: major " + major[0] +
- ", minor " + minor[0]);
- }
-
- // Work around bugs in ATI's Linux drivers where they report they
- // only implement GLX version 1.2 on the server side
- if (major[0] == 1 && minor[0] == 2) {
- String str = GLX.glXGetClientString(display, GLX.GLX_VERSION);
- if (str != null && str.startsWith("1.") &&
- (str.charAt(2) >= '3')) {
- canCreateGLPbuffer = true;
- }
- } else {
- canCreateGLPbuffer = ((major[0] > 1) || (minor[0] > 2));
- }
-
- pbufferSupportInitialized = true;
- } finally {
- unlockToolkit();
- }
- }
- };
- maybeDoSingleThreadedWorkaround(r);
- }
- return canCreateGLPbuffer;
- }
-
- public GLPbuffer createGLPbuffer(final GLCapabilities capabilities,
- final GLCapabilitiesChooser chooser,
- final int initialWidth,
- final int initialHeight,
- final GLContext shareWith) {
- if (!canCreateGLPbuffer()) {
- throw new GLException("Pbuffer support not available with current graphics card");
- }
- final List returnList = new ArrayList();
- Runnable r = new Runnable() {
- public void run() {
- X11PbufferGLDrawable pbufferDrawable = new X11PbufferGLDrawable(capabilities,
- initialWidth,
- initialHeight);
- GLPbufferImpl pbuffer = new GLPbufferImpl(pbufferDrawable, shareWith);
- returnList.add(pbuffer);
- }
- };
- maybeDoSingleThreadedWorkaround(r);
- return (GLPbuffer) returnList.get(0);
- }
-
- public GLContext createExternalGLContext() {
- return new X11ExternalGLContext();
- }
-
- public boolean canCreateExternalGLDrawable() {
- return canCreateGLPbuffer();
- }
-
- public GLDrawable createExternalGLDrawable() {
- return new X11ExternalGLDrawable();
- }
-
- public void loadGLULibrary() {
- GLX.dlopen("/usr/lib/libGLU.so");
- }
-
- public long dynamicLookupFunction(String glFuncName) {
- long res = 0;
- res = GLX.glXGetProcAddressARB(glFuncName);
- if (res == 0) {
- // GLU routines aren't known to the OpenGL function lookup
- res = GLX.dlsym(glFuncName);
- }
- return res;
- }
-
- public static GLCapabilities xvi2GLCapabilities(long display, XVisualInfo info) {
- int[] tmp = new int[1];
- int val = glXGetConfig(display, info, GLX.GLX_USE_GL, tmp, 0);
- if (val == 0) {
- // Visual does not support OpenGL
- return null;
- }
- val = glXGetConfig(display, info, GLX.GLX_RGBA, tmp, 0);
- if (val == 0) {
- // Visual does not support RGBA
- return null;
- }
- GLCapabilities res = new GLCapabilities();
- res.setDoubleBuffered(glXGetConfig(display, info, GLX.GLX_DOUBLEBUFFER, tmp, 0) != 0);
- res.setStereo (glXGetConfig(display, info, GLX.GLX_STEREO, tmp, 0) != 0);
- // Note: use of hardware acceleration is determined by
- // glXCreateContext, not by the XVisualInfo. Optimistically claim
- // that all GLCapabilities have the capability to be hardware
- // accelerated.
- res.setHardwareAccelerated(true);
- res.setDepthBits (glXGetConfig(display, info, GLX.GLX_DEPTH_SIZE, tmp, 0));
- res.setStencilBits (glXGetConfig(display, info, GLX.GLX_STENCIL_SIZE, tmp, 0));
- res.setRedBits (glXGetConfig(display, info, GLX.GLX_RED_SIZE, tmp, 0));
- res.setGreenBits (glXGetConfig(display, info, GLX.GLX_GREEN_SIZE, tmp, 0));
- res.setBlueBits (glXGetConfig(display, info, GLX.GLX_BLUE_SIZE, tmp, 0));
- res.setAlphaBits (glXGetConfig(display, info, GLX.GLX_ALPHA_SIZE, tmp, 0));
- res.setAccumRedBits (glXGetConfig(display, info, GLX.GLX_ACCUM_RED_SIZE, tmp, 0));
- res.setAccumGreenBits(glXGetConfig(display, info, GLX.GLX_ACCUM_GREEN_SIZE, tmp, 0));
- res.setAccumBlueBits (glXGetConfig(display, info, GLX.GLX_ACCUM_BLUE_SIZE, tmp, 0));
- res.setAccumAlphaBits(glXGetConfig(display, info, GLX.GLX_ACCUM_ALPHA_SIZE, tmp, 0));
- if (isMultisampleAvailable()) {
- res.setSampleBuffers(glXGetConfig(display, info, GLX.GLX_SAMPLE_BUFFERS_ARB, tmp, 0) != 0);
- res.setNumSamples (glXGetConfig(display, info, GLX.GLX_SAMPLES_ARB, tmp, 0));
- }
- return res;
- }
-
- public static int[] glCapabilities2AttribList(GLCapabilities caps,
- boolean isMultisampleAvailable,
- boolean pbuffer,
- long display,
- int screen) {
- int colorDepth = (caps.getRedBits() +
- caps.getGreenBits() +
- caps.getBlueBits());
- if (colorDepth < 15) {
- throw new GLException("Bit depths < 15 (i.e., non-true-color) not supported");
- }
- int[] res = new int[MAX_ATTRIBS];
- int idx = 0;
- if (pbuffer) {
- res[idx++] = GLXExt.GLX_DRAWABLE_TYPE;
- res[idx++] = GLXExt.GLX_PBUFFER_BIT;
-
- res[idx++] = GLXExt.GLX_RENDER_TYPE;
- res[idx++] = GLXExt.GLX_RGBA_BIT;
- } else {
- res[idx++] = GLX.GLX_RGBA;
- }
- if (caps.getDoubleBuffered()) {
- res[idx++] = GLX.GLX_DOUBLEBUFFER;
- if (pbuffer) {
- res[idx++] = GL.GL_TRUE;
- }
- } else {
- if (pbuffer) {
- res[idx++] = GLX.GLX_DOUBLEBUFFER;
- res[idx++] = GL.GL_FALSE;
- }
- }
- if (caps.getStereo()) {
- res[idx++] = GLX.GLX_STEREO;
- if (pbuffer) {
- res[idx++] = GL.GL_TRUE;
- }
- }
- // NOTE: don't set (GLX_STEREO, GL_FALSE) in "else" branch for
- // pbuffer case to work around Mesa bug
-
- res[idx++] = GLX.GLX_RED_SIZE;
- res[idx++] = caps.getRedBits();
- res[idx++] = GLX.GLX_GREEN_SIZE;
- res[idx++] = caps.getGreenBits();
- res[idx++] = GLX.GLX_BLUE_SIZE;
- res[idx++] = caps.getBlueBits();
- res[idx++] = GLX.GLX_ALPHA_SIZE;
- res[idx++] = caps.getAlphaBits();
- res[idx++] = GLX.GLX_DEPTH_SIZE;
- res[idx++] = caps.getDepthBits();
- if (caps.getStencilBits() > 0) {
- res[idx++] = GLX.GLX_STENCIL_SIZE;
- res[idx++] = caps.getStencilBits();
- }
- if (caps.getAccumRedBits() > 0 ||
- caps.getAccumGreenBits() > 0 ||
- caps.getAccumBlueBits() > 0 ||
- caps.getAccumAlphaBits() > 0) {
- res[idx++] = GLX.GLX_ACCUM_RED_SIZE;
- res[idx++] = caps.getAccumRedBits();
- res[idx++] = GLX.GLX_ACCUM_GREEN_SIZE;
- res[idx++] = caps.getAccumGreenBits();
- res[idx++] = GLX.GLX_ACCUM_BLUE_SIZE;
- res[idx++] = caps.getAccumBlueBits();
- res[idx++] = GLX.GLX_ACCUM_ALPHA_SIZE;
- res[idx++] = caps.getAccumAlphaBits();
- }
- if (isMultisampleAvailable && caps.getSampleBuffers()) {
- res[idx++] = GLXExt.GLX_SAMPLE_BUFFERS_ARB;
- res[idx++] = GL.GL_TRUE;
- res[idx++] = GLXExt.GLX_SAMPLES_ARB;
- res[idx++] = caps.getNumSamples();
- }
- if (pbuffer) {
- if (caps.getPbufferFloatingPointBuffers()) {
- String glXExtensions = GLX.glXQueryExtensionsString(display, screen);
- if (glXExtensions == null ||
- glXExtensions.indexOf("GLX_NV_float_buffer") < 0) {
- throw new GLException("Floating-point pbuffers on X11 currently require NVidia hardware");
- }
- res[idx++] = GLX.GLX_FLOAT_COMPONENTS_NV;
- res[idx++] = GL.GL_TRUE;
- }
- }
- res[idx++] = 0;
- return res;
- }
-
- public static GLCapabilities attribList2GLCapabilities(int[] iattribs,
- int niattribs,
- int[] ivalues,
- boolean pbuffer) {
- GLCapabilities caps = new GLCapabilities();
-
- for (int i = 0; i < niattribs; i++) {
- int attr = iattribs[i];
- switch (attr) {
- case GLX.GLX_DOUBLEBUFFER:
- caps.setDoubleBuffered(ivalues[i] != GL.GL_FALSE);
- break;
-
- case GLX.GLX_STEREO:
- caps.setStereo(ivalues[i] != GL.GL_FALSE);
- break;
-
- case GLX.GLX_RED_SIZE:
- caps.setRedBits(ivalues[i]);
- break;
-
- case GLX.GLX_GREEN_SIZE:
- caps.setGreenBits(ivalues[i]);
- break;
-
- case GLX.GLX_BLUE_SIZE:
- caps.setBlueBits(ivalues[i]);
- break;
-
- case GLX.GLX_ALPHA_SIZE:
- caps.setAlphaBits(ivalues[i]);
- break;
-
- case GLX.GLX_DEPTH_SIZE:
- caps.setDepthBits(ivalues[i]);
- break;
-
- case GLX.GLX_STENCIL_SIZE:
- caps.setStencilBits(ivalues[i]);
- break;
-
- case GLX.GLX_ACCUM_RED_SIZE:
- caps.setAccumRedBits(ivalues[i]);
- break;
-
- case GLX.GLX_ACCUM_GREEN_SIZE:
- caps.setAccumGreenBits(ivalues[i]);
- break;
-
- case GLX.GLX_ACCUM_BLUE_SIZE:
- caps.setAccumBlueBits(ivalues[i]);
- break;
-
- case GLX.GLX_ACCUM_ALPHA_SIZE:
- caps.setAccumAlphaBits(ivalues[i]);
- break;
-
- case GLXExt.GLX_SAMPLE_BUFFERS_ARB:
- caps.setSampleBuffers(ivalues[i] != GL.GL_FALSE);
- break;
-
- case GLXExt.GLX_SAMPLES_ARB:
- caps.setNumSamples(ivalues[i]);
- break;
-
- case GLX.GLX_FLOAT_COMPONENTS_NV:
- caps.setPbufferFloatingPointBuffers(ivalues[i] != GL.GL_FALSE);
- break;
-
- default:
- break;
- }
- }
-
- return caps;
- }
-
- public void lockToolkit() {
- if (isHeadless) {
- // Workaround for running (to some degree) in headless
- // environments but still supporting rendering via pbuffers
- // For full correctness, would need to implement a Lock class
- return;
- }
-
- if (!Java2D.isOGLPipelineActive() || !Java2D.isQueueFlusherThread()) {
- JAWT.getJAWT().Lock();
- }
- }
-
- public void unlockToolkit() {
- if (isHeadless) {
- // Workaround for running (to some degree) in headless
- // environments but still supporting rendering via pbuffers
- // For full correctness, would need to implement a Lock class
- return;
- }
-
- if (!Java2D.isOGLPipelineActive() || !Java2D.isQueueFlusherThread()) {
- JAWT.getJAWT().Unlock();
- }
- }
-
- public void lockAWTForJava2D() {
- lockToolkit();
- }
- public void unlockAWTForJava2D() {
- unlockToolkit();
- }
-
- // Display connection for use by visual selection algorithm and by all offscreen surfaces
- private static long staticDisplay;
- public static long getDisplayConnection() {
- if (staticDisplay == 0) {
- getX11Factory().lockToolkit();
- try {
- staticDisplay = GLX.XOpenDisplay(null);
- if (DEBUG && (staticDisplay != 0)) {
- long display = staticDisplay;
- int screen = 0; // FIXME
- System.err.println("!!! GLX server vendor : " +
- GLX.glXQueryServerString(display, screen, GLX.GLX_VENDOR));
- System.err.println("!!! GLX server version: " +
- GLX.glXQueryServerString(display, screen, GLX.GLX_VERSION));
- System.err.println("!!! GLX client vendor : " +
- GLX.glXGetClientString(display, GLX.GLX_VENDOR));
- System.err.println("!!! GLX client version: " +
- GLX.glXGetClientString(display, GLX.GLX_VERSION));
- }
-
- if (staticDisplay != 0) {
- String vendor = GLX.glXGetClientString(staticDisplay, GLX.GLX_VENDOR);
- if (vendor != null && vendor.startsWith("ATI")) {
- isVendorATI = true;
- }
- }
- } finally {
- getX11Factory().unlockToolkit();
- }
- if (staticDisplay == 0) {
- throw new GLException("Unable to open default display, needed for visual selection and offscreen surface handling");
- }
- }
- return staticDisplay;
- }
-
- private static boolean checkedMultisample;
- private static boolean multisampleAvailable;
- public static boolean isMultisampleAvailable() {
- if (!checkedMultisample) {
- long display = getDisplayConnection();
- String exts = GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
- if (exts != null) {
- multisampleAvailable = (exts.indexOf("GLX_ARB_multisample") >= 0);
- }
- checkedMultisample = true;
- }
- return multisampleAvailable;
- }
-
- private static String glXGetConfigErrorCode(int err) {
- switch (err) {
- case GLX.GLX_NO_EXTENSION: return "GLX_NO_EXTENSION";
- case GLX.GLX_BAD_SCREEN: return "GLX_BAD_SCREEN";
- case GLX.GLX_BAD_ATTRIBUTE: return "GLX_BAD_ATTRIBUTE";
- case GLX.GLX_BAD_VISUAL: return "GLX_BAD_VISUAL";
- default: return "Unknown error code " + err;
- }
- }
-
- public static int glXGetConfig(long display, XVisualInfo info, int attrib, int[] tmp, int tmp_offset) {
- if (display == 0) {
- throw new GLException("No display connection");
- }
- int res = GLX.glXGetConfig(display, info, attrib, tmp, tmp_offset);
- if (res != 0) {
- throw new GLException("glXGetConfig failed: error code " + glXGetConfigErrorCode(res));
- }
- return tmp[tmp_offset];
- }
-
- public static X11GLDrawableFactory getX11Factory() {
- return (X11GLDrawableFactory) getFactory();
- }
-
- /** Workaround for apparent issue with ATI's proprietary drivers
- where direct contexts still send GLX tokens for GL calls */
- public static boolean isVendorATI() {
- return isVendorATI;
- }
-
- private void maybeDoSingleThreadedWorkaround(Runnable action) {
- if (Threading.isSingleThreaded() &&
- !Threading.isOpenGLThread()) {
- Threading.invokeOnOpenGLThread(action);
- } else {
- action.run();
- }
- }
-
- public boolean canCreateContextOnJava2DSurface() {
- return false;
- }
-
- public GLContext createContextOnJava2DSurface(Graphics g, GLContext shareWith)
- throws GLException {
- throw new GLException("Unimplemented on this platform");
- }
-
- //---------------------------------------------------------------------------
- // Xinerama-related functionality
- //
-
- private boolean checkedXinerama;
- private boolean xineramaEnabled;
- protected synchronized boolean isXineramaEnabled() {
- if (!checkedXinerama) {
- checkedXinerama = true;
- lockToolkit();
- long display = getDisplayConnection();
- xineramaEnabled = GLX.XineramaEnabled(display);
- unlockToolkit();
- }
- return xineramaEnabled;
- }
-
- //----------------------------------------------------------------------
- // Gamma-related functionality
- //
-
- private boolean gotGammaRampLength;
- private int gammaRampLength;
- protected synchronized int getGammaRampLength() {
- if (gotGammaRampLength) {
- return gammaRampLength;
- }
-
- int[] size = new int[1];
- lockToolkit();
- long display = getDisplayConnection();
- boolean res = GLX.XF86VidModeGetGammaRampSize(display,
- GLX.DefaultScreen(display),
- size, 0);
- unlockToolkit();
- if (!res)
- return 0;
- gotGammaRampLength = true;
- gammaRampLength = size[0];
- return gammaRampLength;
- }
-
- protected boolean setGammaRamp(float[] ramp) {
- int len = ramp.length;
- short[] rampData = new short[len];
- for (int i = 0; i < len; i++) {
- rampData[i] = (short) (ramp[i] * 65535);
- }
-
- lockToolkit();
- long display = getDisplayConnection();
- boolean res = GLX.XF86VidModeSetGammaRamp(display,
- GLX.DefaultScreen(display),
- rampData.length,
- rampData, 0,
- rampData, 0,
- rampData, 0);
- unlockToolkit();
- return res;
- }
-
- protected Buffer getGammaRamp() {
- int size = getGammaRampLength();
- ShortBuffer rampData = ShortBuffer.allocate(3 * size);
- rampData.position(0);
- rampData.limit(size);
- ShortBuffer redRampData = rampData.slice();
- rampData.position(size);
- rampData.limit(2 * size);
- ShortBuffer greenRampData = rampData.slice();
- rampData.position(2 * size);
- rampData.limit(3 * size);
- ShortBuffer blueRampData = rampData.slice();
- lockToolkit();
- long display = getDisplayConnection();
- boolean res = GLX.XF86VidModeGetGammaRamp(display,
- GLX.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- unlockToolkit();
- if (!res)
- return null;
- return rampData;
- }
-
- protected void resetGammaRamp(Buffer originalGammaRamp) {
- if (originalGammaRamp == null)
- return; // getGammaRamp failed originally
- ShortBuffer rampData = (ShortBuffer) originalGammaRamp;
- int capacity = rampData.capacity();
- if ((capacity % 3) != 0) {
- throw new IllegalArgumentException("Must not be the original gamma ramp");
- }
- int size = capacity / 3;
- rampData.position(0);
- rampData.limit(size);
- ShortBuffer redRampData = rampData.slice();
- rampData.position(size);
- rampData.limit(2 * size);
- ShortBuffer greenRampData = rampData.slice();
- rampData.position(2 * size);
- rampData.limit(3 * size);
- ShortBuffer blueRampData = rampData.slice();
- lockToolkit();
- long display = getDisplayConnection();
- GLX.XF86VidModeSetGammaRamp(display,
- GLX.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- unlockToolkit();
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11OffscreenGLContext.java b/src/classes/com/sun/opengl/impl/x11/X11OffscreenGLContext.java
deleted file mode 100644
index 132573f7b..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11OffscreenGLContext.java
+++ /dev/null
@@ -1,83 +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.sun.opengl.impl.x11;
-
-import javax.media.opengl.*;
-import com.sun.opengl.impl.*;
-
-public class X11OffscreenGLContext extends X11GLContext {
- private X11OffscreenGLDrawable drawable;
-
- public X11OffscreenGLContext(X11OffscreenGLDrawable drawable,
- GLContext shareWith) {
- super(drawable, shareWith);
- this.drawable = drawable;
- }
-
- public int getOffscreenContextPixelDataType() {
- return GL.GL_UNSIGNED_INT_8_8_8_8_REV;
- }
-
- public int getOffscreenContextReadBuffer() {
- if (drawable.isDoubleBuffered()) {
- return GL.GL_BACK;
- }
- return GL.GL_FRONT;
- }
-
- public boolean offscreenImageNeedsVerticalFlip() {
- // There doesn't seem to be a way to do this in the construction
- // of the Pixmap or GLXPixmap
- return true;
- }
-
- protected int makeCurrentImpl() throws GLException {
- lockToolkit();
- try {
- return super.makeCurrentImpl();
- } finally {
- unlockToolkit();
- }
- }
-
- protected void create() {
- createContext(false);
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11OffscreenGLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11OffscreenGLDrawable.java
deleted file mode 100644
index d70c79334..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11OffscreenGLDrawable.java
+++ /dev/null
@@ -1,145 +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.sun.opengl.impl.x11;
-
-import javax.media.opengl.*;
-import com.sun.opengl.impl.*;
-
-public class X11OffscreenGLDrawable extends X11GLDrawable {
- private long pixmap;
- private boolean isDoubleBuffered;
- // Width and height of the underlying bitmap
- private int width;
- private int height;
-
- public X11OffscreenGLDrawable(GLCapabilities capabilities,
- GLCapabilitiesChooser chooser) {
- super(capabilities, chooser);
- }
-
- public GLContext createContext(GLContext shareWith) {
- return new X11OffscreenGLContext(this, shareWith);
- }
-
- public void setSize(int newWidth, int newHeight) {
- width = newWidth;
- height = newHeight;
- if (pixmap != 0) {
- destroy();
- }
- create();
- }
-
- public int getWidth() {
- return width;
- }
-
- public int getHeight() {
- return height;
- }
-
- private void create() {
- display = X11GLDrawableFactory.getDisplayConnection();
- XVisualInfo vis = chooseVisual(false);
- int bitsPerPixel = vis.depth();
-
- lockToolkit();
- try {
- int screen = GLX.DefaultScreen(display);
- pixmap = GLX.XCreatePixmap(display, (int) GLX.RootWindow(display, screen), width, height, bitsPerPixel);
- if (pixmap == 0) {
- throw new GLException("XCreatePixmap failed");
- }
- drawable = GLX.glXCreateGLXPixmap(display, vis, pixmap);
- if (drawable == 0) {
- GLX.XFreePixmap(display, pixmap);
- pixmap = 0;
- throw new GLException("glXCreateGLXPixmap failed");
- }
- isDoubleBuffered = (X11GLDrawableFactory.glXGetConfig(display, vis, GLX.GLX_DOUBLEBUFFER, new int[1], 0) != 0);
- if (DEBUG) {
- System.err.println("Created pixmap " + toHexString(pixmap) +
- ", GLXPixmap " + toHexString(drawable) +
- ", display " + toHexString(display));
- }
- setChosenGLCapabilities(X11GLDrawableFactory.xvi2GLCapabilities(display, vis));
- } finally {
- unlockToolkit();
- }
- }
-
- public void destroy() {
- if (pixmap != 0) {
- if (DEBUG) {
- System.err.println("Destroying pixmap " + toHexString(pixmap) +
- ", GLXPixmap " + toHexString(drawable) +
- ", display " + toHexString(display));
- }
-
- // Must destroy pixmap and GLXPixmap
- lockToolkit();
-
- if (DEBUG) {
- long cur = GLX.glXGetCurrentContext();
- if (cur != 0) {
- System.err.println("WARNING: found context " + toHexString(cur) + " current during pixmap destruction");
- }
- }
-
- // FIXME: workaround for crashes on NVidia hardware when
- // destroying pixmap (no context is current at the point of the
- // crash, at least from the point of view of
- // glXGetCurrentContext)
- GLX.glXMakeCurrent(display, 0, 0);
-
- GLX.glXDestroyGLXPixmap(display, drawable);
- GLX.XFreePixmap(display, pixmap);
- unlockToolkit();
- drawable = 0;
- pixmap = 0;
- display = 0;
- setChosenGLCapabilities(null);
- }
- }
-
- public boolean isDoubleBuffered() {
- return isDoubleBuffered;
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java
deleted file mode 100644
index bab780219..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLContext.java
+++ /dev/null
@@ -1,100 +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.sun.opengl.impl.x11;
-
-import java.util.*;
-
-import javax.media.opengl.*;
-import com.sun.opengl.impl.*;
-
-public class X11OnscreenGLContext extends X11GLContext {
- protected X11OnscreenGLDrawable drawable;
- // This indicates whether the context we have created is indirect
- // and therefore requires the toolkit to be locked around all GL
- // calls rather than just all GLX calls
- protected boolean isIndirect;
-
- public X11OnscreenGLContext(X11OnscreenGLDrawable drawable,
- GLContext shareWith) {
- super(drawable, shareWith);
- this.drawable = drawable;
- }
-
- protected int makeCurrentImpl() throws GLException {
- int lockRes = drawable.lockSurface();
- boolean exceptionOccurred = false;
- try {
- if (lockRes == X11OnscreenGLDrawable.LOCK_SURFACE_NOT_READY) {
- return CONTEXT_NOT_CURRENT;
- }
- if (lockRes == X11OnscreenGLDrawable.LOCK_SURFACE_CHANGED) {
- destroyImpl();
- }
- return super.makeCurrentImpl();
- } catch (RuntimeException e) {
- exceptionOccurred = true;
- throw e;
- } finally {
- if (exceptionOccurred ||
- (isOptimizable() && lockRes != X11OnscreenGLDrawable.LOCK_SURFACE_NOT_READY)) {
- drawable.unlockSurface();
- }
- }
- }
-
- protected void releaseImpl() throws GLException {
- try {
- super.releaseImpl();
- } finally {
- if (!isOptimizable()) {
- drawable.unlockSurface();
- }
- }
- }
-
- public boolean isOptimizable() {
- return super.isOptimizable() && !isIndirect;
- }
-
- protected void create() {
- createContext(true);
- isIndirect = !GLX.glXIsDirect(drawable.getDisplay(), context);
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java
deleted file mode 100644
index b1a3ebac7..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11OnscreenGLDrawable.java
+++ /dev/null
@@ -1,186 +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.sun.opengl.impl.x11;
-
-import java.awt.Component;
-
-import javax.media.opengl.*;
-import com.sun.opengl.impl.*;
-
-public class X11OnscreenGLDrawable extends X11GLDrawable {
- public static final int LOCK_SURFACE_NOT_READY = 1;
- public static final int LOCK_SURFACE_CHANGED = 2;
- public static final int LOCK_SUCCESS = 3;
-
- protected Component component;
-
- // Variables for lockSurface/unlockSurface
- private JAWT_DrawingSurface ds;
- private JAWT_DrawingSurfaceInfo dsi;
- private JAWT_X11DrawingSurfaceInfo x11dsi;
-
- // Indicates whether the component (if an onscreen context) has been
- // realized. Plausibly, before the component is realized the JAWT
- // should return an error or NULL object from some of its
- // operations; this appears to be the case on Win32 but is not true
- // at least with Sun's current X11 implementation (1.4.x), which
- // crashes with no other error reported if the DrawingSurfaceInfo is
- // fetched from a locked DrawingSurface during the validation as a
- // result of calling show() on the main thread. To work around this
- // we prevent any JAWT or OpenGL operations from being done until
- // addNotify() is called on the component.
- protected boolean realized;
-
- public X11OnscreenGLDrawable(Component component) {
- super(null, null);
- this.component = component;
- }
-
- public GLContext createContext(GLContext shareWith) {
- return new X11OnscreenGLContext(this, shareWith);
- }
-
- public void setRealized(boolean realized) {
- this.realized = realized;
- }
-
- public void setSize(int width, int height) {
- component.setSize(width, height);
- }
-
- public int getWidth() {
- return component.getWidth();
- }
-
- public int getHeight() {
- return component.getHeight();
- }
-
- public void swapBuffers() throws GLException {
- lockToolkit();
- try {
- boolean didLock = false;
-
- if (drawable == 0) {
- if (lockSurface() == LOCK_SURFACE_NOT_READY) {
- return;
- }
-
- didLock = true;
- }
-
- GLX.glXSwapBuffers(display, drawable);
-
- if (didLock) {
- unlockSurface();
- }
- } finally {
- unlockToolkit();
- }
- }
-
- public int lockSurface() throws GLException {
- if (!realized) {
- return LOCK_SURFACE_NOT_READY;
- }
- if (drawable != 0) {
- throw new GLException("Surface already locked");
- }
- ds = JAWT.getJAWT().GetDrawingSurface(component);
- if (ds == null) {
- // Widget not yet realized
- return LOCK_SURFACE_NOT_READY;
- }
- int res = ds.Lock();
- if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
- throw new GLException("Unable to lock surface");
- }
- // See whether the surface changed and if so destroy the old
- // OpenGL context so it will be recreated (NOTE: removeNotify
- // should handle this case, but it may be possible that race
- // conditions can cause this code to be triggered -- should test
- // more)
- int ret = LOCK_SUCCESS;
- if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) {
- ret = LOCK_SURFACE_CHANGED;
- }
- dsi = ds.GetDrawingSurfaceInfo();
- if (dsi == null) {
- // Widget not yet realized
- ds.Unlock();
- JAWT.getJAWT().FreeDrawingSurface(ds);
- ds = null;
- return LOCK_SURFACE_NOT_READY;
- }
- x11dsi = (JAWT_X11DrawingSurfaceInfo) dsi.platformInfo();
- display = x11dsi.display();
- drawable = x11dsi.drawable();
- visualID = x11dsi.visualID();
- if (display == 0 || drawable == 0) {
- // Widget not yet realized
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- JAWT.getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- x11dsi = null;
- display = 0;
- drawable = 0;
- visualID = 0;
- return LOCK_SURFACE_NOT_READY;
- }
- return ret;
- }
-
- public void unlockSurface() {
- if (drawable == 0) {
- throw new GLException("Surface already unlocked");
- }
- ds.FreeDrawingSurfaceInfo(dsi);
- ds.Unlock();
- JAWT.getJAWT().FreeDrawingSurface(ds);
- ds = null;
- dsi = null;
- x11dsi = null;
- display = 0;
- drawable = 0;
- visualID = 0;
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11PbufferGLContext.java b/src/classes/com/sun/opengl/impl/x11/X11PbufferGLContext.java
deleted file mode 100644
index 4207c7d99..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11PbufferGLContext.java
+++ /dev/null
@@ -1,155 +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.sun.opengl.impl.x11;
-
-import javax.media.opengl.*;
-import com.sun.opengl.impl.*;
-
-public class X11PbufferGLContext extends X11GLContext {
- private X11PbufferGLDrawable drawable;
-
- public X11PbufferGLContext(X11PbufferGLDrawable drawable,
- GLContext shareWith) {
- super(drawable, shareWith);
- this.drawable = drawable;
- }
-
- public void bindPbufferToTexture() {
- // FIXME: figure out how to implement this
- throw new GLException("Not yet implemented");
- }
-
- public void releasePbufferFromTexture() {
- // FIXME: figure out how to implement this
- throw new GLException("Not yet implemented");
- }
-
- protected int makeCurrentImpl() throws GLException {
- if (drawable.getDrawable() == 0) {
- // pbuffer not instantiated (yet?)
- if (DEBUG) {
- System.err.println("pbuffer not instantiated");
- }
- return CONTEXT_NOT_CURRENT;
- }
-
- // Note that we have to completely override makeCurrentImpl
- // because the underlying makeCurrent call differs for pbuffers
- lockToolkit();
- try {
- boolean created = false;
- if (context == 0) {
- create();
- if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Created GL context for " + getClass().getName());
- }
- created = true;
- }
-
- if (!GLX.glXMakeContextCurrent(drawable.getDisplay(),
- drawable.getDrawable(),
- drawable.getDrawable(),
- context)) {
- throw new GLException("Error making context current");
- } else {
- mostRecentDisplay = drawable.getDisplay();
- if (DEBUG && (VERBOSE || created)) {
- System.err.println(getThreadName() + ": glXMakeCurrent(display " + toHexString(drawable.getDisplay()) +
- ", drawable " + toHexString(drawable.getDrawable()) +
- ", context " + toHexString(context) + ") succeeded");
- }
- }
-
- if (created) {
- resetGLFunctionAvailability();
- return CONTEXT_CURRENT_NEW;
- }
- return CONTEXT_CURRENT;
- } finally {
- unlockToolkit();
- }
- }
-
- protected void releaseImpl() throws GLException {
- lockToolkit();
- try {
- if (drawable.getDisplay() == 0) {
- throw new GLException("Pbuffer destroyed out from under application-created context");
- }
-
- if (!GLX.glXMakeContextCurrent(drawable.getDisplay(), 0, 0, 0)) {
- throw new GLException("Error freeing OpenGL context");
- }
- } finally {
- unlockToolkit();
- }
- }
-
- public int getFloatingPointMode() {
- return drawable.getFloatingPointMode();
- }
-
- protected void create() {
- if (DEBUG) {
- System.err.println("Creating context for pbuffer " + drawable.getWidth() +
- " x " + drawable.getHeight());
- }
-
- // Create a gl context for the p-buffer.
- X11GLContext other = (X11GLContext) GLContextShareSet.getShareContext(this);
- long share = 0;
- if (other != null) {
- share = other.getContext();
- if (share == 0) {
- throw new GLException("GLContextShareSet returned an invalid OpenGL context");
- }
- }
- context = GLX.glXCreateNewContext(drawable.getDisplay(), drawable.getFBConfig(), GLXExt.GLX_RGBA_TYPE, share, true);
- if (context == 0) {
- throw new GLException("pbuffer creation error: glXCreateNewContext() failed");
- }
- GLContextShareSet.contextCreated(this);
-
- if (DEBUG) {
- System.err.println("Created context for pbuffer " + drawable.getWidth() +
- " x " + drawable.getHeight());
- }
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java b/src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java
deleted file mode 100644
index 4fdc0f80a..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11PbufferGLDrawable.java
+++ /dev/null
@@ -1,239 +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.sun.opengl.impl.x11;
-
-import javax.media.opengl.*;
-import com.sun.opengl.impl.*;
-
-public class X11PbufferGLDrawable extends X11GLDrawable {
- private int initWidth;
- private int initHeight;
-
- // drawable in superclass is a GLXPbuffer
- private GLXFBConfig fbConfig;
- private int width;
- private int height;
-
- protected static final int MAX_PFORMATS = 256;
- protected static final int MAX_ATTRIBS = 256;
-
- public X11PbufferGLDrawable(GLCapabilities capabilities, int initialWidth, int initialHeight) {
- super(capabilities, null);
- this.initWidth = initialWidth;
- this.initHeight = initialHeight;
- if (initWidth <= 0 || initHeight <= 0) {
- throw new GLException("Initial width and height of pbuffer must be positive (were (" +
- initWidth + ", " + initHeight + "))");
- }
-
- if (DEBUG) {
- System.out.println("Pbuffer caps on init: " + capabilities +
- (capabilities.getPbufferRenderToTexture() ? " [rtt]" : "") +
- (capabilities.getPbufferRenderToTextureRectangle() ? " [rect]" : "") +
- (capabilities.getPbufferFloatingPointBuffers() ? " [float]" : ""));
- }
-
- createPbuffer(X11GLDrawableFactory.getDisplayConnection());
- }
-
- public GLContext createContext(GLContext shareWith) {
- return new X11PbufferGLContext(this, shareWith);
- }
-
- public void destroy() {
- lockToolkit();
- if (drawable != 0) {
- GLX.glXDestroyPbuffer(display, drawable);
- drawable = 0;
- }
- unlockToolkit();
- display = 0;
- }
-
- public void setSize(int width, int height) {
- // FIXME
- throw new GLException("Not yet implemented");
- }
-
- public int getWidth() {
- return width;
- }
-
- public int getHeight() {
- return height;
- }
-
- public void createPbuffer(long display) {
- lockToolkit();
- try {
- if (display == 0) {
- throw new GLException("Null display");
- }
-
- if (capabilities.getPbufferRenderToTexture()) {
- throw new GLException("Render-to-texture pbuffers not supported yet on X11");
- }
-
- if (capabilities.getPbufferRenderToTextureRectangle()) {
- throw new GLException("Render-to-texture-rectangle pbuffers not supported yet on X11");
- }
-
- int screen = GLX.DefaultScreen(display);
- int[] iattributes = X11GLDrawableFactory.glCapabilities2AttribList(capabilities,
- X11GLDrawableFactory.isMultisampleAvailable(),
- true, display, screen);
-
- int[] nelementsTmp = new int[1];
- GLXFBConfig[] fbConfigs = GLX.glXChooseFBConfig(display, screen, iattributes, 0, nelementsTmp, 0);
- if (fbConfigs == null || fbConfigs.length == 0 || fbConfigs[0] == null) {
- throw new GLException("pbuffer creation error: glXChooseFBConfig() failed");
- }
- int nelements = nelementsTmp[0];
- if (nelements <= 0) {
- throw new GLException("pbuffer creation error: couldn't find a suitable frame buffer configuration");
- }
- // Note that we currently don't allow selection of anything but
- // the first GLXFBConfig in the returned list
- GLXFBConfig fbConfig = fbConfigs[0];
-
- if (DEBUG) {
- System.err.println("Found " + fbConfigs.length + " matching GLXFBConfigs");
- System.err.println("Parameters of default one:");
- System.err.println("render type: 0x" + Integer.toHexString(queryFBConfig(display, fbConfig, GLX.GLX_RENDER_TYPE)));
- System.err.println("rgba: " + ((queryFBConfig(display, fbConfig, GLX.GLX_RENDER_TYPE) & GLX.GLX_RGBA_BIT) != 0));
- System.err.println("r: " + queryFBConfig(display, fbConfig, GLX.GLX_RED_SIZE));
- System.err.println("g: " + queryFBConfig(display, fbConfig, GLX.GLX_GREEN_SIZE));
- System.err.println("b: " + queryFBConfig(display, fbConfig, GLX.GLX_BLUE_SIZE));
- System.err.println("a: " + queryFBConfig(display, fbConfig, GLX.GLX_ALPHA_SIZE));
- System.err.println("depth: " + queryFBConfig(display, fbConfig, GLX.GLX_DEPTH_SIZE));
- System.err.println("double buffered: " + queryFBConfig(display, fbConfig, GLX.GLX_DOUBLEBUFFER));
- }
-
- // Create the p-buffer.
- int niattribs = 0;
-
- iattributes[niattribs++] = GLXExt.GLX_PBUFFER_WIDTH;
- iattributes[niattribs++] = initWidth;
- iattributes[niattribs++] = GLXExt.GLX_PBUFFER_HEIGHT;
- iattributes[niattribs++] = initHeight;
-
- iattributes[niattribs++] = 0;
-
- long tmpBuffer = GLX.glXCreatePbuffer(display, fbConfig, iattributes, 0);
- if (tmpBuffer == 0) {
- // FIXME: query X error code for detail error message
- throw new GLException("pbuffer creation error: glXCreatePbuffer() failed");
- }
-
- // Set up instance variables
- this.display = display;
- drawable = tmpBuffer;
- this.fbConfig = fbConfig;
-
- // Pick innocent query values if multisampling or floating point buffers not available
- int sbAttrib = X11GLDrawableFactory.isMultisampleAvailable() ? GLXExt.GLX_SAMPLE_BUFFERS_ARB : GLX.GLX_RED_SIZE;
- int samplesAttrib = X11GLDrawableFactory.isMultisampleAvailable() ? GLXExt.GLX_SAMPLES_ARB : GLX.GLX_RED_SIZE;
- int floatNV = capabilities.getPbufferFloatingPointBuffers() ? GLX.GLX_FLOAT_COMPONENTS_NV : GLX.GLX_RED_SIZE;
-
- // Query the fbconfig to determine its GLCapabilities
- int[] iattribs = {
- GLX.GLX_DOUBLEBUFFER,
- GLX.GLX_STEREO,
- GLX.GLX_RED_SIZE,
- GLX.GLX_GREEN_SIZE,
- GLX.GLX_BLUE_SIZE,
- GLX.GLX_ALPHA_SIZE,
- GLX.GLX_DEPTH_SIZE,
- GLX.GLX_STENCIL_SIZE,
- GLX.GLX_ACCUM_RED_SIZE,
- GLX.GLX_ACCUM_GREEN_SIZE,
- GLX.GLX_ACCUM_BLUE_SIZE,
- GLX.GLX_ACCUM_ALPHA_SIZE,
- sbAttrib,
- samplesAttrib,
- floatNV
- };
-
- int[] ivalues = new int[iattribs.length];
- queryFBConfig(display, fbConfig, iattribs, iattribs.length, ivalues);
- setChosenGLCapabilities(X11GLDrawableFactory.attribList2GLCapabilities(iattribs, iattribs.length, ivalues, true));
-
- // Determine the actual width and height we were able to create.
- int[] tmp = new int[1];
- GLX.glXQueryDrawable(display, drawable, GLXExt.GLX_WIDTH, tmp, 0);
- width = tmp[0];
- GLX.glXQueryDrawable(display, drawable, GLXExt.GLX_HEIGHT, tmp, 0);
- height = tmp[0];
-
- if (DEBUG) {
- System.err.println("Created pbuffer " + width + " x " + height);
- }
- } finally {
- unlockToolkit();
- }
- }
-
- public int getFloatingPointMode() {
- // Floating-point pbuffers currently require NVidia hardware on X11
- return GLPbuffer.NV_FLOAT;
- }
-
- public GLXFBConfig getFBConfig() {
- return fbConfig;
- }
-
- private int queryFBConfig(long display, GLXFBConfig fbConfig, int attrib) {
- int[] tmp = new int[1];
- if (GLX.glXGetFBConfigAttrib(display, fbConfig, attrib, tmp, 0) != 0) {
- throw new GLException("glXGetFBConfigAttrib failed");
- }
- return tmp[0];
- }
-
- private void queryFBConfig(long display, GLXFBConfig fbConfig, int[] attribs, int nattribs, int[] values) {
- int[] tmp = new int[1];
- for (int i = 0; i < nattribs; i++) {
- if (GLX.glXGetFBConfigAttrib(display, fbConfig, attribs[i], tmp, 0) != 0) {
- throw new GLException("glXGetFBConfigAttrib failed");
- }
- values[i] = tmp[0];
- }
- }
-}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11SunJDKReflection.java b/src/classes/com/sun/opengl/impl/x11/X11SunJDKReflection.java
deleted file mode 100644
index 0760399ab..000000000
--- a/src/classes/com/sun/opengl/impl/x11/X11SunJDKReflection.java
+++ /dev/null
@@ -1,101 +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.sun.opengl.impl.x11;
-
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.lang.reflect.*;
-import java.security.*;
-
-/** This class encapsulates the reflection routines necessary to peek
- inside a few data structures in the AWT implementation on X11 for
- the purposes of correctly enumerating the available visuals. */
-
-public class X11SunJDKReflection {
- private static Class x11GraphicsDeviceClass;
- private static Method x11GraphicsDeviceGetScreenMethod;
- private static Class x11GraphicsConfigClass;
- private static Method x11GraphicsConfigGetVisualMethod;
- private static boolean initted;
-
- static {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- try {
- x11GraphicsDeviceClass = Class.forName("sun.awt.X11GraphicsDevice");
- x11GraphicsDeviceGetScreenMethod = x11GraphicsDeviceClass.getDeclaredMethod("getScreen", new Class[] {});
- x11GraphicsDeviceGetScreenMethod.setAccessible(true);
-
- x11GraphicsConfigClass = Class.forName("sun.awt.X11GraphicsConfig");
- x11GraphicsConfigGetVisualMethod = x11GraphicsConfigClass.getDeclaredMethod("getVisual", new Class[] {});
- x11GraphicsConfigGetVisualMethod.setAccessible(true);
- initted = true;
- } catch (Exception e) {
- // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5
- }
- return null;
- }
- });
- }
-
- public static int graphicsDeviceGetScreen(GraphicsDevice device) {
- if (!initted) {
- return 0;
- }
-
- try {
- return ((Integer) x11GraphicsDeviceGetScreenMethod.invoke(device, new Object[] {})).intValue();
- } catch (Exception e) {
- return 0;
- }
- }
-
- public static int graphicsConfigurationGetVisualID(GraphicsConfiguration config) {
- if (!initted) {
- return 0;
- }
-
- try {
- return ((Integer) x11GraphicsConfigGetVisualMethod.invoke(config, new Object[] {})).intValue();
- } catch (Exception e) {
- return 0;
- }
- }
-}