[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] OpenGL repaint loop



Fredag den 12. august 2005 11:55 skrev Robert Larsen:
> Mads Bondo Dydensborg wrote:
> >>Vil det ikke sætte processoren i 100% arbejde ?
> >
> >Jow, og det er også sådan spil gør. Hvis du ikke vil det, kan du jo lave:
> >
> >while ( running ) {
> >     if ( World->update() ) { // update returnerer true, hvis noget ændret
> >         World->draw(); // Tilbage til update umiddelbart efter draw.
> >     } else {
> >          sleep( 20 ms );
> >     }
> >}
>
> Fint nok. Det lyder lidt bedre, men min World::update funktion bliver
> kaldt 1000000 gange hvor intet ændres. Er det tungt at sætte tråden til
> at sove, og først vække den, når Update vil returnere 'true' ?
> Altså noget pthread_cond_{wait,signal} ?

Hvis du sætter den til at returnere false, hvis verden ikke er ændret, vil den 
jo kun blive kaldt 1000/20 = 50 gange i sekundet?!

Det er ikke tungt at sætte noget til at vente, hvis du ved hvad du venter på.

Mads

-- 
Mads Bondo Dydensborg     sslug@sslug     http://www.madsdydensborg.dk/

I find the whole business of religion profoundly interesting. But it
does mystify me that otherwise intelligent people take it seriously.
                                        - Douglas Adams



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-09-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *