Slick Forums

Discuss the Slick 2D Library
It is currently Sat Dec 07, 2019 5:57 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jun 04, 2012 5:19 am 
Offline
Game Developer
User avatar

Joined: Sun Nov 12, 2006 8:40 pm
Posts: 585
Just updated to LWJGL 2.8.4 and noticed that the fps counter wasn't quiet hitting 60fps when using container.setTargetFPS(60) even though it should.

Doing a bit of digging I noticed that the problem is that the Slick2D fps counter is losing time (a few milliseconds every frame) hence causing it to be a little off.

Firstly in the GameContainer.java class the method updateFPS() should be amended as follows

Code:
protected void updateFPS() {
                if (getTime() - lastFPS > 1000) {
                        lastFPS += 1000;
                        recordedFPS = fps;
                        fps = 0;
                }
                fps++;
        }


so just the line "lastFPS = getTime();" should be "lastFPS += 1000";

Secondly the lastFPS variable will now need to be initialised with "lastFPS = getTime();" before the Slick game loop beings.

The above change should give proper FPS calculation without loosing time between frames.


Top
 Profile  
 
PostPosted: Mon Jun 04, 2012 6:06 am 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
Thanks, pushed fix in dev branch.


Top
 Profile  
 
PostPosted: Mon Jun 04, 2012 7:06 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Oh that is totally right! Never noticed that one :D

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group