diff options
Diffstat (limited to 'src/jogl/classes/com/sun')
-rw-r--r-- | src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java | 21 | ||||
-rwxr-xr-x | src/jogl/classes/com/sun/opengl/util/Animator.java | 34 |
2 files changed, 42 insertions, 13 deletions
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 add5c7b25..229042d9d 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 @@ -111,7 +111,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio long hdc = nativeWindow.getSurfaceHandle(); if (DEBUG) { - Exception ex = new Exception("WindowsWGLGraphicsConfigurationFactory got HDC 0x"+Long.toHexString(hdc)); + Exception ex = new Exception("WindowsWGLGraphicsConfigurationFactory got HDC "+toHexString(hdc)); ex.printStackTrace(); System.err.println("WindowsWGLGraphicsConfigurationFactory got NW "+nativeWindow); } @@ -128,7 +128,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio // - the graphics driver, copying the HDC's pixelformat to the new one, // - or the Java2D/OpenGL pipeline's configuration if (DEBUG) { - System.err.println("!!!! NOTE: pixel format already chosen for HDC: 0x" + Long.toHexString(hdc)+ + System.err.println("!!!! NOTE: pixel format already chosen for HDC: " + toHexString(hdc)+ ", pixelformat "+pixelFormat); } pixelFormatSet = true; @@ -149,6 +149,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio dummyContext.makeCurrent(); dummyWGLExt = (WGLExt) dummyContext.getPlatformGLExtensions(); } + } else if (DEBUG) { + System.err.println(getThreadName() + ": Not using WGL_ARB_pixel_format, because multisampling not requested"); } int recommendedPixelFormat = pixelFormat; // 1-based pixel format boolean haveWGLChoosePixelFormatARB = false; @@ -189,7 +191,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio } if (DEBUG) { if (recommendedPixelFormat <= 0) { - System.err.print(getThreadName() + ": wglChoosePixelFormatARB didn't recommend a pixel format"); + System.err.print(getThreadName() + ": wglChoosePixelFormatARB didn't recommend a pixel format: "+WGL.GetLastError()); if (capabilities.getSampleBuffers()) { System.err.print(" for multisampled GLCapabilities"); } @@ -202,6 +204,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio availableCaps = WindowsWGLGraphicsConfiguration.HDC2GLCapabilities(dummyWGLExt, hdc, -1, glProfile, pixelFormatSet, onscreen, usePBuffer); gotAvailableCaps = null!=availableCaps ; choosenBywGLPixelFormat = gotAvailableCaps ; + } else if (DEBUG) { + System.err.println(getThreadName() + ": wglChoosePixelFormatARB not available"); } } finally { dummyContext.release(); @@ -212,22 +216,19 @@ public class WindowsWGLGraphicsConfigurationFactory extends GraphicsConfiguratio if (!gotAvailableCaps) { if (DEBUG) { - if (!capabilities.getSampleBuffers()) { - System.err.println(getThreadName() + ": Using ChoosePixelFormat because multisampling not requested"); - } else { - System.err.println(getThreadName() + ": Using ChoosePixelFormat because no wglChoosePixelFormatARB"); - } + System.err.println(getThreadName() + ": Using ChoosePixelFormat ... (LastError: "+WGL.GetLastError()+")"); } pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(capabilities); recommendedPixelFormat = WGL.ChoosePixelFormat(hdc, pfd); if (DEBUG) { - System.err.println(getThreadName() + ": Recommended pixel format = " + recommendedPixelFormat); + System.err.println(getThreadName() + ": ChoosePixelFormat(HDC "+toHexString(hdc)+") = " + recommendedPixelFormat + " (LastError: "+WGL.GetLastError()+")"); + System.err.println(getThreadName() + ": Used " + capabilities); } numFormats = WGL.DescribePixelFormat(hdc, 1, 0, null); if (numFormats == 0) { throw new GLException("Unable to enumerate pixel formats of window " + - toHexString(hdc) + " for GLCapabilitiesChooser"); + toHexString(hdc) + " for GLCapabilitiesChooser (LastError: "+WGL.GetLastError()+")"); } availableCaps = new GLCapabilities[numFormats]; for (int i = 0; i < numFormats; i++) { diff --git a/src/jogl/classes/com/sun/opengl/util/Animator.java b/src/jogl/classes/com/sun/opengl/util/Animator.java index 84637433e..a10717881 100755 --- a/src/jogl/classes/com/sun/opengl/util/Animator.java +++ b/src/jogl/classes/com/sun/opengl/util/Animator.java @@ -53,28 +53,46 @@ import javax.media.opengl.*; */ public class Animator { + protected static final boolean DEBUG = com.sun.opengl.impl.Debug.debug("Animator"); + private volatile ArrayList/*<GLAutoDrawable>*/ drawables = new ArrayList(); private AnimatorImpl impl; private Runnable runnable; private boolean runAsFastAsPossible; + protected ThreadGroup threadGroup; protected Thread thread; protected volatile boolean shouldStop; protected boolean ignoreExceptions; protected boolean printExceptions; /** Creates a new, empty Animator. */ - public Animator() { + public Animator(ThreadGroup tg) { try { // Try to use the AWT-capable Animator implementation by default impl = (AnimatorImpl) Class.forName("com.sun.opengl.util.awt.AWTAnimatorImpl").newInstance(); } catch (Exception e) { impl = new AnimatorImpl(); } + threadGroup = tg; + + if(DEBUG) { + System.out.println("Animator created, ThreadGroup: "+threadGroup); + } + } + + public Animator() { + this((ThreadGroup)null); } /** Creates a new Animator for a particular drawable. */ public Animator(GLAutoDrawable drawable) { - this(); + this((ThreadGroup)null); + add(drawable); + } + + /** Creates a new Animator for a particular drawable. */ + public Animator(ThreadGroup tg, GLAutoDrawable drawable) { + this(tg); add(drawable); } @@ -134,6 +152,9 @@ public class Animator { class MainLoop implements Runnable { public void run() { try { + if(DEBUG) { + System.out.println("Animator started: "+Thread.currentThread()); + } while (!shouldStop) { // Don't consume CPU unless there is work to be done if (drawables.size() == 0) { @@ -152,6 +173,9 @@ public class Animator { Thread.yield(); } } + if(DEBUG) { + System.out.println("Animator stopped: "+Thread.currentThread()); + } } finally { shouldStop = false; synchronized (Animator.this) { @@ -170,7 +194,11 @@ public class Animator { if (runnable == null) { runnable = new MainLoop(); } - thread = new Thread(runnable); + if(null==threadGroup) { + thread = new Thread(runnable); + } else { + thread = new Thread(threadGroup, runnable); + } thread.start(); } |