StandardGame shutdown and restart

Hi folks,

another question to the StandardGame:

I've got an application that can create a StandardGame. If the user closes the game window, it is possible to re-create a new game. In this case the rendering is pretty broken. For example the DebugGameState will just be a gray rectangle without displaying anything. TextureStates also don't work.

What would be the correct way to shut down a standard game, and (even more important) to re-create a new game after the user closed the game window?



Yes, unfortunately that is the case:

Darkfrog mentioned he will be getting to it at some point (right? )

argh…yes, but my biggest problem is I'm not really sure how best to handle it either.  Has anyone else ever done anything with stopping the game and restarting it in the same VM that can help out here?

Could this be a clue where to go in this respect:

That looks very promising.  Interested in putting together a patch for StandardGame? :wink:

Why not, I'll play around with StandardGame's code a bit, and see if I can get it to nicely handle restarts on my system.


Awesome…I think there are several people (including myself) that would appreciate this. :slight_smile:

If you're interested in working on a related task StandardGame has (poor) support for changing resolutions in-game and that needs to be revised to work as well.  I think it primarily has to do with textures not being reloaded but should fall in the same category if you're willing to make everyone happy. :wink:

sancho's suggestion about doTextureCleanup and clearCache seems to fix the problem of textures not reloading.

however when i relaunch my standardgame, i can't get my lights and alphastates (and i guess other renderstates) to initialize the same way they do on first launch.

and the relaunched window also ignores keyboard input at first. i have to manually toggle to another app window and back before it accepts focus for keyboard input.

anyone have any ideas?

Perhaps a new context is not being created or properly tracked or something like that… Try adding DisplaySystem.getDisplaySystem().getCurrentContext().invalidateStates() to your cleanup.

yeah same problem persists. but thanks for the suggestion. i'll keep poking around.

Once we've got a stable way to completely cleanup I'll get the changes added to StandardGame.  It will be nice to have a completely functional way to restart the graphical context. :slight_smile:

Well, if you've destroyed the display and recreated it…  And if both lwjgl and jme are not caching old gl statuses, then you should be golden.  The call I described will ensure jME is not caching anything.  (I'm not even sure if lwjgl caches much or anything.)

If you can provide a simple test to show the problem, I'd gladly troubleshoot.

Guess you wouldnt want to clean the cursor, and in some cases gui details like chat bars and borders…

I'll try to get a look at this ASAP as this is a feature I technically already support in Galaxies Beyond, but the textures just disapear when you dynamically change resolutions. :o

If you are changing resolutions, there is no reason to blow away TextureManager's cache.  (Run our own TestRecreateWindow for example)