Godzil 3 年 前
コミット
cb3af26073
2 ファイル変更15 行追加4 行削除
  1. 6 0
      source/include/display.h
  2. 9 4
      source/main.c

+ 6 - 0
source/include/display.h

@@ -12,6 +12,12 @@
 
 #include <SDL.h>
 
+/***********************************************************************************************************************
+ * Constants
+ **********************************************************************************************************************/
+#define FPS (30)
+#define FRAME_TARGET_TIME (1000 / FPS)
+
 /***********************************************************************************************************************
  * Global variables
  **********************************************************************************************************************/

+ 9 - 4
source/main.c

@@ -19,6 +19,7 @@
 #include <vector.h>
 
 bool isRunning = true;
+int previousFrameTime = 0;
 
 #define N_POINTS (9*9*9)
 vec3_t cubePoints[N_POINTS];
@@ -36,7 +37,7 @@ vec3_t cubeRotation =
     .z = 0,
 };
 
-double fovFactor = 640 ;
+double fovFactor = 820 ;
 
 void setup()
 {
@@ -120,9 +121,13 @@ void update()
 {
     int i;
 
-    cubeRotation.x += 0.001;
-    cubeRotation.y += 0.001;
-    cubeRotation.z += 0.001;
+    while(!SDL_TICKS_PASSED(SDL_GetTicks(), previousFrameTime + FRAME_TARGET_TIME));
+
+    previousFrameTime = SDL_GetTicks();
+
+    cubeRotation.x += 0.01;
+    cubeRotation.y += 0.01;
+    cubeRotation.z += 0.01;
 
     for(i = 0; i < N_POINTS; i++)
     {