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

Author Topic: Get the Window FPS  (Read 5122 times)

0 Members and 1 Guest are viewing this topic.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Get the Window FPS
« on: January 29, 2009, 07:25:43 pm »
I can't seem to find a function like: GetFramerateLimit(); for Window.
Soo.... Is there some other way to find the value for what the current frame rate is?
I know how to get the time since the last display update but that won't do it.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Get the Window FPS
« Reply #1 on: January 29, 2009, 07:42:36 pm »
FPS = 1 / GetFrameTime()
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Get the Window FPS
« Reply #2 on: January 29, 2009, 07:52:16 pm »
Quote from: "Laurent"
FPS = 1 / GetFrameTime()


Donno if that will work for me.

I'm kind of making a "BlackOut" - fade effect for like changing scene. And the scene change includes initiation of the new scene, etc. etc and the initiation of the BlackOut object.

So the GetFrameTime() could be longer than the time for one frame. Or am I wrong? Will GetFrameTime never go above max-seconds for a frame? Like if FPS is 20 then it will never go above 1 / 20?

**EDIT**

Ow yeah, I don't want you to think that I'm letting you do the work for me. I'm trying out various things. I have a simple solution of where I just draw the image for fading 15 times. But I want to be able to regulate it by specifying a time.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Get the Window FPS
« Reply #3 on: January 29, 2009, 08:04:46 pm »
The frame time is the duration of the last frame. So it will always give you the actual FPS.

I'm not sure why you need this information, it's usually only needed for debug display. The frame duration is actually a much more useful information.

EDIT: ok I see now. Just define a total duration for your effect, and use the accumulated time (add the frame time at each frame) to interpolate.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Get the Window FPS
« Reply #4 on: January 29, 2009, 08:06:34 pm »
Quote from: "Laurent"
The frame time is the duration of the last frame. So it will always give you the actual FPS.

I'm not sure why you need this information, it's usually only needed for debug display. The frame duration is actually a much more useful information.


Well as I said in my edited part of the last post. I want to specify the "duration" of the fade.
Though I maybe only need the frame duration. Who knows

Thanks.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Get the Window FPS
« Reply #5 on: January 29, 2009, 08:22:59 pm »
Thanks! Worked like a charm with accumulating the time.

But now I have to solve a way to make the alpha-value change for the image based on the time given. I tried with Sprite::SetColor(); before, it didn't really do anything....

I had like this to try it but the display didn't change:
Code: [Select]
sf::Sprite sprite;
sf::Color color;
for(int i = 255; i >= 0; i--) {
color.a = i;
sprite.SetColor(color);
// And then I drew it to the display
}


Ow yeah, sorry, It's off-topic. But my solution to this was to use Image(Color(0, 0, 0, 35)) instead. But that ends up with that I can't change the color.

** EDIT **
Never mind, I fixed it
Developer and Maker of rbSFML and Programmer at Paradox Development Studio