Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  passive rendered game  (Read 1278 times)
0 Members and 1 Guest are viewing this topic.
Offline stef569

Junior Member





« Posted 2009-01-13 13:56:38 »

What are the drawbacks of using repaint on swing components instead of using a game loop?
relative to the problems in a turn based game:
animated units, static terrain, animated menu, explosion animation, blinking stars, rain, snow(small images moving over the whole screen)
units should be 20% darker when inactive, and they stop animating.

I know
that painting and input both are passed in the awt event thread
that java2d can use software/hardware rendering

I don't know howto update the animations, should I use a swing timer and call update using that? or use gifs and let java update them for me.
But how do you stop a animated gif?

I though about creating a swing timer and let it call repaint every second. To allow a scrolling background for example.
Offline fletchergames

Senior Member





« Reply #1 - Posted 2009-01-13 17:08:08 »

Passive rendering doesn't work well at all.  You don't know when the screen is going to be rendered.

It might render the screen three times when it hasn't changed and then not render when the screen does change.

Active rendering draws the screen as often as possible without slowing down the game logic any more than possible.  Passive rendering won't typically draw the screen as often.
Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #2 - Posted 2009-01-13 19:58:47 »

Having done passive rendering in Swing (including animation...), I can confirm it doesn't work as bad as everyone wants you to believe. I found active rendering somewhat of a headache if you want to use it for a multiplayer game (thread synchronization). I didn't notice much of a difference between active and passive rendering in Swing, but I am pretty sure people will disagree with me and tell you I am a bad coder.

Anyhow, I advice you go OpenGL if rendering is a concern, otherwise, passive rendering in Swing (done correctly) will probably just be fine?

Judge for yourself (passive rendering in Swing): http://www.tiicoon.com/webstart/City.jnlp

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mr_Light

Senior Member




shiny.


« Reply #3 - Posted 2009-01-13 20:25:40 »

not render when the screen does change.
I can't see a reason why you wouldn't have control over that. You might not have control over some additional requests generated from the window but you can always cache the whole screen which swing already does afaik.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline fletchergames

Senior Member





« Reply #4 - Posted 2009-01-14 19:14:51 »

I can't see a reason why you wouldn't have control over that. You might not have control over some additional requests generated from the window but you can always cache the whole screen which swing already does afaik.
You can render to an image that will eventually be drawn to the screen whenever you want, but you can't make it actually be drawn to the screen.  When you call repaint, it just suggests that the screen be repainted when the AWT Event Thread has time.  You could just call paint, but that would really be mixing active and passive rendering.  I have a feeling that might be a bad idea.

Swing does cache the whole screen for you.  In fact, it has a back buffer for every single Swing Component, which seems excessively wasteful.
Offline Mr_Light

Senior Member




shiny.


« Reply #5 - Posted 2009-01-15 01:27:00 »

You can render to an image that will eventually be drawn to the screen whenever you want, but you can't make it actually be drawn to the screen.  When you call repaint, it just suggests that the screen be repainted when the AWT Event Thread has time.  You could just call paint, but that would really be mixing active and passive rendering.  I have a feeling that might be a bad idea.

Swing does cache the whole screen for you.  In fact, it has a back buffer for every single Swing Component, which seems excessively wasteful.
I was a bit warped there - that was not the caching I meant, doesn't matter anyways

Profiling shows that 'excessively wasteful' mismatches with what actually is going on.

repaint will cause a paint there are just no guaranties at what point in time or before what death-line. Unless you use a real-time OS even active rendering doesn't give you either. Repaint does 'guaranty' that there will be a repaint, the task doesn't get dropped no matter how stressed the EDT is.

Mixing active and passive rending will work just fine - why wouldn't it passive rendering is basically a optimised version of active rendering. filthy rich clients guys probably used something similar with there glass layer approach. - or they do fire off a zilion events I don't know.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!