Full Screen or Windowed?

I am currently working on a hexagon turn based strategy game. I use Swing and compile in Java 1.42_01b06. I use windowed mode. My problem is that I get low frame rates (5-10 frames per second). I have 1.4 GHz Processor.

I am now considering using Full Screen API. Also, under consideration is switching to Java 1.5. Is Does 1.5 provide any significant improvment to the paintComponent() performance or do I need to switch to Full Screen?

1.5 is faster than 1.4, on Windows. Fullscreen will get you more performance however I’m not sure why you want an increase in FPS for a turnbased game…?

Cas :slight_smile:

Reasons:
Scrolling the map smoothly. Also animations like when moving a unit on the map. :slight_smile:

What increase is there between 1.4 and 1.5 roughly? 50%? more?
Keeping the version constant, what difference is there between Windowed and Full-Screen 100%? 500%?

Another interesting thing is. If I implement Full-Screen, should I make the game support both and being able to manually switch inside the game? why or why not?

Optimist :wink:

You know there are hw-limitations too, not everything is java’s magic :wink:
I think its very unlikely to archive 50% juct by upgrading your java-version.

lg Clemens

Well, at leist I got your attention. ;D
Seriously. Does this mean I must use full-screen mode to get good frame rates and would not that mean I gotta overhaul everything that has to do with when jPanels receive updates?

Well, what you actually want to be looking at is active rendering, and BufferStrategy. You don’t necessarily need fullscreen rendering - FS rendering might get you a moderate increase in speed but it’s fairly unreliable currently (in 1.6 it’s apparently much better).

Smooth scrolling and such is only really possible with active rendering and a BufferStrategy - Swing was not designed for high speed animation. So that’s your next port of call. I’m not sure if it’s possible to mix buffer strategy rendering inside bits of GUI that are normally rendered though.

Cas :slight_smile:

This is interesting but abit confusing. Swing uses double buffering by default, how would I change it then?
Another thing is VolatileImage, which apparently Java 1.4 uses too, but it still does not use it fully.

Active rendering? Does not that imply Full Screen?

No, active rendering just implies rendering explicitly rather than waiting for paint events. I don’t believe BufferStrategy requires fullscreen mode. And I think you’d want to keep it all double buffered or it’ll look terrible!

Cas :slight_smile:

If you want smooth animation in your game, maybe you should reconsider Swing altogether. It’s not really made with smooth scrolling games in mind. Maybe it is possible with some clever hackery though, but I have never seen anything animate smoothly in a Swing game myself.
Unless your GUI is seriously complex (which is almost never the case in games), I would personally replace it with something custom made inside an active rendering loop.

Cas is correct. Its a bit confusing because the actrive rendering tutorial is aprt of the full screen tutorial. This is historical because theyw ere implemnted as part of the same project inside Sun. But they really are independant things.

If you aren’t active rendering then thats the first thing you want to change.

BUT have you profiled your code yet? You really have no idea where your speed problems really are until you profile. Trust me. Its absolutely step 1 in improving performance.

Hmm, speaking of Full Screen mode. when I set the Displaymode, what refresh mode can I set and what happens if the refresh rate is too high?

What screen settings you can set is dictated by the operating system. If you look at the eample apps in Mike’s tutorial you will see an example that fetches those and allows you to chnage the settings.

If you use an unsupported setting, the result of that too is dictated by the underlying OS.

.

I managed to solve all problems I had earlier. I now have an option inside the game to switch between full screen mode and windowed mode. However a new problem then emerged. The full screen drawing is flickering since it is not double buffered. I need double buffering. The BufferStrategy class can only be used on Window Class and Canvas Class. I use JPanels for everything so far. I read somewhere not to mix AWT and Swing components.

Should I use Canvases for the map and minimap or should full screen and windowed mode have one Map+Minimap EACH and switching between them? I might have miussed something here, is there any simple way to go around this?

you do not want to buffer in panels. That will be slow in comparison to proper page flipping, which is what BufferStrategy gives you.

If your goal is performance, ditch the panels.

I dont need much speed, perhaps 20-25 frames/second. So, I cannot use any existing class to get buffering when using JPanel with active rendering in full screen, I must switch to Canvas?

Full information on Bufferstrategy is here:

http://java.sun.com/docs/books/tutorial/extra/fullscreen/bufferstrategy.html

You can use BufferStrategy with any component that provided a createBufferStrategy call.

For best performance though you want to use it on a full screen exclusive window. This allows the BufferStratgey to use video memory page-flipping.