Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Switching between fullscreen and windowed  RSS feed

 
Jeremy Tartaglia
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to allow my game to switch between fullscreen mode and a windowed mode, but all the code I can find for this is either flawed code someone posted on a forum someplace, or documentation for a version of Java I'm not using. I'm writing the game in Java 1.4.2 (mostly because that's what Borland JBuilder X uses), which I've read already has some serious issues with fullscreen graphics.

Anyway is there any good, stable way of accomplishing this task? Thanks!
 
Gregory Jones
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you seen this site

http://fivedots.coe.psu.ac.th/~ad/jg/ - "Killer Game Programming in Java"
- the author's web site full book is available

Not sure if the examples are flawed since I am not copying directly just using it to point me in the right direction.

The source code is also available where you could see serveral different examples.

Aside from that you will have to provide more details on how you are implementing you graphics. I am new to java graphics but from what I have seen with AWT there is more than one way to do things.

HTH
Gregory Jones
 
Jeremy Tartaglia
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have the book (may consider picking up up at some point), but basically what I want is to, on the fly, be able to press some key or key combination (preferrably Alt+Enter) to switch between full screen and windowed. Obviously, in OSes which don't support full screen exclusive graphics (like Linux, UNIX, and MacOS?) it will be utterly useless until those features get implemented.

It's a lot of code to digest, but here's what I've got now:



It works, sort of. If I start in full screen mode, the game runs fine, switching to windowed also works fine, but switching back to windowed mode loses the graphics context. After that it gets wonky. Everything shows back up, but the screen never resizes and other weird stuff. Starting in windowed mode just delays the problem.

I'm sure I'm making some amatuerish mistake, but I can't see anything wrong.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!