|
|
@@ -30,8 +30,8 @@
|
|
|
#endif
|
|
|
|
|
|
#include <time.h>
|
|
|
-#include <sys/timeb.h>
|
|
|
-#include <iostream.h>
|
|
|
+#include <chrono>
|
|
|
+#include <iostream>
|
|
|
#include <math.h>
|
|
|
|
|
|
extern void pfeil();
|
|
|
@@ -42,9 +42,9 @@ extern void zifferblatt(int);
|
|
|
extern void spirale(int, int);
|
|
|
|
|
|
GLfloat movpropeller = 0.0f;
|
|
|
-struct _timeb tstruct;
|
|
|
struct tm *jetzt;
|
|
|
time_t ltime;
|
|
|
+int milliseconds = 0;
|
|
|
|
|
|
int tmp=0;
|
|
|
float drehung=0.0;
|
|
|
@@ -81,13 +81,17 @@ void RenderScene(void)
|
|
|
glPushMatrix();
|
|
|
|
|
|
glScalef(0.3f, 0.3f, 0.3f);
|
|
|
+ if(jetzt == nullptr) {
|
|
|
+ std::cerr << "Fehler: std::localtime konnte nicht ausgefÜhrt werden!" << std::endl;
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
+ }
|
|
|
zifferblatt(jetzt->tm_hour);
|
|
|
|
|
|
glPopMatrix();
|
|
|
glPushMatrix();
|
|
|
glTranslatef(0.0f, 0.5f, 0.0f);
|
|
|
glScalef(0.15f, 0.15f, 0.15f);
|
|
|
- spirale(jetzt->tm_sec, tstruct.millitm);
|
|
|
+ spirale(jetzt->tm_sec, milliseconds);
|
|
|
|
|
|
glPopMatrix();
|
|
|
glPushMatrix();
|
|
|
@@ -145,6 +149,9 @@ void Reshape(int width,int height)
|
|
|
|
|
|
void Animate ()
|
|
|
{
|
|
|
+ auto now = std::chrono::system_clock::now();
|
|
|
+ auto duration = now.time_since_epoch();
|
|
|
+ auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
|
|
|
// An dieser Stelle werden Berechnungen durchgeführt, die zu einer
|
|
|
// Animation der Szene erforderlich sind. Dieser Prozess läuft im Hintergrund.
|
|
|
|
|
|
@@ -153,10 +160,9 @@ void Animate ()
|
|
|
else
|
|
|
movpropeller = 0.0f;
|
|
|
|
|
|
- _ftime( &tstruct );
|
|
|
- time( <ime );
|
|
|
- jetzt = localtime( <ime );
|
|
|
-
|
|
|
+ milliseconds = millis % 1000;
|
|
|
+ std::time_t t = std::time(nullptr);
|
|
|
+ jetzt = std::localtime(&t);
|
|
|
|
|
|
glutPostRedisplay(); // Bewirkt redraw des Fensters
|
|
|
}
|
|
|
@@ -164,7 +170,15 @@ void Animate ()
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
|
- cout<<"Startprogramm fuer das Bachelor gd-Praktikum"<<endl;
|
|
|
+ std::cout<<"Startprogramm fuer das Bachelor gd-Praktikum"<<std::endl;
|
|
|
+
|
|
|
+ std::time_t t = std::time(nullptr);
|
|
|
+ jetzt = std::localtime(&t);
|
|
|
+ if(jetzt == nullptr) {
|
|
|
+ std::cerr << "Fehler: std::localtime konnte nicht ausgefÜhrt werden!" << std::endl;
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
+ }
|
|
|
+
|
|
|
glutInit ( &argc, argv );
|
|
|
glutInitDisplayMode ( GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH );
|
|
|
glutInitWindowSize ( 600,600 );
|