Hmm… do you do something like that:
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
?
Because that takes my machine down if BufferStrategie is used. Java(w) doesnt run anymore but something eats tons of cpu cycles… bringing my machine to a crawling speed (1mhz alike - really).
Unfortunately I don’t know the reason… it could be my OS (win98se), gfx driver (deto 30.82), directx (9.0) or whatsoever
[I hadn’t submitted a bug report… simply because I don’t know were, how and I’m also afraid I would need yet another login (and I already have 5 of those _only_ for sun pages).]
Well… adding a WindowListener wich flags runRenderLoop (or so) to false works much better.
[...]
try
{
Graphics2D g;
BufferStrategy bufferStrategy;
GraphicsConfiguration gc = device.getDefaultConfiguration();
createBufferStrategy(2);
bufferStrategy = getBufferStrategy();
mainFrame.addWindowListener(this);
[...]
while(runRenderLoop)
{
g = (Graphics2D)bufferStrategy.getDrawGraphics();
if (!bufferStrategy.contentsLost())
{
[...]
bufferStrategy.show();
g.dispose();
}
}
}
catch (Exception e)
{
System.out.println("[dirty]exit");
e.printStackTrace();
}
finally
{
System.out.println("[clean]exit");
}
[...]
//-----------------------------------------
public void windowActivated(WindowEvent e) {System.out.println("wActivated");}
public void windowClosed(WindowEvent e) {System.out.println("wClosed");}
public void windowClosing(WindowEvent e)
{
System.out.println("wClosing");
runRenderLoop=false;
}
public void windowDeactivated(WindowEvent e) {System.out.println("wDeactivated");}
public void windowDeiconified(WindowEvent e) {System.out.println("wDeiconified");}
public void windowIconified(WindowEvent e) {System.out.println("wIconified");}
public void windowOpened(WindowEvent e) {System.out.println("wOpened");}
Oh… the game itself is a nice demo