aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-06-11 07:05:29 +0000
committerSven Gothel <[email protected]>2009-06-11 07:05:29 +0000
commit0dec290ca2ff1245f16787bb3ccc62dab4bd9bfb (patch)
tree5dbeb595e2683333401a260ccbd92c550f70fffa /src
parent3c5704666a2f64f66de432ef21ac223cc81131e8 (diff)
- Fixing SPEC documentation for bindings JOGL and NativeWindow,
lot's of javadoc changes/fixes. - Fixing transparency values RGB[A] in GLX and EGL, adding those in GLCapabilities. - Adding EGLPbuffer (untested yet) Added EGLOnscreenContext, EGLOnscreenDrawable and EGLPbufferContext, EGLPbufferDrawable, which completes the now abstract EGLContext and EGLDrawable. - Decoupling EGLDrawableFactory and DynamicLookupHelper: Since OpenGL ES has 2 libraries and hence 2 DynamicLookupHelper, one for each, these are decoupled in EGLES1DynamicLookupHelper and EGLES2DynamicLookupHelper, where each uses the base class EGLDynamicLookupHelper. EGLDynamicLookupHelper act's also as the owner of these singleton instances. EGLDrawableFactory is now pure singleton, and has no more relation to the ES[12] libraries. Still, GLDrawableFactory.getFactory(GLProfile) stays, due to the selection of the right factory, ie EGLDrawableFactory or a native one (X11GLX, WindowsWGL or MacOSXCGL). Added GLDrawableImpl.getDynamicLookupHelper(). DynamicLookupHelper implementation is pushed down to the specialisation of GLDrawableImpl, hence removed GLDrawableImpl implements DynamicLookupHelper. - Fixing Locking - Always throw an Exception if unlock is called without being locked. - Removed NativeWindow.LOCK_NOT_SUPPORTED, since it made the locking state ambiguos. - Using a generated Exception at locking to mark the object locked, and to let it throw in case of double locking. - Removed redundant lockToolkit() calls, where lockSurface() calls are made - Fixing GLWindow wrapped toolkit (e.g. AWTWindow) usage - In case the passed NativeWindow only contains a wrapper window, we use the NativeWindowFactory.getNativeWindow() pipeline to produce a valid NativeWindow. This object is only referenced within the drawable, hence we have to use it for actual NativeWindow related operations. - Add setVisible(): lockSurface()/unlockSurface() to allow getting the windowHandle - Overwriting all drawable related Window method's, using the drawable's NativeWindow if exists. - getNativeWindow() - lockSurface()/unlockSurface()/.. - getWindowHandle()/getSurfaceHandle() - Fix NativeWindowFactory.getNativeWindowType(), so the custom and pure values are set once (static init) - not overwritten (prev. bug). - NEWT: Added WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY support in AWTWindow. Now the proper dispose() calls are made to all GLEventListeners if the AWT window is being closed - before it is actually destroyed. - Threading now uses the AWTThreadingPlugin, a ThreadingPlugin interface AWT implementation, containing the refactored Threading code. - Reintroduced getChosen*Capabilities and getRequested*Capabilites, where get*Capabilities is renamed back to getRequested*Capabilities. The semantics are necessary to allow the drawables (and NativeWindow) to be regenerated in case of a device change in a multihead environment. Otherwise there is a risk that recursive choosing of the Capabilities will degenerate the result. - Multihead logic .. Exception: Xinerama, where all monitors share the same static configuration, and the window handle 'survive' X11, MacOSX and Win32 with a Xinerama behavior 1) Recognition of a display/screen/surface change - It is prooven that the JAWT model (JAWT_LOCK_SURFACE_CHANGED) while locking the surface is not reliably propagated, ie doesn't work here, if the display change happens. - AWT's Canvas.getGraphicsConfiguration() can reliably being used to detect this case, ie compare the old GraphicsConfiguration with the new one. - A solution for other native windowing toolkits must be found, ie query the current underlying pixel-configuration, if it changed - act. In which case the the following shall be done: 2.0) - notify all GLEventListener via the dispose(GLAutoDrawable) 2.1) - destroy the OpenGL context 2.2) - call GLDrawable's setRealized(false) 2.3) - call GLDrawable's setRealized(true) 2.4) - create a new OpenGL context 2.5) - notify all GLEventListener via the init(GLAutoDrawable) Steps 2.0 - 2.5 are executed with GLAutoDrawable's dispose(true) call. Step 2.3, setRealized(true) on GLDrawable shall: 2.3.1) - Choose the GLCapabilities again, based on the requested ones, and update the choosen ones in the AbstractGraphicsConfiguration. 2.3.2) - Update AbstractScreen within the new AbstractGraphicsConfiguration to reflect the possible screen change. DONE: Xinerama mode: X11 + Xinerama, MacOSX DONE: Introducing GLAutoDrawable.dispose(boolean regenerate) DONE: 2.3.1 on setRealized(true): Windows, MacOSX (implicit on createContext) TODO: Windows setRealized(true) on AWT Canvas getGraphicsConfiguration(), can't lock the JAWT surface sometimes - exception, code disabled, see GLCanvas.java TODO: 2.3.1 on setRealized(true): X11 and EGL TODO: Find a test case, without Xinerama behavior TODO: Code for Newt/NativeWindow to detect (1) and propagate GLAutoDrawable's dispose(true). TESTS: - MacOSX (Xinerama) OK - X11 -TwinView (NV) OK -Xinerama (NV) OK - Win32 (Xinerama) OK - GLAutoDrawable's dispose(true) - git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1929 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java6
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java9
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableHelper.java26
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java24
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java23
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/ThreadingPlugin.java62
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/awt/AWTThreadingPlugin.java130
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java57
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java86
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java314
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java249
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLES1DynamicLookupHelper.java73
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLES2DynamicLookupHelper.java73
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java9
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java150
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java44
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenContext.java91
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java69
-rwxr-xr-xsrc/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferContext.java62
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java124
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java6
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java21
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java3
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java15
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java11
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java3
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java8
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java25
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLContext.java3
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java3
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java5
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java53
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java3
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java21
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java6
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java24
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java11
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java40
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java66
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java10
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXContext.java2
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXContext.java5
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java18
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java41
-rw-r--r--src/jogl/classes/javax/media/opengl/GLAutoDrawable.java35
-rw-r--r--src/jogl/classes/javax/media/opengl/GLCapabilities.java81
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawable.java16
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java79
-rw-r--r--src/jogl/classes/javax/media/opengl/GLEventListener.java18
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java83
-rwxr-xr-xsrc/jogl/classes/javax/media/opengl/Threading.java106
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java159
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java86
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/GraphicsConfigurationFactoryImpl.java2
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java15
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java22
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java28
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java5
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java6
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java1
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java2
-rw-r--r--src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java1
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java14
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/Capabilities.java133
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java9
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java43
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java10
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java49
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java164
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java54
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/package.html111
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java16
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java4
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Window.java34
-rw-r--r--src/newt/classes/com/sun/javafx/newt/WindowEvent.java2
-rw-r--r--src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java65
-rw-r--r--src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java98
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java4
-rwxr-xr-xsrc/newt/native/X11Window.c2
83 files changed, 2537 insertions, 1114 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
index c744aaf06..48a58b962 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -306,7 +306,7 @@ public abstract class GLContextImpl extends GLContext {
/** Helper routine which resets a ProcAddressTable generated by the
GLEmitter by looking up anew all of its function pointers. */
protected void resetProcAddressTable(Object table) {
- GLProcAddressHelper.resetProcAddressTable(table, getDrawableImpl().getFactoryImpl());
+ GLProcAddressHelper.resetProcAddressTable(table, getDrawableImpl().getDynamicLookupHelper() );
}
/** Indicates whether the underlying OpenGL context has been
@@ -385,14 +385,14 @@ public abstract class GLContextImpl extends GLContext {
} catch (Exception e) {}
}
// dynamic function lookup at last incl name aliasing (not cached)
- GLDrawableFactoryImpl factoryImpl = getDrawableImpl().getFactoryImpl();
+ DynamicLookupHelper dynLookup = getDrawableImpl().getDynamicLookupHelper();
String tmpBase = GLExtensionNames.normalizeVEN(GLExtensionNames.normalizeARB(glFunctionName, true), true);
long addr = 0;
int variants = GLExtensionNames.getFuncNamePermutationNumber(tmpBase);
for(int i = 0; 0==addr && i < variants; i++) {
String tmp = GLExtensionNames.getFuncNamePermutation(tmpBase, i);
try {
- addr = factoryImpl.dynamicLookupFunction(tmp);
+ addr = dynLookup.dynamicLookupFunction(tmp);
} catch (Exception e) { }
}
if(0!=addr) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index 16f0ab913..de911950a 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -51,7 +51,7 @@ import java.lang.reflect.*;
Independent Bitmaps on Windows, pixmaps on X11). Direct access to
these GLDrawables is not supplied directly to end users, though
they may be instantiated by the GLJPanel implementation. */
-public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements DynamicLookupHelper {
+public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
protected static final boolean DEBUG = Debug.debug("GLDrawableFactory");
/** Creates a (typically software-accelerated) offscreen GLDrawable
@@ -62,9 +62,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements
int width,
int height);
- /** DynamicLookupHelper: Dynamically looks up the given function. */
- public abstract long dynamicLookupFunction(String glFuncName);
-
protected GLDrawableFactoryImpl() {
super();
}
@@ -72,8 +69,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements
/**
* Returns the sole GLDrawableFactoryImpl instance.
*
- * @arg esProfile GLProfile to determine the EGL factory type,
- * maybe null in case of non ES profile, ie GL2 or GL3.
+ * @arg glProfile GLProfile to determine the factory type, ie EGLDrawableFactory,
+ * or one of the native GLDrawableFactory's, ie X11/GLX, Windows/WGL or MacOSX/CGL.
*/
public static GLDrawableFactoryImpl getFactoryImpl(GLProfile glp) {
return (GLDrawableFactoryImpl) getFactory(glp);
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableHelper.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableHelper.java
index e7fea1cee..3ede86196 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableHelper.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableHelper.java
@@ -124,6 +124,13 @@ public class GLDrawableHelper {
GLContext context,
Runnable runnable,
Runnable initAction) {
+ if(null==context) {
+ if (DEBUG) {
+ Exception e = new GLException(Thread.currentThread().getName()+" GLDrawableHelper " + this + ".invokeGL(): NULL GLContext");
+ e.printStackTrace();
+ }
+ return;
+ }
// Support for recursive makeCurrent() calls as well as calling
// other drawables' display() methods from within another one's
GLContext lastContext = GLContext.getCurrent();
@@ -145,14 +152,16 @@ public class GLDrawableHelper {
initAction.run();
}
}
- if (DEBUG && VERBOSE) {
- System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running runnable");
- }
- runnable.run();
- if (autoSwapBufferMode) {
- if (drawable != null) {
- drawable.swapBuffers();
- }
+ if(null!=runnable) {
+ if (DEBUG && VERBOSE) {
+ System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running runnable");
+ }
+ runnable.run();
+ if (autoSwapBufferMode) {
+ if (drawable != null) {
+ drawable.swapBuffers();
+ }
+ }
}
}
} finally {
@@ -170,4 +179,5 @@ public class GLDrawableHelper {
}
}
}
+
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
index 01be01dbd..c470d7d4d 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLDrawableImpl.java
@@ -41,6 +41,7 @@ package com.sun.opengl.impl;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
+import com.sun.gluegen.runtime.DynamicLookupHelper;
public abstract class GLDrawableImpl implements GLDrawable {
protected static final boolean DEBUG = Debug.debug("GLDrawable");
@@ -51,8 +52,14 @@ public abstract class GLDrawableImpl implements GLDrawable {
this.factory = factory;
this.component = comp;
this.realized = realized;
+ this.requestedCapabilities = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getRequestedCapabilities(); // a copy ..
}
+ /**
+ * Returns the DynamicLookupHelper
+ */
+ public abstract DynamicLookupHelper getDynamicLookupHelper();
+
public GLDrawableFactoryImpl getFactoryImpl() {
return (GLDrawableFactoryImpl) getFactory();
}
@@ -71,17 +78,15 @@ public abstract class GLDrawableImpl implements GLDrawable {
}
public GLProfile getGLProfile() {
- return getGLCapabilities().getGLProfile();
+ return requestedCapabilities.getGLProfile();
}
- public GLCapabilities getGLCapabilities() {
- GLCapabilities caps = (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getCapabilities();
- if (caps == null) {
- throw new GLException("No GLCapabilities: "+this);
- }
+ public GLCapabilities getChosenGLCapabilities() {
+ return (GLCapabilities)component.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); // a copy
+ }
- // Must return a new copy to avoid mutation by end user
- return (GLCapabilities)caps.clone();
+ public GLCapabilities getRequestedGLCapabilities() {
+ return requestedCapabilities;
}
public NativeWindow getNativeWindow() {
@@ -129,13 +134,14 @@ public abstract class GLDrawableImpl implements GLDrawable {
public String toString() {
return getClass().getName()+"[realized "+getRealized()+
- ", capabilities "+getGLCapabilities()+
+ ", capabilities "+getChosenGLCapabilities()+
", window "+getNativeWindow()+
", factory "+getFactory()+"]";
}
protected GLDrawableFactory factory;
protected NativeWindow component;
+ protected GLCapabilities requestedCapabilities;
// Indicates whether the component (if an onscreen context) has been
// realized. Plausibly, before the component is realized the JAWT
diff --git a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
index ff8043f7e..30109dcf6 100644
--- a/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
+++ b/src/jogl/classes/com/sun/opengl/impl/GLPbufferImpl.java
@@ -157,11 +157,18 @@ public class GLPbufferImpl implements GLPbuffer {
context.releasePbufferFromTexture();
}
- public GLCapabilities getGLCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
if (pbufferDrawable == null)
return null;
- return pbufferDrawable.getGLCapabilities();
+ return pbufferDrawable.getChosenGLCapabilities();
+ }
+
+ public GLCapabilities getRequestedGLCapabilities() {
+ if (pbufferDrawable == null)
+ return null;
+
+ return pbufferDrawable.getRequestedGLCapabilities();
}
public GLProfile getGLProfile() {
@@ -217,7 +224,13 @@ public class GLPbufferImpl implements GLPbuffer {
PropertyChangeListener listener) {}
*/
+ public void dispose(boolean regenerate) {
+ // Offscreen ..
+ // FIXME: action required ?
+ }
+
public void destroy() {
+ // FIXME: not calling event listeners ..
if (Threading.isSingleThreaded() &&
!Threading.isOpenGLThread()) {
Threading.invokeOnOpenGLThread(destroyAction);
@@ -291,11 +304,9 @@ public class GLPbufferImpl implements GLPbuffer {
class DestroyAction implements Runnable {
public void run() {
- GLContext current = GLContext.getCurrent();
- if (current == context) {
- context.release();
+ if (null != context) {
+ context.destroy();
}
- context.destroy();
pbufferDrawable.destroy();
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/ThreadingPlugin.java b/src/jogl/classes/com/sun/opengl/impl/ThreadingPlugin.java
new file mode 100644
index 000000000..5c52f871e
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/impl/ThreadingPlugin.java
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import javax.media.opengl.*;
+
+public interface ThreadingPlugin {
+ /** Indicates whether the current thread is the single thread on
+ which this implementation of the javax.media.opengl APIs
+ performs all of its OpenGL-related work. This method should only
+ be called if the single-thread model is in effect. */
+ public boolean isOpenGLThread() throws GLException;
+
+ /** Executes the passed Runnable on the single thread used for all
+ OpenGL work in this javax.media.opengl API implementation. It is
+ not specified exactly which thread is used for this
+ purpose. This method should only be called if the single-thread
+ model is in use and if the current thread is not the OpenGL
+ thread (i.e., if <code>isOpenGLThread()</code> returns
+ false). It is up to the end user to check to see whether the
+ current thread is the OpenGL thread and either execute the
+ Runnable directly or perform the work inside it. */
+ public void invokeOnOpenGLThread(Runnable r) throws GLException;
+}
+
diff --git a/src/jogl/classes/com/sun/opengl/impl/awt/AWTThreadingPlugin.java b/src/jogl/classes/com/sun/opengl/impl/awt/AWTThreadingPlugin.java
new file mode 100755
index 000000000..e94911ac2
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/impl/awt/AWTThreadingPlugin.java
@@ -0,0 +1,130 @@
+/*
+ * 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.awt;
+
+import javax.media.opengl.*;
+
+import java.awt.event.*;
+
+import java.awt.EventQueue;
+import java.lang.reflect.InvocationTargetException;
+
+import com.sun.opengl.impl.*;
+
+public class AWTThreadingPlugin implements ThreadingPlugin {
+
+ public AWTThreadingPlugin() {}
+
+ public boolean isOpenGLThread() throws GLException {
+ switch (Threading.getMode()) {
+ case Threading.AWT:
+ if (Java2D.isOGLPipelineActive()) {
+ // FIXME: ideally only the QFT would be considered to be the
+ // "OpenGL thread", but we can not currently run all of
+ // JOGL's OpenGL work on that thread. See the FIXME in
+ // invokeOnOpenGLThread.
+ return (Java2D.isQueueFlusherThread() ||
+ (Threading.isX11() && EventQueue.isDispatchThread()));
+ } else {
+ return EventQueue.isDispatchThread();
+ }
+ case Threading.WORKER:
+ if (Java2D.isOGLPipelineActive()) {
+ // FIXME: ideally only the QFT would be considered to be the
+ // "OpenGL thread", but we can not currently run all of
+ // JOGL's OpenGL work on that thread. See the FIXME in
+ // invokeOnOpenGLThread.
+ return (Java2D.isQueueFlusherThread() ||
+ (Threading.isX11() && GLWorkerThread.isWorkerThread()));
+ } else {
+ return GLWorkerThread.isWorkerThread();
+ }
+ default:
+ throw new InternalError("Illegal single-threading mode " + Threading.getMode());
+ }
+ }
+
+ public void invokeOnOpenGLThread(Runnable r) throws GLException {
+ switch (Threading.getMode()) {
+ case Threading.AWT:
+ // FIXME: ideally should run all OpenGL work on the Java2D QFT
+ // thread when it's enabled, but unfortunately there are
+ // deadlock issues on X11 platforms when making our
+ // heavyweight OpenGL contexts current on the QFT because we
+ // perform the JAWT lock inside the makeCurrent()
+ // implementation, which attempts to grab the AWT lock on the
+ // QFT which is not allowed. For now, on X11 platforms,
+ // continue to perform this work on the EDT.
+ if (Java2D.isOGLPipelineActive() && !Threading.isX11()) {
+ Java2D.invokeWithOGLContextCurrent(null, r);
+ } else {
+ try {
+ EventQueue.invokeAndWait(r);
+ } catch (InvocationTargetException e) {
+ throw new GLException(e.getTargetException());
+ } catch (InterruptedException e) {
+ throw new GLException(e);
+ }
+ }
+ r.run();
+ break;
+
+ case Threading.WORKER:
+ if (!GLWorkerThread.isStarted()) {
+ synchronized (GLWorkerThread.class) {
+ if (!GLWorkerThread.isStarted()) {
+ GLWorkerThread.start();
+ }
+ }
+ }
+ try {
+ GLWorkerThread.invokeAndWait(r);
+ } catch (InvocationTargetException e) {
+ throw new GLException(e.getTargetException());
+ } catch (InterruptedException e) {
+ throw new GLException(e);
+ }
+ break;
+
+ default:
+ throw new InternalError("Illegal single-threading mode " + Threading.getMode());
+ }
+ }
+}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
index 9643a7945..6125b4831 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLContext.java
@@ -42,8 +42,8 @@ import com.sun.gluegen.runtime.ProcAddressTable;
import java.nio.*;
import java.util.*;
-public class EGLContext extends GLContextImpl {
- private EGLDrawable drawable;
+public abstract class EGLContext extends GLContextImpl {
+ protected EGLDrawable drawable;
private long eglContext;
private boolean eglQueryStringInitialized;
private boolean eglQueryStringAvailable;
@@ -92,7 +92,11 @@ public class EGLContext extends GLContextImpl {
return eglContext;
}
- private int makeCurrentImplInner() throws GLException {
+ protected int makeCurrentImpl() throws GLException {
+ if(EGL.EGL_NO_DISPLAY==drawable.getDisplay() ) {
+ System.err.println("drawable not properly initialized");
+ return CONTEXT_NOT_CURRENT;
+ }
boolean created = false;
if (eglContext == 0) {
create();
@@ -119,37 +123,7 @@ public class EGLContext extends GLContextImpl {
return CONTEXT_CURRENT;
}
- protected int makeCurrentImpl() throws GLException {
- if(EGL.EGL_NO_DISPLAY==drawable.getDisplay() ) {
- System.err.println("drawable not properly initialized");
- return CONTEXT_NOT_CURRENT;
- }
-
- int lockRes = NativeWindow.LOCK_SUCCESS;
- // FIXME: freezes AWT: int lockRes = drawable.lockSurface();
- boolean exceptionOccurred = false;
- try {
- if (lockRes == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return CONTEXT_NOT_CURRENT;
- }
- if (lockRes == NativeWindow.LOCK_SURFACE_CHANGED) {
- destroyImpl();
- }
- return makeCurrentImplInner();
- } catch (RuntimeException e) {
- exceptionOccurred = true;
- throw e;
- } finally {
- if (exceptionOccurred ||
- (isOptimizable() && lockRes != NativeWindow.LOCK_SURFACE_NOT_READY)) {
- drawable.unlockSurface();
- }
- }
- }
-
protected void releaseImpl() throws GLException {
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
if (!EGL.eglMakeCurrent(drawable.getDisplay(),
EGL.EGL_NO_SURFACE,
EGL.EGL_NO_SURFACE,
@@ -157,10 +131,6 @@ public class EGLContext extends GLContextImpl {
throw new GLException("Error freeing OpenGL context 0x" +
Long.toHexString(eglContext) + ": error code " + EGL.eglGetError());
}
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
- drawable.unlockSurface();
- }
}
protected void destroyImpl() throws GLException {
@@ -258,7 +228,7 @@ public class EGLContext extends GLContextImpl {
public synchronized String getPlatformExtensionsString() {
if (!eglQueryStringInitialized) {
eglQueryStringAvailable =
- getDrawableImpl().getFactoryImpl().dynamicLookupFunction("eglQueryString") != 0;
+ getDrawableImpl().getDynamicLookupHelper().dynamicLookupFunction("eglQueryString") != 0;
eglQueryStringInitialized = true;
}
if (eglQueryStringAvailable) {
@@ -279,6 +249,10 @@ public class EGLContext extends GLContextImpl {
}
}
+ public abstract void bindPbufferToTexture();
+
+ public abstract void releasePbufferFromTexture();
+
//----------------------------------------------------------------------
// Currently unimplemented stuff
//
@@ -287,13 +261,6 @@ public class EGLContext extends GLContextImpl {
throw new GLException("Not yet implemented");
}
- public void bindPbufferToTexture() {
- throw new GLException("Should not call this");
- }
-
- public void releasePbufferFromTexture() {
- throw new GLException("Should not call this");
- }
public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
throw new GLException("Should not call this");
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
index b54e52fac..a07030eb1 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawable.java
@@ -37,19 +37,20 @@ package com.sun.opengl.impl.egl;
import com.sun.opengl.impl.GLDrawableImpl;
import com.sun.nativewindow.impl.NWReflection;
+import com.sun.gluegen.runtime.DynamicLookupHelper;
import javax.media.nativewindow.*;
import javax.media.nativewindow.egl.*;
import javax.media.opengl.*;
-public class EGLDrawable extends GLDrawableImpl {
+public abstract class EGLDrawable extends GLDrawableImpl {
+ protected boolean ownEGLDisplay = false;
private long eglDisplay;
private EGLGraphicsConfiguration eglConfig;
- private boolean ownEGLDisplay = false;
- private long eglSurface = 0;
+ private long eglSurface;
private int[] tmp = new int[1];
- public EGLDrawable(EGLDrawableFactory factory,
+ protected EGLDrawable(EGLDrawableFactory factory,
NativeWindow component) throws GLException {
super(factory, component, false);
eglSurface=EGL.EGL_NO_SURFACE;
@@ -68,21 +69,54 @@ public class EGLDrawable extends GLDrawableImpl {
return eglConfig;
}
- public GLProfile getGLProfile() {
- return (null==eglConfig)?super.getGLProfile():((GLCapabilities)eglConfig.getCapabilities()).getGLProfile();
+ public GLCapabilities getChosenGLCapabilities() {
+ return (null==eglConfig)?super.getChosenGLCapabilities():(GLCapabilities)eglConfig.getChosenCapabilities();
}
- public GLCapabilities getGLCapabilities() {
- return (null==eglConfig)?super.getGLCapabilities():(GLCapabilities)eglConfig.getCapabilities();
+ public abstract GLContext createContext(GLContext shareWith);
+
+ protected abstract long createSurface(long eglDpy, _EGLConfig eglNativeCfg);
+
+ private void recreateSurface() {
+ if(EGL.EGL_NO_SURFACE!=eglSurface) {
+ EGL.eglDestroySurface(eglDisplay, eglSurface);
+ }
+ eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig());
}
- public GLContext createContext(GLContext shareWith) {
- return new EGLContext(this, shareWith);
+ public int lockSurface() throws GLException {
+ int ret = super.lockSurface();
+ if(NativeWindow.LOCK_SURFACE_NOT_READY == ret) {
+ if (DEBUG) {
+ System.err.println("EGLDrawable.lockSurface: surface not ready");
+ }
+ return ret;
+ }
+ if (NativeWindow.LOCK_SURFACE_CHANGED == ret) {
+ AbstractGraphicsConfiguration aConfig = component.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ // ensure this is a EGLGraphicsConfiguration, ie setRealized(true) already validated the EGL config and eglSurface.
+ if(EGL.EGL_NO_SURFACE!=eglSurface && aConfig instanceof EGLGraphicsConfiguration) {
+ if(DEBUG) {
+ System.err.println("NativeWindow.LOCK_SURFACE_CHANGED: "+component);
+ }
+ ((EGLGraphicsConfiguration)aConfig).updateGraphicsConfiguration();
+ recreateSurface();
+ } else {
+ ret = NativeWindow.LOCK_SUCCESS; // overwrite result, no surface change action required yet
+ }
+ }
+ return ret;
}
+
public void setRealized(boolean realized) {
+ super.setRealized(realized);
+
if (realized) {
- lockSurface();
+ if ( NativeWindow.LOCK_SURFACE_NOT_READY == lockSurface() ) {
+ throw new GLException("Couldn't lock surface");
+ }
+ // lockSurface() also resolved the window/surface handles
try {
AbstractGraphicsConfiguration aConfig = component.getGraphicsConfiguration().getNativeGraphicsConfiguration();
AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice();
@@ -127,7 +161,7 @@ public class EGLDrawable extends GLDrawableImpl {
}
EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay);
DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
- GLCapabilities caps = (GLCapabilities) aConfig.getCapabilities();
+ GLCapabilities caps = (GLCapabilities) aConfig.getChosenCapabilities(); // yes, use the already choosen Capabilities (x11,win32,..)
eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(e).chooseGraphicsConfiguration(caps, null, s);
if (null == eglConfig) {
throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
@@ -135,16 +169,9 @@ public class EGLDrawable extends GLDrawableImpl {
System.err.println("Chosen eglConfig: "+eglConfig);
}
}
-
+ eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig());
if(DEBUG) {
- System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getWindowHandle())+", "+component);
- }
- // Create the window surface
- eglSurface = EGL.eglCreateWindowSurface(eglDisplay, eglConfig.getNativeConfig(), component.getWindowHandle(), null);
- if (EGL.EGL_NO_SURFACE==eglSurface) {
- throw new GLException("Creation of window surface (eglCreateWindowSurface) failed, component: "+component+", error 0x"+Integer.toHexString(EGL.eglGetError()));
- } else if(DEBUG) {
- System.err.println("setSurface result: eglSurface 0x"+Long.toHexString(eglSurface));
+ System.err.println("setSurface using component: handle 0x"+Long.toHexString(component.getWindowHandle())+" -> 0x"+Long.toHexString(eglSurface));
}
} finally {
unlockSurface();
@@ -161,11 +188,6 @@ public class EGLDrawable extends GLDrawableImpl {
eglDisplay=EGL.EGL_NO_DISPLAY;
eglConfig=null;
}
- super.setRealized(realized);
- }
-
- public void setSize(int width, int height) {
- // FIXME: anything to do here?
}
public int getWidth() {
@@ -183,22 +205,28 @@ public class EGLDrawable extends GLDrawableImpl {
}
public void swapBuffers() throws GLException {
- getFactoryImpl().lockToolkit();
+ boolean didLock = false;
try {
if (component.getSurfaceHandle() == 0) {
if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
return;
}
+ didLock = true;
}
EGL.eglSwapBuffers(eglDisplay, eglSurface);
} finally {
- unlockSurface();
- getFactoryImpl().unlockToolkit();
+ if(didLock) {
+ unlockSurface();
+ }
}
}
+ public DynamicLookupHelper getDynamicLookupHelper() {
+ return EGLDynamicLookupHelper.getDynamicLookupHelper(getGLProfile());
+ }
+
public String toString() {
return "EGLDrawable[ realized "+getRealized()+
", window "+getNativeWindow()+
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
index 79c2a83b6..396580c1d 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDrawableFactory.java
@@ -57,96 +57,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
- // We need more than one of these on certain devices (the NVidia APX 2500 in particular)
- private List/*<NativeLibrary>*/ glesLibraries = new ArrayList();
-
- public EGLDrawableFactory(String esProfile) {
+ public EGLDrawableFactory() {
super();
-
- loadGLESLibrary(esProfile);
- EGL.resetProcAddressTable(this);
- }
-
- private NativeLibrary loadFirstAvailable(List/*<String>*/ libNames, ClassLoader loader) {
- for (Iterator iter = libNames.iterator(); iter.hasNext(); ) {
- NativeLibrary lib = NativeLibrary.open((String) iter.next(), loader, false /*global*/);
- if (lib != null) {
- return lib;
- }
- }
- return null;
- }
-
- private void loadGLESLibrary(String esProfile) {
- List/*<NativeLibrary>*/ libs = new ArrayList();
-
- // Try several variants
- List/*<String>*/ glesLibNames = new ArrayList();
- List/*<String>*/ eglLibNames = new ArrayList();
-
- // ES
- if(GLProfile.UsesNativeGLES2(esProfile)) {
- glesLibNames.add("GLES20");
- glesLibNames.add("GLESv2");
- glesLibNames.add("GLESv2_CM");
- // for windows distributions using the 'unlike' lib prefix
- // where our tool does not add it.
- glesLibNames.add("libGLES20");
- glesLibNames.add("libGLESv2");
- glesLibNames.add("libGLESv2_CM");
- } else if(GLProfile.UsesNativeGLES1(esProfile)) {
- glesLibNames.add("GLES_CM");
- glesLibNames.add("GLES_CL");
- glesLibNames.add("GLESv1_CM");
- // for windows distributions using the 'unlike' lib prefix,
- // where our tool does not add it.
- glesLibNames.add("libGLES_CM");
- glesLibNames.add("libGLES_CL");
- glesLibNames.add("libGLESv1_CM");
- } else {
- throw new GLException("Invalid GL Profile for EGL: "+esProfile);
- }
-
- // EGL
- eglLibNames.add("EGL");
- // for windows distributions using the 'unlike' lib prefix,
- // where our tool does not add it.
- eglLibNames.add("libEGL");
-
- ClassLoader loader = getClass().getClassLoader();
- NativeLibrary lib = null;
-
- // ES libraries ..
- lib = loadFirstAvailable(glesLibNames, loader);
- if (lib == null) {
- throw new GLException("Unable to dynamically load OpenGL ES library for profile \"" + esProfile + "\"");
- }
- glesLibraries.add(lib);
-
- // ES libraries ..
- lib = loadFirstAvailable(glesLibNames, loader);
- if (lib == null) {
- throw new GLException("Unable to dynamically load OpenGL ES library for profile \"" + esProfile + "\"");
- }
- glesLibraries.add(lib);
-
- // EGL libraries ..
- lib = loadFirstAvailable(eglLibNames, loader);
- if (lib == null) {
- throw new GLException("Unable to dynamically load EGL library for profile \"" + esProfile + "\"");
- }
- glesLibraries.add(lib);
-
- if (GLProfile.UsesNativeGLES2(esProfile)) {
- NativeLibLoader.loadES2();
- } else if (GLProfile.UsesNativeGLES1(esProfile)) {
- NativeLibLoader.loadES1();
- }
}
public GLDrawable createGLDrawable(NativeWindow target) {
target = NativeWindowFactory.getNativeWindow(target, null);
- return new EGLDrawable(this, target);
+ return new EGLOnscreenDrawable(this, target);
}
public GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
@@ -157,15 +74,20 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
public boolean canCreateGLPbuffer() {
- // Not supported on OpenGL ES
- return false;
+ return true;
}
public GLPbuffer createGLPbuffer(final GLCapabilities capabilities,
final GLCapabilitiesChooser chooser,
final int initialWidth,
final int initialHeight,
final GLContext shareWith) {
- throw new GLException("Pbuffer support not available on OpenGL ES");
+ if (!canCreateGLPbuffer()) {
+ throw new GLException("Pbuffer support not available with this EGL implementation");
+ }
+ EGLPbufferDrawable pbufferDrawable = new EGLPbufferDrawable(this, capabilities, chooser,
+ initialWidth,
+ initialHeight);
+ return new GLPbufferImpl(pbufferDrawable, shareWith);
}
public GLContext createExternalGLContext() {
@@ -184,226 +106,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
public void loadGLULibrary() {
}
- private long dynamicLookupFunctionOnLibs(String glFuncName) {
- String funcName=glFuncName;
- long addr = dynamicLookupFunctionOnLibsImpl(funcName);
- if( 0==addr && NativeWindowFactory.getNativeWindowType(false)==NativeWindowFactory.TYPE_WINDOWS ) {
- // Hack: try some C++ decoration here for Imageon's emulation libraries ..
- final int argAlignment=4; // 4 byte alignment of each argument
- final int maxArguments=12; // experience ..
- for(int arg=0; 0==addr && arg<=maxArguments; arg++) {
- funcName = "_"+glFuncName+"@"+(arg*argAlignment);
- addr = dynamicLookupFunctionOnLibsImpl(funcName);
- }
- }
- if(DEBUG) {
- if(0!=addr) {
- System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" 0x"+Long.toHexString(addr));
- } else {
- System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" ** FAILED ** ");
- }
- }
- return addr;
- }
-
- private long dynamicLookupFunctionOnLibsImpl(String glFuncName) {
- // Look up this function name in all known libraries
- for (Iterator iter = glesLibraries.iterator(); iter.hasNext(); ) {
- NativeLibrary lib = (NativeLibrary) iter.next();
- long addr = lib.lookupFunction(glFuncName);
- if (addr != 0) {
- return addr;
- }
- }
- return 0;
- }
-
- private long eglGetProcAddressHandle = 0;
-
- public long dynamicLookupFunction(String glFuncName) {
- if(null==glFuncName) {
- return 0;
- }
-
- // bootstrap eglGetProcAddress
- if(0==eglGetProcAddressHandle) {
- eglGetProcAddressHandle = dynamicLookupFunctionOnLibs("eglGetProcAddress");
- if(0==eglGetProcAddressHandle) {
- GLException e = new GLException("Couldn't find eglGetProcAddress function entry");
- if(DEBUG) {
- e.printStackTrace();
- }
- throw e;
- }
- }
-
- if(glFuncName.equals("eglGetProcAddress")) {
- return eglGetProcAddressHandle;
- }
-
- long addr = EGL.eglGetProcAddress(eglGetProcAddressHandle, glFuncName);
- if(DEBUG) {
- if(0!=addr) {
- System.err.println("Lookup-EGL: <"+glFuncName+"> 0x"+Long.toHexString(addr));
- }
- }
- if(0==addr) {
- addr = dynamicLookupFunctionOnLibs(glFuncName);
- }
- return addr;
- }
-
public boolean canCreateContextOnJava2DSurface() {
return false;
}
- /*
-
- // FIXME: this is the OpenGL ES 2 initialization order
-
- // Initialize everything
- public void initialize() throws GLException {
- System.out.println("EGLDrawableFactory.initEGL()");
- if (!initEGL()) {
- throw new GLException("EGL init failed");
- }
- System.out.println("EGLDrawableFactory.chooseConfig()");
- if (!chooseConfig()) {
- throw new GLException("EGL choose config failed");
- }
- System.out.println("EGLDrawableFactory.checkDisplay()");
- if (!checkDisplay()) {
- throw new GLException("EGL check display failed");
- }
- System.out.println("EGLDrawableFactory.checkConfig()");
- if (!checkConfig()) {
- throw new GLException("EGL check config failed");
- }
- System.out.println("EGLDrawableFactory.createWindow()");
- if (!createWindow()) {
- throw new GLException("KD window init failed");
- }
- System.out.println("EGLDrawableFactory.setWindowVisible()");
- setWindowVisible();
- System.out.println("EGLDrawableFactory.setWindowFullscreen()");
- setWindowFullscreen();
- System.out.println("EGLDrawableFactory.realizeWindow()");
- if (!realizeWindow()) {
- throw new GLException("EGL/GLES window realize failed");
- }
- System.out.println("EGLDrawableFactory.createSurface()");
- if (!createSurface()) {
- throw new GLException("EGL create window surface failed");
- }
- System.out.println("EGLDrawableFactory.createContext()");
- if (!createContext()) {
- throw new GLException("EGL create context failed");
- }
- System.out.println("EGLDrawableFactory.makeCurrent()");
- if (!makeCurrent()) {
- throw new GLException("EGL make current failed");
- }
- System.out.println("EGLDrawableFactory.updateWindowSize()");
- updateWindowSize();
- }
-
- */
-
- /*
-
- // FIXME: this is the OpenGL ES 1 initialization order
-
- // Initialize everything
- public void initialize() throws GLException {
- System.out.println("EGLDrawableFactory.initEGL()");
- if (!initEGL()) {
- throw new GLException("EGL init failed");
- }
- System.out.println("EGLDrawableFactory.chooseConfig()");
- if (!chooseConfig()) {
- throw new GLException("EGL choose config failed");
- }
- System.out.println("EGLDrawableFactory.checkDisplay()");
- if (!checkDisplay()) {
- throw new GLException("EGL check display failed");
- }
- System.out.println("EGLDrawableFactory.checkConfig()");
- if (!checkConfig()) {
- throw new GLException("EGL check config failed");
- }
- System.out.println("EGLDrawableFactory.createContext()");
- if (!createContext()) {
- throw new GLException("EGL create context failed");
- }
- //
- // OpenKODE Core window system initialisation.
- //
- System.out.println("EGLDrawableFactory.createWindow()");
- if (!createWindow()) {
- throw new GLException("KD window init failed");
- }
- // System.out.println("EGLDrawableFactory.setWindowVisible()");
- // setWindowVisible();
- System.out.println("EGLDrawableFactory.setWindowFullscreen()");
- setWindowFullscreen();
- System.out.println("EGLDrawableFactory.realizeWindow()");
- if (!realizeWindow()) {
- throw new GLException("EGL/GLES window realize failed");
- }
- System.out.println("EGLDrawableFactory.createSurface()");
- if (!createSurface()) {
- throw new GLException("EGL create window surface failed");
- }
- System.out.println("EGLDrawableFactory.makeCurrent()");
- if (!makeCurrent()) {
- throw new GLException("EGL make current failed");
- }
- System.out.println("EGLDrawableFactory.updateWindowSize()");
- updateWindowSize();
- }
-
- */
-
- /*
-
- // Process incoming events -- must be called every frame
- public void processEvents() {
- if (shouldExit()) {
- shutdown();
- }
- }
-
- public void swapBuffers() {
- swapBuffers0();
- }
-
- private native boolean initEGL();
- private native boolean chooseConfig();
- private native boolean checkDisplay();
- private native boolean checkConfig();
- private native boolean createWindow();
- private native void setWindowVisible();
- private native void setWindowFullscreen();
- private native boolean realizeWindow();
- private native boolean createSurface();
- private native boolean createContext();
- private native boolean makeCurrent();
- private native void updateWindowSize();
- private native void swapBuffers0();
-
- // Runs the native message loop one step and checks to see if we should exit
- private native boolean shouldExit();
- public native void shutdown();
-
- public void testGetDirectBufferAddress() {
- java.nio.FloatBuffer buf = com.sun.opengl.impl.InternalBufferUtil.newFloatBuffer(12);
- int addr = getDirectBufferAddress(buf);
- System.out.println("Direct FloatBuffer's address: 0x" + Integer.toHexString(addr));
- }
- public native int getDirectBufferAddress(java.nio.Buffer buf);
-
- */
-
public GLContext createContextOnJava2DSurface(Object graphics, GLContext shareWith)
throws GLException {
throw new GLException("Unimplemented on this platform");
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java
new file mode 100755
index 000000000..97080b5f7
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.egl;
+
+import java.util.*;
+import javax.media.nativewindow.*;
+import javax.media.opengl.*;
+import com.sun.opengl.impl.*;
+import com.sun.nativewindow.impl.*;
+import com.sun.gluegen.runtime.NativeLibrary;
+import com.sun.gluegen.runtime.DynamicLookupHelper;
+
+/**
+ * Abstract implementation of the DynamicLookupHelper for EGL,
+ * which decouples it's dependencies to EGLDrawableFactory.
+ *
+ * Currently two implementations exist, one for ES1 and one for ES2.
+ */
+public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper {
+ protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("EGL");
+
+ private static final EGLDynamicLookupHelper eglES1DynamicLookupHelper;
+ private static final EGLDynamicLookupHelper eglES2DynamicLookupHelper;
+ private List/*<NativeLibrary>*/ glesLibraries;
+
+ static {
+ EGLDynamicLookupHelper tmp=null;
+ try {
+ tmp = new EGLES1DynamicLookupHelper();
+ } catch (Throwable t) {
+ if(DEBUG) {
+ t.printStackTrace();
+ }
+ }
+ eglES1DynamicLookupHelper = tmp;
+
+ tmp=null;
+ try {
+ tmp = new EGLES2DynamicLookupHelper();
+ } catch (Throwable t) {
+ if(DEBUG) {
+ t.printStackTrace();
+ }
+ }
+ eglES2DynamicLookupHelper = tmp;
+ }
+
+ public static EGLDynamicLookupHelper getDynamicLookupHelper(GLProfile glp) {
+ if (glp.usesNativeGLES2()) {
+ if(null==eglES2DynamicLookupHelper) {
+ throw new GLException("EGLDynamicLookupHelper for ES2 not available");
+ }
+ return eglES2DynamicLookupHelper;
+ } else if (glp.usesNativeGLES1()) {
+ if(null==eglES1DynamicLookupHelper) {
+ throw new GLException("EGLDynamicLookupHelper for ES1 not available");
+ }
+ return eglES1DynamicLookupHelper;
+ } else {
+ throw new GLException("Unsupported: "+glp);
+ }
+ }
+
+ public static EGLDynamicLookupHelper getDynamicLookupHelper(int esProfile) {
+ if (2==esProfile) {
+ if(null==eglES2DynamicLookupHelper) {
+ throw new GLException("EGLDynamicLookupHelper for ES2 not available");
+ }
+ return eglES2DynamicLookupHelper;
+ } else if (1==esProfile) {
+ if(null==eglES1DynamicLookupHelper) {
+ throw new GLException("EGLDynamicLookupHelper for ES1 not available");
+ }
+ return eglES1DynamicLookupHelper;
+ } else {
+ throw new GLException("Unsupported: ES"+esProfile);
+ }
+ }
+
+ protected EGLDynamicLookupHelper() {
+ loadGLESLibrary(getESProfile());
+ EGL.resetProcAddressTable(this);
+ }
+
+ /** Must return the proper ES profile number, 1 for ES1 and 2 for ES2 */
+ protected abstract int getESProfile();
+
+ /** Must return at least one OpenGL ES library name */
+ protected abstract List/*<String>*/ getGLESLibNames();
+
+ /** May return OpenGL ES library name(s) */
+ protected List/*<String>*/ getEGLLibNames() {
+ List/*<String>*/ eglLibNames = new ArrayList();
+
+ // EGL
+ eglLibNames.add("EGL");
+ // for windows distributions using the 'unlike' lib prefix,
+ // where our tool does not add it.
+ eglLibNames.add("libEGL");
+
+ return eglLibNames;
+ }
+
+ private NativeLibrary loadFirstAvailable(List/*<String>*/ libNames, ClassLoader loader) {
+ for (Iterator iter = libNames.iterator(); iter.hasNext(); ) {
+ NativeLibrary lib = NativeLibrary.open((String) iter.next(), loader, false /*global*/);
+ if (lib != null) {
+ return lib;
+ }
+ }
+ return null;
+ }
+
+ private void loadGLESLibrary(int esProfile) {
+ List/*<String>*/ glesLibNames = getGLESLibNames();
+ List/*<String>*/ eglLibNames = getEGLLibNames();
+
+ ClassLoader loader = getClass().getClassLoader();
+ NativeLibrary lib = null;
+
+ glesLibraries = new ArrayList();
+
+ // ES libraries ..
+ lib = loadFirstAvailable(glesLibNames, loader);
+ if (lib == null) {
+ throw new GLException("Unable to dynamically load OpenGL ES library for profile ES" + esProfile);
+ }
+ glesLibraries.add(lib);
+
+ if(null!=eglLibNames && eglLibNames.size()>0) {
+ // EGL libraries ..
+ lib = loadFirstAvailable(eglLibNames, loader);
+ if (lib == null) {
+ throw new GLException("Unable to dynamically load EGL library for profile ES" + esProfile);
+ }
+ glesLibraries.add(lib);
+ }
+
+ if (esProfile==2) {
+ NativeLibLoader.loadES2();
+ } else if (esProfile==1) {
+ NativeLibLoader.loadES1();
+ } else {
+ throw new GLException("Unsupported: ES"+esProfile);
+ }
+ }
+
+ private long dynamicLookupFunctionOnLibs(String glFuncName) {
+ String funcName=glFuncName;
+ long addr = dynamicLookupFunctionOnLibsImpl(funcName);
+ if( 0==addr && NativeWindowFactory.getNativeWindowType(false)==NativeWindowFactory.TYPE_WINDOWS ) {
+ // Hack: try some C++ decoration here for Imageon's emulation libraries ..
+ final int argAlignment=4; // 4 byte alignment of each argument
+ final int maxArguments=12; // experience ..
+ for(int arg=0; 0==addr && arg<=maxArguments; arg++) {
+ funcName = "_"+glFuncName+"@"+(arg*argAlignment);
+ addr = dynamicLookupFunctionOnLibsImpl(funcName);
+ }
+ }
+ if(DEBUG) {
+ if(0!=addr) {
+ System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" 0x"+Long.toHexString(addr));
+ } else {
+ System.err.println("Lookup-Native: "+glFuncName+" / "+funcName+" ** FAILED ** ");
+ }
+ }
+ return addr;
+ }
+
+ private long dynamicLookupFunctionOnLibsImpl(String glFuncName) {
+ // Look up this function name in all known libraries
+ for (Iterator iter = glesLibraries.iterator(); iter.hasNext(); ) {
+ NativeLibrary lib = (NativeLibrary) iter.next();
+ long addr = lib.lookupFunction(glFuncName);
+ if (addr != 0) {
+ return addr;
+ }
+ }
+ return 0;
+ }
+
+ private long eglGetProcAddressHandle = 0;
+
+ public long dynamicLookupFunction(String glFuncName) {
+ if(null==glFuncName) {
+ return 0;
+ }
+
+ // bootstrap eglGetProcAddress
+ if(0==eglGetProcAddressHandle) {
+ eglGetProcAddressHandle = dynamicLookupFunctionOnLibs("eglGetProcAddress");
+ if(0==eglGetProcAddressHandle) {
+ GLException e = new GLException("Couldn't find eglGetProcAddress function entry");
+ if(DEBUG) {
+ e.printStackTrace();
+ }
+ throw e;
+ }
+ }
+
+ if(glFuncName.equals("eglGetProcAddress")) {
+ return eglGetProcAddressHandle;
+ }
+
+ long addr = EGL.eglGetProcAddress(eglGetProcAddressHandle, glFuncName);
+ if(DEBUG) {
+ if(0!=addr) {
+ System.err.println("Lookup-EGL: <"+glFuncName+"> 0x"+Long.toHexString(addr));
+ }
+ }
+ if(0==addr) {
+ addr = dynamicLookupFunctionOnLibs(glFuncName);
+ }
+ return addr;
+ }
+}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLES1DynamicLookupHelper.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLES1DynamicLookupHelper.java
new file mode 100755
index 000000000..7e60e25c0
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLES1DynamicLookupHelper.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.egl;
+
+import java.util.*;
+import javax.media.nativewindow.*;
+import javax.media.opengl.*;
+import com.sun.opengl.impl.*;
+import com.sun.nativewindow.impl.*;
+import com.sun.gluegen.runtime.NativeLibrary;
+
+/**
+ * Implementation of the EGLDynamicLookupHelper for ES1.
+ */
+public class EGLES1DynamicLookupHelper extends EGLDynamicLookupHelper {
+
+ protected EGLES1DynamicLookupHelper() {
+ super();
+ }
+
+ protected int getESProfile() {
+ return 1;
+ }
+
+ protected List/*<String>*/ getGLESLibNames() {
+ List/*<String>*/ glesLibNames = new ArrayList();
+
+ glesLibNames.add("GLES_CM");
+ glesLibNames.add("GLES_CL");
+ glesLibNames.add("GLESv1_CM");
+ // for windows distributions using the 'unlike' lib prefix,
+ // where our tool does not add it.
+ glesLibNames.add("libGLES_CM");
+ glesLibNames.add("libGLES_CL");
+ glesLibNames.add("libGLESv1_CM");
+
+ return glesLibNames;
+ }
+}
+
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLES2DynamicLookupHelper.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLES2DynamicLookupHelper.java
new file mode 100755
index 000000000..cfd0558c9
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLES2DynamicLookupHelper.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.egl;
+
+import java.util.*;
+import javax.media.nativewindow.*;
+import javax.media.opengl.*;
+import com.sun.opengl.impl.*;
+import com.sun.nativewindow.impl.*;
+import com.sun.gluegen.runtime.NativeLibrary;
+
+/**
+ * Implementation of the EGLDynamicLookupHelper for ES2.
+ */
+public class EGLES2DynamicLookupHelper extends EGLDynamicLookupHelper {
+
+ protected EGLES2DynamicLookupHelper() {
+ super();
+ }
+
+ protected int getESProfile() {
+ return 2;
+ }
+
+ protected List/*<String>*/ getGLESLibNames() {
+ List/*<String>*/ glesLibNames = new ArrayList();
+
+ glesLibNames.add("GLES20");
+ glesLibNames.add("GLESv2");
+ glesLibNames.add("GLESv2_CM");
+ // for windows distributions using the 'unlike' lib prefix
+ // where our tool does not add it.
+ glesLibNames.add("libGLES20");
+ glesLibNames.add("libGLESv2");
+ glesLibNames.add("libGLESv2_CM");
+
+ return glesLibNames;
+ }
+}
+
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java
index 2a594c9a1..1635e8d63 100755
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLExternalContext.java
@@ -86,4 +86,13 @@ public class EGLExternalContext extends EGLContext {
public boolean isCreated() {
return created;
}
+
+ public void bindPbufferToTexture() {
+ throw new GLException("Should not call this");
+ }
+
+ public void releasePbufferFromTexture() {
+ throw new GLException("Should not call this");
+ }
+
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
index c6d60190c..43f6b2de2 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java
@@ -42,7 +42,8 @@ import com.sun.opengl.impl.*;
import com.sun.gluegen.runtime.NativeLibrary;
public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
-
+ protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
+
public _EGLConfig getNativeConfig() {
return _config;
}
@@ -51,8 +52,11 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return configID;
}
- public EGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities caps, _EGLConfig cfg, int cfgID) {
- super(screen, caps);
+ public EGLGraphicsConfiguration(AbstractGraphicsScreen screen,
+ GLCapabilities capsChosen, GLCapabilities capsRequested, GLCapabilitiesChooser chooser,
+ _EGLConfig cfg, int cfgID) {
+ super(screen, capsChosen, capsRequested);
+ this.chooser = chooser;
_config = cfg;
configID = cfgID;
}
@@ -61,6 +65,22 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return super.clone();
}
+ protected void updateGraphicsConfiguration() {
+ EGLGraphicsConfiguration newConfig = (EGLGraphicsConfiguration)
+ GraphicsConfigurationFactory.getFactory(getScreen().getDevice()).chooseGraphicsConfiguration(getRequestedCapabilities(),
+ chooser,
+ getScreen());
+ if(null!=newConfig) {
+ // FIXME: setScreen( ... );
+ setChosenCapabilities(newConfig.getChosenCapabilities());
+ _config = newConfig.getNativeConfig();
+ configID = newConfig.getNativeConfigID();
+ if(DEBUG) {
+ System.err.println("!!! updateGraphicsConfiguration: "+this);
+ }
+ }
+ }
+
public static _EGLConfig EGLConfigId2EGLConfig(GLProfile glp, long display, int configID) {
int[] attrs = new int[] {
EGL.EGL_CONFIG_ID, configID,
@@ -110,48 +130,126 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_TYPE, val, 0)) {
caps.setBackgroundOpaque(val[0] != EGL.EGL_TRANSPARENT_RGB);
}
- /**
- // FIXME - Add transparency values to Capabilities !
if(!caps.isBackgroundOpaque()) {
if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_RED_VALUE, val, 0)) {
- caps.setTransparentRed(val[0]);
+ caps.setTransparentRedValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]);
+ }
+ if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_GREEN_VALUE, val, 0)) {
+ caps.setTransparentGreenValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]);
}
+ if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_BLUE_VALUE, val, 0)) {
+ caps.setTransparentBlueValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]);
+ }
+ /** Not defined in EGL
+ if(EGL.eglGetConfigAttrib(display, _config, EGL.EGL_TRANSPARENT_ALPHA_VALUE, val, 0)) {
+ caps.setTransparentAlphaValue(val[0]==EGL.EGL_DONT_CARE?-1:val[0]);
+ } */
}
- */
return caps;
}
- public static int[] GLCapabilities2AttribList(GLCapabilities caps) {
- int[] attrs = new int[] {
- EGL.EGL_RENDERABLE_TYPE, -1,
- // FIXME: does this need to be configurable?
- EGL.EGL_SURFACE_TYPE, EGL.EGL_WINDOW_BIT, // or EGL_PBUFFER_BIT, EGL_PIXMAP_BIT
- EGL.EGL_RED_SIZE, caps.getRedBits(),
- EGL.EGL_GREEN_SIZE, caps.getGreenBits(),
- EGL.EGL_BLUE_SIZE, caps.getBlueBits(),
- EGL.EGL_ALPHA_SIZE, (caps.getAlphaBits() > 0 ? caps.getAlphaBits() : EGL.EGL_DONT_CARE),
- EGL.EGL_STENCIL_SIZE, (caps.getStencilBits() > 0 ? caps.getStencilBits() : EGL.EGL_DONT_CARE),
- EGL.EGL_DEPTH_SIZE, caps.getDepthBits(),
- EGL.EGL_SAMPLES, (caps.getSampleBuffers() ? caps.getNumSamples() : 1),
- EGL.EGL_TRANSPARENT_TYPE,(caps.isBackgroundOpaque() ? EGL.EGL_NONE : EGL.EGL_TRANSPARENT_TYPE),
- EGL.EGL_NONE
- };
+ public static int[] GLCapabilities2AttribList(GLCapabilities caps, int eglSurfaceType) {
+ int[] attrs = new int[32];
+ int idx=0;
+
+ switch(eglSurfaceType) {
+ case EGL.EGL_WINDOW_BIT:
+ case EGL.EGL_PBUFFER_BIT:
+ case EGL.EGL_PIXMAP_BIT:
+ break;
+ default:
+ throw new GLException("Invalid EGL_SURFACE_TYPE 0x"+Integer.toHexString(eglSurfaceType));
+ }
+
+ attrs[idx++] = EGL.EGL_SURFACE_TYPE;
+ attrs[idx++] = eglSurfaceType;
+
+ attrs[idx++] = EGL.EGL_RED_SIZE;
+ attrs[idx++] = caps.getRedBits();
+
+ attrs[idx++] = EGL.EGL_GREEN_SIZE;
+ attrs[idx++] = caps.getGreenBits();
+
+ attrs[idx++] = EGL.EGL_BLUE_SIZE;
+ attrs[idx++] = caps.getBlueBits();
+
+ attrs[idx++] = EGL.EGL_ALPHA_SIZE;
+ attrs[idx++] = caps.getAlphaBits() > 0 ? caps.getAlphaBits() : EGL.EGL_DONT_CARE;
+
+ attrs[idx++] = EGL.EGL_STENCIL_SIZE;
+ attrs[idx++] = caps.getStencilBits() > 0 ? caps.getStencilBits() : EGL.EGL_DONT_CARE;
+
+ attrs[idx++] = EGL.EGL_DEPTH_SIZE;
+ attrs[idx++] = caps.getDepthBits();
+
+ attrs[idx++] = EGL.EGL_SAMPLES;
+ attrs[idx++] = caps.getSampleBuffers() ? caps.getNumSamples() : 1;
+
+ attrs[idx++] = EGL.EGL_TRANSPARENT_TYPE;
+ attrs[idx++] = caps.isBackgroundOpaque() ? EGL.EGL_NONE : EGL.EGL_TRANSPARENT_TYPE;
+ // 20
+
+ if(!caps.isBackgroundOpaque()) {
+ attrs[idx++] = EGL.EGL_TRANSPARENT_RED_VALUE;
+ attrs[idx++] = caps.getTransparentRedValue()>=0?caps.getTransparentRedValue():EGL.EGL_DONT_CARE;
+
+ attrs[idx++] = EGL.EGL_TRANSPARENT_GREEN_VALUE;
+ attrs[idx++] = caps.getTransparentGreenValue()>=0?caps.getTransparentGreenValue():EGL.EGL_DONT_CARE;
+
+ attrs[idx++] = EGL.EGL_TRANSPARENT_BLUE_VALUE;
+ attrs[idx++] = caps.getTransparentBlueValue()>=0?caps.getTransparentBlueValue():EGL.EGL_DONT_CARE;
+
+ /** Not define in EGL
+ attrs[idx++] = EGL.EGL_TRANSPARENT_ALPHA_VALUE;
+ attrs[idx++] = caps.getTransparentAlphaValue()>=0?caps.getTransparentAlphaValue():EGL.EGL_DONT_CARE; */
+ }
+
+ // 26
+
+ attrs[idx++] = EGL.EGL_RENDERABLE_TYPE;
if(caps.getGLProfile().usesNativeGLES1()) {
- attrs[1] = EGL.EGL_OPENGL_ES_BIT;
+ attrs[idx++] = EGL.EGL_OPENGL_ES_BIT;
}
else if(caps.getGLProfile().usesNativeGLES2()) {
- attrs[1] = EGL.EGL_OPENGL_ES2_BIT;
+ attrs[idx++] = EGL.EGL_OPENGL_ES2_BIT;
} else {
- attrs[1] = EGL.EGL_OPENGL_BIT;
+ attrs[idx++] = EGL.EGL_OPENGL_BIT;
}
+ // 28
+
+ attrs[idx++] = EGL.EGL_NONE;
+
+ return attrs;
+ }
+
+ public static int[] CreatePBufferSurfaceAttribList(int width, int height, int texFormat) {
+ int[] attrs = new int[16];
+ int idx=0;
+
+ attrs[idx++] = EGL.EGL_WIDTH;
+ attrs[idx++] = width;
+
+ attrs[idx++] = EGL.EGL_HEIGHT;
+ attrs[idx++] = height;
+
+ attrs[idx++] = EGL.EGL_TEXTURE_FORMAT;
+ attrs[idx++] = texFormat;
+
+ attrs[idx++] = EGL.EGL_TEXTURE_TARGET;
+ attrs[idx++] = EGL.EGL_NO_TEXTURE==texFormat ? EGL.EGL_NO_TEXTURE : EGL.EGL_TEXTURE_2D;
+
+ attrs[idx++] = EGL.EGL_NONE;
+
return attrs;
}
public String toString() {
- return getClass().toString()+"["+getScreen()+", eglConfigID "+configID+ ", "+getCapabilities()+"]";
+ return getClass().toString()+"["+getScreen()+", eglConfigID "+configID+ ", "+getChosenCapabilities()+"]";
}
+
+ private GLCapabilitiesChooser chooser;
private _EGLConfig _config;
private int configID;
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
index c332ed9b6..e0a025c4a 100644
--- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java
@@ -46,8 +46,7 @@ import com.sun.opengl.impl.*;
GraphicsDevice and GraphicsConfiguration abstractions. */
public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactory {
- // Keep this under the same debug flag as the drawable factory for convenience
- protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("EGLDrawableFactory");
+ protected static final boolean DEBUG = GraphicsConfigurationFactory.DEBUG || com.sun.opengl.impl.Debug.debug("EGL");
public EGLGraphicsConfigurationFactory() {
// become the selector for KD/EGL ..
@@ -71,18 +70,14 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
}
- if (chooser == null) {
- chooser = new DefaultGLCapabilitiesChooser();
- }
-
return chooseGraphicsConfigurationStatic((GLCapabilities) capabilities,
(GLCapabilitiesChooser) chooser,
- absScreen);
+ absScreen, EGL.EGL_WINDOW_BIT);
}
public static EGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities capabilities,
GLCapabilitiesChooser chooser,
- AbstractGraphicsScreen absScreen) {
+ AbstractGraphicsScreen absScreen, int eglSurfaceType) {
if (capabilities == null) {
capabilities = new GLCapabilities(null);
}
@@ -102,12 +97,16 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
throw new GLException("Invalid EGL display: "+absDevice);
}
- EGLGraphicsConfiguration res = eglChooseConfig(eglDisplay, capabilities, absScreen);
+ EGLGraphicsConfiguration res = eglChooseConfig(eglDisplay, capabilities, capabilities, chooser, absScreen, eglSurfaceType);
if(null!=res) {
return res;
}
if(DEBUG) {
- System.err.println("eglChooseConfig failed with given capabilities");
+ System.err.println("eglChooseConfig failed with given capabilities surfaceType 0x"+Integer.toHexString(eglSurfaceType)+", "+capabilities);
+ }
+
+ if (chooser == null) {
+ chooser = new DefaultGLCapabilitiesChooser();
}
_EGLConfig[] configs = new _EGLConfig[10];
@@ -133,12 +132,12 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(DEBUG) {
System.err.println("Choosen "+caps[chosen]);
}
- res = eglChooseConfig(eglDisplay, caps[chosen], absScreen);
+ res = eglChooseConfig(eglDisplay, caps[chosen], capabilities, chooser, absScreen, eglSurfaceType);
if(null!=res) {
return res;
}
if(DEBUG) {
- System.err.println("eglChooseConfig failed with eglGetConfig/choosen capabilities");
+ System.err.println("eglChooseConfig failed with eglGetConfig/choosen capabilities surfaceType 0x"+Integer.toHexString(eglSurfaceType));
}
// Last try .. add a fixed embedded profile [ATI, Nokia, ..]
@@ -153,24 +152,25 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
System.err.println("trying fixed caps: "+fixedCaps);
}
- res = eglChooseConfig(eglDisplay, fixedCaps, absScreen);
+ res = eglChooseConfig(eglDisplay, fixedCaps, capabilities, chooser, absScreen, eglSurfaceType);
if(null==res) {
throw new GLException("Graphics configuration failed [direct caps, eglGetConfig/chooser and fixed-caps]");
}
return res;
}
- protected static EGLGraphicsConfiguration eglChooseConfig(long eglDisplay, GLCapabilities capabilities,
- AbstractGraphicsScreen absScreen) {
- GLProfile glp = capabilities.getGLProfile();
- int[] attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capabilities);
+ protected static EGLGraphicsConfiguration eglChooseConfig(long eglDisplay,
+ GLCapabilities capsChoosen0, GLCapabilities capsRequested, GLCapabilitiesChooser chooser,
+ AbstractGraphicsScreen absScreen, int eglSurfaceType) {
+ GLProfile glp = capsChoosen0.getGLProfile();
+ int[] attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChoosen0, eglSurfaceType);
_EGLConfig[] configs = new _EGLConfig[10];
int[] numConfigs = new int[1];
if (!EGL.eglChooseConfig(eglDisplay,
attrs, 0,
configs, configs.length,
numConfigs, 0)) {
- throw new GLException("Graphics configuration selection (eglChooseConfig) failed for "+capabilities);
+ throw new GLException("Graphics configuration selection (eglChooseConfig) failed for surfaceType 0x"+Integer.toHexString(eglSurfaceType)+", "+capsChoosen0);
}
if (numConfigs[0] > 0) {
if(DEBUG) {
@@ -182,16 +182,16 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(!EGL.eglGetConfigAttrib(eglDisplay, configs[0], EGL.EGL_CONFIG_ID, val, 0)) {
if(DEBUG) {
// FIXME: this happens on a ATI PC Emulation ..
- System.err.println("EGL couldn't retrieve ConfigID for already chosen eglConfig "+capabilities+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ System.err.println("EGL couldn't retrieve ConfigID for already chosen eglConfig "+capsChoosen0+", error 0x"+Integer.toHexString(EGL.eglGetError()));
}
val[0]=0;
}
- GLCapabilities resCaps = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0]);
+ GLCapabilities capsChoosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0]);
if(DEBUG) {
- System.err.println("eglChooseConfig found: "+capabilities+" -> "+resCaps);
+ System.err.println("eglChooseConfig found: surfaceType 0x"+Integer.toHexString(eglSurfaceType)+", "+capsChoosen0+" -> "+capsChoosen1);
}
- return new EGLGraphicsConfiguration(absScreen, resCaps, configs[0], val[0]);
+ return new EGLGraphicsConfiguration(absScreen, capsChoosen1, capsRequested, chooser, configs[0], val[0]);
}
return null;
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenContext.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenContext.java
new file mode 100755
index 000000000..ee706b50f
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenContext.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.egl;
+
+import javax.media.nativewindow.*;
+import javax.media.opengl.*;
+import com.sun.opengl.impl.*;
+import com.sun.gluegen.runtime.ProcAddressTable;
+import java.nio.*;
+import java.util.*;
+
+public class EGLOnscreenContext extends EGLContext {
+ public EGLOnscreenContext(EGLOnscreenDrawable drawable, GLContext shareWith) {
+ super(drawable, shareWith);
+ }
+
+ protected int makeCurrentImpl() throws GLException {
+ int lockRes = drawable.lockSurface();
+ boolean exceptionOccurred = false;
+ try {
+ if (lockRes == NativeWindow.LOCK_SURFACE_NOT_READY) {
+ return CONTEXT_NOT_CURRENT;
+ }
+ if (lockRes == NativeWindow.LOCK_SURFACE_CHANGED) {
+ destroyImpl();
+ }
+ return super.makeCurrentImpl();
+ } catch (RuntimeException e) {
+ exceptionOccurred = true;
+ throw e;
+ } finally {
+ if (exceptionOccurred ||
+ (isOptimizable() && lockRes != NativeWindow.LOCK_SURFACE_NOT_READY)) {
+ drawable.unlockSurface();
+ }
+ }
+ }
+
+ protected void releaseImpl() throws GLException {
+ try {
+ super.releaseImpl();
+ } finally {
+ if (!isOptimizable()) {
+ drawable.unlockSurface();
+ }
+ }
+ }
+
+ public void bindPbufferToTexture() {
+ throw new GLException("Should not call this");
+ }
+
+ public void releasePbufferFromTexture() {
+ throw new GLException("Should not call this");
+ }
+
+}
+
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java
new file mode 100644
index 000000000..a86fa8b81
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLOnscreenDrawable.java
@@ -0,0 +1,69 @@
+/*
+ * 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.egl;
+
+import javax.media.opengl.*;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.egl.*;
+import com.sun.opengl.impl.*;
+import com.sun.nativewindow.impl.NullWindow;
+
+import java.nio.LongBuffer;
+
+public class EGLOnscreenDrawable extends EGLDrawable {
+ protected EGLOnscreenDrawable(EGLDrawableFactory factory, NativeWindow component) throws GLException {
+ super(factory, component);
+ }
+
+ public GLContext createContext(GLContext shareWith) {
+ return new EGLOnscreenContext(this, shareWith);
+ }
+
+ protected long createSurface(long eglDpy, _EGLConfig eglNativeCfg) {
+ long surf = EGL.eglCreateWindowSurface(eglDpy, eglNativeCfg, component.getWindowHandle(), null);
+ if (EGL.EGL_NO_SURFACE==surf) {
+ throw new GLException("Creation of window surface (eglCreateWindowSurface) failed, component: "+component+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ } else if(DEBUG) {
+ System.err.println("setSurface result: eglSurface 0x"+Long.toHexString(surf));
+ }
+ return surf;
+ }
+}
+
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferContext.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferContext.java
new file mode 100755
index 000000000..2a7a7705c
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferContext.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.egl;
+
+import javax.media.nativewindow.*;
+import javax.media.opengl.*;
+import com.sun.opengl.impl.*;
+import com.sun.gluegen.runtime.ProcAddressTable;
+import java.nio.*;
+import java.util.*;
+
+public class EGLPbufferContext extends EGLContext {
+ public EGLPbufferContext(EGLPbufferDrawable drawable, GLContext shareWith) {
+ super(drawable, shareWith);
+ }
+
+ public int getFloatingPointMode() {
+ return 0; // FIXME ??
+ }
+
+ public void bindPbufferToTexture() {
+ throw new GLException("Not yet implemented");
+ }
+
+ public void releasePbufferFromTexture() {
+ throw new GLException("Not yet implemented");
+ }
+}
+
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
new file mode 100644
index 000000000..0ab1838b2
--- /dev/null
+++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLPbufferDrawable.java
@@ -0,0 +1,124 @@
+/*
+ * 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.egl;
+
+import javax.media.opengl.*;
+import javax.media.nativewindow.*;
+import javax.media.nativewindow.egl.*;
+import com.sun.opengl.impl.*;
+import com.sun.nativewindow.impl.NullWindow;
+
+import java.nio.LongBuffer;
+
+public class EGLPbufferDrawable extends EGLDrawable {
+ private int width, height;
+ private int texFormat;
+ protected static final boolean useTexture = false; // No yet ..
+
+ protected EGLPbufferDrawable(EGLDrawableFactory factory,
+ GLCapabilities caps,
+ GLCapabilitiesChooser chooser,
+ int width, int height) {
+ super(factory, new NullWindow(createEGLGraphicsConfiguration(caps, chooser)));
+ if (width <= 0 || height <= 0) {
+ throw new GLException("Width and height of pbuffer must be positive (were (" +
+ width + ", " + height + "))");
+ }
+
+ // get choosen ones ..
+ caps = (GLCapabilities) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+
+ this.width=width;
+ this.height=height;
+ if(useTexture) {
+ this.texFormat = caps.getAlphaBits() > 0 ? EGL.EGL_TEXTURE_RGBA : EGL.EGL_TEXTURE_RGB ;
+ } else {
+ this.texFormat = EGL.EGL_NO_TEXTURE;
+ }
+
+ NullWindow nw = (NullWindow) getNativeWindow();
+ nw.setSize(width, height);
+
+ ownEGLDisplay = true;
+
+ if (DEBUG) {
+ System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration());
+ }
+ }
+
+ protected static EGLGraphicsConfiguration createEGLGraphicsConfiguration(GLCapabilities caps, GLCapabilitiesChooser chooser) {
+ long eglDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Failed to created EGL default display: error 0x"+Integer.toHexString(EGL.eglGetError()));
+ } else if(DEBUG) {
+ System.err.println("eglDisplay(EGL_DEFAULT_DISPLAY): 0x"+Long.toHexString(eglDisplay));
+ }
+ if (!EGL.eglInitialize(eglDisplay, null, null)) {
+ throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ }
+ EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay);
+ DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, 0);
+ EGLGraphicsConfiguration eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(caps, chooser, s, EGL.EGL_PBUFFER_BIT);
+ if (null == eglConfig) {
+ EGL.eglTerminate(eglDisplay);
+ throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
+ } else if(DEBUG) {
+ System.err.println("Chosen eglConfig: "+eglConfig);
+ }
+ return eglConfig;
+ }
+
+ protected long createSurface(long eglDpy, _EGLConfig eglNativeCfg) {
+ int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(width, height, texFormat);
+ long surf = EGL.eglCreatePbufferSurface(eglDpy, eglNativeCfg, attrs, 0);
+ if (EGL.EGL_NO_SURFACE==surf) {
+ throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+width+"x"+height+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ } else if(DEBUG) {
+ System.err.println("setSurface result: eglSurface 0x"+Long.toHexString(surf));
+ }
+ return surf;
+ }
+
+ public GLContext createContext(GLContext shareWith) {
+ return new EGLPbufferContext(this, shareWith);
+ }
+
+}
+
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
index b42f35e17..897ed9e98 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLContext.java
@@ -111,7 +111,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
}
MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLCapabilities capabilities = (GLCapabilities)config.getRequestedCapabilities();
GLProfile glProfile = capabilities.getGLProfile();
// FIXME: Shall being moved to MacOSXCGLGraphicsConfiguration !
int[] viewNotReady = new int[1];
@@ -173,7 +173,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
// NativeWindow's AbstractGraphicsConfiguration,
// since the public API doesn't provide for a different GLCapabilities per context.
// Note: These restrictions of the platform's API might be considered as a bug anyways.
- if (!config.getIsUpdated()) {
+ {
// Figure out what attributes we really got
GLCapabilities caps = new GLCapabilities(glProfile);
CGL.queryPixelFormat(pixelFormat, iattribs, 0, idx, ivalues, 0);
@@ -239,7 +239,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
}
- config.update(caps);
+ config.setChosenCapabilities(caps);
}
} finally {
CGL.deletePixelFormat(pixelFormat);
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
index 18ec81b81..d2330dcfe 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawable.java
@@ -42,6 +42,7 @@ package com.sun.opengl.impl.macosx.cgl;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
+import com.sun.gluegen.runtime.DynamicLookupHelper;
public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
// The Java2D/OpenGL pipeline on OS X uses low-level CGLContextObjs
@@ -81,6 +82,26 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl {
super(factory, comp, realized);
}
+ public void setRealized(boolean realized) {
+ super.setRealized(realized);
+
+ if(realized) {
+ int lockRes = lockSurface();
+ try {
+ // nothing to do, but complied with protocol,
+ // ie resolved the window/surface handles
+ } finally {
+ if ( lockRes != NativeWindow.LOCK_SURFACE_NOT_READY ) {
+ unlockSurface();
+ }
+ }
+ }
+ }
+
+ public DynamicLookupHelper getDynamicLookupHelper() {
+ return (MacOSXCGLDrawableFactory) getFactoryImpl() ;
+ }
+
protected static String getThreadName() {
return Thread.currentThread().getName();
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 9e3f1820a..d8c2a016d 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -46,8 +46,9 @@ import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
import com.sun.nativewindow.impl.*;
+import com.sun.gluegen.runtime.DynamicLookupHelper;
-public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
+public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
public MacOSXCGLDrawableFactory() {
super();
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
index 0ada5668f..b5d2fc38e 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
@@ -42,23 +42,16 @@ import com.sun.opengl.impl.*;
import com.sun.gluegen.runtime.NativeLibrary;
public class MacOSXCGLGraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
- private boolean isUpdated = false;
-
- public MacOSXCGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities caps) {
- super(screen, caps);
+ public MacOSXCGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities capsChosen, GLCapabilities capsRequested) {
+ super(screen, capsChosen, capsRequested);
}
public Object clone() {
return super.clone();
}
- protected void update(GLCapabilities caps) {
- setCapabilities(caps);
- isUpdated=true;
- }
-
- public boolean getIsUpdated() {
- return isUpdated;
+ protected void setChosenCapabilities(GLCapabilities caps) {
+ super.setChosenCapabilities(caps);
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
index 3c797fb75..f59268b5e 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
@@ -57,15 +57,6 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GraphicsConfiguration
return chooseGraphicsConfigurationStatic(capabilities, chooser, absScreen, false);
}
- /** FIXME: remove
- protected static MacOSXCGLGraphicsConfiguration createDefaultGraphicsConfiguration(AbstractGraphicsScreen absScreen, boolean usePBuffer) {
- if (absScreen == null) {
- throw new IllegalArgumentException("AbstractGraphicsScreen is null");
- }
-
- return new MacOSXCGLGraphicsConfiguration(absScreen, new GLCapabilities());
- }*/
-
protected static MacOSXCGLGraphicsConfiguration chooseGraphicsConfigurationStatic(Capabilities capabilities,
CapabilitiesChooser chooser,
AbstractGraphicsScreen absScreen, boolean usePBuffer) {
@@ -87,7 +78,7 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GraphicsConfiguration
capabilities = new GLCapabilities(null);
}
- return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilities)capabilities);
+ return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilities)capabilities, (GLCapabilities)capabilities);
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
index e11ac512b..19ee5b94b 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXOnscreenCGLContext.java
@@ -80,6 +80,7 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
// This can happen if the window currently is zero-sized, for example.
// Make sure we don't leave the surface locked in this case.
drawable.unlockSurface();
+ lockRes = NativeWindow.LOCK_SURFACE_NOT_READY;
}
}
return ret;
@@ -98,7 +99,7 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
try {
super.releaseImpl();
} finally {
- if (!isOptimizable()) {
+ if (!isOptimizable() && drawable.isSurfaceLocked()) {
drawable.unlockSurface();
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
index 94d80f346..4a8712b06 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLContext.java
@@ -81,7 +81,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
// Initialize render-to-texture support if requested
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
GL gl = getGL();
boolean rect = gl.isGL2() && capabilities.getPbufferRenderToTextureRectangle();
if (rect) {
@@ -139,7 +139,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
protected boolean create() {
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
if (capabilities.getPbufferFloatingPointBuffers() &&
!isTigerOrLater) {
throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later");
@@ -221,7 +221,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
class NSOpenGLImpl implements Impl {
public long create() {
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
if (capabilities.getPbufferFloatingPointBuffers() &&
!isTigerOrLater) {
throw new GLException("Floating-point pbuffers supported only on OS X 10.4 or later");
@@ -278,7 +278,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
int i = 0;
attrs[i++] = CGL.kCGLPFAPBuffer;
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
if (capabilities.getPbufferFloatingPointBuffers())
attrs[i++] = CGL.kCGLPFAColorFloat;
if (capabilities.getDoubleBuffered())
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index 2e6716cf4..54101331d 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -94,7 +94,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
private void createPbuffer() {
NullWindow nw = (NullWindow) getNativeWindow();
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
GLProfile glProfile = capabilities.getGLProfile();
int renderTarget;
if (glProfile.isGL2() && capabilities.getPbufferRenderToTextureRectangle()) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
index b1e37f12c..3fa48b7ba 100644
--- a/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
@@ -90,23 +90,22 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GraphicsConfigurat
System.err.println("MacOSXAWTCGLGraphicsConfigurationFactory: made "+macScreen);
}
+ GraphicsConfiguration gc = device.getDefaultConfiguration();
+ AWTGraphicsConfiguration.SetupCapabilitiesPixelformat(capabilities, gc);
+ if(DEBUG) {
+ System.err.println("AWT Colormodel compatible: "+capabilities);
+ }
+
MacOSXCGLGraphicsConfiguration macConfig = (MacOSXCGLGraphicsConfiguration)
GraphicsConfigurationFactory.getFactory(macDevice).chooseGraphicsConfiguration(capabilities,
chooser,
macScreen);
- if (macConfig != null) {
- // FIXME: we have nothing to match .. so choose the 1st
- GraphicsConfiguration[] configs = device.getConfigurations();
- if(configs.length>0) {
- return new AWTGraphicsConfiguration(awtScreen, macConfig.getCapabilities(), configs[0], macConfig);
- }
+
+ if (macConfig == null) {
+ throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+macScreen);
}
-
- // 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;
+
+ // FIXME: we have nothing to match .. so choose the default
+ return new AWTGraphicsConfiguration(awtScreen, macConfig.getChosenCapabilities(), macConfig.getRequestedCapabilities(), gc, macConfig);
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
index 901d26e8b..dc9d66073 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
@@ -66,7 +66,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
private void create() {
NullWindow nw = (NullWindow) getNativeWindow();
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)nw.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLCapabilities capabilities = (GLCapabilities)config.getRequestedCapabilities();
int width = getWidth();
int height = getHeight();
BITMAPINFO info = BITMAPINFO.create();
@@ -111,7 +111,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
throw new GLException("Error selecting bitmap into new device context");
}
- config.update(getFactory(), nw, true);
+ config.updateGraphicsConfiguration(getFactory(), nw, true);
}
public void destroy() {
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLContext.java
index 0f553ffbb..4ab34d0e2 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLContext.java
@@ -62,6 +62,9 @@ public class WindowsOnscreenWGLContext extends WindowsWGLContext {
return CONTEXT_NOT_CURRENT;
}
if (lockRes == NativeWindow.LOCK_SURFACE_CHANGED) {
+ if (DEBUG) {
+ System.err.println("!!! SURFACE_CHANGED WindowsOnscreenWGLContext.makeCurrentImpl: NEW CONTEXT");
+ }
destroyImpl();
}
int ret = super.makeCurrentImpl();
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
index e98b570ed..9c492e244 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLContext.java
@@ -96,8 +96,7 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext {
System.err.println("WindowsPbufferWGLContext: super.makeCurrentImpl() = " + res);
}
if (res == CONTEXT_CURRENT_NEW) {
- WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLCapabilities capabilities = drawable.getChosenGLCapabilities();
// Initialize render-to-texture support if requested
GL gl = getGL();
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
index 46d46de02..2d996ca40 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -132,7 +132,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
int width, height;
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLCapabilities capabilities = (GLCapabilities)config.getRequestedCapabilities();
GLProfile glProfile = capabilities.getGLProfile();
if (DEBUG) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
index 3af9109b9..13ee50773 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -119,11 +119,10 @@ public class WindowsWGLContext extends GLContextImpl {
* called by {@link #makeCurrentImpl()}.
*/
protected void create() {
- AbstractGraphicsConfiguration config = drawable.getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ GLCapabilities glCaps = drawable.getChosenGLCapabilities();
if(DEBUG) {
- System.err.println("WindowsWGLContext.create got "+config);
+ System.err.println("WindowsWGLContext.create got "+glCaps);
}
- GLCapabilities glCaps = (GLCapabilities) config.getCapabilities();
if (drawable.getNativeWindow().getSurfaceHandle() == 0) {
throw new GLException("Internal error: attempted to create OpenGL context without an associated drawable");
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
index d638926ab..3915c7af0 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawable.java
@@ -42,53 +42,40 @@ package com.sun.opengl.impl.windows.wgl;
import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
+import com.sun.gluegen.runtime.DynamicLookupHelper;
public abstract class WindowsWGLDrawable extends GLDrawableImpl {
- // Workaround for problems on Intel 82855 cards
- private int setPixelFormatFailCount;
private static final int MAX_SET_PIXEL_FORMAT_FAIL_COUNT = 5;
public WindowsWGLDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized) {
super(factory, comp, realized);
}
- public int lockSurface() throws GLException {
- int ret = super.lockSurface();
+ public void setRealized(boolean realized) {
+ super.setRealized(realized);
+
+ if(!realized) {
+ return; // nothing todo ..
+ }
+
+ int ret = lockSurface();
if(NativeWindow.LOCK_SURFACE_NOT_READY == ret) {
- if (DEBUG) {
- System.err.println("WindowsWGLDrawable.lockSurface: surface not ready");
- }
- return ret;
+ throw new GLException("WindowsWGLDrawable.setRealized(true): lockSurface - surface not ready");
}
- NativeWindow nativeWindow = getNativeWindow();
- WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)nativeWindow.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- if (!config.getIsUpdated()) {
- try {
- config.update(getFactory(), nativeWindow, false);
- setPixelFormatFailCount = 0;
- } catch (RuntimeException e) {
+ try {
+ NativeWindow nativeWindow = getNativeWindow();
+ WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)nativeWindow.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ config.updateGraphicsConfiguration(getFactory(), nativeWindow, false);
if (DEBUG) {
- System.err.println("WindowsWGLDrawable.lockSurface: squelching exception");
- e.printStackTrace();
+ System.err.println("!!! WindowsWGLDrawable.setRealized(true): "+config);
}
- // Workaround for problems seen on Intel 82855 cards in particular
- // Make it look like the lockSurface() call didn't succeed
+ } finally {
unlockSurface();
- if (e instanceof GLException) {
- if (++setPixelFormatFailCount == MAX_SET_PIXEL_FORMAT_FAIL_COUNT) {
- setPixelFormatFailCount = 0;
- throw e;
- }
- return NativeWindow.LOCK_SURFACE_NOT_READY;
- } else {
- // Probably a user error in the GLCapabilitiesChooser or similar.
- // Don't propagate non-GLExceptions out because calling code
- // expects to catch only that exception type
- throw new GLException(e);
- }
- }
}
- return ret;
+ }
+
+ public DynamicLookupHelper getDynamicLookupHelper() {
+ return (WindowsWGLDrawableFactory) getFactoryImpl() ;
}
protected static String getThreadName() {
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index c092621b1..d15ba3423 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -45,8 +45,9 @@ import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
import com.sun.nativewindow.impl.NWReflection;
+import com.sun.gluegen.runtime.DynamicLookupHelper;
-public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
+public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
private static final boolean VERBOSE = Debug.verbose();
// Handle to GLU32.dll
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index babea70a1..54080fa3d 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -47,12 +47,12 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
private PIXELFORMATDESCRIPTOR pixelfmt;
private int pixelfmtID;
- private boolean isUpdated = false;
+ private boolean isChosen = false;
private GLCapabilitiesChooser chooser;
- public WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities caps, PIXELFORMATDESCRIPTOR pixelfmt, int pixelfmtID,
- GLCapabilitiesChooser chooser) {
- super(screen, caps);
+ public WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilities capsChosen, GLCapabilities capsRequested,
+ PIXELFORMATDESCRIPTOR pixelfmt, int pixelfmtID, GLCapabilitiesChooser chooser) {
+ super(screen, capsChosen, capsRequested);
this.chooser=chooser;
this.pixelfmt = pixelfmt;
this.pixelfmtID = pixelfmtID;
@@ -62,18 +62,19 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
return super.clone();
}
- protected void update(GLDrawableFactory factory, NativeWindow nativeWindow, boolean useOffScreen) {
+ protected void updateGraphicsConfiguration(GLDrawableFactory factory, NativeWindow nativeWindow, boolean useOffScreen) {
WindowsWGLGraphicsConfigurationFactory.updateGraphicsConfiguration(chooser, factory, nativeWindow, useOffScreen);
}
protected void setCapsPFD(GLCapabilities caps, PIXELFORMATDESCRIPTOR pfd, int pfdID) {
+ // FIXME: setScreen ( .. )
this.pixelfmt = pfd;
this.pixelfmtID = pfdID;
- setCapabilities(caps);
- isUpdated=true;
+ setChosenCapabilities(caps);
+ isChosen=true;
}
- public boolean getIsUpdated() {
- return isUpdated;
+ public boolean getCapabilitiesChosen() {
+ return isChosen;
}
public PIXELFORMATDESCRIPTOR getPixelFormat() { return pixelfmt; }
@@ -433,7 +434,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
}
public String toString() {
- return "WindowsWGLGraphicsConfiguration["+getScreen()+", pfdID " + pixelfmtID + ", " + getCapabilities() +"]";
+ return "WindowsWGLGraphicsConfiguration["+getScreen()+", pfdID " + pixelfmtID + ", " + getChosenCapabilities() +"]";
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index e336cc48d..d508c0e12 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -62,7 +62,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if(null==absScreen) {
absScreen = DefaultGraphicsScreen.createScreenDevice(0);
}
- return new WindowsWGLGraphicsConfiguration(absScreen, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps, useOffScreen), -1, null);
+ return new WindowsWGLGraphicsConfiguration(absScreen, caps, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps, useOffScreen), -1, null);
}
protected static WindowsWGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilities caps,
@@ -71,7 +71,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
if(null==absScreen) {
absScreen = DefaultGraphicsScreen.createScreenDevice(0);
}
- return new WindowsWGLGraphicsConfiguration(absScreen, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps, useOffScreen), -1,
+ return new WindowsWGLGraphicsConfiguration(absScreen, caps, caps, WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(caps, useOffScreen), -1,
(GLCapabilitiesChooser)chooser);
}
@@ -87,7 +87,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio
}
WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) nativeWindow.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- GLCapabilities capabilities = (GLCapabilities) config.getCapabilities();
+ GLCapabilities capabilities = (GLCapabilities) config.getRequestedCapabilities();
GLProfile glProfile = capabilities.getGLProfile();
long hdc = nativeWindow.getSurfaceHandle();
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
index d682df5eb..7bcfd259a 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
@@ -81,6 +81,11 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
if(DEBUG) {
System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: got "+absScreen);
}
+ GraphicsConfiguration gc = device.getDefaultConfiguration();
+ AWTGraphicsConfiguration.SetupCapabilitiesPixelformat(capabilities, gc);
+ if(DEBUG) {
+ System.err.println("AWT Colormodel compatible: "+capabilities);
+ }
long displayHandle = 0;
@@ -94,19 +99,12 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GraphicsConfigura
GraphicsConfigurationFactory.getFactory(winDevice).chooseGraphicsConfiguration(capabilities,
chooser,
winScreen);
- if (winConfig != null) {
- // FIXME: we have nothing to match .. so choose the 1st
- GraphicsConfiguration[] configs = device.getConfigurations();
- if(configs.length>0) {
- return new AWTGraphicsConfiguration(awtScreen, winConfig.getCapabilities(), configs[0], winConfig);
- }
+
+ if (winConfig == null) {
+ throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+winScreen);
}
-
- // 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;
+
+ // FIXME: we have nothing to match .. so choose the default
+ return new AWTGraphicsConfiguration(awtScreen, winConfig.getChosenCapabilities(), winConfig.getRequestedCapabilities(), gc, winConfig);
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
index 480a91ea7..8a28010dc 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXContext.java
@@ -132,7 +132,7 @@ public abstract class X11GLXContext extends GLContextImpl {
if(DEBUG) {
System.err.println("X11GLXContext.createContext got "+config);
}
- GLCapabilities glCaps = (GLCapabilities) config.getCapabilities();
+ GLCapabilities glCaps = (GLCapabilities) config.getChosenCapabilities();
long display = config.getScreen().getDevice().getHandle();
if(config.getFBConfigID()<0) {
@@ -282,13 +282,8 @@ public abstract class X11GLXContext extends GLContextImpl {
}
protected void releaseImpl() throws GLException {
- getDrawableImpl().getFactoryImpl().lockToolkit();
- try {
- if (!GLX.glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), 0, 0, 0)) {
+ if (!GLX.glXMakeContextCurrent(drawable.getNativeWindow().getDisplayHandle(), 0, 0, 0)) {
throw new GLException("Error freeing OpenGL context");
- }
- } finally {
- getDrawableImpl().getFactoryImpl().unlockToolkit();
}
}
@@ -355,7 +350,7 @@ public abstract class X11GLXContext extends GLContextImpl {
public synchronized String getPlatformExtensionsString() {
if (!glXQueryExtensionsStringInitialized) {
glXQueryExtensionsStringAvailable =
- getDrawableImpl().getFactoryImpl().dynamicLookupFunction("glXQueryExtensionsString") != 0;
+ getDrawableImpl().getDynamicLookupHelper().dynamicLookupFunction("glXQueryExtensionsString") != 0;
glXQueryExtensionsStringInitialized = true;
}
if (glXQueryExtensionsStringAvailable) {
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java
index 1ed58dbb2..ae57a254b 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawable.java
@@ -43,11 +43,47 @@ import javax.media.nativewindow.*;
import javax.media.opengl.*;
import com.sun.opengl.impl.*;
import com.sun.nativewindow.impl.x11.*;
+import com.sun.gluegen.runtime.DynamicLookupHelper;
public abstract class X11GLXDrawable extends GLDrawableImpl {
- protected X11GLXDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized) {
- super(factory, comp, realized);
+ protected X11GLXDrawable(GLDrawableFactory factory, NativeWindow comp, boolean realized) {
+ super(factory, comp, realized);
+ }
+
+ public DynamicLookupHelper getDynamicLookupHelper() {
+ return (X11GLXDrawableFactory) getFactoryImpl() ;
+ }
+
+ public int lockSurface() throws GLException {
+ int ret = super.lockSurface();
+ if(NativeWindow.LOCK_SURFACE_NOT_READY == ret) {
+ if (DEBUG) {
+ System.err.println("X11GLXDrawable.lockSurface: surface not ready");
+ }
+ return ret;
+ }
+ if (NativeWindow.LOCK_SURFACE_CHANGED == ret) {
+ X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ config.updateGraphicsConfiguration();
+ }
+ return ret;
+ }
+
+ public void setRealized(boolean realized) {
+ super.setRealized(realized);
+
+ if(realized) {
+ int lockRes = lockSurface();
+ try {
+ // nothing to do, but complied with protocol,
+ // ie resolved the window/surface handles
+ } finally {
+ if ( lockRes != NativeWindow.LOCK_SURFACE_NOT_READY ) {
+ unlockSurface();
+ }
+ }
}
+ }
//---------------------------------------------------------------------------
// Internals only below this point
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index 29bfc18a7..13eec3333 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -51,7 +51,7 @@ import com.sun.nativewindow.impl.NWReflection;
import com.sun.nativewindow.impl.x11.*;
import com.sun.nativewindow.impl.jawt.x11.*;
-public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
+public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements DynamicLookupHelper {
public X11GLXDrawableFactory() {
super();
// Must initialize GLX support eagerly in case a pbuffer is the
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
index 7644fad74..84e9bfc50 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -41,15 +41,18 @@ import com.sun.gluegen.runtime.NativeLibrary;
import com.sun.nativewindow.impl.x11.*;
public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implements Cloneable {
- // Keep this under the same debug flag as the drawable factory for convenience
protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
public static final int MAX_ATTRIBS = 128;
private long fbConfig;
private int fbConfigID;
+ private GLCapabilitiesChooser chooser;
- public X11GLXGraphicsConfiguration(X11GraphicsScreen screen, GLCapabilities caps, XVisualInfo info, long fbcfg, int fbcfgID) {
- super(screen, caps, info);
+ public X11GLXGraphicsConfiguration(X11GraphicsScreen screen,
+ GLCapabilities capsChosen, GLCapabilities capsRequested, GLCapabilitiesChooser chooser,
+ XVisualInfo info, long fbcfg, int fbcfgID) {
+ super(screen, capsChosen, capsRequested, info);
+ this.chooser=chooser;
fbConfig = fbcfg;
fbConfigID = fbcfgID;
}
@@ -61,6 +64,23 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
public long getFBConfig() { return fbConfig; }
public int getFBConfigID() { return fbConfigID; }
+ protected void updateGraphicsConfiguration() {
+ X11GLXGraphicsConfiguration newConfig = (X11GLXGraphicsConfiguration)
+ GraphicsConfigurationFactory.getFactory(getScreen().getDevice()).chooseGraphicsConfiguration(getRequestedCapabilities(),
+ chooser,
+ getScreen());
+ if(null!=newConfig) {
+ // FIXME: setScreen( ... );
+ setXVisualInfo(newConfig.getXVisualInfo());
+ setChosenCapabilities(newConfig.getChosenCapabilities());
+ fbConfig = newConfig.getFBConfig();
+ fbConfigID = newConfig.getFBConfigID();
+ if(DEBUG) {
+ System.err.println("!!! updateGraphicsConfiguration: "+this);
+ }
+ }
+ }
+
public static int[] GLCapabilities2AttribList(GLCapabilities caps,
boolean forFBAttr,
boolean isMultisampleAvailable,
@@ -98,15 +118,14 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
res[idx++] = GLX.GLX_TRANSPARENT_TYPE;
res[idx++] = caps.isBackgroundOpaque()?GLX.GLX_NONE:GLX.GLX_TRANSPARENT_RGB;
if(!caps.isBackgroundOpaque()) {
- // FIXME - Add transparency values to Capabilities !
res[idx++] = GLX.GLX_TRANSPARENT_RED_VALUE;
- res[idx++] = 64;
+ res[idx++] = caps.getTransparentRedValue()>=0?caps.getTransparentRedValue():(int)GLX.GLX_DONT_CARE;
res[idx++] = GLX.GLX_TRANSPARENT_GREEN_VALUE;
- res[idx++] = 64;
+ res[idx++] = caps.getTransparentGreenValue()>=0?caps.getTransparentGreenValue():(int)GLX.GLX_DONT_CARE;
res[idx++] = GLX.GLX_TRANSPARENT_BLUE_VALUE;
- res[idx++] = 64;
+ res[idx++] = caps.getTransparentBlueValue()>=0?caps.getTransparentBlueValue():(int)GLX.GLX_DONT_CARE;
res[idx++] = GLX.GLX_TRANSPARENT_ALPHA_VALUE;
- res[idx++] = 64;
+ res[idx++] = caps.getTransparentAlphaValue()>=0?caps.getTransparentAlphaValue():(int)GLX.GLX_DONT_CARE;
}
} else {
if (caps.getDoubleBuffered()) {
@@ -243,6 +262,22 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
caps.setPbufferFloatingPointBuffers(ivalues[i] != GL.GL_FALSE);
break;
+ case GLX.GLX_TRANSPARENT_RED_VALUE:
+ caps.setTransparentRedValue(ivalues[i]);
+ break;
+
+ case GLX.GLX_TRANSPARENT_GREEN_VALUE:
+ caps.setTransparentGreenValue(ivalues[i]);
+ break;
+
+ case GLX.GLX_TRANSPARENT_BLUE_VALUE:
+ caps.setTransparentBlueValue(ivalues[i]);
+ break;
+
+ case GLX.GLX_TRANSPARENT_ALPHA_VALUE:
+ caps.setTransparentAlphaValue(ivalues[i]);
+ break;
+
default:
break;
}
@@ -279,6 +314,19 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
res.setNumSamples (glXGetFBConfig(display, fbcfg, GLX.GLX_SAMPLES, tmp, 0));
}
res.setBackgroundOpaque(glXGetFBConfig(display, fbcfg, GLX.GLX_TRANSPARENT_TYPE, tmp, 0) == GLX.GLX_NONE);
+ if(!res.isBackgroundOpaque()) {
+ glXGetFBConfig(display, fbcfg, GLX.GLX_TRANSPARENT_RED_VALUE, tmp, 0);
+ res.setTransparentRedValue(tmp[0]==GLX.GLX_DONT_CARE?-1:tmp[0]);
+
+ glXGetFBConfig(display, fbcfg, GLX.GLX_TRANSPARENT_GREEN_VALUE, tmp, 0);
+ res.setTransparentGreenValue(tmp[0]==GLX.GLX_DONT_CARE?-1:tmp[0]);
+
+ glXGetFBConfig(display, fbcfg, GLX.GLX_TRANSPARENT_BLUE_VALUE, tmp, 0);
+ res.setTransparentBlueValue(tmp[0]==GLX.GLX_DONT_CARE?-1:tmp[0]);
+
+ glXGetFBConfig(display, fbcfg, GLX.GLX_TRANSPARENT_ALPHA_VALUE, tmp, 0);
+ res.setTransparentAlphaValue(tmp[0]==GLX.GLX_DONT_CARE?-1:tmp[0]);
+ }
try {
res.setPbufferFloatingPointBuffers(glXGetFBConfig(display, fbcfg, GLXExt.GLX_FLOAT_COMPONENTS_NV, tmp, 0) != GL.GL_FALSE);
} catch (Exception e) {}
@@ -385,7 +433,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
}
public String toString() {
- return "X11GLXGraphicsConfiguration["+getScreen()+", visualID 0x" + Long.toHexString(getVisualID()) + ", fbConfigID 0x" + Long.toHexString(fbConfigID) + ", " + getCapabilities() +"]";
+ return "X11GLXGraphicsConfiguration["+getScreen()+", visualID 0x" + Long.toHexString(getVisualID()) + ", fbConfigID 0x" + Long.toHexString(fbConfigID) + ", " + getChosenCapabilities() +"]";
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 27568cbaa..bfc7f59b4 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -79,6 +79,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
// Utilizing FBConfig
//
+ GLCapabilities capsFB = null;
NativeWindowFactory.getDefaultFactory().getToolkitLock().lock();
try {
long visID = X11Lib.DefaultVisualID(display, x11Screen.getIndex());
@@ -92,7 +93,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
throw new Exception("Could not fetch FBConfig for "+caps);
}
fbcfg = fbcfgsL.get(0);
- GLCapabilities capFB = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfg);
+ capsFB = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glProfile, display, fbcfg);
int[] tmpID = new int[1];
fbid = X11GLXGraphicsConfiguration.glXGetFBConfig(display, fbcfg, GLX.GLX_FBCONFIG_ID, tmpID, 0);
@@ -101,13 +102,12 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
if (xvis==null) {
throw new GLException("Error: Choosen FBConfig has no visual");
}
- caps = capFB;
} catch (Throwable t) {
} finally {
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
- return new X11GLXGraphicsConfiguration(x11Screen, caps, xvis, fbcfg, fbid);
+ return new X11GLXGraphicsConfiguration(x11Screen, (null!=capsFB)?capsFB:caps, caps, null, xvis, fbcfg, fbid);
}
protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationStatic(Capabilities capabilities,
@@ -221,7 +221,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
- return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], retXVisualInfo, fbcfgsL.get(chosen), retFBID);
+ return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capabilities, chooser, retXVisualInfo, fbcfgsL.get(chosen), retFBID);
}
protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationXVisual(GLCapabilities capabilities,
@@ -289,7 +289,7 @@ public class X11GLXGraphicsConfigurationFactory extends GraphicsConfigurationFac
} finally {
NativeWindowFactory.getDefaultFactory().getToolkitLock().unlock();
}
- return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], retXVisualInfo, 0, -1);
+ return new X11GLXGraphicsConfiguration(x11Screen, caps[chosen], capabilities, chooser, retXVisualInfo, 0, -1);
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXContext.java
index 7113e8640..2393eda15 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXContext.java
@@ -47,7 +47,6 @@ import com.sun.opengl.impl.*;
import com.sun.opengl.impl.x11.*;
public class X11OnscreenGLXContext extends X11GLXContext {
- protected X11OnscreenGLXDrawable 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
@@ -56,7 +55,6 @@ public class X11OnscreenGLXContext extends X11GLXContext {
public X11OnscreenGLXContext(X11OnscreenGLXDrawable drawable,
GLContext shareWith) {
super(drawable, shareWith);
- this.drawable = drawable;
}
protected int makeCurrentImpl() throws GLException {
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXContext.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXContext.java
index 6fc2ea9d6..3938c0ecc 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXContext.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXContext.java
@@ -82,8 +82,11 @@ public class X11PbufferGLXContext extends X11GLXContext {
throw new GLException("GLContextShareSet returned an invalid OpenGL context");
}
}
+ X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)
+ getGLDrawable().getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+
context = GLX.glXCreateNewContext(drawable.getNativeWindow().getDisplayHandle(),
- drawable.getFBConfig(), GLX.GLX_RGBA_TYPE, share, true);
+ config.getFBConfig(), GLX.GLX_RGBA_TYPE, share, true);
if (context == 0) {
throw new GLException("pbuffer creation error: glXCreateNewContext() failed");
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
index f89a27365..1aafe89c8 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11PbufferGLXDrawable.java
@@ -49,12 +49,6 @@ import com.sun.nativewindow.impl.x11.*;
import java.nio.LongBuffer;
public class X11PbufferGLXDrawable extends X11GLXDrawable {
- // drawable in superclass is a GLXPbuffer
- private long fbConfig;
-
- protected static final int MAX_PFORMATS = 256;
- protected static final int MAX_ATTRIBS = 256;
-
protected X11PbufferGLXDrawable(GLDrawableFactory factory, AbstractGraphicsScreen screen,
GLCapabilities caps,
GLCapabilitiesChooser chooser,
@@ -68,7 +62,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
nw.setSize(width, height);
if (DEBUG) {
- caps = (GLCapabilities) getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getCapabilities();
System.out.println("Pbuffer config: " + getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration());
}
@@ -107,7 +100,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
NullWindow nw = (NullWindow) getNativeWindow();
- GLCapabilities capabilities = (GLCapabilities)config.getCapabilities();
+ GLCapabilities capabilities = (GLCapabilities)config.getChosenCapabilities();
if (capabilities.getPbufferRenderToTexture()) {
throw new GLException("Render-to-texture pbuffers not supported yet on X11");
@@ -117,8 +110,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
throw new GLException("Render-to-texture-rectangle pbuffers not supported yet on X11");
}
- fbConfig = config.getFBConfig();
-
// Create the p-buffer.
int niattribs = 0;
int[] iattributes = new int[5];
@@ -129,7 +120,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
iattributes[niattribs++] = nw.getHeight();
iattributes[niattribs++] = 0;
- long drawable = GLX.glXCreatePbuffer(display, fbConfig, iattributes, 0);
+ long drawable = GLX.glXCreatePbuffer(display, config.getFBConfig(), iattributes, 0);
if (drawable == 0) {
// FIXME: query X error code for detail error message
throw new GLException("pbuffer creation error: glXCreatePbuffer() failed");
@@ -158,9 +149,4 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
// Floating-point pbuffers currently require NVidia hardware on X11
return GLPbuffer.NV_FLOAT;
}
-
- public long getFBConfig() {
- return fbConfig;
- }
-
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
index e21bf96f9..3ab435fcb 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java
@@ -104,30 +104,39 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GraphicsConfiguration
System.err.println("X11AWTGLXGraphicsConfigurationFactory: made "+x11Screen);
}
+ GraphicsConfiguration gc = device.getDefaultConfiguration();
+ AWTGraphicsConfiguration.SetupCapabilitiesPixelformat(capabilities, gc);
+ if(DEBUG) {
+ System.err.println("AWT Colormodel compatible: "+capabilities);
+ }
+
X11GraphicsConfiguration x11Config = (X11GraphicsConfiguration)
GraphicsConfigurationFactory.getFactory(x11Device).chooseGraphicsConfiguration(capabilities,
chooser,
x11Screen);
- if (x11Config != null) {
- long visualID = x11Config.getVisualID();
- // 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(awtScreen, x11Config.getCapabilities(), config, x11Config);
- }
+ if (x11Config == null) {
+ throw new GLException("Unable to choose a GraphicsConfiguration: "+capabilities+",\n\t"+chooser+"\n\t"+x11Screen);
+ }
+
+ long visualID = x11Config.getVisualID();
+ // 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(awtScreen, x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(),
+ config, x11Config);
}
}
}
-
// 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;
+ // Let's take the default configuration as used on Windows and MacOSX then ..
+ if(DEBUG) {
+ System.err.println("!!! Using default configuration");
+ }
+ return new AWTGraphicsConfiguration(awtScreen, x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(), gc, x11Config);
}
}
diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
index 629142f64..90a914a40 100644
--- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
@@ -50,8 +50,16 @@ import javax.media.opengl.glu.*;
calls to {@link GLContext#makeCurrent makeCurrent} will block if
the context is current on another thread. This allows the internal
GLContext for the GLAutoDrawable to be used both by the event
- based rendering mechanism as well by end users directly. */
+ based rendering mechanism as well by end users directly.<p>
+ The implementation shall initialize itself as soon as possible,
+ ie if an attached window is become visible.
+ The it shall call {@link GLDrawable#setRealized setRealized(true)}
+ and create the GLContext.
+ The followup {@link #display display} call will ensure that all
+ {@link GLEventListener#init init} calls for
+ registered {@link GLEventListener}s will be made.
+ */
public interface GLAutoDrawable extends GLDrawable {
/**
* Returns the context associated with this drawable. The returned
@@ -77,7 +85,24 @@ public interface GLAutoDrawable extends GLDrawable {
during this update cycle. */
public void removeGLEventListener(GLEventListener listener);
- /** Destroys all resources associated with this GLAutoDrawable.
+ /** Destroys the GLContext associated with this GLAutoDrawable.
+ Causes disposing of all OpenGL resources
+ by calling {@link GLEventListener#dispose dispose} for all
+ registered {@link GLEventListener}s,
+ and then destroys the GLContext.
+ The implementation shall also call {@link GLDrawable#setRealized setRealized(false)}
+ to notify GLDrawable.<p>
+
+ If the argument <code>regenerate</code> is true,
+ the implementation shall call {@link GLDrawable#setRealized setRealized(true)}
+ and create a new GLContext.
+ The followup {@link #display display} call will ensure that all
+ {@link GLEventListener#init init} calls for
+ registered {@link GLEventListener}s will be made.*/
+ public void dispose(boolean regenerate);
+
+ /** Destroys all resources associated with this GLAutoDrawable,
+ inclusive the GLContext.
If a window is attached to it's implementation, it shall be closed.
Causes disposing of all OpenGL resources
by calling {@link GLEventListener#dispose dispose} for all
@@ -93,7 +118,11 @@ public interface GLAutoDrawable extends GLDrawable {
routine may be called manually for better control over the
rendering process. It is legal to call another GLAutoDrawable's
display method from within the {@link GLEventListener#display
- display} callback. */
+ display} callback.<p>
+ In case of a new generated OpenGL context,
+ the implementation shall call {@link GLEventListener#init init} for all
+ registered {@link GLEventListener}s <i>before</i> making the
+ actual {@link GLEventListener#display display} calls.*/
public void display();
/** Enables or disables automatic buffer swapping for this drawable.
diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
index 69263ad70..a0cac4b4e 100644
--- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java
+++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java
@@ -41,11 +41,17 @@ package javax.media.opengl;
import javax.media.nativewindow.Capabilities;
-/** Specifies a set of OpenGL capabilities that a rendering context
- must support, such as color depth and whether stereo is enabled.
+/** Specifies a set of OpenGL capabilities.<br>
+ At creation time of a {@link GLDrawable} using {@link GLDrawableFactory},
+ an instance of this class is passed,
+ describing the desired capabilities that a rendering context
+ must support, such as the OpenGL profile, color depth and whether stereo is enabled.<br>
+
+ The actual capabilites of created {@link GLDrawable}s are then reflected by their own
+ GLCapabilites instance, which can be queried with {@link GLDrawable#getGLCapabilities()}.<br>
+
It currently contains the minimal number of routines which allow
configuration on all supported window systems. */
-
public class GLCapabilities extends Capabilities implements Cloneable {
private GLProfile glProfile = null;
private boolean doubleBuffered = true;
@@ -64,10 +70,6 @@ public class GLCapabilities extends Capabilities implements Cloneable {
private boolean sampleBuffers = false;
private int numSamples = 2;
- // Support for transparent windows containing OpenGL content
- // (currently only has an effect on Mac OS X)
- private boolean backgroundOpaque = true;
-
// Bits for pbuffer creation
private boolean pbufferFloatingPointBuffers;
private boolean pbufferRenderToTexture;
@@ -88,6 +90,32 @@ public class GLCapabilities extends Capabilities implements Cloneable {
}
}
+ public boolean equals(Object obj) {
+ if(!(obj instanceof GLCapabilities)) {
+ return false;
+ }
+ GLCapabilities other = (GLCapabilities)obj;
+ boolean res = super.equals(obj) &&
+ other.getGLProfile()==glProfile &&
+ other.getDoubleBuffered()==doubleBuffered &&
+ other.getStereo()==stereo &&
+ other.getHardwareAccelerated()==hardwareAccelerated &&
+ other.getDepthBits()==depthBits &&
+ other.getStencilBits()==stencilBits &&
+ other.getAccumRedBits()==accumRedBits &&
+ other.getAccumGreenBits()==accumGreenBits &&
+ other.getAccumBlueBits()==accumBlueBits &&
+ other.getAccumAlphaBits()==accumAlphaBits &&
+ other.getSampleBuffers()==sampleBuffers &&
+ other.getPbufferFloatingPointBuffers()==pbufferFloatingPointBuffers &&
+ other.getPbufferRenderToTexture()==pbufferRenderToTexture &&
+ other.getPbufferRenderToTextureRectangle()==pbufferRenderToTextureRectangle;
+ if(sampleBuffers) {
+ res = res && other.getNumSamples()==numSamples;
+ }
+ return res;
+ }
+
/** Returns the GL profile you desire or used by the drawable. */
public GLProfile getGLProfile() {
return glProfile;
@@ -275,35 +303,13 @@ public class GLCapabilities extends Capabilities implements Cloneable {
return pbufferRenderToTextureRectangle;
}
- /** For on-screen OpenGL contexts on some platforms, sets whether
- the background of the context should be considered opaque. On
- supported platforms, setting this to false, in conjunction with
- other changes at the window toolkit level, can allow
- hardware-accelerated OpenGL content inside of windows of
- arbitrary shape. To achieve this effect it is necessary to use
- an OpenGL clear color with an alpha less than 1.0. The default
- value for this flag is <code>true</code>; setting it to false
- may incur a certain performance penalty, so it is not
- recommended to arbitrarily set it to false. */
- public void setBackgroundOpaque(boolean opaque) {
- backgroundOpaque = opaque;
- }
-
- /** Indicates whether the background of this OpenGL context should
- be considered opaque. Defaults to true.
-
- @see #setBackgroundOpaque
- */
- public boolean isBackgroundOpaque() {
- return backgroundOpaque;
- }
-
/** Returns a textual representation of this GLCapabilities
object. */
public String toString() {
- return getClass().toString()+"[" +
- super.toString()+
- ", GL profile: " + glProfile +
+ StringBuffer msg = new StringBuffer();
+ msg.append("GLCapabilities[");
+ msg.append(super.toString());
+ msg.append(", GL profile: " + glProfile +
", DoubleBuffered: " + doubleBuffered +
", Stereo: " + stereo +
", HardwareAccelerated: " + hardwareAccelerated +
@@ -314,11 +320,10 @@ public class GLCapabilities extends Capabilities implements Cloneable {
", Blue Accum: " + accumBlueBits +
", Alpha Accum: " + accumAlphaBits +
", Multisample: " + sampleBuffers +
- ", Num samples: "+(sampleBuffers ? numSamples : 0) +
- ", Opaque: " + backgroundOpaque +
- ", PBuffer-FloatingPointBuffers: "+pbufferFloatingPointBuffers+
+ ", Num samples: "+(sampleBuffers ? numSamples : 0));
+ msg.append(", PBuffer-FloatingPointBuffers: "+pbufferFloatingPointBuffers+
", PBuffer-RenderToTexture: "+pbufferRenderToTexture+
- ", PBuffer-RenderToTextureRectangle: "+pbufferRenderToTextureRectangle+
- " ]";
+ ", PBuffer-RenderToTextureRectangle: "+pbufferRenderToTextureRectangle+ "]");
+ return msg.toString();
}
}
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java
index f85147a79..023689a82 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java
@@ -119,7 +119,13 @@ public interface GLDrawable {
* component. <code>setRealized</code> allows the
* <code>GLDrawable</code> to re-initialize and destroy any
* associated resources as the component becomes realized and
- * unrealized, respectively.
+ * unrealized, respectively.<br><br>
+ * The minimum implementation shall at least call
+ * {@link NativeWindow#lockSurface() NativeWindow.lockSurface()} and if successfull
+ * release it with {@link NativeWindow#unlockSurface() NativeWindow.unlockSurface()}
+ * in case realized is true.
+ * This is important since this resolve the window/surface handles,
+ * which are assumed to be present after <code>setRealized(true)</code>.
*
* <P>
*
@@ -144,13 +150,13 @@ public interface GLDrawable {
public void swapBuffers() throws GLException;
/** Fetches the {@link GLCapabilities} corresponding to the chosen
- OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.
+ OpenGL capabilities (pixel format / visual / GLProfile) for this drawable.<br>
On some platforms, the pixel format is not directly associated
with the drawable; a best attempt is made to return a reasonable
- value in this case.
- Returns a copy of the queried object.
+ value in this case. <br>
+ @return A copy of the queried object.
*/
- public GLCapabilities getGLCapabilities();
+ public GLCapabilities getChosenGLCapabilities();
/** Fetches the {@link GLProfile} for this drawable.
Returns the GLProfile object, no copy.
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 6cfe66dff..88570ee07 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -85,8 +85,7 @@ public abstract class GLDrawableFactory {
protected GLDrawableFactory() {
}
- private static final GLDrawableFactory eglES1Factory;
- private static final GLDrawableFactory eglES2Factory;
+ private static final GLDrawableFactory eglFactory;
private static final GLDrawableFactory nativeOSFactory;
private static final String nativeOSType;
@@ -96,25 +95,14 @@ public abstract class GLDrawableFactory {
static {
GLDrawableFactory tmp = null;
try {
- tmp = (GLDrawableFactory) NWReflection.createInstance("com.sun.opengl.impl.egl.EGLDrawableFactory", new Object[] { GLProfile.GLES1 });
+ tmp = (GLDrawableFactory) NWReflection.createInstance("com.sun.opengl.impl.egl.EGLDrawableFactory");
} catch (Throwable t) {
if (GLProfile.DEBUG) {
- System.err.println("GLDrawableFactory.static - EGLDrawableFactory GLES1 - not available");
+ System.err.println("GLDrawableFactory.static - EGLDrawableFactory - not available");
t.printStackTrace();
}
}
- eglES1Factory = tmp;
-
- tmp = null;
- try {
- tmp = (GLDrawableFactory) NWReflection.createInstance("com.sun.opengl.impl.egl.EGLDrawableFactory", new Object[] { GLProfile.GLES2 });
- } catch (Throwable t) {
- if (GLProfile.DEBUG) {
- System.err.println("GLDrawableFactory.static - EGLDrawableFactory GLES2 - not available");
- t.printStackTrace();
- }
- }
- eglES2Factory = tmp;
+ eglFactory = tmp;
nativeOSType = NativeWindowFactory.getNativeWindowType(false);
@@ -157,61 +145,18 @@ public abstract class GLDrawableFactory {
/**
* Returns the sole GLDrawableFactory instance.
*
- * @arg nw NativeWindow object to query the ES GLProfile type,
- * which itself helps to determine the EGL factory type.
+ * @arg glProfile GLProfile to determine the factory type, ie EGLDrawableFactory,
+ * or one of the native GLDrawableFactory's, ie X11/GLX, Windows/WGL or MacOSX/CGL.
*/
- public static GLDrawableFactory getFactory(NativeWindow nw) throws GLException {
- return getFactory(nw.getGraphicsConfiguration().getNativeGraphicsConfiguration());
+ public static GLDrawableFactory getFactory(GLProfile glProfile) throws GLException {
+ return getFactoryImpl(glProfile.getImplName());
}
- /**
- * Returns the sole GLDrawableFactory instance.
- *
- * @arg agc AbstractGraphicsConfiguration object to query the ES GLProfile type,
- * which itself helps to determine the EGL factory type.
- */
- public static GLDrawableFactory getFactory(AbstractGraphicsConfiguration agc) throws GLException {
- if(null==agc) {
- throw new GLException("Null AbstractGraphicsConfiguration");
- }
- if( !(agc.getCapabilities() instanceof GLCapabilities) ) {
- throw new GLException("Unsupported AbstractGraphicsConfiguration for OpenGL: "+agc);
- }
- return getFactory((GLCapabilities)agc.getCapabilities());
- }
-
- /**
- * Returns the sole GLDrawableFactory instance.
- *
- * @arg esCaps GLCapabilities object to query the ES GLProfile type,
- * which itself helps to determine the EGL factory type.
- */
- public static GLDrawableFactory getFactory(GLCapabilities esCaps) throws GLException {
- return getFactory(esCaps.getGLProfile());
- }
-
- /**
- * Returns the sole GLDrawableFactory instance.
- *
- * @arg esProfile GLProfile to determine the EGL factory type.
- */
- public static GLDrawableFactory getFactory(GLProfile esProfile) throws GLException {
- return getFactory(esProfile.getImplName());
- }
-
- protected static GLDrawableFactory getFactory(String profileImpl) throws GLException {
- if ( GLProfile.UsesNativeGLES1(profileImpl) ) {
- if(null==eglES1Factory) throw new GLException("GLDrawableFactory unavailable for EGL/ES1: "+profileImpl);
- return eglES1Factory;
- } else if ( GLProfile.UsesNativeGLES2(profileImpl) ) {
- if(null==eglES2Factory) throw new GLException("GLDrawableFactory unavailable for EGL/ES2: "+profileImpl);
- return eglES2Factory;
+ protected static GLDrawableFactory getFactoryImpl(String glProfileImplName) throws GLException {
+ if ( GLProfile.UsesNativeGLES(glProfileImplName) ) {
+ if(null==eglFactory) throw new GLException("GLDrawableFactory unavailable for EGL: "+glProfileImplName);
+ return eglFactory;
}
-
- return getNativeOSFactory();
- }
-
- protected static GLDrawableFactory getNativeOSFactory() {
if(null==nativeOSFactory) throw new GLException("GLDrawableFactory unavailable for Native Platform "+nativeOSType);
return nativeOSFactory;
}
diff --git a/src/jogl/classes/javax/media/opengl/GLEventListener.java b/src/jogl/classes/javax/media/opengl/GLEventListener.java
index d2c851a69..08e4a84fb 100644
--- a/src/jogl/classes/javax/media/opengl/GLEventListener.java
+++ b/src/jogl/classes/javax/media/opengl/GLEventListener.java
@@ -49,8 +49,9 @@ import java.util.EventListener;
public interface GLEventListener extends EventListener {
/** Called by the drawable immediately after the OpenGL context is
initialized. Can be used to perform one-time OpenGL
- initialization such as setup of lights and display lists. Note
- that this method may be called more than once if the underlying
+ initialization per GLContext, such as setup of lights and display lists.<p>
+
+ Note that this method may be called more than once if the underlying
OpenGL context for the GLAutoDrawable is destroyed and
recreated, for example if a GLCanvas is removed from the widget
hierarchy and later added again.
@@ -63,8 +64,12 @@ public interface GLEventListener extends EventListener {
native window manager, ie window close, but also
manually by calling {@link GLAutoDrawable#destroy destroy}.
Shall be used to perform final release of all OpenGL
- resources, such as memory buffers and GLSL programs.
- You might also want to exit your application after receiving this signal.
+ resources per GLContext, such as memory buffers and GLSL programs.<P>
+
+ Note that this event does not imply the end of life of the application.
+ It could be produced with a followup call to {@link #init(GLAutoDrawable)}
+ in case the GLContext has been recreated,
+ e.g. due to a pixel configuration change in a multihead environment.
*/
public void dispose(GLAutoDrawable drawable);
@@ -105,6 +110,11 @@ public interface GLEventListener extends EventListener {
adjustments to compensate for a device change if it knows that the mode
on the new device is identical the previous mode.<p>
+ Note that this method is for application logic purpose only,
+ all necessary OpenGL specific reconfiguration are made through
+ {@link #dispose(GLAutoDrawable)} and {@link #init(GLAutoDrawable)},
+ if necessary.<p>
+
<b>NOTE: Implementations are not required to implement this method. The
Reference Implementation DOES NOT IMPLEMENT this method.</b>
*/
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 20414126b..0ca95aaa0 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -44,9 +44,13 @@ import com.sun.opengl.impl.*;
import com.sun.nativewindow.impl.NWReflection;
/**
- * Manages all available OpenGL Profiles.
- * Each GLProfile is a singleton instance queried at static initialization time.
- * All returned GLProfile objects are references to such singletons.
+ * Specifies the the OpenGL profile.
+ *
+ * This class static singleton initialization queries the availability of all OpenGL Profiles
+ * and instantiates singleton GLProfile objects for each available profile.
+ *
+ * The platform default profile may be used, using {@link GLProfile#GetProfileDefault()},
+ * or more specialized versions using the other static GetProfile methods.
*/
public class GLProfile implements Cloneable {
public static final boolean DEBUG = Debug.debug("GLProfile");
@@ -55,44 +59,41 @@ public class GLProfile implements Cloneable {
// Public (user-visible) profiles
//
- /** The desktop OpenGL >= 3.1 profile */
+ /** The desktop OpenGL profile 3.x, with x >= 1 */
public static final String GL3 = "GL3";
- /** The desktop OpenGL [1.5 .. 3.0] profile */
+ /** The desktop OpenGL profile 1.x up to 3.0 */
public static final String GL2 = "GL2";
- /** The embedded OpenGL ES >= 1.0 profile */
+ /** The embedded OpenGL profile ES 1.x, with x >= 0 */
public static final String GLES1 = "GLES1";
- /** The embedded OpenGL ES >= 2.0 profile */
+ /** The embedded OpenGL profile ES 2.x, with x >= 0 */
public static final String GLES2 = "GLES2";
- /** The intersection of the desktop GL2 and embedded ES1 profiles */
+ /** The intersection of the desktop GL2 and embedded ES1 profile */
public static final String GL2ES1 = "GL2ES1";
- /** The intersection of the desktop GL2 and embedded ES2 profiles */
+ /** The intersection of the desktop GL3, GL2 and embedded ES2 profile */
public static final String GL2ES2 = "GL2ES2";
/**
- * All GL Profiles in the order of default detection.
- * Order: GL2, GL2ES2, GL2ES1, GL3, GLES2, GLES1
+ * All GL Profiles in the order of default detection: GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL3
*/
- public static final String[] GL_PROFILE_LIST = new String[] { GL2, GL2ES2, GL2ES1, GL3, GLES2, GLES1 };
+ public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL3 };
/**
- * All GL2ES2 Profiles in the order of default detection
- * Order: GL2ES2, GL2, GL3, GLES2
+ * All GL2ES2 Profiles in the order of default detection: GL2ES2, GL2, GLES2, GL3
*/
- public static final String[] GL2ES2_PROFILE_LIST = new String[] { GL2ES2, GL2, GL3, GLES2 };
+ public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL2, GLES2, GL3 };
/**
- * All GL2ES1 Profiles in the order of default detection
- * Order: GL2ES1, GL2, GLES1
+ * All GL2ES1 Profiles in the order of default detection: GL2ES1, GL2, GLES1
*/
- public static final String[] GL2ES1_PROFILE_LIST = new String[] { GL2ES1, GL2, GLES1 };
+ public static final String[] GL_PROFILE_LIST_GL2ES1 = new String[] { GL2ES1, GL2, GLES1 };
/** Returns a default GLProfile object, reflecting the best for the running platform.
- * It selects the first of the set {@link GLProfile#GL_PROFILE_LIST}
+ * It selects the first of the set {@link GLProfile#GL_PROFILE_LIST_ALL}
*/
public static final GLProfile GetProfileDefault() {
if(null==defaultGLProfile) {
@@ -119,26 +120,26 @@ public class GLProfile implements Cloneable {
/**
* Returns a profile, implementing the interface GL2ES1.
- * It selects the first of the set: {@link GLProfile#GL2ES1_PROFILE_LIST}
+ * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES1}
*
* @throws GLException if no implementation for the given profile is found.
*/
public static final GLProfile GetProfileGL2ES1()
throws GLException
{
- return GetProfile(GL2ES1_PROFILE_LIST);
+ return GetProfile(GL_PROFILE_LIST_GL2ES1);
}
/**
* Returns a profile, implementing the interface GL2ES2.
- * It selects the first of the set: {@link GLProfile#GL2ES2_PROFILE_LIST}
+ * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES2}
*
* @throws GLException if no implementation for the given profile is found.
*/
public static final GLProfile GetProfileGL2ES2()
throws GLException
{
- return GetProfile(GL2ES2_PROFILE_LIST);
+ return GetProfile(GL_PROFILE_LIST_GL2ES2);
}
/**
@@ -239,27 +240,27 @@ public class GLProfile implements Cloneable {
return profileImpl;
}
- /** Indicates whether this profile is capable os GL3. */
+ /** Indicates whether this profile is capable of GL3. */
public final boolean isGL3() {
return GL3.equals(profile);
}
- /** Indicates whether this profile is capable os GL2. */
+ /** Indicates whether this profile is capable of GL2. */
public final boolean isGL2() {
return GL2.equals(profile);
}
- /** Indicates whether this profile is capable os GLES1. */
+ /** Indicates whether this profile is capable of GLES1. */
public final boolean isGLES1() {
return GLES1.equals(profile);
}
- /** Indicates whether this profile is capable os GLES2. */
+ /** Indicates whether this profile is capable of GLES2. */
public final boolean isGLES2() {
return GLES2.equals(profile);
}
- /** Indicates whether this profile is capable os GL2ES1. */
+ /** Indicates whether this profile is capable of GL2ES1. */
public final boolean isGL2ES1() {
return GL2ES1.equals(profile) || isGL2() || isGLES1() ;
}
@@ -643,7 +644,7 @@ public class GLProfile implements Cloneable {
if(hasDesktopGL||hasDesktopGLES12) {
try {
- hasNativeOSFactory = null!=GLDrawableFactory.getNativeOSFactory();
+ hasNativeOSFactory = null!=GLDrawableFactory.getFactoryImpl(GL2);
} catch (Throwable t) {
if (DEBUG) {
System.err.println("GLProfile.static - Native platform GLDrawable factory not available");
@@ -664,8 +665,16 @@ public class GLProfile implements Cloneable {
hasGL2ES12Impl = hasDesktopGLES12 && null!=NWReflection.getClass("com.sun.opengl.impl.gl2es12.GL2ES12Impl");
boolean btest = false;
+
+ boolean hasEGLDynLookup = null!=NWReflection.getClass("com.sun.opengl.impl.egl.EGLDynamicLookupHelper");
+ boolean hasEGLDrawableFactory = false;
try {
- btest = null!=GLDrawableFactory.getFactory(GLES2) && null!=NWReflection.getClass("com.sun.opengl.impl.es2.GLES2Impl");
+ if(hasEGLDynLookup) {
+ hasEGLDrawableFactory = null!=GLDrawableFactory.getFactoryImpl(GLES2);
+ btest = hasEGLDrawableFactory &&
+ null!=NWReflection.getClass("com.sun.opengl.impl.es2.GLES2Impl") &&
+ null!=com.sun.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(2);
+ }
} catch (Throwable t) {
if (DEBUG) {
System.err.println("GLProfile.static - GL ES2 Factory/Library not available");
@@ -676,7 +685,11 @@ public class GLProfile implements Cloneable {
btest = false;
try {
- btest = null!=GLDrawableFactory.getFactory(GLES1) && null!=NWReflection.getClass("com.sun.opengl.impl.es1.GLES1Impl");
+ if(hasEGLDynLookup) {
+ btest = hasEGLDrawableFactory &&
+ null!=NWReflection.getClass("com.sun.opengl.impl.es1.GLES1Impl") &&
+ null!=com.sun.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(1);
+ }
} catch (Throwable t) {
if (DEBUG) {
System.err.println("GLProfile.static - GL ES1 Factory/Library not available");
@@ -696,9 +709,9 @@ public class GLProfile implements Cloneable {
System.err.println("GLProfile.static hasGLES1Impl "+hasGLES1Impl);
}
- HashMap/*<String, GLProfile>*/ _mappedProfiles = new HashMap(GL_PROFILE_LIST.length);
- for(int i=0; i<GL_PROFILE_LIST.length; i++) {
- String profile = GL_PROFILE_LIST[i];
+ HashMap/*<String, GLProfile>*/ _mappedProfiles = new HashMap(GL_PROFILE_LIST_ALL.length);
+ for(int i=0; i<GL_PROFILE_LIST_ALL.length; i++) {
+ String profile = GL_PROFILE_LIST_ALL[i];
String profileImpl = ComputeProfileImpl(profile);
if(null!=profileImpl) {
GLProfile glProfile = new GLProfile(profile, profileImpl);
@@ -720,7 +733,7 @@ public class GLProfile implements Cloneable {
}
mappedProfiles = _mappedProfiles; // final ..
if(null==defaultGLProfile) {
- throw new GLException("No profile available: "+list2String(GL_PROFILE_LIST));
+ throw new GLException("No profile available: "+list2String(GL_PROFILE_LIST_ALL));
}
}
diff --git a/src/jogl/classes/javax/media/opengl/Threading.java b/src/jogl/classes/javax/media/opengl/Threading.java
index 763389aca..23202b96f 100755
--- a/src/jogl/classes/javax/media/opengl/Threading.java
+++ b/src/jogl/classes/javax/media/opengl/Threading.java
@@ -39,14 +39,15 @@
package javax.media.opengl;
-// FIXME: refactor Java SE dependencies
-//import java.awt.EventQueue;
import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import com.sun.opengl.impl.*;
+import javax.media.nativewindow.NativeWindowFactory;
+import com.sun.nativewindow.impl.NWReflection;
+
/** This API provides access to the threading model for the implementation of
the classes in this package.
@@ -122,21 +123,25 @@ import com.sun.opengl.impl.*;
*/
public class Threading {
+ public static final int AWT = 1;
+ public static final int WORKER = 2;
+
+ protected static final boolean DEBUG = Debug.debug("Threading");
+
private static boolean singleThreaded = true;
- private static final int AWT = 1;
- private static final int WORKER = 2;
private static int mode;
- /* FIXME: refactor Java SE dependencies
+ private static boolean hasAWT;
// We need to know whether we're running on X11 platforms to change
// our behavior when the Java2D/JOGL bridge is active
- private static boolean isX11;
- */
+ private static boolean _isX11;
+
+ private static final ThreadingPlugin threadingPlugin;
static {
+ Object threadingPluginTmp =
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
String workaround = System.getProperty("opengl.1thread");
- /* FIXME: refactor Java SE dependencies
// Default to using the AWT thread on all platforms except
// Windows. On OS X there is instability apparently due to
// using the JAWT on non-AWT threads. On X11 platforms there
@@ -145,12 +150,16 @@ public class Threading {
// while holding the AWT lock. The optimization of
// makeCurrent / release calls isn't worth these stability
// problems.
- String osName = System.getProperty("os.name");
- boolean isWindows = osName.startsWith("Windows");
- isX11 = !(isWindows || osName.startsWith("Mac OS"));
- */
- // int defaultMode = (isWindows ? WORKER : AWT);
- int defaultMode = AWT;
+ hasAWT = NWReflection.isClassAvailable("java.awt.Canvas") &&
+ NWReflection.isClassAvailable("javax.media.opengl.awt.GLCanvas");
+
+ String osType = NativeWindowFactory.getNativeWindowType(false);
+ _isX11 = NativeWindowFactory.TYPE_X11.equals(osType);
+ // boolean isWindows = NativeWindowFactory.TYPE_WINDOWS.equals(osType);
+
+ // int defaultMode = (isWindows ? WORKER : ( hasAWT ? AWT : WORKER ) );
+ int defaultMode = ( hasAWT ? AWT : WORKER );
+
mode = defaultMode;
if (workaround != null) {
workaround = workaround.toLowerCase();
@@ -168,14 +177,27 @@ public class Threading {
}
}
printWorkaroundNotice();
- return null;
+
+ Object threadingPluginObj=null;
+ // try to fetch the AWTThreadingPlugin
+ try {
+ threadingPluginObj = NWReflection.createInstance("com.sun.opengl.impl.awt.AWTThreadingPlugin");
+ } catch (Throwable t) { }
+ return threadingPluginObj;
}
});
+ threadingPlugin = (ThreadingPlugin) threadingPluginTmp;
+ if(DEBUG) {
+ System.err.println("Threading: hasAWT "+hasAWT+", mode "+((mode==AWT)?"AWT":"WORKER")+", plugin "+threadingPlugin);
+ }
}
/** No reason to ever instantiate this class */
private Threading() {}
+ public static boolean isX11() { return _isX11; }
+ public static int getMode() { return mode; }
+
/** If an implementation of the javax.media.opengl APIs offers a
multithreading option but the default behavior is single-threading,
this API provides a mechanism for end users to disable single-threading
@@ -211,34 +233,14 @@ public class Threading {
throw new GLException("Should only call this in single-threaded mode");
}
+ if(null!=threadingPlugin) {
+ return threadingPlugin.isOpenGLThread();
+ }
+
switch (mode) {
case AWT:
- /* FIXME: refactor Java SE dependencies
- if (Java2D.isOGLPipelineActive()) {
- // FIXME: ideally only the QFT would be considered to be the
- // "OpenGL thread", but we can not currently run all of
- // JOGL's OpenGL work on that thread. See the FIXME in
- // invokeOnOpenGLThread.
- return (Java2D.isQueueFlusherThread() ||
- (isX11 && EventQueue.isDispatchThread()));
- } else {
- return EventQueue.isDispatchThread();
- }
- */
return true;
case WORKER:
- /* FIXME: refactor Java SE dependencies
- if (Java2D.isOGLPipelineActive()) {
- // FIXME: ideally only the QFT would be considered to be the
- // "OpenGL thread", but we can not currently run all of
- // JOGL's OpenGL work on that thread. See the FIXME in
- // invokeOnOpenGLThread.
- return (Java2D.isQueueFlusherThread() ||
- (isX11 && GLWorkerThread.isWorkerThread()));
- } else {
- return GLWorkerThread.isWorkerThread();
- }
- */
return GLWorkerThread.isWorkerThread();
default:
throw new InternalError("Illegal single-threading mode " + mode);
@@ -263,29 +265,13 @@ public class Threading {
throw new GLException ("Should only call this from other threads than the OpenGL thread");
}
+ if(null!=threadingPlugin) {
+ threadingPlugin.invokeOnOpenGLThread(r);
+ return;
+ }
+
switch (mode) {
case AWT:
- /* FIXME: refactor Java SE dependencies
- // FIXME: ideally should run all OpenGL work on the Java2D QFT
- // thread when it's enabled, but unfortunately there are
- // deadlock issues on X11 platforms when making our
- // heavyweight OpenGL contexts current on the QFT because we
- // perform the JAWT lock inside the makeCurrent()
- // implementation, which attempts to grab the AWT lock on the
- // QFT which is not allowed. For now, on X11 platforms,
- // continue to perform this work on the EDT.
- if (Java2D.isOGLPipelineActive() && !isX11) {
- Java2D.invokeWithOGLContextCurrent(null, r);
- } else {
- try {
- EventQueue.invokeAndWait(r);
- } catch (InvocationTargetException e) {
- throw new GLException(e.getTargetException());
- } catch (InterruptedException e) {
- throw new GLException(e);
- }
- }
- */
r.run();
break;
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 7ed6d3c3c..fa242ef08 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -48,7 +48,6 @@ import com.sun.opengl.impl.*;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Component;
-import java.awt.EventQueue;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
@@ -87,6 +86,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
private GraphicsConfiguration chosen;
private AWTGraphicsConfiguration awtConfig;
private GLCapabilitiesChooser glCapChooser;
+ private GLContext shareWithContext;
/** Creates a new GLCanvas component with a default set of OpenGL
capabilities, using the default OpenGL capabilities selection
@@ -134,6 +134,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
glProfile = capabilities.getGLProfile();
+ // FIXME: all this shall move to addNotify(),
+ // since only there a GraphicsConfiguration is available ..
+ if(null==device) {
+ GraphicsConfiguration gc = super.getGraphicsConfiguration();
+ if(null!=gc) {
+ device = gc.getDevice();
+ }
+ }
+
/*
* Save the chosen capabilities for use in getGraphicsConfiguration().
*/
@@ -152,13 +161,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
* save these for later use in getGraphicsConfiguration().
*/
this.glCapChooser = chooser;
+ this.shareWithContext=shareWith;
}
if (!Beans.isDesignTime()) {
if(null==awtConfig) {
throw new GLException("Error: AWTGraphicsConfiguration is null");
}
- drawable = GLDrawableFactory.getFactory(awtConfig).createGLDrawable(NativeWindowFactory.getNativeWindow(this, awtConfig));
- context = (GLContextImpl) drawable.createContext(shareWith);
+ drawable = GLDrawableFactory.getFactory(glProfile).createGLDrawable(NativeWindowFactory.getNativeWindow(this, awtConfig));
+ context = (GLContextImpl) drawable.createContext(shareWithContext);
context.setSynchronized(true);
}
if(DEBUG) {
@@ -245,8 +255,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
* block, both devices should have the same visual list, and the
* same configuration should be selected here.
*/
- AWTGraphicsConfiguration config = chooseGraphicsConfiguration((GLCapabilities)awtConfig.getCapabilities(), glCapChooser, gc.getDevice());
+ AWTGraphicsConfiguration config = chooseGraphicsConfiguration((GLCapabilities)awtConfig.getRequestedCapabilities(), glCapChooser, gc.getDevice());
final GraphicsConfiguration compatible = (null!=config)?config.getGraphicsConfiguration():null;
+ if(DEBUG) {
+ System.err.println("!!! Created Config (n): HAVE GC "+gc);
+ System.err.println("!!! Created Config (n): Choosen GC "+compatible);
+ System.err.println("!!! Created Config (n): Choosen CF "+config);
+ System.err.println("!!! Created Config (n): EQUALS CAPS "+config.getChosenCapabilities().equals(awtConfig.getChosenCapabilities()));
+ }
if (compatible != null) {
/*
@@ -254,7 +270,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
* any outside callers of this method.
*/
chosen = compatible;
- awtConfig = config; // FIXME: ??
+ /**
+ * FIXME: On Windows: I get a JAWT_LOCK_ERROR in the WindowsJAWTWindow.lock() .. funny,
+ * is it because the AWT holds the lock while updating the context on a display change?
+ * This failure doesn't happen all times, but sometimes .. sync problem ?
+ if( !config.getChosenCapabilities().equals(awtConfig.getChosenCapabilities())) {
+ dispose(true);
+ }
+ */
+ awtConfig = config;
}
}
@@ -306,6 +330,36 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
+ public void dispose(boolean regenerate) {
+ if(DEBUG) {
+ Exception ex1 = new Exception("dispose("+regenerate+") - start");
+ ex1.printStackTrace();
+ }
+ disposeRegenerate=regenerate;
+
+ if (Threading.isSingleThreaded() &&
+ !Threading.isOpenGLThread()) {
+ // Workaround for termination issues with applets --
+ // sun.applet.AppletPanel should probably be performing the
+ // remove() call on the EDT rather than on its own thread
+ if (Threading.isAWTMode() &&
+ Thread.holdsLock(getTreeLock())) {
+ // The user really should not be invoking remove() from this
+ // thread -- but since he/she is, we can not go over to the
+ // EDT at this point. Try to destroy the context from here.
+ drawableHelper.invokeGL(drawable, context, disposeAction, null);
+ } else {
+ Threading.invokeOnOpenGLThread(disposeOnEventDispatchThreadAction);
+ }
+ } else {
+ drawableHelper.invokeGL(drawable, context, disposeAction, null);
+ }
+
+ if(DEBUG) {
+ System.err.println("dispose("+regenerate+") - stop");
+ }
+ }
+
/**
* Just an alias for removeNotify
*/
@@ -373,33 +427,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
Exception ex1 = new Exception("removeNotify - start");
ex1.printStackTrace();
}
- drawableHelper.invokeGL(drawable, context, disposeAction, null);
if (Beans.isDesignTime()) {
super.removeNotify();
} else {
try {
- if (Threading.isSingleThreaded() &&
- !Threading.isOpenGLThread()) {
- // Workaround for termination issues with applets --
- // sun.applet.AppletPanel should probably be performing the
- // remove() call on the EDT rather than on its own thread
- if (Threading.isAWTMode() &&
- Thread.holdsLock(getTreeLock())) {
- // The user really should not be invoking remove() from this
- // thread -- but since he/she is, we can not go over to the
- // EDT at this point. Try to destroy the context from here.
- destroyAction.run();
- } else {
- Threading.invokeOnOpenGLThread(destroyAction);
- }
- } else {
- destroyAction.run();
- }
+ dispose(false);
} finally {
- if(null!=drawable) {
- drawable.setRealized(false);
- }
drawable=null;
super.removeNotify();
}
@@ -474,15 +508,23 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
public GLProfile getGLProfile() {
- return getGLCapabilities().getGLProfile();
+ return glProfile;
}
- public GLCapabilities getGLCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
if (awtConfig == null) {
throw new GLException("No AWTGraphicsConfiguration: "+this);
}
- return (GLCapabilities)awtConfig.getCapabilities();
+ return (GLCapabilities)awtConfig.getChosenCapabilities();
+ }
+
+ public GLCapabilities getRequestedGLCapabilities() {
+ if (awtConfig == null) {
+ throw new GLException("No AWTGraphicsConfiguration: "+this);
+ }
+
+ return (GLCapabilities)awtConfig.getRequestedCapabilities();
}
public NativeWindow getNativeWindow() {
@@ -501,13 +543,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
// Internals only below this point
//
- class DisposeAction implements Runnable {
- public void run() {
- drawableHelper.dispose(GLCanvas.this);
- }
- }
- private DisposeAction disposeAction = new DisposeAction();
-
private void maybeDoSingleThreadedWorkaround(Runnable eventDispatchThreadAction,
Runnable invokeGLAction) {
if (Threading.isSingleThreaded() &&
@@ -518,6 +553,40 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
}
}
+ private boolean disposeRegenerate;
+ private DisposeAction disposeAction = new DisposeAction();
+
+ class DisposeAction implements Runnable {
+ public void run() {
+ drawableHelper.dispose(GLCanvas.this);
+
+ if(null!=context) {
+ context.makeCurrent(); // implicit wait for lock ..
+ context.destroy();
+ context=null;
+ }
+
+ if(null!=drawable) {
+ drawable.setRealized(false);
+ }
+
+ if(disposeRegenerate && null!=drawable) {
+ drawable.setRealized(true);
+ context = (GLContextImpl) drawable.createContext(shareWithContext);
+ context.setSynchronized(true);
+ }
+ }
+ }
+
+ private DisposeOnEventDispatchThreadAction disposeOnEventDispatchThreadAction =
+ new DisposeOnEventDispatchThreadAction();
+
+ class DisposeOnEventDispatchThreadAction implements Runnable {
+ public void run() {
+ drawableHelper.invokeGL(drawable, context, disposeAction, null);
+ }
+ }
+
class InitAction implements Runnable {
public void run() {
drawableHelper.init(GLCanvas.this);
@@ -567,24 +636,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
private SwapBuffersOnEventDispatchThreadAction swapBuffersOnEventDispatchThreadAction =
new SwapBuffersOnEventDispatchThreadAction();
- class DestroyAction implements Runnable {
- public void run() {
- if(DEBUG) {
- Exception ex1 = new Exception("DestroyAction - start");
- ex1.printStackTrace();
- }
- GLContext current = GLContext.getCurrent();
- if(null!=current) {
- context.destroy();
- context = null;
- }
- if(DEBUG) {
- System.out.println("DestroyAction - end");
- }
- }
- }
- private DestroyAction destroyAction = new DestroyAction();
-
// Disables the AWT's erasing of this Canvas's background on Windows
// in Java SE 6. This internal API is not available in previous
// releases, but the system property
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index eff9b8f3f..2e7bbda64 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -204,6 +204,45 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
}
}
+ public synchronized void dispose(boolean regenerate) {
+ if(DEBUG) {
+ Exception ex1 = new Exception("dispose("+regenerate+") - start");
+ ex1.printStackTrace();
+ }
+ if (backend != null) {
+ disposeRegenerate=regenerate;
+ disposeContext=backend.getContext();
+ disposeDrawable=backend.getDrawable();
+
+ if (Threading.isSingleThreaded() &&
+ !Threading.isOpenGLThread()) {
+ // Workaround for termination issues with applets --
+ // sun.applet.AppletPanel should probably be performing the
+ // remove() call on the EDT rather than on its own thread
+ if (Threading.isAWTMode() &&
+ Thread.holdsLock(getTreeLock())) {
+ // The user really should not be invoking remove() from this
+ // thread -- but since he/she is, we can not go over to the
+ // EDT at this point. Try to destroy the context from here.
+ drawableHelper.invokeGL(disposeDrawable, disposeContext, disposeAction, null);
+ } else {
+ Threading.invokeOnOpenGLThread(disposeOnEventDispatchThreadAction);
+ }
+ } else {
+ drawableHelper.invokeGL(disposeDrawable, disposeContext, disposeAction, null);
+ }
+
+ backend.setContext(disposeContext);
+ if(null==disposeContext) {
+ isInitialized = false;
+ }
+ }
+
+ if(DEBUG) {
+ System.err.println("dispose("+regenerate+") - stop");
+ }
+ }
+
/**
* Just an alias for removeNotify
*/
@@ -286,8 +325,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
Exception ex1 = new Exception("removeNotify - start");
ex1.printStackTrace();
}
+ dispose(false);
if (backend != null) {
- drawableHelper.invokeGL(backend.getDrawable(), backend.getContext(), disposeAction, null);
backend.destroy();
backend = null;
}
@@ -407,8 +446,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return oglPipelineEnabled;
}
- public GLCapabilities getGLCapabilities() {
- return backend.getGLCapabilities();
+ public GLCapabilities getChosenGLCapabilities() {
+ return backend.getChosenGLCapabilities();
}
public final GLProfile getGLProfile() {
@@ -544,12 +583,39 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return "AWT-GLJPanel[ "+((null!=backend)?backend.getDrawable().getClass().getName():"null-drawable")+", "+drawableHelper+"]";
}
+ private boolean disposeRegenerate;
+ private GLContext disposeContext;
+ private GLDrawable disposeDrawable;
+ private DisposeAction disposeAction = new DisposeAction();
+
class DisposeAction implements Runnable {
public void run() {
updater.dispose(GLJPanel.this);
+
+ if(null!=disposeContext) {
+ disposeContext.destroy();
+ disposeContext=null;
+ }
+ if(null!=disposeDrawable) {
+ disposeDrawable.setRealized(false);
+ }
+ if(disposeRegenerate && null!=disposeDrawable) {
+ disposeDrawable.setRealized(true);
+ disposeContext = (GLContextImpl) disposeDrawable.createContext(shareWith);
+ disposeContext.setSynchronized(true);
+ }
}
}
- private DisposeAction disposeAction = new DisposeAction();
+
+ private DisposeOnEventDispatchThreadAction disposeOnEventDispatchThreadAction =
+ new DisposeOnEventDispatchThreadAction();
+
+ class DisposeOnEventDispatchThreadAction implements Runnable {
+ public void run() {
+ drawableHelper.invokeGL(disposeDrawable, disposeContext, disposeAction, null);
+ }
+ }
+
class InitAction implements Runnable {
public void run() {
@@ -628,7 +694,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
public GLDrawable getDrawable();
// Called to fetch the "real" GLCapabilities for the backend
- public GLCapabilities getGLCapabilities();
+ public GLCapabilities getChosenGLCapabilities();
// Called to fetch the "real" GLProfile for the backend
public GLProfile getGLProfile();
@@ -871,11 +937,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return offscreenDrawable;
}
- public GLCapabilities getGLCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
if (offscreenDrawable == null) {
return null;
}
- return offscreenDrawable.getGLCapabilities();
+ return offscreenDrawable.getChosenGLCapabilities();
}
public GLProfile getGLProfile() {
@@ -969,11 +1035,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return pbuffer;
}
- public GLCapabilities getGLCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
if (pbuffer == null) {
return null;
}
- return pbuffer.getGLCapabilities();
+ return pbuffer.getChosenGLCapabilities();
}
public GLProfile getGLProfile() {
@@ -1147,7 +1213,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable {
return joglDrawable;
}
- public GLCapabilities getGLCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
// FIXME: should do better than this; is it possible to using only platform-independent code?
return new GLCapabilities(null);
}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/GraphicsConfigurationFactoryImpl.java b/src/nativewindow/classes/com/sun/nativewindow/impl/GraphicsConfigurationFactoryImpl.java
index 85d50e6bd..4e8e281a8 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/GraphicsConfigurationFactoryImpl.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/GraphicsConfigurationFactoryImpl.java
@@ -38,6 +38,6 @@ public class GraphicsConfigurationFactoryImpl extends GraphicsConfigurationFacto
public AbstractGraphicsConfiguration chooseGraphicsConfiguration(Capabilities capabilities,
CapabilitiesChooser chooser,
AbstractGraphicsScreen screen) {
- return new DefaultGraphicsConfiguration(screen, capabilities);
+ return new DefaultGraphicsConfiguration(screen, capabilities, capabilities);
}
}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java
index 3d873209f..424b44c8c 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java
@@ -69,24 +69,21 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory {
private NativeWindow getAWTNativeWindow(Object winObj, AbstractGraphicsConfiguration config) {
if (nativeWindowConstructor == null) {
try {
- String osName = System.getProperty("os.name");
- String osNameLowerCase = osName.toLowerCase();
+ String osType = getNativeWindowType(false);
String windowClassName = null;
// We break compile-time dependencies on the AWT here to
// make it easier to run this code on mobile devices
- if (osNameLowerCase.startsWith("wind")) {
+ if (osType.equals(TYPE_WINDOWS)) {
windowClassName = "com.sun.nativewindow.impl.jawt.windows.WindowsJAWTWindow";
- } else if (osNameLowerCase.startsWith("mac os x")) {
+ } else if (osType.equals(TYPE_MACOSX)) {
windowClassName = "com.sun.nativewindow.impl.jawt.macosx.MacOSXJAWTWindow";
- } else {
+ } else if (osType.equals(TYPE_X11)) {
// Assume Linux, Solaris, etc. Should probably test for these explicitly.
windowClassName = "com.sun.nativewindow.impl.jawt.x11.X11JAWTWindow";
- }
-
- if (windowClassName == null) {
- throw new IllegalArgumentException("OS " + osName + " not yet supported");
+ } else {
+ throw new IllegalArgumentException("OS " + getNativeOSName(false) + " not yet supported");
}
nativeWindowConstructor = NWReflection.getConstructor(windowClassName, new Class[] { Object.class, AbstractGraphicsConfiguration.class });
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java
index e448cd5d3..46128b227 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java
@@ -39,7 +39,7 @@ package com.sun.nativewindow.impl;
import javax.media.nativewindow.*;
public class NullWindow implements NativeWindow {
- protected boolean locked;
+ private Exception lockedStack = null;
protected int width, height, scrnIndex;
protected long surfaceHandle, displayHandle;
protected AbstractGraphicsConfiguration config;
@@ -59,28 +59,34 @@ public class NullWindow implements NativeWindow {
}
public synchronized void invalidate() {
- locked = false;
displayHandle=0;
scrnIndex=-1;
surfaceHandle=0;
}
public synchronized int lockSurface() throws NativeWindowException {
- if (locked) {
- throw new NativeWindowException("Surface already locked");
+ if (null!=lockedStack) {
+ lockedStack.printStackTrace();
+ throw new NativeWindowException("Surface already locked - "+this);
}
- locked = true;
+ lockedStack = new Exception("NullWindow previously locked by "+Thread.currentThread().getName());
return LOCK_SUCCESS;
}
public synchronized void unlockSurface() {
- if (locked) {
- locked = false;
+ if (null!=lockedStack) {
+ lockedStack = null;
+ } else {
+ throw new NativeWindowException("NullWindow not locked");
}
}
public synchronized boolean isSurfaceLocked() {
- return locked;
+ return null!=lockedStack;
+ }
+
+ public Exception getLockedStack() {
+ return lockedStack;
}
public long getDisplayHandle() {
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java
index 83e8e2266..5c13ab71c 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java
@@ -55,7 +55,6 @@ public abstract class JAWTWindow implements NativeWindow {
// lifetime: forever
protected Component component;
- protected boolean locked;
protected AbstractGraphicsConfiguration config;
// lifetime: valid after lock, forever until invalidate
@@ -78,12 +77,11 @@ public abstract class JAWTWindow implements NativeWindow {
protected abstract void initNative() throws NativeWindowException;
public synchronized void invalidate() {
- locked = false;
component = null;
drawable= 0;
}
- private Exception lockedStack = null;
+ private volatile Exception lockedStack = null;
public synchronized int lockSurface() throws NativeWindowException {
if(DEBUG) {
@@ -94,19 +92,23 @@ public abstract class JAWTWindow implements NativeWindow {
throw new NativeWindowException("JAWT already locked - "+this);
}
}
+
if (null!=lockedStack) {
lockedStack.printStackTrace();
throw new NativeWindowException("Surface already locked - "+this);
}
- lockedStack = new Exception("JAWTWindow previous locked by:");
+
+ lockedStack = new Exception("JAWTWindow previously locked by "+Thread.currentThread().getName());
+
return LOCK_SUCCESS;
}
public synchronized void unlockSurface() {
if (null!=lockedStack) {
lockedStack = null;
+ // notifyAll();
} else {
- throw new RuntimeException("JAWTWindow not locked");
+ throw new NativeWindowException("JAWTWindow not locked");
}
}
@@ -154,12 +156,16 @@ public abstract class JAWTWindow implements NativeWindow {
StringBuffer sb = new StringBuffer();
sb.append("JAWT-Window[config "+config+
- ", windowHandle "+getWindowHandle()+
- ", surfaceHandle "+getSurfaceHandle()+
- ", pos "+component.getX()+"/"+component.getY()+", size "+getWidth()+"x"+getHeight()+
- ", visible "+component.isVisible()+
- ", locked "+locked+
- ", wrappedWindow "+getWrappedWindow()+"]");
+ ", windowHandle 0x"+Long.toHexString(getWindowHandle())+
+ ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle()));
+ if(null!=component) {
+ sb.append(", pos "+component.getX()+"/"+component.getY()+", size "+getWidth()+"x"+getHeight()+
+ ", visible "+component.isVisible());
+ } else {
+ sb.append(", component NULL");
+ }
+ sb.append(", locked "+isSurfaceLocked()+
+ ", wrappedWindow "+getWrappedWindow()+"]");
return sb.toString();
}
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
index ef1984474..2d85f1d4d 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java
@@ -70,6 +70,7 @@ public class MacOSXJAWTWindow extends JAWTWindow {
}
int res = ds.Lock();
if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
+ super.unlockSurface();
throw new NativeWindowException("Unable to lock surface");
}
// See whether the surface changed and if so destroy the old
@@ -127,7 +128,9 @@ public class MacOSXJAWTWindow extends JAWTWindow {
}
public void unlockSurface() throws NativeWindowException {
- if(!isSurfaceLocked()) return;
+ if(!isSurfaceLocked()) {
+ throw new RuntimeException("JAWTWindow not locked");
+ }
ds.FreeDrawingSurfaceInfo(dsi);
ds.Unlock();
JAWT.getJAWT().FreeDrawingSurface(ds);
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
index e624641cd..591213038 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java
@@ -74,6 +74,7 @@ public class WindowsJAWTWindow extends JAWTWindow {
}
int res = ds.Lock();
if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
+ super.unlockSurface();
throw new NativeWindowException("Unable to lock surface");
}
// See whether the surface changed and if so destroy the old
@@ -130,7 +131,9 @@ public class WindowsJAWTWindow extends JAWTWindow {
}
public void unlockSurface() {
- if(!isSurfaceLocked()) return;
+ if(!isSurfaceLocked()) {
+ throw new RuntimeException("JAWTWindow not locked");
+ }
long startTime = 0;
if (PROFILING) {
startTime = System.currentTimeMillis();
@@ -141,7 +144,6 @@ public class WindowsJAWTWindow extends JAWTWindow {
ds = null;
dsi = null;
win32dsi = null;
- drawable = 0;
super.unlockSurface();
if (PROFILING) {
long endTime = System.currentTimeMillis();
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java
index f53a048bf..75133488f 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java
@@ -68,6 +68,7 @@ public class X11JAWTWindow extends JAWTWindow {
}
int res = ds.Lock();
if ((res & JAWTFactory.JAWT_LOCK_ERROR) != 0) {
+ super.unlockSurface();
throw new NativeWindowException("Unable to lock surface");
}
// See whether the surface changed and if so destroy the old
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
index 1844b1c37..890f017ab 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11GraphicsConfigurationFactory.java
@@ -47,7 +47,7 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(null==screen || !(screen instanceof X11GraphicsScreen)) {
throw new NativeWindowException("Only valid X11GraphicsScreen are allowed");
}
- return new X11GraphicsConfiguration((X11GraphicsScreen)screen, capabilities, getXVisualInfo(screen, capabilities));
+ return new X11GraphicsConfiguration((X11GraphicsScreen)screen, capabilities, capabilities, getXVisualInfo(screen, capabilities));
}
public static XVisualInfo getXVisualInfo(AbstractGraphicsScreen screen, long visualID)
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java
index 1643c30d8..1c67d6184 100644
--- a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java
+++ b/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java
@@ -67,6 +67,7 @@ public class X11NativeWindowFactory extends NativeWindowFactoryImpl {
return;
}
owner = null;
+ notifyAll();
}
};
diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
index 8cf8d1b0d..e53f75251 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java
@@ -51,8 +51,20 @@ public interface AbstractGraphicsConfiguration extends Cloneable {
/**
* Return the capabilities reflecting this graphics configuration,
* which may differ from the capabilites used to choose this configuration.
+ *
+ * @return A copy of the Capabilities to avoid mutation by the user.
*/
- public Capabilities getCapabilities();
+ public Capabilities getChosenCapabilities();
+
+ /**
+ * Return the capabilities used to choose this graphics configuration.
+ *
+ * These may be used to reconfigure the NativeWindow in case
+ * the device changes in a multi screen environment.
+ *
+ * @return A copy of the Capabilities to avoid mutation by the user.
+ */
+ public Capabilities getRequestedCapabilities();
/**
* In case this instance already reflects a native configuration,
diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
index 201d2538f..6c4c93003 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
@@ -50,6 +50,13 @@ public class Capabilities implements Cloneable {
private int blueBits = 8;
private int alphaBits = 0;
+ // Support for transparent windows containing OpenGL content
+ private boolean backgroundOpaque = true;
+ private int transparentValueRed = -1;
+ private int transparentValueGreen = -1;
+ private int transparentValueBlue = -1;
+ private int transparentValueAlpha = -1;
+
/** Creates a Capabilities object. All attributes are in a default
state.
*/
@@ -63,6 +70,26 @@ public class Capabilities implements Cloneable {
}
}
+ public boolean equals(Object obj) {
+ if(!(obj instanceof Capabilities)) {
+ return false;
+ }
+ Capabilities other = (Capabilities)obj;
+ boolean res = other.getRedBits()==redBits &&
+ other.getGreenBits()==greenBits &&
+ other.getBlueBits()==blueBits &&
+ other.getAlphaBits()==alphaBits &&
+ other.isBackgroundOpaque()==backgroundOpaque;
+ if(!backgroundOpaque) {
+ res = res && other.getTransparentRedValue()==transparentValueRed &&
+ other.getTransparentGreenValue()==transparentValueGreen &&
+ other.getTransparentBlueValue()==transparentValueBlue &&
+ other.getTransparentAlphaValue()==transparentValueAlpha;
+ }
+
+ return res;
+ }
+
/** Returns the number of bits requested for the color buffer's red
component. On some systems only the color depth, which is the
sum of the red, green, and blue bits, is considered. */
@@ -119,14 +146,114 @@ public class Capabilities implements Cloneable {
this.alphaBits = alphaBits;
}
+ /** For on-screen OpenGL contexts on some platforms, sets whether
+ the background of the context should be considered opaque. On
+ supported platforms, setting this to false, in conjunction with
+ the transparency values, may allow
+ hardware-accelerated OpenGL content inside of windows of
+ arbitrary shape. To achieve this effect it is necessary to use
+ an OpenGL clear color with an alpha less than 1.0. The default
+ value for this flag is <code>true</code>; setting it to false
+ may incur a certain performance penalty, so it is not
+ recommended to arbitrarily set it to false.<br>
+ If not set already, the transparency values for red, green, blue and alpha
+ are set to their default value, which is half of the value range
+ of the framebuffer's corresponding component,
+ ie <code> redValue = ( 1 << ( redBits - 1 ) ) -1 </code>.
+ */
+ public void setBackgroundOpaque(boolean opaque) {
+ backgroundOpaque = opaque;
+ if(!opaque) {
+ if(transparentValueRed<0)
+ transparentValueRed = ( 1 << ( getRedBits() - 1 ) ) - 1 ;
+ if(transparentValueGreen<0)
+ transparentValueGreen = ( 1 << ( getGreenBits() - 1 ) ) - 1 ;
+ if(transparentValueBlue<0)
+ transparentValueBlue = ( 1 << ( getBlueBits() - 1 ) ) - 1 ;
+ if(transparentValueAlpha<0)
+ transparentValueAlpha = ( 1 << ( getAlphaBits() - 1 ) ) - 1 ;
+ }
+ }
+
+ /** Indicates whether the background of this OpenGL context should
+ be considered opaque. Defaults to true.
+
+ @see #setBackgroundOpaque
+ */
+ public boolean isBackgroundOpaque() {
+ return backgroundOpaque;
+ }
+
+ /** Gets the transparent red value for the frame buffer configuration.
+ * This value is undefined if {@link #isBackgroundOpaque()} equals true.
+ * @see #setTransparentRedValue
+ */
+ public int getTransparentRedValue() { return transparentValueRed; }
+
+ /** Gets the transparent green value for the frame buffer configuration.
+ * This value is undefined if {@link #isBackgroundOpaque()} equals true.
+ * @see #setTransparentGreenValue
+ */
+ public int getTransparentGreenValue() { return transparentValueGreen; }
+
+ /** Gets the transparent blue value for the frame buffer configuration.
+ * This value is undefined if {@link #isBackgroundOpaque()} equals true.
+ * @see #setTransparentBlueValue
+ */
+ public int getTransparentBlueValue() { return transparentValueBlue; }
+
+ /** Gets the transparent alpha value for the frame buffer configuration.
+ * This value is undefined if {@link #isBackgroundOpaque()} equals true.
+ * @see #setTransparentAlphaValue
+ */
+ public int getTransparentAlphaValue() { return transparentValueAlpha; }
+
+ /** Sets the transparent red value for the frame buffer configuration,
+ ranging from 0 to the maximum frame buffer value for red.
+ This value is ignored if {@link #isBackgroundOpaque()} equals true.<br>
+ It defaults to half of the frambuffer value for red. <br>
+ A value of -1 is interpreted as any value. */
+ public void setTransparentRedValue(int transValueRed) { transparentValueRed=transValueRed; }
+
+ /** Sets the transparent green value for the frame buffer configuration,
+ ranging from 0 to the maximum frame buffer value for green.
+ This value is ignored if {@link #isBackgroundOpaque()} equals true.<br>
+ It defaults to half of the frambuffer value for green.<br>
+ A value of -1 is interpreted as any value. */
+ public void setTransparentGreenValue(int transValueGreen) { transparentValueGreen=transValueGreen; }
+
+ /** Sets the transparent blue value for the frame buffer configuration,
+ ranging from 0 to the maximum frame buffer value for blue.
+ This value is ignored if {@link #isBackgroundOpaque()} equals true.<br>
+ It defaults to half of the frambuffer value for blue.<br>
+ A value of -1 is interpreted as any value. */
+ public void setTransparentBlueValue(int transValueBlue) { transparentValueBlue=transValueBlue; }
+
+ /** Sets the transparent alpha value for the frame buffer configuration,
+ ranging from 0 to the maximum frame buffer value for alpha.
+ This value is ignored if {@link #isBackgroundOpaque()} equals true.<br>
+ It defaults to half of the frambuffer value for alpha.<br>
+ A value of -1 is interpreted as any value. */
+ public void setTransparentAlphaValue(int transValueAlpha) { transparentValueAlpha=transValueAlpha; }
+
+
/** Returns a textual representation of this Capabilities
object. */
public String toString() {
- return getClass().toString()+"[" +
- "Red: " + redBits +
+ StringBuffer msg = new StringBuffer();
+ msg.append("Capabilities[");
+ msg.append("Red: " + redBits +
", Green: " + greenBits +
", Blue: " + blueBits +
", Alpha: " + alphaBits +
- " ]";
+ ", Opaque: " + backgroundOpaque);
+ if(!backgroundOpaque) {
+ msg.append(", Transparent RGBA: [0x"+ Integer.toHexString(transparentValueRed)+
+ " 0x"+ Integer.toHexString(transparentValueGreen)+
+ " 0x"+ Integer.toHexString(transparentValueBlue)+
+ " 0x"+ Integer.toHexString(transparentValueAlpha)+"] ");
+ }
+ msg.append("]");
+ return msg.toString();
}
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
index 4d99216f0..246aeb03e 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java
@@ -42,7 +42,7 @@ package javax.media.nativewindow;
/** Provides a mechanism by which applications can customize the
window type selection for a given {@link Capabilities}.
Developers can implement this interface and pass an instance into
- the appropriate method of {@link NativeWindowFactory}; the chooser
+ the method {@link GraphicsConfigurationFactory#chooseGraphicsConfiguration}; the chooser
will be called at window creation time, on some platforms. */
public interface CapabilitiesChooser {
@@ -56,10 +56,9 @@ public interface CapabilitiesChooser {
not necessarily required, that the chooser select that entry.
<P> <em>Note:</em> this method is called automatically by the
- {@link NativeWindowFactory} when an instance of this class is
- passed in to its {@link
- NativeWindowFactory#chooseGraphicsConfiguration
- chooseGraphicsConfiguration} method. It should generally not be
+ {@link GraphicsConfigurationFactory#chooseGraphicsConfiguration} method
+ when an instance of this class is passed in to it.
+ It should generally not be
invoked by users directly, unless it is desired to delegate the
choice to some other CapabilitiesChooser object.
*/
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
index 7aba7e171..f5448dfa7 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
@@ -34,11 +34,14 @@ package javax.media.nativewindow;
public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphicsConfiguration {
private AbstractGraphicsScreen screen;
- private Capabilities capabilities;
+ private Capabilities capabilitiesChosen;
+ private Capabilities capabilitiesRequested;
- public DefaultGraphicsConfiguration(AbstractGraphicsScreen screen, Capabilities caps) {
+ public DefaultGraphicsConfiguration(AbstractGraphicsScreen screen,
+ Capabilities capsChosen, Capabilities capsRequested) {
this.screen = screen;
- this.capabilities = caps;
+ this.capabilitiesChosen = capsChosen;
+ this.capabilitiesRequested = capsRequested;
}
public Object clone() {
@@ -53,8 +56,12 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
return screen;
}
- public Capabilities getCapabilities() {
- return (Capabilities)capabilities.clone();
+ public Capabilities getChosenCapabilities() {
+ return (Capabilities)capabilitiesChosen.clone();
+ }
+
+ public Capabilities getRequestedCapabilities() {
+ return (Capabilities)capabilitiesRequested.clone();
}
public AbstractGraphicsConfiguration getNativeGraphicsConfiguration() {
@@ -63,17 +70,31 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
/**
* Set the capabilities to a new value.
- * Despite the architecture's goal to gather this data upfront,
- * on some platforms we can gather the info only after the window creation..
- * However, if you can, please use {@link GraphicsConfigurationFactory GraphicsConfigurationFactory}.
+ *
+ * The use case for setting the Capabilities at a later time is
+ * a change of the graphics device in a multi-screen environment.<br>
+ *
+ * A copy of the passed object is being used.
*
* @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
*/
- protected void setCapabilities(Capabilities caps) {
- capabilities = (Capabilities) caps.clone();
+ protected void setChosenCapabilities(Capabilities capsChosen) {
+ capabilitiesChosen = (Capabilities) capsChosen.clone();
+ }
+
+ /**
+ * Set a new screen.
+ *
+ * the use case for setting a new screen at a later time is
+ * a change of the graphics device in a multi-screen environment.<br>
+ *
+ * A copy of the passed object is being used.
+ */
+ protected void setScreen(DefaultGraphicsScreen screen) {
+ this.screen = (AbstractGraphicsScreen) screen.clone();
}
public String toString() {
- return getClass().toString()+"[" + screen +", "+ capabilities +"]";
+ return getClass().toString()+"[" + screen +", "+ capabilitiesChosen +"]";
}
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
index ab0255c86..686360726 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
@@ -40,7 +40,7 @@ import com.sun.nativewindow.impl.*;
/**
* Provides the mechanism by which the graphics configuration for a
* given window can be chosen before the window is created. On some
- * window systems (X11 in particular) the graphics configuration
+ * window systems (EGL/OpenKODE and X11 in particular) the graphics configuration
* decides parameters related to hardware accelerated rendering such
* as the OpenGL pixel format. On these platforms it is necessary to
* choose the graphics configuration early. Note that the selection of
@@ -172,7 +172,7 @@ public abstract class GraphicsConfigurationFactory {
* Here the validation of the capabilities is performed later.
* In this case, the AbstractGraphicsConfiguration implementation
* must allow an overwrite of the Capabilites, for example
- * {@link DefaultGraphicsConfiguration#setCapabilities DefaultGraphicsConfiguration.setCapabilities()}.
+ * {@link DefaultGraphicsConfiguration#setChosenCapabilities DefaultGraphicsConfiguration.setChosenCapabilities(..)}.
* </P>
*
* <P>
@@ -183,8 +183,8 @@ public abstract class GraphicsConfigurationFactory {
* returned graphics configuration must be specified in the
* documentation binding this particular API to the underlying
* window toolkit. The Reference Implementation accepts {@link
- * AWTGraphicsDevice AWTGraphicsDevice} objects and returns {@link
- * AWTGraphicsConfiguration AWTGraphicsConfiguration} objects. On
+ * javax.media.nativewindow.awt.AWTGraphicsDevice AWTGraphicsDevice} objects and returns {@link
+ * javax.media.nativewindow.awt.AWTGraphicsConfiguration AWTGraphicsConfiguration} objects. On
* X11 platforms where the AWT is not in use, it also accepts
* {@link javax.media.nativewindow.x11.X11GraphicsDevice
* X11GraphicsDevice} objects and returns {@link
@@ -198,7 +198,7 @@ public abstract class GraphicsConfigurationFactory {
* the selection of the graphics configuration to fail.
*
* @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
- * @see javax.media.nativewindow.DefaultGraphicsConfiguration#setCapabilities(Capabilities caps)
+ * @see javax.media.nativewindow.DefaultGraphicsConfiguration#setChosenCapabilities(Capabilities caps)
*/
public abstract AbstractGraphicsConfiguration
chooseGraphicsConfiguration(Capabilities capabilities,
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
index f55815aaa..ea053e317 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
@@ -52,24 +52,53 @@ package javax.media.nativewindow;
it, and any time it is visible and locked, provide information
such as the window handle.
*/
-
public interface NativeWindow {
- public static final int LOCK_NOT_SUPPORTED = 0;
+ /** Returned by {@link #lockSurface()} if the surface is not ready to be locked. */
public static final int LOCK_SURFACE_NOT_READY = 1;
+
+ /** Returned by {@link #lockSurface()} if the surface is locked, but has changed. */
public static final int LOCK_SURFACE_CHANGED = 2;
+
+ /** Returned by {@link #lockSurface()} if the surface is locked, and is unchanged. */
public static final int LOCK_SUCCESS = 3;
/**
- * Lock this surface
+ * Lock the surface of this native window<P>
+ *
+ * The window handle, see {@link #getWindowHandle()},
+ * and the surface handle, see {@link #lockSurface()}, <br>
+ * shall be set and be valid after a successfull call,
+ * ie a return value other than {@link #LOCK_SURFACE_NOT_READY}.<P>
+ *
+ * @return {@link #LOCK_SUCCESS}, {@link #LOCK_SURFACE_CHANGED} or {@link #LOCK_SURFACE_NOT_READY}.
+ *
+ * @throws NativeWindowException if surface is already locked
*/
public int lockSurface() throws NativeWindowException ;
/**
- * Unlock this surface
+ * Unlock the surface of this native window
+ *
+ * Shall not modify the window handle, see {@link #getWindowHandle()},
+ * or the surface handle, see {@link #lockSurface()} <P>
+ *
+ * @throws NativeWindowException if surface is not locked
+ */
+ public void unlockSurface() throws NativeWindowException ;
+
+ /**
+ * Return if surface is locked
*/
- public void unlockSurface();
public boolean isSurfaceLocked();
+ /**
+ * Return the lock-exception, or null if not locked.
+ *
+ * The lock-exception is created at {@link #lockSurface()}
+ * and hence holds the locker's call stack.
+ */
+ public Exception getLockedStack();
+
/**
* render all native window information invalid,
* as if the native window was destroyed
@@ -79,6 +108,11 @@ public interface NativeWindow {
/**
* Returns the window handle for this NativeWindow. <P>
*
+ * The window handle should be set/update by {@link #lockSurface()},
+ * where {@link #unlockSurface()} is not allowed to modify it.<br>
+ * After {@link #unlockSurface()} it is no more guaranteed
+ * that the window handle is still valid.<p>
+ *
* The window handle shall reflect the platform one
* for all window related operations, e.g. open, close, resize. <P>
*
@@ -90,6 +124,11 @@ public interface NativeWindow {
/**
* Returns the handle to the surface for this NativeWindow. <P>
*
+ * The surface handle should be set/update by {@link #lockSurface()},
+ * where {@link #unlockSurface()} is not allowed to modify it.
+ * After {@link #unlockSurface()} it is no more guaranteed
+ * that the surface handle is still valid.
+ *
* The surface handle shall reflect the platform one
* for all drawable surface operations, e.g. opengl, swap-buffer. <P>
*
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
index d14800e30..5de4622f2 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java
@@ -64,88 +64,92 @@ public abstract class NativeWindowFactory {
public static final String TYPE_DEFAULT = "default";
private static NativeWindowFactory defaultFactory;
- private static Map/*<Class, NativeWindowFactory>*/ registeredFactories =
- Collections.synchronizedMap(new HashMap());
+ private static Map/*<Class, NativeWindowFactory>*/ registeredFactories;
private static Class nativeWindowClass;
- private static String nativeWindowingType=null;
+ private static String nativeWindowingTypePure;
+ private static String nativeOSNamePure;
+ private static String nativeWindowingTypeCustom;
+ private static String nativeOSNameCustom;
/** Creates a new NativeWindowFactory instance. End users do not
need to call this method. */
protected NativeWindowFactory() {
}
- private static boolean initialized = false;
- private static void initialize() {
- synchronized (NativeWindowFactory.class) {
- if (initialized) {
- return;
+ private static String _getNativeWindowingType(String osNameLowerCase) {
+ if (osNameLowerCase.startsWith("kd")) {
+ return TYPE_EGL;
+ } else if (osNameLowerCase.startsWith("wind")) {
+ return TYPE_WINDOWS;
+ } else if (osNameLowerCase.startsWith("mac os x") ||
+ osNameLowerCase.startsWith("darwin")) {
+ return TYPE_MACOSX;
+ } else if (osNameLowerCase.equals("awt")) {
+ return TYPE_AWT;
+ } else {
+ return TYPE_X11;
+ }
+ }
+
+ static {
+ // Gather the windowing OS first
+ nativeOSNamePure = System.getProperty("os.name");
+ nativeOSNameCustom = System.getProperty("nativewindow.ws.name");
+ if(null==nativeOSNameCustom||nativeOSNameCustom.length()==0) {
+ nativeOSNameCustom = nativeOSNamePure;
+ }
+ nativeWindowingTypePure = _getNativeWindowingType(nativeOSNamePure.toLowerCase());
+ nativeWindowingTypeCustom = _getNativeWindowingType(nativeOSNameCustom.toLowerCase());
+
+ registeredFactories = Collections.synchronizedMap(new HashMap());
+
+ String factoryClassName = null;
+
+ // We break compile-time dependencies on the AWT here to
+ // make it easier to run this code on mobile devices
+
+ NativeWindowFactory factory = new NativeWindowFactoryImpl();
+ nativeWindowClass = javax.media.nativewindow.NativeWindow.class;
+ registerFactory(nativeWindowClass, factory);
+ defaultFactory = factory;
+
+ Class componentClass = null;
+ try {
+ componentClass = Class.forName("java.awt.Component");
+ } catch (Exception e) { }
+
+ if(TYPE_X11.equals(nativeWindowingTypeCustom)) {
+ // Assume X11 platform -- should probably test for these explicitly
+ NativeWindowFactory _factory = null;
+ if (componentClass != null) {
+ try {
+ Constructor factoryConstructor =
+ NWReflection.getConstructor("com.sun.nativewindow.impl.x11.awt.X11AWTNativeWindowFactory", new Class[] {});
+ _factory = (NativeWindowFactory) factoryConstructor.newInstance(null);
+ } catch (Exception e) { }
+ }
+ if (null ==_factory) {
+ // Try the non-AWT X11 native window factory
+ try {
+ Constructor factoryConstructor =
+ NWReflection.getConstructor("com.sun.nativewindow.impl.x11.X11NativeWindowFactory", new Class[] {});
+ _factory = (NativeWindowFactory) factoryConstructor.newInstance(null);
+ } catch (Exception e) { }
}
- initialized = true;
-
- String factoryClassName = null;
-
- // We break compile-time dependencies on the AWT here to
- // make it easier to run this code on mobile devices
-
- NativeWindowFactory factory = new NativeWindowFactoryImpl();
- nativeWindowClass = javax.media.nativewindow.NativeWindow.class;
- registerFactory(nativeWindowClass, factory);
- defaultFactory = factory;
-
- Class componentClass = null;
- try {
- componentClass = Class.forName("java.awt.Component");
- } catch (Exception e) { }
-
- if(TYPE_X11.equals(getNativeWindowType(true))) {
- // Assume X11 platform -- should probably test for these explicitly
- NativeWindowFactory _factory = null;
- if (componentClass != null) {
- try {
- Constructor factoryConstructor =
- NWReflection.getConstructor("com.sun.nativewindow.impl.x11.awt.X11AWTNativeWindowFactory", new Class[] {});
- _factory = (NativeWindowFactory) factoryConstructor.newInstance(null);
- } catch (Exception e) { }
- }
- if (null ==_factory) {
- // Try the non-AWT X11 native window factory
- try {
- Constructor factoryConstructor =
- NWReflection.getConstructor("com.sun.nativewindow.impl.x11.X11NativeWindowFactory", new Class[] {});
- _factory = (NativeWindowFactory) factoryConstructor.newInstance(null);
- } catch (Exception e) { }
- }
- if (null !=_factory) {
- factory = _factory;
- }
+ if (null !=_factory) {
+ factory = _factory;
}
- registerFactory(componentClass, factory);
- defaultFactory = factory;
}
+ registerFactory(componentClass, factory);
+ defaultFactory = factory;
+ }
+
+ public static String getNativeOSName(boolean useCustom) {
+ return useCustom?nativeOSNameCustom:nativeOSNamePure;
}
public static String getNativeWindowType(boolean useCustom) {
- if(null==nativeWindowingType) {
- String osName = useCustom?System.getProperty("nativewindow.ws.name"):null;
- if(null==osName||osName.length()==0) {
- osName = System.getProperty("os.name");
- }
- String osNameLowerCase = osName.toLowerCase();
- String windowType;
- if (osNameLowerCase.startsWith("kd")) {
- nativeWindowingType = NativeWindowFactory.TYPE_EGL;
- } else if (osNameLowerCase.startsWith("wind")) {
- nativeWindowingType = NativeWindowFactory.TYPE_WINDOWS;
- } else if (osNameLowerCase.startsWith("mac os x") ||
- osNameLowerCase.startsWith("darwin")) {
- nativeWindowingType = NativeWindowFactory.TYPE_MACOSX;
- } else if (useCustom && osNameLowerCase.equals("awt")) {
- nativeWindowingType = NativeWindowFactory.TYPE_AWT;
- } else {
- nativeWindowingType = NativeWindowFactory.TYPE_X11;
- }
- }
- return nativeWindowingType;
+ return useCustom?nativeWindowingTypeCustom:nativeWindowingTypePure;
}
/** Sets the default NativeWindowFactory. Certain operations on
@@ -160,7 +164,6 @@ public abstract class NativeWindowFactory {
within the Java binding to OpenGL. By default, if the AWT is
available, the default toolkit will support the AWT. */
public static void setDefaultFactory(NativeWindowFactory factory) {
- initialize();
defaultFactory = factory;
}
@@ -176,7 +179,6 @@ public abstract class NativeWindowFactory {
within the Java binding to OpenGL. By default, if the AWT is
available, the default toolkit will support the AWT. */
public static NativeWindowFactory getDefaultFactory() {
- initialize();
return defaultFactory;
}
@@ -187,7 +189,6 @@ public abstract class NativeWindowFactory {
NativeWindow implementation, or it might be that of a toolkit
class like {@link java.awt.Component Component}. */
public static NativeWindowFactory getFactory(Class windowClass) throws IllegalArgumentException {
- initialize();
if (nativeWindowClass.isAssignableFrom(windowClass)) {
return (NativeWindowFactory) registeredFactories.get(nativeWindowClass);
}
@@ -206,22 +207,21 @@ public abstract class NativeWindowFactory {
given class. This does not need to be called by end users,
only implementors of new NativeWindowFactory subclasses. */
protected static void registerFactory(Class windowClass, NativeWindowFactory factory) {
- initialize();
registeredFactories.put(windowClass, factory);
}
- /** Converts the given window object and it's optional
+ /** Converts the given window object and it's
{@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration} into a
- {@link NativeWindow NativeWindow} which can be operated upon by the
- {@link GLDrawableFactory GLDrawableFactory}. The object may be a
- component for a particular window toolkit, such as an AWT
- Canvas. In this case {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration}
- must be valid. It may also be a NativeWindow object, in which no
- conversion is necessary and {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration}
- will be ignored. The particular implementation of the
+ {@link NativeWindow NativeWindow} which can be operated upon by a custom
+ toolkit, e.g. {@link javax.media.opengl.GLDrawableFactory javax.media.opengl.GLDrawableFactory}.<br>
+ The object may be a component for a particular window toolkit, such as an AWT
+ Canvas. It may also be a NativeWindow object itself.<br>
+ You shall utilize {@link javax.media.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}
+ to construct a proper {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration}.<br>
+ The particular implementation of the
NativeWindowFactory is responsible for handling objects from a
particular window toolkit. The built-in NativeWindowFactory
- handles NativeWindow instances as well as AWT Components.
+ handles NativeWindow instances as well as AWT Components.<br>
@throws IllegalArgumentException if the given window object
could not be handled by any of the registered
diff --git a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
index 89af0c6f6..56d5c5ce9 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/awt/AWTGraphicsConfiguration.java
@@ -41,7 +41,10 @@ package javax.media.nativewindow.awt;
import javax.media.nativewindow.*;
import java.awt.GraphicsConfiguration;
+import java.awt.Transparency;
+import java.awt.image.ColorModel;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import com.sun.nativewindow.impl.Debug;
/** A wrapper for an AWT GraphicsConfiguration allowing it to be
handled in a toolkit-independent manner. */
@@ -50,14 +53,16 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
private GraphicsConfiguration config;
AbstractGraphicsConfiguration encapsuled;
- public AWTGraphicsConfiguration(AWTGraphicsScreen screen, Capabilities caps, GraphicsConfiguration config, AbstractGraphicsConfiguration encapsuled) {
- super(screen, caps);
+ public AWTGraphicsConfiguration(AWTGraphicsScreen screen,
+ Capabilities capsChosen, Capabilities capsRequested,
+ GraphicsConfiguration config, AbstractGraphicsConfiguration encapsuled) {
+ super(screen, capsChosen, capsRequested);
this.config = config;
this.encapsuled=encapsuled;
}
- public AWTGraphicsConfiguration(AWTGraphicsScreen screen, Capabilities caps, GraphicsConfiguration config) {
- super(screen, caps);
+ public AWTGraphicsConfiguration(AWTGraphicsScreen screen, Capabilities capsChosen, Capabilities capsRequested, GraphicsConfiguration config) {
+ super(screen, capsChosen, capsRequested);
this.config = config;
this.encapsuled=null;
}
@@ -74,7 +79,46 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple
return (null!=encapsuled)?encapsuled:this;
}
+ /**
+ * Setup the Capabilities RGBA size in regard to the given GraphicsConfiguration ColorModel
+ */
+ public static Capabilities SetupCapabilitiesPixelformat(Capabilities capabilities, GraphicsConfiguration gc) {
+ int cmTransparency = capabilities.isBackgroundOpaque()?Transparency.OPAQUE:Transparency.TRANSLUCENT;
+ ColorModel cm = gc.getColorModel(cmTransparency);
+ if(null==cm && !capabilities.isBackgroundOpaque()) {
+ capabilities.setBackgroundOpaque(true);
+ cmTransparency = Transparency.OPAQUE;
+ cm = gc.getColorModel(cmTransparency);
+ }
+ if(null==cm) {
+ throw new NativeWindowException("Could not determine AWT ColorModel");
+ }
+ int cmBitsPerPixel = cm.getPixelSize();
+ int bitsPerPixel = 0;
+ int[] bitesPerComponent = cm.getComponentSize();
+ if(bitesPerComponent.length>=3) {
+ capabilities.setRedBits(bitesPerComponent[0]);
+ bitsPerPixel += bitesPerComponent[0];
+ capabilities.setGreenBits(bitesPerComponent[1]);
+ bitsPerPixel += bitesPerComponent[1];
+ capabilities.setBlueBits(bitesPerComponent[2]);
+ bitsPerPixel += bitesPerComponent[2];
+ }
+ if(bitesPerComponent.length>=4) {
+ capabilities.setAlphaBits(bitesPerComponent[3]);
+ bitsPerPixel += bitesPerComponent[3];
+ } else {
+ capabilities.setAlphaBits(0);
+ }
+ if(Debug.debugAll()) {
+ if(cmBitsPerPixel!=bitsPerPixel) {
+ System.err.println("AWT Colormodel bits per components/pixel mismatch: "+bitsPerPixel+" != "+cmBitsPerPixel);
+ }
+ }
+ return capabilities;
+ }
+
public String toString() {
- return getClass().toString()+"[" + getScreen() + ", " + getCapabilities() + ", " + config +", encapsuled "+encapsuled+"]";
+ return getClass().toString()+"[" + getScreen() + ", " + getChosenCapabilities() + ", " + config +", encapsuled "+encapsuled+"]";
}
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/package.html b/src/nativewindow/classes/javax/media/nativewindow/package.html
new file mode 100644
index 000000000..ce9dbbb7a
--- /dev/null
+++ b/src/nativewindow/classes/javax/media/nativewindow/package.html
@@ -0,0 +1,111 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>NativeWindow Protocol Draft Public Review Specification</title>
+</head>
+ <body>
+
+<h2><i>NativeWindow Protocol</i> Specification Overview</h2>
+
+<h3>Preface</h3>
+ This specification, an optional set of packages, describing a <i>protocol</i> for a
+ <i>native windowing interface</i> binding to Java(TM).<br>
+ Currently specified <i>native windowing systems</i> are:<br><br>
+ <ul>
+ <li> EGL/OpenKODE Windowing System</li>
+ <li> X11 Windowing System</li>
+ <li> Microsoft Windows</li>
+ <li> Apple MacOSX</li>
+ <li> Java's AWT</li>
+ </ul>
+ <br>
+ However, any other native windowing system may be added to the implementation,
+ using a generic string identifier and an optional specialisation of:<br><br>
+ <ul>
+ <li>{@link javax.media.nativewindow.AbstractGraphicsDevice AbstractGraphicsDevice},<br>
+ <br>
+ Shall return the new string identifier with {@link javax.media.nativewindow.AbstractGraphicsDevice#getType() getType()}</li><br>
+ <li>{@link javax.media.nativewindow.AbstractGraphicsScreen AbstractGraphicsScreen}</li>
+ <li>{@link javax.media.nativewindow.AbstractGraphicsConfiguration AbstractGraphicsConfiguration}</li><br>
+ </ul>
+ <br>
+ The implementor has to provide the following:<br><br>
+ <ul>
+ <li> The specialisation of the abstract class {@link javax.media.nativewindow.NativeWindowFactory NativeWindowFactory}<br>
+ <br>
+ shall be registered with {@link javax.media.nativewindow.NativeWindowFactory#registerFactory NativeWindowFactory.registerFactory(..)}.</li><br>
+
+ <li> The specialisation of the abstract class {@link javax.media.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory}<br>
+ <br>
+ shall be registered with {@link javax.media.nativewindow.GraphicsConfigurationFactory#registerFactory GraphicsConfigurationFactory.registerFactory(..)}.</li><br>
+ </ul><br>
+ This protocol <i>does not</i> describe how to <i>create</i> native windows, but how to <i>bind</i> a native window to an implementation of
+ {@link javax.media.nativewindow.NativeWindow NativeWindow}.<br>
+ However, an implementation of this protocol (e.g. {@link com.sun.javafx.newt}) may support the creation.<br>
+
+<h3>Dependencies</h3>
+ This binding has dependencies to the following:<br><br>
+ <ul>
+ <li> Either of the following Java implementations:<br>
+ <ul>
+ <li> <a href="http://java.sun.com/j2se/1.4.2/docs/api/">Java SE 1.4 or later</a> </li><br>
+ <li> <a href="http://java.sun.com/javame/technology/cdc/">Java ME CDC 1.1.2 (JSR 218)</a> and
+ <a href="http://java.sun.com/products/foundation/">Foundation Profile 1.1.2 (JSR 219)</a><br>
+ and either of the following <i>java.nio</i> implementations:<br>
+ <ul>
+ <li> <a href="http://java.sun.com/javame/reference/apis/jsr239/java/nio/package-summary.html"> JSR239 <i>java.nio</i> subset</a> </li>
+ <li> <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/package-summary.html"> Java 1.4 <i>java.nio</i> implementation</a> </li>
+ </ul><br>
+ </ul>
+ </ul>
+ <br>
+
+<h3>Package Structure</h3>
+ The packages defined by this specification include:<br><br>
+<ul>
+ <li>The <b>javax.media.nativewindow</b> package<br>
+ <br>
+ This package contains Java bindings for a native windowing system.<br>
+ Subsequent packages contain marker type classes, containing native characteristics of the windowing system.</li><br><br>
+ <ul>
+ <li>The <b>javax.media.nativewindow.awt</b> package<br>
+ <br>
+ This sub package contains classes to cover the native characteristics of the AWT windowing system.</li><br>
+
+ <li>The <b>javax.media.nativewindow.x11</b> package<br>
+ <br>
+ This sub package contains classes to cover the native characteristics of the X11 windowing system.</li><br>
+
+ <li>The <b>javax.media.nativewindow.windows</b> package<br>
+ <br>
+ This sub package contains classes to cover the native characteristics of the Windows windowing system.</li><br>
+
+ <li>The <b>javax.media.nativewindow.macosx</b> package<br>
+ <br>
+ This sub package contains classes to cover the native characteristics of the MacOSX windowing system.</li><br>
+
+ <li>The <b>javax.media.nativewindow.egl</b> package<br>
+ <br>
+ This sub package contains classes to cover the native characteristics of the EGL/OpenKODE windowing system.</li><br>
+ </ul>
+</ul>
+
+<h3>Factory Model</h3>
+Running on a platform with a supported windowing system, the factory model shall be used
+to instantiate a native window, see {@link javax.media.nativewindow.NativeWindowFactory NativeWindowFactory}.<br>
+The implementor has to specialize
+All supported
+Regardless of the knowledge of the underly
+<br>
+
+<h3>Revision History<br>
+ </h3>
+
+<ul>
+<li> Early Draft Review, June 2009
+</ul>
+ <br>
+ <br>
+ <br>
+</body>
+</html>
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java
index 8784033bc..9c2351cc4 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsConfiguration.java
@@ -37,15 +37,17 @@ import com.sun.nativewindow.impl.x11.XVisualInfo;
/** Encapsulates a graphics configuration, or OpenGL pixel format, on
X11 platforms. Objects of this type are returned from {@link
- NativeWindowFactory#chooseGraphicsConfiguration
- NativeWindowFactory.chooseGraphicsConfiguration()} on X11
+ javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration
+ GraphicsConfigurationFactory.chooseGraphicsConfiguration()} on X11
platforms when toolkits other than the AWT are being used. */
public class X11GraphicsConfiguration extends DefaultGraphicsConfiguration implements Cloneable {
private XVisualInfo info;
- public X11GraphicsConfiguration(X11GraphicsScreen screen, Capabilities caps, XVisualInfo info) {
- super(screen, caps);
+ public X11GraphicsConfiguration(X11GraphicsScreen screen,
+ Capabilities capsChosen, Capabilities capsRequested,
+ XVisualInfo info) {
+ super(screen, capsChosen, capsRequested);
this.info = info;
}
@@ -57,11 +59,15 @@ public class X11GraphicsConfiguration extends DefaultGraphicsConfiguration imple
return info;
}
+ protected void setXVisualInfo(XVisualInfo info) {
+ this.info = info;
+ }
+
public long getVisualID() {
return (null!=info)?info.visualid():0;
}
public String toString() {
- return getClass().toString()+"["+getScreen()+", visualID 0x" + Long.toHexString(getVisualID()) + ", " + getCapabilities() +"]";
+ return getClass().toString()+"["+getScreen()+", visualID 0x" + Long.toHexString(getVisualID()) + ", " + getChosenCapabilities() +"]";
}
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
index 1dcc7f026..afee33688 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/x11/X11GraphicsScreen.java
@@ -38,8 +38,8 @@ import com.sun.nativewindow.impl.x11.*;
/** Encapsulates a screen index on X11
platforms. Objects of this type are passed to {@link
- NativeWindowFactory#chooseGraphicsConfiguration
- NativeWindowFactory.chooseGraphicsConfiguration()} on X11
+ javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration
+ GraphicsConfigurationFactory.chooseGraphicsConfiguration()} on X11
platforms when toolkits other than the AWT are being used. */
public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneable {
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
index d55829a5d..10a31f451 100755
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/Window.java
@@ -181,7 +181,7 @@ public abstract class Window implements NativeWindow
for (Iterator iter = keyListeners.iterator(); iter.hasNext(); ) {
sb.append(iter.next()+", ");
}
- sb.append("]");
+ sb.append("] ]");
return sb.toString();
}
@@ -189,7 +189,7 @@ public abstract class Window implements NativeWindow
protected AbstractGraphicsConfiguration config;
protected long windowHandle;
- protected boolean locked=false;
+ protected Exception lockedStack = null;
protected boolean fullscreen, visible;
protected int width, height, x, y;
protected int eventMask;
@@ -220,23 +220,29 @@ public abstract class Window implements NativeWindow
// NativeWindow impl
//
- public int lockSurface() throws NativeWindowException {
- if (locked) {
- throw new NativeWindowException("Surface already locked");
+ public synchronized int lockSurface() throws NativeWindowException {
+ if (null!=lockedStack) {
+ lockedStack.printStackTrace();
+ throw new NativeWindowException("Surface already locked - "+this);
}
- // locked = true;
- // return LOCK_SUCCESS;
- return LOCK_NOT_SUPPORTED;
+ lockedStack = new Exception("NEWT-Window previously locked by "+Thread.currentThread().getName());
+ return LOCK_SUCCESS;
}
- public void unlockSurface() {
- if (locked) {
- locked = false;
+ public synchronized void unlockSurface() {
+ if (null!=lockedStack) {
+ lockedStack = null;
+ } else {
+ throw new NativeWindowException("NEWT-Window not locked");
}
}
- public boolean isSurfaceLocked() {
- return locked;
+ public synchronized boolean isSurfaceLocked() {
+ return null!=lockedStack;
+ }
+
+ public synchronized Exception getLockedStack() {
+ return lockedStack;
}
public synchronized void destroy() {
@@ -258,10 +264,8 @@ public abstract class Window implements NativeWindow
}
public void invalidate(boolean internal) {
- unlockSurface();
screen = null;
windowHandle = 0;
- locked = false;
fullscreen=false;
visible=false;
eventMask = 0;
diff --git a/src/newt/classes/com/sun/javafx/newt/WindowEvent.java b/src/newt/classes/com/sun/javafx/newt/WindowEvent.java
index 634672f32..c5aa65e3d 100644
--- a/src/newt/classes/com/sun/javafx/newt/WindowEvent.java
+++ b/src/newt/classes/com/sun/javafx/newt/WindowEvent.java
@@ -39,6 +39,7 @@ public class WindowEvent extends Event {
public static final int EVENT_WINDOW_DESTROY_NOTIFY = 102;
public static final int EVENT_WINDOW_GAINED_FOCUS = 103;
public static final int EVENT_WINDOW_LOST_FOCUS = 104;
+ // public static final int EVENT_WINDOW_REPAINT = 105; // TODO
public WindowEvent(int eventType, Window source, long when) {
this(false, eventType, source, when);
@@ -55,6 +56,7 @@ public class WindowEvent extends Event {
case EVENT_WINDOW_DESTROY_NOTIFY: return "EVENT_WINDOW_DESTROY_NOTIFY";
case EVENT_WINDOW_GAINED_FOCUS: return "EVENT_WINDOW_GAINED_FOCUS";
case EVENT_WINDOW_LOST_FOCUS: return "EVENT_WINDOW_LOST_FOCUS";
+ // case EVENT_WINDOW_REPAINT: return "EVENT_WINDOW_REPAINT";
default: return "unknown (" + type + ")";
}
}
diff --git a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java b/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
index 6c20cfbcf..cb8c56d55 100644
--- a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
@@ -67,6 +67,7 @@ public class AWTWindow extends Window {
private boolean gotDisplaySize;
private int displayWidth;
private int displayHeight;
+ private volatile boolean awtCreated=false;
public void setTitle(String title) {
super.setTitle(title);
@@ -75,28 +76,47 @@ public class AWTWindow extends Window {
}
}
+ Object syncObj = new Object();
+
protected void createNative(Capabilities caps) {
config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen());
if (config == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
+
runOnEDT(new Runnable() {
public void run() {
- frame = new Frame(getTitle());
- frame.setUndecorated(isUndecorated());
- frame.setLayout(new BorderLayout());
- canvas = new Canvas();
- Listener listener = new Listener();
- canvas.addMouseListener(listener);
- canvas.addMouseMotionListener(listener);
- canvas.addKeyListener(listener);
- canvas.addComponentListener(listener);
- frame.add(canvas, BorderLayout.CENTER);
- frame.setSize(width, height);
- frame.setLocation(x, y);
- frame.addComponentListener(new MoveListener());
+ synchronized (syncObj) {
+ frame = new Frame(getTitle());
+ frame.setUndecorated(isUndecorated());
+ frame.setLayout(new BorderLayout());
+ canvas = new Canvas( ((AWTGraphicsConfiguration) config).getGraphicsConfiguration() );
+ Listener listener = new Listener();
+ canvas.addMouseListener(listener);
+ canvas.addMouseMotionListener(listener);
+ canvas.addKeyListener(listener);
+ canvas.addComponentListener(listener);
+ frame.add(canvas, BorderLayout.CENTER);
+ frame.setSize(width, height);
+ frame.setLocation(x, y);
+ frame.addComponentListener(new MoveListener());
+ frame.addWindowListener(new WindowEventListener());
+ awtCreated=true;
+ syncObj.notifyAll();
+ }
}
});
+
+ // make sure we are finished ..
+ while(!awtCreated) {
+ synchronized (syncObj) {
+ if(!awtCreated) {
+ try {
+ syncObj.wait();
+ } catch (InterruptedException e) {}
+ }
+ }
+ }
}
protected void closeNative() {
@@ -179,6 +199,7 @@ public class AWTWindow extends Window {
switch (w.getType()) {
case com.sun.javafx.newt.WindowEvent.EVENT_WINDOW_RESIZED:
case com.sun.javafx.newt.WindowEvent.EVENT_WINDOW_MOVED:
+ case com.sun.javafx.newt.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY:
if ((eventMask & com.sun.javafx.newt.EventListener.WINDOW) != 0) {
sendWindowEvent(w.getType());
}
@@ -360,4 +381,22 @@ public class AWTWindow extends Window {
enqueueEvent(com.sun.javafx.newt.KeyEvent.EVENT_KEY_TYPED, e);
}
}
+
+ class WindowEventListener implements WindowListener {
+ public void windowActivated(WindowEvent e) {
+ }
+ public void windowClosed(WindowEvent e) {
+ }
+ public void windowClosing(WindowEvent e) {
+ enqueueEvent(com.sun.javafx.newt.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY, null);
+ }
+ public void windowDeactivated(WindowEvent e) {
+ }
+ public void windowDeiconified(WindowEvent e) {
+ }
+ public void windowIconified(WindowEvent e) {
+ }
+ public void windowOpened(WindowEvent e) {
+ }
+ }
}
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
index ec7458539..f769aed27 100644
--- a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
@@ -91,7 +91,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
}
public void windowDestroyNotify(WindowEvent e) {
- sendDispose = true;
+ sendDestroy = true;
}
});
}
@@ -151,9 +151,9 @@ public class GLWindow extends Window implements GLAutoDrawable {
shouldNotCallThis();
}
- public synchronized void destroy() {
- if(Window.DEBUG_WINDOW_EVENT) {
- Exception e1 = new Exception("GLWindow.destroy 1: "+this);
+ public synchronized void dispose(boolean regenerate) {
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ Exception e1 = new Exception("GLWindow.destroy("+regenerate+") 1: "+this);
e1.printStackTrace();
}
@@ -166,6 +166,27 @@ public class GLWindow extends Window implements GLAutoDrawable {
drawable.setRealized(false);
}
+ if(regenerate) {
+ drawable.setRealized(true);
+ if(getSurfaceHandle()==0) {
+ throw new GLException("SurfaceHandle==NULL after setRealize(true) "+this);
+ }
+ context = drawable.createContext(null);
+ }
+
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ System.out.println("GLWindow.dispose("+regenerate+") fin: "+this);
+ }
+ }
+
+ public synchronized void destroy() {
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
+ Exception e1 = new Exception("GLWindow.destroy 1: "+this);
+ e1.printStackTrace();
+ }
+
+ dispose(false);
+
Screen _screen = null;
Display _device = null;
if(null!=window) {
@@ -178,7 +199,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
window.destroy();
}
- if(Window.DEBUG_WINDOW_EVENT) {
+ if(Window.DEBUG_WINDOW_EVENT || window.DEBUG_IMPLEMENTATION) {
System.out.println("GLWindow.destroy fin: "+this);
}
@@ -271,10 +292,13 @@ public class GLWindow extends Window implements GLAutoDrawable {
if (window.getWrappedWindow() != null) {
nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), nw.getGraphicsConfiguration());
}
- factory = GLDrawableFactory.getFactory(nw);
+ GLCapabilities glCaps = (GLCapabilities) nw.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities();
+ factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
drawable = factory.createGLDrawable(nw);
- window.setVisible(true);
drawable.setRealized(true);
+ if(getSurfaceHandle()==0) {
+ throw new GLException("SurfaceHandle==NULL after setRealize(true) "+this);
+ }
context = drawable.createContext(null);
}
}
@@ -372,7 +396,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
}
public String toString() {
- return "NEWT-GLWindow[ "+drawable+", "+helper+", "+factory+"]";
+ return "NEWT-GLWindow[ "+drawable+", \n\t"+window+", \n\t"+helper+", \n\t"+factory+"]";
}
//----------------------------------------------------------------------
@@ -386,7 +410,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
private GLDrawableHelper helper = new GLDrawableHelper();
// To make reshape events be sent immediately before a display event
private boolean sendReshape=false;
- private boolean sendDispose=false;
+ private boolean sendDestroy=false;
private boolean perfLog = false;
public GLDrawableFactory getFactory() {
@@ -423,11 +447,11 @@ public class GLWindow extends Window implements GLAutoDrawable {
}
public void display() {
- if(window.getSurfaceHandle()!=0) {
+ if(getSurfaceHandle()!=0) {
pumpMessages();
- if (sendDispose) {
+ if (sendDestroy) {
destroy();
- sendDispose=false;
+ sendDestroy=false;
} else {
helper.invokeGL(drawable, context, displayAction, initAction);
}
@@ -435,7 +459,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
}
private void sendDisposeEvent() {
- if(disposeAction!=null && drawable!=null && context != null && window!=null && window.getSurfaceHandle()!=0) {
+ if(disposeAction!=null && drawable!=null && context != null && window!=null && getSurfaceHandle()!=0) {
helper.invokeGL(drawable, context, disposeAction, null);
}
}
@@ -449,7 +473,7 @@ public class GLWindow extends Window implements GLAutoDrawable {
}
public void swapBuffers() {
- if(window.getSurfaceHandle()!=0) {
+ if(getSurfaceHandle()!=0) {
if (context != null && context != GLContext.getCurrent()) {
// Assume we should try to make the context current before swapping the buffers
helper.invokeGL(drawable, context, swapBuffersAction, initAction);
@@ -531,6 +555,44 @@ public class GLWindow extends Window implements GLAutoDrawable {
private SwapBuffersAction swapBuffersAction = new SwapBuffersAction();
//----------------------------------------------------------------------
+ // GLDrawable methods
+ //
+
+ public NativeWindow getNativeWindow() {
+ return null!=drawable ? drawable.getNativeWindow() : null;
+ }
+
+ public synchronized int lockSurface() throws NativeWindowException {
+ if(null!=drawable) return drawable.getNativeWindow().lockSurface();
+ return NativeWindow.LOCK_SURFACE_NOT_READY;
+ }
+
+ public synchronized void unlockSurface() {
+ if(null!=drawable) drawable.getNativeWindow().unlockSurface();
+ else throw new NativeWindowException("NEWT-GLWindow not locked");
+ }
+
+ public synchronized boolean isSurfaceLocked() {
+ if(null!=drawable) return drawable.getNativeWindow().isSurfaceLocked();
+ return false;
+ }
+
+ public synchronized Exception getLockedStack() {
+ if(null!=drawable) return drawable.getNativeWindow().getLockedStack();
+ return null;
+ }
+
+ public long getWindowHandle() {
+ if(null!=drawable) return drawable.getNativeWindow().getWindowHandle();
+ return super.getWindowHandle();
+ }
+
+ public long getSurfaceHandle() {
+ if(null!=drawable) return drawable.getNativeWindow().getSurfaceHandle();
+ return super.getSurfaceHandle();
+ }
+
+ //----------------------------------------------------------------------
// GLDrawable methods that are not really needed
//
@@ -541,12 +603,12 @@ public class GLWindow extends Window implements GLAutoDrawable {
public void setRealized(boolean realized) {
}
- public GLCapabilities getGLCapabilities() {
+ public GLCapabilities getChosenGLCapabilities() {
if (drawable == null) {
throw new GLException("No drawable yet");
}
- return drawable.getGLCapabilities();
+ return drawable.getChosenGLCapabilities();
}
public GLProfile getGLProfile() {
@@ -557,10 +619,6 @@ public class GLWindow extends Window implements GLAutoDrawable {
return drawable.getGLProfile();
}
- public NativeWindow getNativeWindow() {
- return drawable.getNativeWindow();
- }
-
//----------------------------------------------------------------------
// Internals only below this point
//
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java
index e5a34a264..587bf185e 100755
--- a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java
@@ -63,8 +63,8 @@ public class KDWindow extends Window {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
- GLCapabilities eglCaps = (GLCapabilities)config.getCapabilities();
- int[] eglAttribs = EGLGraphicsConfiguration.GLCapabilities2AttribList(eglCaps);
+ GLCapabilities eglCaps = (GLCapabilities)config.getChosenCapabilities();
+ int[] eglAttribs = EGLGraphicsConfiguration.GLCapabilities2AttribList(eglCaps, EGL.EGL_WINDOW_BIT);
windowHandle = 0;
windowID = ++_windowID;
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index dbfa0017e..ba4cf14bd 100755
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -526,7 +526,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_DispatchMessages
case Expose:
if(evt.xexpose.window==w) {
DBG_PRINT( "event . Expose call 0x%X\n", evt.xexpose.window);
- (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) evt.xexpose.width, (jint) evt.xexpose.height);
+ /* FIXME: Might want to send a repaint event .. */
}
break;
case UnmapNotify: