Jump to content
  • Advertisement
Sign in to follow this  
brainlesspinkey

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

This topic is 5070 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!