Re: Smooth running applet

Discussion in 'Java' started by Karl von Laudermann, Jul 2, 2003.

  1. (dr) wrote in message news:<>...
    > Hello,
    >
    > I'm writing an animated applet, which I want to run smoothly in the
    > browser. The way I do it now is to draw on a buffered java.awt.Image,
    > copy the image to the screen and then make the thread go to sleep for
    > some specified time.


    I would think it would be easier and probably more reliable to use
    java.swing.Timer to control animations, rather than using thread sleep
    directly.

    > > Two problems arise,

    >
    > I) The animation is not synchronized with the monitor refresh rate.


    How fast are you planning to animate? There's no reason to go faster
    than 60 fps, because the human eye won't notice any improvement beyond
    that. And AFAIK all monitors have a *minimum* refresh rate of 60 Hz,
    so there shouldn't be any problem here. You'd only care about monitor
    synchronization if the refresh rate were lower than your animation
    speed, because then you'd get dropped frames.

    > II) The animation works fine on my machine, but might not do so on
    > your machine.


    Um, how so? One can't offer a solution without knowing what the actual
    problem is. How do you anticipate the behavior to differ on a another
    machine?
    Karl von Laudermann, Jul 2, 2003
    #1
    1. Advertising

  2. Karl von Laudermann

    Roedy Green Guest

    On 2 Jul 2003 06:45:06 -0700, (Karl von Laudermann)
    wrote or quoted :

    >How fast are you planning to animate? There's no reason to go faster
    >than 60 fps, because the human eye won't notice any improvement beyond
    >that


    movies are only 24.


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 2, 2003
    #2
    1. Advertising

  3. Tim Tyler <> wrote in message news:<>...
    > The synchronising of redraws with the monitor refresh prevents
    > animations "ripping" - and it does that at any frame rate.
    >
    > The idea is to update your animation when the scan is *not*
    > on top of what is being animated - thereby preventing the flicker
    > and glitches caused by undrawn and half-redrawn images being
    > presented to the user.
    >
    > It is a common issue for games programmers using Java.


    Ah, I hadn't thought of that. Still, at monitor refresh rates of 60 Hz
    and higher, would the human eye even notice if one frame were
    partially updated?
    Karl von Laudermann, Jul 3, 2003
    #3
  4. Karl von Laudermann

    Tim Tyler Guest

    Karl von Laudermann <> wrote:
    : Tim Tyler <> wrote in message news:<>...

    :> The synchronising of redraws with the monitor refresh prevents
    :> animations "ripping" - and it does that at any frame rate.
    :>
    :> The idea is to update your animation when the scan is *not*
    :> on top of what is being animated - thereby preventing the flicker
    :> and glitches caused by undrawn and half-redrawn images being
    :> presented to the user.
    :>
    :> It is a common issue for games programmers using Java.

    : Ah, I hadn't thought of that. Still, at monitor refresh rates of 60 Hz
    : and higher, would the human eye even notice if one frame were
    : partially updated?

    If it was just one frame then probably not.

    However animations don't last for just one frame.

    For me, the biggest problems are noticable when scrolling the screen.

    The problem produces a "step" in any vertical walls scrolling horizontally.

    The position of the step varies according to the update rate - it might
    appear randomly flickering up and down the wall's surface - or it might
    appear fixed at one location - if your update rate matched the refresh
    rate of the monitor. In that case there would be a persitent redraw
    glitch maintained at approximately the same point for seconds at a time.

    Recalling when I could scroll the screen instantaneously - using the
    BBC's VIDC hardware - and synchronise with the monitor refresh rate
    so the discontinuity was guaranteed to happen during "flyback" I can
    testify that the effect was *much* slicker than is possible today
    using Java.

    I have written a scrolling game in Java: http://rockz.co.uk/

    It is about as good as anything at illustrating the effect.
    --
    __________
    |im |yler http://timtyler.org/
    Tim Tyler, Jul 4, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bryan Young

    Urgent.... Smooth Refresh

    Bryan Young, Jan 25, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    851
    Jeff @ Dart
    Jan 25, 2005
  2. Tim Tyler

    Re: Smooth running applet

    Tim Tyler, Jul 2, 2003, in forum: Java
    Replies:
    0
    Views:
    861
    Tim Tyler
    Jul 2, 2003
  3. Roedy Green

    Re: Smooth running applet

    Roedy Green, Jul 2, 2003, in forum: Java
    Replies:
    0
    Views:
    801
    Roedy Green
    Jul 2, 2003
  4. Steve Horsley

    Swing missing smooth fonts in Linux

    Steve Horsley, Feb 6, 2004, in forum: Java
    Replies:
    0
    Views:
    1,155
    Steve Horsley
    Feb 6, 2004
  5. Guest
    Replies:
    2
    Views:
    554
    Walter Wang [MSFT]
    Jul 17, 2006
Loading...

Share This Page