diff options
Diffstat (limited to 'src/net/java/games/jogl')
4 files changed, 34 insertions, 22 deletions
diff --git a/src/net/java/games/jogl/impl/GLContext.java b/src/net/java/games/jogl/impl/GLContext.java index 5e074f02d..0e20a5691 100644 --- a/src/net/java/games/jogl/impl/GLContext.java +++ b/src/net/java/games/jogl/impl/GLContext.java @@ -239,7 +239,7 @@ public abstract class GLContext { if (mustDoMakeCurrent) { if (curContext != null) { if (DEBUG && VERBOSE) { - System.err.println("Freeing context " + curContext + " due to recursive makeCurrent"); + System.err.println(getThreadName() + ": Freeing context " + curContext + " due to recursive makeCurrent"); } curContext.free(); } @@ -264,7 +264,7 @@ public abstract class GLContext { return; } if (DEBUG && VERBOSE) { - System.err.println("Making context " + this + " current"); + System.err.println(getThreadName() + ": Making context " + this + " current"); } } ctxStack.push(this, initAction); @@ -316,7 +316,7 @@ public abstract class GLContext { // kicks in. if (mustDoMakeCurrent && !mustSkipFreeForRenderingThread) { if (DEBUG && VERBOSE) { - System.err.println("Freeing context " + this); + System.err.println(getThreadName() + ": Freeing context " + this); } try { @@ -327,7 +327,7 @@ public abstract class GLContext { if (curContext != null) { if (DEBUG && VERBOSE) { - System.err.println("Making context " + curContext + " current again"); + System.err.println(getThreadName() + ": Making context " + curContext + " current again"); } try { curContext.makeCurrent(curInitAction); @@ -501,7 +501,7 @@ public abstract class GLContext { functionAvailability.flush(); if (!haveResetGLUProcAddressTable) { if (DEBUG) { - System.err.println("!!! Initializing GLU extension address table"); + System.err.println(getThreadName() + ": !!! Initializing GLU extension address table"); } resetProcAddressTable(gluProcAddressTable); haveResetGLUProcAddressTable = true; // Only need to do this once globally @@ -647,7 +647,7 @@ public abstract class GLContext { protected synchronized void setRealized(boolean realized) { this.realized = realized; if (DEBUG) { - System.err.println("GLContext.setRealized(" + realized + ") for context " + this); + System.err.println(getThreadName() + ": GLContext.setRealized(" + realized + ") for context " + this); } } @@ -664,7 +664,7 @@ public abstract class GLContext { if (getRenderingThread() != null && Thread.currentThread() != getRenderingThread()) { if (DEBUG) { - System.err.println("Deferred destroy for context " + this); + System.err.println(getThreadName() + ": Deferred destroy for context " + this); } deferredDestroy = true; return; @@ -760,4 +760,8 @@ public abstract class GLContext { } } } + + protected static String getThreadName() { + return Thread.currentThread().getName(); + } } diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java index cbdf359dc..d808634f2 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java @@ -135,7 +135,7 @@ public abstract class WindowsGLContext extends GLContext { if (hglrc == 0) { create(); if (DEBUG) { - System.err.println("!!! Created GL context for " + getClass().getName()); + System.err.println(getThreadName() + ": !!! Created GL context for " + getClass().getName()); } created = true; } @@ -144,7 +144,7 @@ public abstract class WindowsGLContext extends GLContext { throw new GLException("Error making context current: " + WGL.GetLastError()); } else { if (DEBUG && VERBOSE) { - System.err.println("wglMakeCurrent(hdc " + hdcToString(hdc) + + System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + hdcToString(hdc) + ", hglrc " + hdcToString(hglrc) + ") succeeded"); } } @@ -185,7 +185,7 @@ public abstract class WindowsGLContext extends GLContext { throw new GLException("Unable to delete OpenGL context"); } if (DEBUG) { - System.err.println("!!! Destroyed OpenGL context " + hglrc); + System.err.println(getThreadName() + ": !!! Destroyed OpenGL context " + hglrc); } hglrc = 0; } @@ -215,7 +215,7 @@ public abstract class WindowsGLContext extends GLContext { protected void resetGLFunctionAvailability() { super.resetGLFunctionAvailability(); if (DEBUG) { - System.err.println("!!! Initializing OpenGL extension address table"); + System.err.println(getThreadName() + ": !!! Initializing OpenGL extension address table"); } resetProcAddressTable(getGLProcAddressTable()); } @@ -309,7 +309,7 @@ public abstract class WindowsGLContext extends GLContext { dc = WindowsGLContextFactory.getDummyGLContext( device ).hdc; rc = WindowsGLContextFactory.getDummyGLContext( device ).hglrc; if( !WGL.wglMakeCurrent( dc, rc ) ) { - System.err.println("Error Making WGLC Current: " + WGL.GetLastError() ); + System.err.println(getThreadName() + ": Error Making WGLC Current: " + WGL.GetLastError() ); } else { freeWGLC = true; } @@ -392,18 +392,18 @@ public abstract class WindowsGLContext extends GLContext { // Remove one-basing of pixel format (added on later) recommendedPixelFormat = pformats[0] - 1; if (DEBUG) { - System.err.println("Used wglChoosePixelFormatARB to recommend pixel format " + recommendedPixelFormat); + System.err.println(getThreadName() + ": Used wglChoosePixelFormatARB to recommend pixel format " + recommendedPixelFormat); } } } else { if (DEBUG) { - System.err.println("wglChoosePixelFormatARB failed: " + WGL.GetLastError() ); + System.err.println(getThreadName() + ": wglChoosePixelFormatARB failed: " + WGL.GetLastError() ); Thread.dumpStack(); } } if (DEBUG) { if (recommendedPixelFormat < 0) { - System.err.print("wglChoosePixelFormatARB didn't recommend a pixel format"); + System.err.print(getThreadName() + ": wglChoosePixelFormatARB didn't recommend a pixel format"); if (capabilities.getSampleBuffers()) { System.err.print(" for multisampled GLCapabilities"); } @@ -472,9 +472,9 @@ public abstract class WindowsGLContext extends GLContext { if (!gotAvailableCaps) { if (DEBUG) { if (!capabilities.getSampleBuffers()) { - System.err.println("Using ChoosePixelFormat because multisampling not requested"); + System.err.println(getThreadName() + ": Using ChoosePixelFormat because multisampling not requested"); } else { - System.err.println("Using ChoosePixelFormat because no wglChoosePixelFormatARB: dummyGL = " + dummyGL); + System.err.println(getThreadName() + ": Using ChoosePixelFormat because no wglChoosePixelFormatARB: dummyGL = " + dummyGL); } } pfd = glCapabilities2PFD(capabilities, onscreen); @@ -502,7 +502,7 @@ public abstract class WindowsGLContext extends GLContext { (numFormats - 1) + ")"); } if (DEBUG) { - System.err.println("Chosen pixel format (" + pixelFormat + "):"); + System.err.println(getThreadName() + ": Chosen pixel format (" + pixelFormat + "):"); System.err.println(availableCaps[pixelFormat]); } pixelFormat += 1; // one-base the index @@ -519,15 +519,15 @@ public abstract class WindowsGLContext extends GLContext { if (!WGL.SetPixelFormat(hdc, pixelFormat, pfd)) { int lastError = WGL.GetLastError(); if (DEBUG) { - System.err.println("SetPixelFormat failed: current context = " + WGL.wglGetCurrentContext() + + System.err.println(getThreadName() + ": SetPixelFormat failed: current context = " + WGL.wglGetCurrentContext() + ", current DC = " + WGL.wglGetCurrentDC()); - System.err.println("GetPixelFormat(hdc " + hdcToString(hdc) + ") returns " + WGL.GetPixelFormat(hdc)); + System.err.println(getThreadName() + ": GetPixelFormat(hdc " + hdcToString(hdc) + ") returns " + WGL.GetPixelFormat(hdc)); } throw new GLException("Unable to set pixel format " + pixelFormat + " for device context " + hdcToString(hdc) + ": error code " + lastError); } hglrc = WGL.wglCreateContext(hdc); if (DEBUG) { - System.err.println("!!! Created OpenGL context " + hglrc + " for device context " + hdcToString(hdc) + " using pixel format " + pixelFormat); + System.err.println(getThreadName() + ": !!! Created OpenGL context " + hglrc + " for device context " + hdcToString(hdc) + " using pixel format " + pixelFormat); } if (hglrc == 0) { throw new GLException("Unable to create OpenGL context"); diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java b/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java index 6d60704fa..dd6f8daca 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java @@ -56,6 +56,9 @@ import net.java.games.jogl.*; import net.java.games.jogl.impl.*; public class WindowsGLContextFactory extends GLContextFactory { + private static final boolean DEBUG = Debug.debug("WindowsGLContextFactory"); + private static final boolean VERBOSE = Debug.verbose(); + // On Windows we want to be able to use some extension routines like // wglChoosePixelFormatARB during the creation of the user's first // GLContext. However, this and other routines' function pointers @@ -174,6 +177,11 @@ public class WindowsGLContextFactory extends GLContextFactory { */ private static void checkForDummyContext( final GraphicsDevice device ) { if (!pendingContextSet.contains(device) && !dummyContextMap.containsKey( device ) ) { + if (DEBUG) { + System.err.println("WindowsGLContextFactory.checkForDummyContext() called on thread " + + Thread.currentThread().getName()); + } + pendingContextSet.add(device); GraphicsConfiguration config = device.getDefaultConfiguration(); Rectangle rect = config.getBounds(); diff --git a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java index 64978e7e0..d66412e74 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLContext.java @@ -185,7 +185,7 @@ public class WindowsOnscreenGLContext extends WindowsGLContext { } GLContextShareSet.contextDestroyed(this); if (DEBUG) { - System.err.println("!!! Destroyed OpenGL context " + hglrc + " due to JAWT_LOCK_SURFACE_CHANGED"); + System.err.println(getThreadName() + ": !!! Destroyed OpenGL context " + hglrc + " due to JAWT_LOCK_SURFACE_CHANGED"); } hglrc = 0; } |