Connecting Tech Pros Worldwide Help | Site Map

Problem with Simple Directmedia Layer (SDL_Delay)

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 18th, 2007, 03:35 AM
SpiralCorp
Guest
 
Posts: n/a
Default Problem with Simple Directmedia Layer (SDL_Delay)

I'm having some trouble with SDL_Delay. I'm trying to limit framerate
for a
little tech-demo practice thing I'm doing. Now, this works perfectly:

==============
while (fps.stop() < ( 1000 / FPS ) ){ //fps.stop() being part of my
timer
//wait // class it returns the
enlapsed time
} //between start()
and stop().
==============

Of course, this uses up all the CPU time available and skips when
anything
else happens. None of which are acceptable. So I used this instead:

==============
time = 33 - fps.stop(); //Time being Uint32
if ( time 0 ){
SDL_Delay( time );
}
==============

This is when it all breaks down. The delay has a very unpredictable
behaviour.
It starts working just fine and with no speed variations... then the
animation
just stops and none of the events respond. Clearly stuck in the delay
function.

So what gives? Am I doing anything wrong?

Heres the whole code from the modified version (SDL_Delay one)
http://pastebin.com/m3719631

Thanks


  #2  
Old July 18th, 2007, 04:05 AM
Ian Collins
Guest
 
Posts: n/a
Default Re: Problem with Simple Directmedia Layer (SDL_Delay)

SpiralCorp wrote:
Quote:
I'm having some trouble with SDL_Delay.
This isn't a standard C++ function, try a group dedicated to your platform.


--
Ian Collins.
  #3  
Old July 18th, 2007, 04:15 AM
Kai-Uwe Bux
Guest
 
Posts: n/a
Default Re: Problem with Simple Directmedia Layer (SDL_Delay)

SpiralCorp wrote:
Quote:
I'm having some trouble with SDL_Delay. I'm trying to limit framerate
for a
little tech-demo practice thing I'm doing. Now, this works perfectly:
>
==============
while (fps.stop() < ( 1000 / FPS ) ){ //fps.stop() being part of my
timer
//wait // class it returns the
enlapsed time
} //between start()
and stop().
==============
>
Of course, this uses up all the CPU time available and skips when
anything
else happens. None of which are acceptable. So I used this instead:
>
==============
time = 33 - fps.stop(); //Time being Uint32
UInt32 looks like an _unsigned_ type. Note that unsigned types cannot hold
negative values. If fps.stop() returns something greater than 33, the left
hand side is negative and will be converted to a (probably very large)
unsigned integer in the assignment.
Quote:
if ( time 0 ){
Note that the above condition is equivalent to time != 0 if time is
unsigned. Is that really what you want?

Quote:
SDL_Delay( time );
}
==============
>
This is when it all breaks down. The delay has a very unpredictable
behaviour.
It starts working just fine and with no speed variations... then the
animation
just stops and none of the events respond. Clearly stuck in the delay
function.
>
So what gives? Am I doing anything wrong?
>
Heres the whole code from the modified version (SDL_Delay one)
http://pastebin.com/m3719631

Best

Kai-Uwe Bux

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.