Give a string description to each place I enter or leave the GL DangerZone

This commit is contained in:
Bill Kuker 2012-09-27 16:15:45 +00:00
parent 02360f89dd
commit b82be4fc02
2 changed files with 10 additions and 10 deletions

View File

@ -41,7 +41,7 @@ public class OpenGLUtils {
log.debug("OpenGL is disabled"); log.debug("OpenGL is disabled");
} else { } else {
log.debug("Initializing OpenGL"); log.debug("Initializing OpenGL");
enterDangerZone(); enterDangerZone("earlyInitialize");
if (SystemInfo.getPlatform() == Platform.UNIX) { if (SystemInfo.getPlatform() == Platform.UNIX) {
log.debug("Dismissing splash screen (Linux/Java/JOGL bug)"); log.debug("Dismissing splash screen (Linux/Java/JOGL bug)");
// Fixes a linux / X bug: Splash must be closed before GL Init // Fixes a linux / X bug: Splash must be closed before GL Init
@ -56,7 +56,7 @@ public class OpenGLUtils {
} }
log.debug("Calling GLProfile.initSingleton()"); log.debug("Calling GLProfile.initSingleton()");
GLProfile.initSingleton(); GLProfile.initSingleton();
exitDangerZone(); exitDangerZone("earlyInitialize");
} }
} }
@ -76,8 +76,8 @@ public class OpenGLUtils {
* exitDangerZone is not called after this the 3D user preference will be * exitDangerZone is not called after this the 3D user preference will be
* disabled at the next startup. * disabled at the next startup.
*/ */
static void enterDangerZone() { static void enterDangerZone(String where) {
log.verbose("Entering GL DangerZone"); log.verbose("Entering GL DangerZone: " + where);
inTheDangerZone = true; inTheDangerZone = true;
Application.getPreferences().set3dEnabled(false); Application.getPreferences().set3dEnabled(false);
try { try {
@ -93,11 +93,11 @@ public class OpenGLUtils {
* *
* Safe to call when not in the danger-zone. Safe to call quite often * Safe to call when not in the danger-zone. Safe to call quite often
*/ */
static void exitDangerZone() { static void exitDangerZone(String where) {
if (!inTheDangerZone) if (!inTheDangerZone)
return; return;
inTheDangerZone = false; inTheDangerZone = false;
log.verbose("Exiting GL DangerZone"); log.verbose("Exiting GL DangerZone: " + where);
Application.getPreferences().set3dEnabled(true); Application.getPreferences().set3dEnabled(true);
try { try {
Preferences.userRoot().flush(); Preferences.userRoot().flush();

View File

@ -97,7 +97,7 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
addHierarchyListener(new HierarchyListener(){ addHierarchyListener(new HierarchyListener(){
@Override @Override
public void hierarchyChanged(HierarchyEvent e) { public void hierarchyChanged(HierarchyEvent e) {
OpenGLUtils.enterDangerZone(); OpenGLUtils.enterDangerZone("RocketFigure3d added to parent container");
RocketFigure3d.this.removeHierarchyListener(this); RocketFigure3d.this.removeHierarchyListener(this);
} }
}); });
@ -134,7 +134,7 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
private void initGLCanvas() { private void initGLCanvas() {
log.debug("Initializing RocketFigure3D OpenGL Canvas"); log.debug("Initializing RocketFigure3D OpenGL Canvas");
OpenGLUtils.enterDangerZone(); OpenGLUtils.enterDangerZone("initGLCanvas");
try { try {
log.debug("Setting up GL capabilities..."); log.debug("Setting up GL capabilities...");
@ -174,7 +174,7 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
this.add(new JLabel("Unable to load 3d Libraries: " this.add(new JLabel("Unable to load 3d Libraries: "
+ t.getMessage())); + t.getMessage()));
} finally { } finally {
OpenGLUtils.exitDangerZone(); OpenGLUtils.exitDangerZone("initGLCanvas");
} }
} }
@ -314,7 +314,7 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
drawExtras(gl, glu); drawExtras(gl, glu);
drawCarets(gl, glu); drawCarets(gl, glu);
OpenGLUtils.exitDangerZone(); OpenGLUtils.exitDangerZone("display()");
} }