diff options
Diffstat (limited to 'src/jogl/classes')
10 files changed, 77 insertions, 11 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index fed55aeef..4fbd0e478 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -41,7 +41,6 @@ package com.jogamp.opengl.util; import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLException; /** <P> An Animator can be attached to one or more {@link @@ -125,11 +124,15 @@ public class Animator extends AnimatorBase { } class MainLoop implements Runnable { + public String toString() { + return "[started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", frames "+getTotalFrames()+", drawable "+drawables.size()+"]"; + } + public void run() { try { synchronized (Animator.this) { if(DEBUG) { - System.err.println("Animator started: "+Thread.currentThread()); + System.err.println("Animator start:" + Thread.currentThread() + ": " + toString()); } startTime = System.currentTimeMillis(); @@ -147,7 +150,7 @@ public class Animator extends AnimatorBase { while (!stopIssued && (pauseIssued || drawablesEmpty)) { boolean wasPaused = pauseIssued; if (DEBUG) { - System.err.println("Animator paused: " + Thread.currentThread()); + System.err.println("Animator pause:" + Thread.currentThread() + ": " + toString()); } setIsAnimatingSynced(false); // barrier Animator.this.notifyAll(); @@ -162,7 +165,7 @@ public class Animator extends AnimatorBase { curTime = startTime; totalFrames = 0; if (DEBUG) { - System.err.println("Animator resume: " + Thread.currentThread()); + System.err.println("Animator resume:" + Thread.currentThread() + ": " + toString()); } } } @@ -184,7 +187,7 @@ public class Animator extends AnimatorBase { } finally { synchronized (Animator.this) { if(DEBUG) { - System.err.println("Animator stopped: "+Thread.currentThread()); + System.err.println("Animator stop " + Thread.currentThread() + ": " + toString()); } stopIssued = false; pauseIssued = false; diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index 4a8579767..01c2ea664 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -111,7 +111,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { public synchronized void remove(GLAutoDrawable drawable) { if(DEBUG) { - System.err.println("Animator remove: "+drawable.hashCode()+" - "+Thread.currentThread()); + System.err.println("Animator remove: "+drawable.hashCode()+" - "+Thread.currentThread() + ": "+toString()); } boolean paused = pause(); diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 395ee3704..c433e8b68 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -52,6 +52,7 @@ import com.jogamp.common.util.ReflectionUtil; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.ProxySurface; /** <P> Provides a virtual machine- and operating system-independent mechanism for creating {@link GLDrawable}s. </P> @@ -425,6 +426,23 @@ public abstract class GLDrawableFactory { int width, int height); /** + * Highly experimental API entry, allowing developer of new windowing system bindings + * to leverage the native window handle to produce a NativeSurface implementation (ProxySurface), having the required GLCapabilities.<br> + * Such surface can be used to instantiate a GLDrawable and hence test your new binding w/o the + * costs of providing a full set of abstraction like the AWT GLCanvas or even the native NEWT bindings. + * + * @param device the platform's target device, shall not be <code>null</code> + * @param windowHandle the native window handle + * @param caps the requested GLCapabilties + * @param chooser the custom chooser, may be null for default + * @return The proxy surface wrapping the windowHandle on the device + */ + public abstract ProxySurface createProxySurface(AbstractGraphicsDevice device, + long windowHandle, + GLCapabilitiesImmutable caps, + GLCapabilitiesChooser chooser); + + /** * Returns true if it is possible to create a GLPbuffer. Some older * graphics cards do not have this capability. * diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 585590170..e04ced6fa 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -232,6 +232,21 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { GLCapabilitiesChooser chooser, int width, int height); + public ProxySurface createProxySurface(AbstractGraphicsDevice device, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { + if(null == device) { + throw new GLException("No shared device for requested: "+device); + } + + device.lock(); + try { + return createProxySurfaceImpl(device, windowHandle, capsRequested, chooser); + } finally { + device.unlock(); + } + } + + protected abstract ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice device, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser); + //--------------------------------------------------------------------------- // // External GLDrawable construction diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index f81e5a70e..b6599de1b 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -225,6 +225,11 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return ns; } + protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice device, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { + WrappedSurface ns = new WrappedSurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(device, capsRequested, capsRequested, chooser), windowHandle); + return ns; + } + protected GLContext createExternalGLContextImpl() { AbstractGraphicsScreen absScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_EGL); return new EGLExternalContext(absScreen); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index fa0a0b6ed..6ce793490 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -173,6 +173,12 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { return ns; } + protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice device, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { + AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + WrappedSurface ns = new WrappedSurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, true), windowHandle); + return ns; + } + protected GLContext createExternalGLContextImpl() { return MacOSXExternalCGLContext.create(this, null); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java index c839c87f1..55d3a0853 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java @@ -39,11 +39,8 @@ package jogamp.opengl.macosx.cgl; -import java.util.*; -import javax.media.nativewindow.*; import javax.media.opengl.*; -import jogamp.opengl.*; public class MacOSXOnscreenCGLContext extends MacOSXCGLContext { @@ -52,21 +49,25 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext { super(drawable, shareWith); } + @Override protected void makeCurrentImpl(boolean newCreated) throws GLException { super.makeCurrentImpl(newCreated); CGL.updateContext(contextHandle); } + @Override protected void releaseImpl() throws GLException { super.releaseImpl(); } + @Override protected void swapBuffers() { if (!CGL.flushBuffer(contextHandle)) { throw new GLException("Error swapping buffers"); } } + @Override protected void update() throws GLException { if (contextHandle == 0) { throw new GLException("Context not created"); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java index bd311217d..513dc3a04 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java @@ -41,12 +41,10 @@ package jogamp.opengl.macosx.cgl; import java.lang.ref.WeakReference; -import java.security.*; import java.util.*; import javax.media.nativewindow.*; import javax.media.opengl.*; -import jogamp.opengl.*; public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable { private List/*<WeakReference<GLContext>>*/ createdContexts = diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 5afbb9218..3cbef2569 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -65,6 +65,7 @@ import javax.media.opengl.GLProfile; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.util.ReflectionUtil; +import javax.media.opengl.GLCapabilities; import jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.GDISurface; @@ -445,6 +446,15 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { return ns; } + protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice adevice, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { + // FIXME device/windowHandle -> screen ?! + WindowsGraphicsDevice device = (WindowsGraphicsDevice) adevice; + AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); + GDISurface ns = new GDISurface(cfg, windowHandle); + return ns; + } + protected final GLContext createExternalGLContextImpl() { return WindowsExternalWGLContext.create(this, null); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 755c078b9..8203a440c 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -177,6 +177,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { try { String glXVendorName = GLXUtil.getVendorName(sharedDevice.getHandle()); X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, 0); + if (null == sharedScreen) { throw new GLException("Couldn't create shared screen for device: "+sharedDevice+", idx 0"); } @@ -407,6 +408,15 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { return ns; } + protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice adevice, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { + // FIXME device/windowHandle -> screen ?! + X11GraphicsDevice device = (X11GraphicsDevice) adevice; + X11GraphicsScreen screen = new X11GraphicsScreen(device, 0); + X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); + WrappedSurface ns = new WrappedSurface(cfg, windowHandle); + return ns; + } + protected final GLContext createExternalGLContextImpl() { return X11ExternalGLXContext.create(this, null); } |