Results 1 to 5 of 5

Thread: CL_FramerateCounter.set_fps_limit() not working properly, need assistance

  1. #1
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default CL_FramerateCounter.set_fps_limit() not working properly, need assistance

    I was hoping to limit it to 60 fps, because I've noticed that in windowed mode it runs between 60 and 62 and in full screen mode between 74 and 77 without usage of limiter. Now when I've set limit of 60, it runs 34-56 in windowed mode (which makes it run unsteady) and in fullscreen mode it seems to run fine. Can this be fixed somehow?

  2. #2
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default

    No, there are irregular slowdowns and speedups in full screen mode too

  3. #3
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default

    I have a background process that is working currently, maybe that slows down. Sorry for bothering you!!!

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    CL_FramerateCounter works by performing a CL_System::sleep() when your program runs to fast.

    Looking at its code...
    Code:
    void CL_FramerateCounter::keep_alive()
    {
    	int cur_time = CL_System::get_time();
    	int delta_time = cur_time - impl->start_time;
    	impl->start_time = cur_time;
    	
    	if (delta_time < impl->frame_time)
    	{
    		CL_System::sleep(impl->frame_time - delta_time);
    		impl->total_time += impl->frame_time;
    	}
    	else
    	{
    		impl->total_time += delta_time;
    	}
    		
    	if(impl->total_time >= 1000)	// One second has passed
    	{
    		impl->fps_result = impl->fps_counter + 1;
    		impl->fps_counter = impl->total_time = 0;
    	}
    	impl->fps_counter++;	// Increase fps
    }
    The code looks incorrect - and could cause problems like what you are suggesting.

    You could try fixing it ... this is my untested attempt:

    Code:
    void CL_FramerateCounter::keep_alive()
    {
    	int cur_time = CL_System::get_time();
    	int delta_time = cur_time - impl->start_time;
    	impl->start_time = cur_time;
    	
    	if (delta_time < impl->frame_time)
    	{
    		CL_System::sleep(impl->frame_time - delta_time);
    	}
    	impl->total_time += delta_time;
    		
    	if(impl->total_time >= 1000)	// One second has passed
    	{
    		impl->fps_result = impl->fps_counter + 1;
    		impl->fps_counter = 0;
    		impl->total_time -= 1000;
    	}
    	impl->fps_counter++;	// Increase fps
    }

    Personally i would not use this method, as the accuracy of the system timer is not very accurate.

    Either, design the program so it runs at all framerates (moving game objects using speed*time_delta)

    Or use CL_DisplayWindowDescription - set_frame_rate(60) when creating the application window.
    Last edited by rombust; 02-13-2009 at 01:05 PM. Reason: typo

  5. #5
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default

    I'm using your CL_FramerateCounter and that is the only class where I was able to find set_frame_rate. Its working, I've set frame rate to 25 fps and get_fps() is returning 26 no matter what resolution or how many animations or calculations there are. Is this the right way? Thanks.

Similar Threads

  1. Working with Linux
    By Ciperl in forum Other RTsoft Games
    Replies: 3
    Last Post: 04-17-2013, 09:58 AM
  2. Dinkedit for dink smallwood v1.6 not working
    By axeflame in forum Dink Smallwood HD
    Replies: 3
    Last Post: 11-13-2007, 01:53 PM
  3. What are you working on?
    By whisperstorm in forum Novashell Game Creation System
    Replies: 8
    Last Post: 06-19-2007, 03:52 PM
  4. I can't get funeral quest working over my firewall
    By rmcnew in forum Funeral Quest
    Replies: 4
    Last Post: 01-12-2004, 07:16 AM
  5. I could not get it working
    By in forum Other RTsoft Games
    Replies: 5
    Last Post: 06-03-2003, 06:13 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •