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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - inaudax

Pages: [1]
1
Graphics / Vsync limits entire loop to 60 cycles per second
« on: September 13, 2014, 07:29:12 am »
My understanding of vsync in SFML is that it is only supposed to limit the calls to the display() function of sf::RenderWindow.  However, whenever I have vsync enabled the entire game loop gets limited to 60 cycles per second.  Has anyone else encountered this issue?

2
System / Re: sf::Clock speed inconsistent
« on: December 26, 2013, 06:06:27 am »
Why do people always convert sf::Time objects immediately to float (or even worse, double)? The idea behind the sf::Time class is to have a unique and type-safe way to refer to time spans in SFML. As it overloads all the necessary operators, there is no need for conversions. Only do so if you really need the float value, for example to multiply the time with a velocity.

By the way, I would rename updateTimer to updateTime (or even clearer: interval or frameDuration or similar).
float delta = 0.f;
int updates = 0;

//in loop
sf::Time now = clock.getElapsedTime();
delta += (now - time) / updateTime;

I tried doing it without the conversion but it gave me an error with the division operator.   Probably just something I did wrong.  I'll double (no pun intended) check.  Duly noted on the naming.  Thanks!

3
System / Re: sf::Clock speed inconsistent
« on: December 25, 2013, 09:42:30 am »
I figured it out:

//before loop starts
sf::Clock clock;
sf::Time time = clock.getElapsedTime();
sf::Time updateTimer = sf::seconds( 1.0f / 60.0f );
double delta = 0;
int updates = 0;

//in loop
sf::Time now = clock.getElapsedTime();
delta += ( now.asSeconds() - time.asSeconds() ) / updateTimer.asSeconds();
time = now;
while ( delta >= 1 )
{
     Update();
     updates++;
     delta--;
}

 

This put it at a solid and consistent 60 fps which is what I was looking for.

4
System / Re: sf::Clock speed inconsistent
« on: December 25, 2013, 09:15:24 am »
Please use the [ code=cpp ][ /code ] forum tags  ;)

As for your problem, you probably want something like this...

//Before loop
sf::Clock clock;
sf::Time updateTime = clock.getElapsedTime();
sf::Time updateTimer = sf::seconds( 1.0f / 60.0f );

int updates = 0;

//in loop
updateTime += clock.restart();
while ( updateTime >= updateTimer )
{
     Update();
}

Still get the same...

5
System / sf::Clock speed inconsistent
« on: December 25, 2013, 06:26:38 am »
I am having an issue with the clock speed being inconsistent.  Long story short, when I call my render method the clock speed seems to slow down a bit.  When I disable the render method the clock speeds back up.  Anyone else encountered this issue?  The amount is very small and barely noticeable.  Below is a very simplified sample of the code I am using:

//Before loop
sf::Clock clock;
sf::Time updateTime = clock.getElapsedTime();
sf::Time updateTimer = sf::seconds( 1.0f / 60.0f );

int updates = 0;

//in loop
if ( clock.getElapsedTime() - updateTime > updateTimer )
{
     updateTime = clock.getElapsedTime();
     updates++;
     Update();
}

Without my render method being called, updates runs around 58 or 59 fps but when I call my render method it drops to around 53 and 54 fps.  At the same time I get around 300 fps on my render method so I know it is not the whole thing slowing down.

Suggestions?

BTW I am a noob so I appreciate any feedback.

Thanks!

6
Graphics / Re: Linking problem
« on: November 18, 2013, 02:37:42 am »
Regardless of how sure you are, you should provide the full build command see here on how to.

My guess is that you're linking dynamically but still have SFML_STATIC defined.

That is exactly what it was.  I thought I had gotten rid of the definition but I double checked after reading your post and now it is working perfectly.  Thanks!

7
Graphics / Linking problem
« on: November 18, 2013, 01:24:39 am »
I am having a linking problem with a project I am working on.  I have been over the linking many times and I know for sure that everything is linked properly but whenever I call "draw" on my RenderWindow object I get a link error with RenderStates.  If I use any of the colors i.e. sf::Color::Red I also get a link error but not if I define the color by rgb.  Those are the only errors that I get when I try to compile.  Anyone had this issue or have any suggestions?

Pages: [1]
anything