diff --git a/src/itdelatrisu/opsu/Container.java b/src/itdelatrisu/opsu/Container.java index fd0300ee..1a2b96d4 100644 --- a/src/itdelatrisu/opsu/Container.java +++ b/src/itdelatrisu/opsu/Container.java @@ -68,6 +68,7 @@ public class Container extends AppGameContainer { public void start() throws SlickException { try { setup(); + ErrorHandler.setGlString(); getDelta(); while (running()) gameLoop(); diff --git a/src/itdelatrisu/opsu/ErrorHandler.java b/src/itdelatrisu/opsu/ErrorHandler.java index 1dc4d227..3fb23259 100644 --- a/src/itdelatrisu/opsu/ErrorHandler.java +++ b/src/itdelatrisu/opsu/ErrorHandler.java @@ -33,6 +33,7 @@ import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.UIManager; +import org.lwjgl.opengl.GL11; import org.newdawn.slick.util.Log; import org.newdawn.slick.util.ResourceLoader; @@ -73,9 +74,23 @@ public class ErrorHandler { message = { desc, scroll }, messageReport = { descReport, scroll }; + /** OpenGL string (if any). */ + private static String glString = null; + // This class should not be instantiated. private ErrorHandler() {} + /** + * Sets the OpenGL version string. + */ + public static void setGlString() { + try { + String glVersion = GL11.glGetString(GL11.GL_VERSION); + String glVendor = GL11.glGetString(GL11.GL_VENDOR); + glString = String.format("%s (%s)", glVersion, glVendor); + } catch (Exception e) {} + } + /** * Displays an error popup and logs the given error. * @param error a description of the error @@ -197,6 +212,11 @@ public class ErrorHandler { sb.append("**JRE:** "); sb.append(System.getProperty("java.version")); sb.append('\n'); + if (glString != null) { + sb.append("**OpenGL Version:** "); + sb.append(glString); + sb.append('\n'); + } if (error != null) { sb.append("**Error:** `"); sb.append(error); diff --git a/src/itdelatrisu/opsu/Opsu.java b/src/itdelatrisu/opsu/Opsu.java index 4a7a3abd..f3b9c0df 100644 --- a/src/itdelatrisu/opsu/Opsu.java +++ b/src/itdelatrisu/opsu/Opsu.java @@ -107,10 +107,13 @@ public class Opsu extends StateBasedGame { } catch (FileNotFoundException e) { Log.error(e); } + + // set default exception handler Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { ErrorHandler.error("** Uncaught Exception! **", e, true); + System.exit(1); } }); @@ -123,15 +126,19 @@ public class Opsu extends StateBasedGame { } catch (UnknownHostException e) { // shouldn't happen } catch (IOException e) { - ErrorHandler.error(String.format( + errorAndExit( + null, + String.format( "opsu! could not be launched for one of these reasons:\n" + "- An instance of opsu! is already running.\n" + "- Another program is bound to port %d. " + "You can change the port opsu! uses by editing the \"Port\" field in the configuration file.", - Options.getPort()), null, false); - System.exit(1); + Options.getPort() + ) + ); } + // load natives File nativeDir; if (!Utils.isJarRunning() && ( (nativeDir = new File("./target/natives/")).isDirectory() ||