Sign in to follow this  

[java] animation "tears" in linux but not windows

This topic is 4727 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am writing a simple java application to practice java. I am using a animation framework similiar to the one outlined here: http://fivedots.coe.psu.ac.th/~ad/jg/ When i run my program, i set it for, and get about 82ups, and 82 fps. In windows, everything is smooth, even when i launch it 6 times and the ups goes down. However, in linux, it goes ok, but gets kinda jerky, i believe that this is called tearing. Could it be because I am not using the j3d timer? i am just using the regular system timer right now. I also think another possibility is that maybe i have to sync my framerate with the refresh rate of the monitor maybe? Anyway, any help would be appreciated. thanks for any input -pinkey

Share this post


Link to post
Share on other sites
WOW! MAJOR DIFFERENCE!!!
I added, in my render method, a
this.getToolkit().sync();
and it is super smooth!

If I may, I'd like to ask some questions about why this works:
first off, what the heck is a toolkit?
should it be done every render? or more often?
what other cool stuff can the toolkit do?

thank you for the quick amazingly affective response.

-pinkey

Share this post


Link to post
Share on other sites
The reason you're animation looks like it is tearing is becuase you rendering faster than the monitor is refreshing. Basically the monitor is still updating the scan lines, but in the mean-time you've altered the data.

The sync() method prevents this from happening, I think it just makes the rendering thread wait untill the monitor is ready for the next frame, therefore it must called every frame you do some rendering.

You can get more info about the Toolkit here.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you have timing problems that are OS dependent, it's practially always windows that is wrong: windows is the only JVM from sun which has had broken timers (right the way up until the latest version of java).

In this cases, you're not seeing any bug or incompatibility in java, but instead in your graphics drivers (although, arguably, Sun could have made the earlier jvm specs more intelligent about enforcing / interacting with sync'ing to monitor).

What you're seeing is that your grapihcs drivers on windows are configured differently to your graphics drivers on linux - the former are doing an automatic sync in the driver / OS / windowing system. You can disable this manually if you have a good enough card + drivers (usually in the advanced properties of the Display), and see what difference it makes.

redmilamber

Share this post


Link to post
Share on other sites

This topic is 4727 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this