Jump to content

  • Log In with Google      Sign In   
  • Create Account

Blits per second


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 najmuddin   Members   -  Reputation: 181

Like
0Likes
Like

Posted 29 December 2012 - 01:21 AM

Greetings!

Before anything I must say excuse me for my english, I'm trying to do my best :).

I'm developing my first game in C++ using SDL. I blit all of the surfaces into one I call buffer and then I blit that one into the screen (as I used to do when I used Allegro). I'm not using delays, I just control the time in which each object is rendered but anyway, even if nothing has changed, the whole surfaces are blitted into the screen at every cycle of the game. My questions are:

1- Should I avoid blitting if nothing has changed?
2- What could be the consequences of that if the V-Sync is disabled and the game is running al high FPS?

Thank you !

Sponsor:

#2 kd7tck   Members   -  Reputation: 715

Like
1Likes
Like

Posted 29 December 2012 - 03:34 AM

You should cap renderer refresh rate at the monitor refresh rate, typically 60 fps.  This doesn't mean that you limit the number of game cycles to 60 hz, only the blitting.  As long as you keep it lined up at monitor refresh rate, it is okay to disable v-sync.  Otherwise v-sync might be needed on slower systems.  When the program is refreshing every say half second and there is no v-sync, this will result in tearing artifacts or partially drawn passes in cases of high fps.

 

Now if nothing changes, simply copy your last output and refresh. Sometimes it is best to draw to another target like a texture or surface(aka software renderer), then blit that until something changes.



#3 najmuddin   Members   -  Reputation: 181

Like
0Likes
Like

Posted 29 December 2012 - 09:04 AM

Thank you... 

 

So. if I want to do it could I do something like this:

 

int timerA = GetTime();   // GetTime returns miliseconds after the code started
int timerB;

while(!Esc())
{
  timerB = GetTime();

  if((TimerB - TimerA) >= 16)  // 16 is the aproximation to 1000 milisecs. / 60.
  {
    blit(buffer, screen);
    timerA = GetTime();
  }
}

 

 

Is there a better way to set the blitting at 60Hz (without using that aproximate value)? 



#4 kd7tck   Members   -  Reputation: 715

Like
1Likes
Like

Posted 29 December 2012 - 01:26 PM

Abstract away.  Personaly now that I think about it, as long as you don't blit more than the monitor refresh rate you don't need to worry about this. This should only be implimented to slow down a fast program, v-sync can be used in place of it if you want. In the cases of slow programs just let er rip and use delta time to calculate movements based on time, rather than frame number.

class TimeDif(){
     long range = 16;
     long lastTime = GetTime();

     bool getDif(){
          long dif = GetTime() - lastTime;

          if(dif >= range){
               lastTime = GetTime();
               return true;
          }

          return false;
     }

}

Edited by kd7tck, 29 December 2012 - 01:28 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS