October 22, 20169 yr 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 October 22, 20169 yr by venetox
October 27, 20169 yr 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.
October 28, 20169 yr 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.
October 29, 20169 yr It's capped at 60 (I think) FPS. I wouldn't recommend going this way, everything will look stuttered. Yeah it would be better if there was an event for when the client paints, since onPaint is probably ran at the same frequency as onLoop.
Create an account or sign in to comment