Save CPU time instead of wait for vsync

Share your advanced PureBasic knowledge/code with the community.
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

Thanx for the help!

Very weird! I get a few beeps per second, but when I run my game on a windowed screen I get only 4-6% processor usage... :shock:

A delay of 1 or 2 works, but anything higher than 10 gives me massive slowdowns....

SetFrameRate() uses exactly the same value as EnumDisplaySettings_() command gives: 60.

This is driving me nuts! I want my Amiga back... and one refreshrate for all people on this planet!

So for now I'll stick to the original FlipBuffers().
The Human Code Machine / Masters' Design Group
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

why are you using delay() in a loop? i think its the badest think a coder can do, isnt it? if you set delay(2) for example the game may run smooth on your machine but on a slower machine this may happen that your game may run slower...

And i dont like to limit the fps of a game! As i said before... on slower machines the game may run slower due fact of setting the fps the game should run! I even dislike this way, because when i buy a very expensive and powerfull gfxcard, i want fell the power of this and getting a nice fps instead just only 25 or 50 or 60 fps for example!
Pantcho!!
Enthusiast
Enthusiast
Posts: 538
Joined: Tue Feb 24, 2004 3:43 am
Location: Israel
Contact:

Post by Pantcho!! »

I dont understand what is you are all talking but i understood that you are saying that the graphics in PB uses loads of cpu resources
and va!n is right it might go slow on fast computers if you put on delay

my recommand: do a user lib that dedects cpu speed+ graphics card and put on a appropiate delay. :shock:

good day!
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

va!n wrote:why are you using delay() in a loop? i think its the badest think a coder can do, isnt it? if you set delay(2) for example the game may run smooth on your machine but on a slower machine this may happen that your game may run slower...
And i dont like to limit the fps of a game! As i said before... on slower machines the game may run slower due fact of setting the fps the game should run! I even dislike this way, because when i buy a very expensive and powerfull gfxcard, i want fell the power of this and getting a nice fps instead just only 25 or 50 or 60 fps for example!
Well, i suppose you are talking about adding a static value for Delay() after Flipbuffers(), then yes, you are right in what you say.
But the myFlipBuffers routine just delays a dynamic value which, for each frame, will depend on the surplus rendering time, so it shouldn't to slow down a slower machine.
Pantcho!! wrote:my recommand: do a user lib that dedects cpu speed+ graphics card and put on a appropiate delay. :shock:
Yes, that is a not bad idea. To use a static parameter for a Delay() function after FlipBuffers() which depends on machine speed :)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

@va!n 2D Games don't need more than 60fps and I don't want to use subpixel precision with a simple 2D Game!

@Psychophanta I get diffrent results using your approach! On my notebook your routine works great! But on my desktop PC movement is still jerky as mentioned above!

@Fred Perhaps you can add an optional parameter to FlipBuffers() which gives cpu back to the system until vsync was reached.
The Human Code Machine / Masters' Design Group
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

THCM wrote:@Psychophanta I get diffrent results using your approach! On my notebook your routine works great! But on my desktop PC movement is still jerky as mentioned above!
Dunno! but i guees it could be due to the different accuracy of hardware ticks :?
THCM wrote:@Fred Perhaps you can add an optional parameter to FlipBuffers() which gives cpu back to the system until vsync was reached.
Ohhh! it seems to be not so easy to do it well done.
Take a look at here:
viewtopic.php?t=12747
http://www.codeproject.com/gdi/tearingfreedrawing.asp
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply