Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dashboard effect in Java application



yes I tried the very similar code
but instead of 	paint(getGraphics());
I used
                         Graphics g = getGraphics();
                            paint(g);
                         g.dispose();

it gives small gain (~5%) if at all
it requires some additional code to clean frame (images are transparent)

in general in cube situation painting time (80ms on PBG4)  >> dt (6ms)
you'll never sleep

so I decided not to use it

thanks anyway for your suggestion

On Dec 21, 2004, at 4:19 PM, Pete Kirkham wrote:

That reminds me- you are sleeping in an application that is having difficulty performing its operations fast enough:

            Thread.sleep(dt);
            repaint();

Whereas you can do something like:

       	start_time = System.currentTimeMillis();

       	paint current frame to buffer
		(so there's no req't to recalculate if paint
		 is called between frames)

	paint(getGraphics());

	sleep_time = start_time + dt - System.currentTimeMillis();

	if (sleep_time > 0) {
	  Thread.sleep(sleep_time);
	}

so you only sleep if you can render the frames fast enough, and then for an amount that lets you update at the frame rate, not some unknown period.


Pete _______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Dmitry Markman

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Dashboard effect in Java application (From: Levi Yourchuck <email@hidden>)
 >Re: Dashboard effect in Java application (From: Pete Kirkham <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.