C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Timer-Funktion

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Timo G366ttig
Guest





PostPosted: Tue Jun 01, 2004 4:13 pm    Post subject: Timer-Funktion Reply with quote



Hallo NG,

für ein kleines OpenGL-Projekt suche ich nach einer Möglichkeit, ein
Codestück in bestimmten Zeitabständen aufzurufen.
Also sowas:

for (int i=0; i<100; "warte 1 Sek.")
{
.....
i++;
}

Gibt es da eine einfache Möglichkeit in den Standardbibliotheken?

TIA,
Timo

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Ludwig Pumberger
Guest





PostPosted: Tue Jun 01, 2004 5:49 pm    Post subject: Re: Timer-Funktion Reply with quote



Timo Göttig schrieb:

Quote:
für ein kleines OpenGL-Projekt suche ich nach einer Möglichkeit, ein
Codestück in bestimmten Zeitabständen aufzurufen.
Also sowas:

for (int i=0; i<100; "warte 1 Sek.")
{
.....
i++;
}

Gibt es da eine einfache Möglichkeit in den Standardbibliotheken?

C++ bietet nichts passendes. Dein Betriebssystem sollte aber irgendwas
anbieten. Die Posixfunktion dafür heisst glaube ich sleep (oder wait, oder
delay, kann mir das nie merken).
Böse auf Multithreading Systemen:

start = time(0);
while(start < time(0) + 1)
;

Mit Standardmitteln möglich aber NICHT empfehlenswert.

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Bernhard Walle
Guest





PostPosted: Tue Jun 01, 2004 6:22 pm    Post subject: Re: Timer-Funktion Reply with quote



* Ludwig Pumberger <elpeka (AT) gmx (DOT) at> [2004-06-01 19:49]:
Quote:
Timo Göttig schrieb:

für ein kleines OpenGL-Projekt suche ich nach einer Möglichkeit, ein
Codestück in bestimmten Zeitabständen aufzurufen.
Also sowas:

for (int i=0; i<100; "warte 1 Sek.")
{
.....
i++;
}

Gibt es da eine einfache Möglichkeit in den Standardbibliotheken?

C++ bietet nichts passendes. Dein Betriebssystem sollte aber irgendwas
anbieten. Die Posixfunktion dafür heisst glaube ich sleep (oder wait, oder
delay, kann mir das nie merken).

unsigned int sleep(unsigned int sec);

Quote:
Böse auf Multithreading Systemen:

Wohl auch auf Multitasking-Systemen. (Klassisches UNIX war Single-Thread
aber Multi-Task.)


Gruß,
Bernhard
--
_________ http://www.bwalle.de _________________________________________________
"I might disagree with what you have to say, but I'll defend to
the death your right to say it."
-- Voltaire

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Andreas Volz
Guest





PostPosted: Tue Jun 01, 2004 6:48 pm    Post subject: Re: Timer-Funktion Reply with quote


Quote:
Hallo NG,

für ein kleines OpenGL-Projekt suche ich nach einer Möglichkeit, ein
Codestück in bestimmten Zeitabständen aufzurufen.
Also sowas:

for (int i=0; i<100; "warte 1 Sek.")
{
.....
i++;
}

Gibt es da eine einfache Möglichkeit in den Standardbibliotheken?

Relativ einfach und portabel bekommst du das mit GLUT hin. Jedoch gibt
es für C++ und OpenGL noch geeignetere OpenGL Tools Bibliotheken. Das
ist jedoch in einer anderen Gruppe On-Topic.

Frag hier noch mal (Englisch):
news:comp.graphics.api.opengl

Gruß
Andreas

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Torsten Robitzki
Guest





PostPosted: Tue Jun 01, 2004 9:00 pm    Post subject: Re: Timer-Funktion Reply with quote

Quote:
Böse auf Multithreading Systemen:

start = time(0);
while(start < time(0) + 1)
;


Nicht nur da! Überall, wo man nicht alleine auf dem Zielsystem ist, wird
das keiner gerne sehen.

mfg Torsten

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Torsten Robitzki
Guest





PostPosted: Tue Jun 01, 2004 9:07 pm    Post subject: Re: Timer-Funktion Reply with quote

Timo Göttig wrote:

Quote:
Hallo NG,

für ein kleines OpenGL-Projekt suche ich nach einer Möglichkeit, ein
Codestück in bestimmten Zeitabständen aufzurufen.
Also sowas:

for (int i=0; i<100; "warte 1 Sek.")
{
.....
i++;
}

Ich fänd
for( int i = 0; i != 100; ++i )
{
.....
"warte 1 Sek."
}

schöner :-)

Quote:
Gibt es da eine einfache Möglichkeit in den Standardbibliotheken?

gibt es leider nicht, eine der wohl portabelsten Möglichkeiten ist, aus
Posix (Ist das richtig?) die select() Funktion zu nehmen und auf eine
leere Menge von Descriptoren zu warten oder wenn Du posix threads hast,
eine timed condition variable zu nehmen und auf diese mit time out zu
warten.

mfg Torsten

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Georg Maaß
Guest





PostPosted: Wed Jun 02, 2004 10:38 am    Post subject: Re: Timer-Funktion Reply with quote

Torsten Robitzki wrote:
Quote:
Nicht nur da! Überall, wo man nicht alleine auf dem Zielsystem ist, wird
das keiner gerne sehen.

EON sieht das gerne und kassiert am Ende über die Stromrechnung ab. ;-)

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Marco Budde
Guest





PostPosted: Wed Jun 02, 2004 5:11 pm    Post subject: Re: Timer-Funktion Reply with quote

Timo Göttig wrote:

Quote:
für ein kleines OpenGL-Projekt suche ich nach einer Möglichkeit, ein
Codestück in bestimmten Zeitabständen aufzurufen.
Also sowas:

for (int i=0; i<100; "warte 1 Sek.")
{
.....
i++;
}

Gibt es da eine einfache Möglichkeit in den Standardbibliotheken?

Portabel geht das leider nur mit Polling, so nach dem Motto:

...
time_t start;
time_t stop;

time (&start);

// wait 5 seconds
do
{
}
while (difftime (time (&stop), start) < 5)
...

Aber das ist natürlich extrem ungünstig. Am besten die OS-Funktionen für
sowas portable als Funktion wrappen, z.B. "sleep()" oder "Sleep()".

cu, Marco

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Timo Göttig
Guest





PostPosted: Thu Jun 10, 2004 3:27 pm    Post subject: Re: Timer-Funktion Reply with quote

Hallo NG,

vielen Dank für die zahlreichen Vorschläge!
Per PM kam dann der für mich sinnvollste Vorschlag: die auxIdleFunc() aus
den OpenGL-Bibliotheken.

Es grüßt
Timo Göttig
--
carpe diem noctemque!

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.