Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SetFramerateLimit problem  (Read 11753 times)

0 Members and 1 Guest are viewing this topic.

Dominator

  • Newbie
  • *
  • Posts: 37
    • View Profile
SetFramerateLimit problem
« on: July 08, 2009, 04:44:22 pm »
Hi!
I recently found out about SFML, so I wanted to try it, but I already have a problem with my first test program.

I'm programming in C# using the .NET bindings.
The problem is, that the framerate limit doesn't behave as intended.

I'm trying to set the limit to 60 fps, but when I run the program, the frame rate stays only at 32 fps. But when I move another window over the SFML window, the framerate strangely rises up to 64 fps.

If I disable the limit and enable vertical sync, it perfectly stays at 60 fps, but I don't want to use vertical sync since it varies on different computers.

What I already did, was using SFML 1.5, SFML SVN and even SFML2 SVN in Windows with Visual Studio 2008 and in Ubuntu with monodevelop, but always with the same behavior.

I'm just using this simple code:
Code: [Select]

using System;
using SFML.Graphics;
using SFML.Window;

namespace SFML_Test
{
  class Program
  {
    static void App_Closed(object sender, EventArgs e)
    {
      ((RenderWindow)sender).Close();
    }

    static void Main(string[] args)
    {

      RenderWindow App = new RenderWindow(new VideoMode(640, 480, 32), "SFML_Test");
      App.Closed += new EventHandler(App_Closed);

      App.SetFramerateLimit(60);

      while (App.IsOpened())
      {      
        App.DispatchEvents();
        App.Display();
      }
    }
  }
}


I would really appreciate any ideas that could solve this problem, because I'd like to use SFML in the future instead of SDL for platform independent developing.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SetFramerateLimit problem
« Reply #1 on: July 08, 2009, 05:42:28 pm »
It works fine for me, the framerate is steady at 60 with your example.

How do you measure the framerate? What is your graphics card? Is your driver up-to-date?
Laurent Gomila - SFML developer

Dominator

  • Newbie
  • *
  • Posts: 37
    • View Profile
SetFramerateLimit problem
« Reply #2 on: July 08, 2009, 05:48:21 pm »
I measured it first with 1 / App.GetFrameTime(), and then to make sure with fraps, but both show the same fps.

I've got a GF 8800 GTX with driver version 185.85 - vsync is set to app-controlled.
I don't think that the driver is the problem, since it behaves the same way in Ubuntu.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SetFramerateLimit problem
« Reply #3 on: July 08, 2009, 05:53:51 pm »
Did you try on Windows Vista or XP?
Laurent Gomila - SFML developer

Dominator

  • Newbie
  • *
  • Posts: 37
    • View Profile
SetFramerateLimit problem
« Reply #4 on: July 08, 2009, 06:07:57 pm »
Windows XP SP 3.

Edit: Installed the latest driver now, but nothing changed.

Edit2: On a different computer with XP SP 3 and a Radeon X1950 it runs with 64 fps.

Where do the 32/64 frames come from, when I set it to exactly 60?

Daazku

  • Hero Member
  • *****
  • Posts: 896
    • View Profile
SetFramerateLimit problem
« Reply #5 on: July 08, 2009, 07:42:43 pm »
Quote from: "Dominator"
Windows XP SP 3.

Edit: Installed the latest driver now, but nothing changed.

Edit2: On a different computer with XP SP 3 and a Radeon X1950 it runs with 64 fps.

Where do the 32/64 frames come from, when I set it to exactly 60?


It will be MAXED to ~60fps. It can be lesser.
Pensez à mettre le tag [Résolu] une fois la réponse à votre question trouvée.
Remember to add the tag [Solved] when you got an answer to your question.

Dominator

  • Newbie
  • *
  • Posts: 37
    • View Profile
SetFramerateLimit problem
« Reply #6 on: July 08, 2009, 07:49:01 pm »
Quote from: "Daazku"
It will be MAXED to ~60fps. It can be lesser.


Yes, but 32 fps is far too little when setting the limit to 60.
I get about 7500 fps without the limit.

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
SetFramerateLimit problem
« Reply #7 on: July 08, 2009, 08:03:15 pm »
I did a simple test and I got my framerate ~62 using SetFramerateLimit.  With VerticalSync enabled I get from 59-61.

drpitch

  • Newbie
  • *
  • Posts: 18
    • View Profile
SetFramerateLimit problem
« Reply #8 on: July 08, 2009, 10:26:19 pm »
Are you sure you don't have vertical sync enabled??
That leap from 60 to 30 fps is a bit suspect...

Dominator

  • Newbie
  • *
  • Posts: 37
    • View Profile
SetFramerateLimit problem
« Reply #9 on: July 09, 2009, 12:29:37 am »
Quote from: "Astrof"
I did a simple test and I got my framerate ~62 using SetFramerateLimit. With VerticalSync enabled I get from 59-61.


Sorry, but posting that it works for you doesn't help me at all.
I already know that it should work, but it simply doesn't for me.

Quote from: "drpitch"
Are you sure you don't have vertical sync enabled??
That leap from 60 to 30 fps is a bit suspect...


Yes I'm sure, since I get ~60 fps when enabled and exactly 32 fps when disabled.

Nkognito

  • Newbie
  • *
  • Posts: 33
    • View Profile
SetFramerateLimit problem
« Reply #10 on: July 09, 2009, 02:35:33 am »
Aren't you doing some huge thing in the main loop (like loading image/music every time or recreating the window), how percent is you app using from the processor ?
The world ends with you, expand your world to enjoy every moment...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SetFramerateLimit problem
« Reply #11 on: July 09, 2009, 07:57:22 am »
What if you try different values for the framerate limit?
Laurent Gomila - SFML developer

Dominator

  • Newbie
  • *
  • Posts: 37
    • View Profile
SetFramerateLimit problem
« Reply #12 on: July 09, 2009, 12:50:39 pm »
Quote from: "Nkognito"
Aren't you doing some huge thing in the main loop (like loading image/music every time or recreating the window), how percent is you app using from the processor ?


See my first post for the code I'm using.
The loop only contains App.DispatchEvents() and App.Display().

Quote from: "Laurent"
What if you try different values for the framerate limit?


Did some tests now:

<22 = fps stay around limit
22-31 = exactly 21 fps
32-61 = exactly 32 fps
62-700 = exactly 64 fps
>700 = unstable jumping between 65 and ~4000 fps

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SetFramerateLimit problem
« Reply #13 on: July 09, 2009, 02:02:39 pm »
Very weird. You should try a sample compiled with the C++ version of SFML, just to make sure that this issue is not related to the C or .Net bindings.

If you can't do it directly let me know, I'll send you such a program.
Laurent Gomila - SFML developer

Dominator

  • Newbie
  • *
  • Posts: 37
    • View Profile
SetFramerateLimit problem
« Reply #14 on: July 09, 2009, 02:21:25 pm »
Same problem in C++.  :(

For now I'll use a workaround.
First I'm enabling vsync and if it equals 60 fps I leave it on, else I disable it again and set the frame limit to 60.

The only problem that can occur then is when vsync doesn't equal 60 fps and the frame limit doesn't work either.

 

anything