123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #include "Render.h"
- #include <Zeit.h>
- // Inhalt der Render Klasse aus Render.h
- // Konstruktor
- Render::Render( Bildschirm *b )
- {
- bildschirm = b;
- beendet = 0;
- ref = 1;
- }
- // Destruktor
- Render::~Render()
- {
- beenden( );
- bildschirm->release();
- }
- // nicht constant
- void Render::thread()
- {
- ZeitMesser *timer = new ZeitMesser();
- while( !beendet )
- {
- double tickVal = timer->getSekunden();
- timer->messungStart();
- bildschirm->tick( tickVal );
- bildschirm->render();
- if( tickVal < 1.0 / 30.0 )
- Sleep( (int)( ( 1.0 / 30.0 - tickVal ) * 1000 ) );
- timer->messungEnde();
- }
- timer->release();
- beendet = 0;
- run = 0;
- }
- void Render::beenden()
- {
- beendet = 1;
- warteAufThread( 1000 );
- }
- // constant
- // Reference Counting
- Render *Render::getThis()
- {
- ref++;
- return this;
- }
- Render *Render::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
|