lwjgl exception handling

So, I’m using OpenGl and OpenAl in my game. The problem I have is when the application crashes and these two “things” aren’t closed down properly. I have a feeling this isn’t too good.

My question is how I can I efficiently close these two “things” when the game crashes. Do I put the entire initiation and start of the game in a try/catch block

try{
start display.
init Gl
init Al
create instance of game
start game

}catch {
GL.destroy
Al.destroy
}

Maybe I should start the entire game as its own thread and then close the Al and Gl in the main thread?

I just realized it was a stupid question, and that I’ve already answered it. I put the whole game-loop in a try/catch/finally block and in finally I close GL and Al.

… your feelings are wrong however, as GL and AL are automatically cleaned up when the process exits, so if you’re writing desktop apps… no real need to do it.

Cas :slight_smile:

Really? I always get a console warning that Al wasnt closed properly.

It doesn’t matter. It just tells you that “YOU” didn’t close it, because you might want to close it by yourself. The error by itself probably means nothing, it just notifies you.