Skip to content

Commit

Permalink
Freeze at startup correction
Browse files Browse the repository at this point in the history
  • Loading branch information
YvesBoyadjian committed Nov 3, 2024
1 parent 0fa08e3 commit d7ad8c6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 51 deletions.
79 changes: 28 additions & 51 deletions application/src/application/MainGLFW.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,23 @@ protected Object doInBackground() throws Exception {
buildPhysics();
loadSavedGame();
SwingUtilities.invokeLater(() -> {
try {
startOpenGL();
startViewer();
loadPlanks();
buildHeroPhysics();
setEscapeCallback();
addIdleListeners();
runVisu();
} catch (Exception e) {
JOptionPane.showMessageDialog(window, e.toString(), "Exception in Bigfoot Hunting", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
System.exit(-1); // Necessary, because of Linux
} catch (Error e) {
JOptionPane.showMessageDialog(window, e.toString(), "Error in Bigfoot Hunting", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
System.exit(-1); // Necessary, because of Linux
}
});
} catch (Exception e) {
JOptionPane.showMessageDialog(window, e.toString(), "Exception in Bigfoot Hunting", JOptionPane.ERROR_MESSAGE);
Expand Down Expand Up @@ -1719,56 +1729,7 @@ public static void runVisu() {
});

SwingUtilities.invokeLater(() -> {
try {
loop();
} catch (Exception e) {
viewer.setVisible(false);
JOptionPane.showMessageDialog(window, e.toString(), "Exception in Mount Rainier Island", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
System.exit(-1); // Necessary, because of Linux
} catch (Error e) {
viewer.setVisible(false);
JOptionPane.showMessageDialog(window, e.toString(), "Error in Mount Rainier Island", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
System.exit(-1); // Necessary, because of Linux
}

//// Can call "alc" functions at any time
// long device = alcOpenDevice((ByteBuffer)null);
// ALCCapabilities deviceCaps = ALC.createCapabilities(device);
//
// long context = alcCreateContext(device, (IntBuffer)null);
// alcMakeContextCurrent(context);
// AL.createCapabilities(deviceCaps);
//// Can now call "al" functions
//
// IntBuffer buffer = BufferUtils.createIntBuffer(1);
// AL10.alGenBuffers(buffer);
//
// String args = "ressource/" + "AMBSea_Falaise 2 (ID 2572)_LS_16bit.wav";
// File file = new File(args);
// if (!file.exists()) {
// file = new File("application/" + args);
// }
// URL url = null;
// try {
// url = file.toURL();
// } catch (MalformedURLException e) {
// e.printStackTrace();
// }
//
// long time = 0;
// try {
// time = createBufferData(buffer.get(0),url);
// } catch (UnsupportedAudioFileException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }

//InputStream seaSound = loadMP3Sound("AMBSea_Falaise 2 (ID 2572)_LS_16bit.mp3");

//seaClip = playSound(seaSound,true, 0.0001f);

AtomicInteger seaAtomicInteger = new AtomicInteger();

Expand All @@ -1789,7 +1750,7 @@ public static void runVisu() {

seaRenderer.play();

seaRenderer.setVolume(0.0f);
seaRenderer.setVolume(0.001f);

seaAudioLatch.countDown();

Expand Down Expand Up @@ -1844,7 +1805,7 @@ public static void runVisu() {

forestRenderer.play();

forestRenderer.setVolume(0.0f);
forestRenderer.setVolume(0.001f);

forestAudioLatch.countDown();

Expand Down Expand Up @@ -1908,6 +1869,22 @@ public static void runVisu() {
}
});
//aliveThread.start();
SwingUtilities.invokeLater(() -> {

try {
loop();
} catch (Exception e) {
viewer.setVisible(false);
JOptionPane.showMessageDialog(window, e.toString(), "Exception in Mount Rainier Island", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
System.exit(-1); // Necessary, because of Linux
} catch (Error e) {
viewer.setVisible(false);
JOptionPane.showMessageDialog(window, e.toString(), "Error in Mount Rainier Island", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
System.exit(-1); // Necessary, because of Linux
}
});
});
}

Expand Down
10 changes: 10 additions & 0 deletions retroboss/src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,23 @@ protected Object doInBackground() throws Exception {
MainGLFW.buildPhysics();
MainGLFW.loadSavedGame();
SwingUtilities.invokeLater(() -> {
try {
MainGLFW.startOpenGL();
MainGLFW.startViewer();
MainGLFW.loadPlanks();
MainGLFW.buildHeroPhysics();
MainGLFW.setEscapeCallback();
MainGLFW.addIdleListeners();
MainGLFW.runVisu();
} catch (Exception e) {
JOptionPane.showMessageDialog(MainGLFW.window, e.toString(), "Exception in Retro Boss", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
System.exit(-1); // Necessary, because of Linux
} catch (Error e) {
JOptionPane.showMessageDialog(MainGLFW.window, e.toString(), "Error in Retro Boss", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
System.exit(-1); // Necessary, because of Linux
}
});
} catch (Exception e) {
JOptionPane.showMessageDialog(MainGLFW.window, e.toString(), "Exception in Retro Boss", JOptionPane.ERROR_MESSAGE);
Expand Down

0 comments on commit d7ad8c6

Please sign in to comment.