Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LWJGL Game not properly ending

Tags:

java

opengl

lwjgl

I currently have a simple problem with LWJGL right now. If I were to run my game, it does actually run everything correctly and it appears to close out correctly, but when I look inside my Task Manager, I notice that my game is taking up 25% CPU after I close it (about 2-3% when it's actually running) and I'm thinking that I may have missed something when ending the application.

My main function code:

public static void main(String[] args){
    try {
        init();
    }catch(LWJGLException e){
        System.out.println("LWJGLException\n");
        e.printStackTrace();
    }
    try{
        gameLoop();
    }catch(Exception ex){
        ex.printStackTrace();
    }finally{
        cleanup();
    }
}

cleanup:

public static void cleanup(){
    System.out.println("Running cleanup code.");
    Display.destroy();
    System.exit(0);
}

It does actually manage to read "Running cleanup code." My problem is that I don't know if there is something else I need to do to clear out all of the processes. This game is also using a single thread.

like image 298
Epsilia Avatar asked Nov 13 '22 19:11

Epsilia


1 Answers

There is nothing wrong with your code at all, I think. If your problem is what I think it is you wouldn't be able to immediately fix it.

Here are some basic questions you should ask your self. What OS are you using? What is your Java version and/or LWJGL version? (Updating them might help) Have you ever heard of/or played a game called Minecraft? If you are using Linux and seen this when closing Minecraft then that could be the problem you're having.

like image 197
Jasper Creyf Avatar answered Nov 15 '22 10:11

Jasper Creyf