Jump to content

Cost of Drawing / Reducing paint refresh rate


Recommended Posts

Posted (edited)

Just had a thought. If you wanted to limit your refresh rate to say 10fps.

 

Instead of redrawing each time in your onpaint. Have an Image stored in memory, then ever 1/10th of a second update it in your paint code.

 

So some code off the top of my head. functions wont be right and you will have to put everything that you currently do in redrawImage and have it output to a single image of just the stuff to be drawn.

currenttime = System.currentTimeMilliseconds();
if(nextdrawtime-currenttime <= 0)
{
	storedImage = redrawImage();
	nextdrawtime = currenttime+100;
}

g.draw(storedImage); // I know that won't be correct call, on phone and don't use paint much

 

That would mean every 100ms it updates the storedImage with the new stuff that should be on screen then draws it. If its less than 100ms since last redraw of image, just draw image from memory, which should be a lot less resource intensive then doing all of the other stuff. In theory at least, just an idea, no clue if it will have intended effect.

Edited by venetox
Posted

Just add a timer and find the average frequency of the paint and only paint every x time.

 

In LoL, it's based on every time DX EndScene is called, which is effectively measured through FPS. So if your FPS is 300, there's no sense in drawing 300x a second when your monitor is only 60 Hz.

 

It's capped at 60  (I think) FPS.

I wouldn't recommend going this way, everything will look stuttered.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...