Browse Source

fixed bug where SDL_Delay recieved an unacceptable value

iver 7 months ago
parent
commit
6ece9d1dab

BIN
builds/final binaries/librasteriver.so


BIN
builds/final binaries/main.bin


+ 9 - 2
src/RasterIver/source code/rasteriver.c

@@ -1419,8 +1419,15 @@ for (int id_x = -width / 2; id_x < width / 2; id_x++){
             delta_time = elapsed_ticks / (double)SDL_GetPerformanceFrequency();
             
             double target_frame_time = 1.0 / fps_cap;
-            
-            SDL_Delay((Uint32)((target_frame_time - delta_time) * 1000.0));
+
+            Uint32 delay_time = (Uint32)((target_frame_time - delta_time) * 1000.0);
+                
+            if (delay_time > 1000){
+                debug_tick_func(RI_DEBUG_MEDIUM, "SDL_Delay is over 1000ms");
+            }
+            else{
+                SDL_Delay(delay_time);
+            }
         }
         
         if (show_fps || debug_fps || fps_cap > 0){

+ 7 - 7
src/launch program/main.c

@@ -13,31 +13,31 @@ int main(){
     RI_SetFlag(RI_FLAG_DEBUG_LEVEL, RI_DEBUG_HIGH);
     RI_SetFlag(RI_FLAG_DEBUG_TICK, 0);
     RI_SetFlag(RI_FLAG_DEBUG_FPS, 0);
-    RI_SetFlag(RI_FLAG_SHOW_FPS, 0);
+    RI_SetFlag(RI_FLAG_SHOW_FPS, 1);
     RI_SetFlag(RI_FLAG_SHOW_FRAME, 0);
     RI_SetFlag(RI_FLAG_SHOW_BUFFER, RI_BUFFER_COMPLETE);
     RI_SetFlag(RI_FLAG_CLEAN_POLYGONS, 1);
     RI_SetFlag(RI_FLAG_POPULATE_POLYGONS, 0);
     RI_SetFlag(RI_FLAG_BE_MASTER_RENDERER, 1);
     RI_SetFlag(RI_FLAG_SHOW_INFO, 0);
-//    RI_SetFpsCap(120);
+    RI_SetFpsCap(120);
 
     if (RI_Init(width, height, "Rasteriver Test") == RI_ERROR){
         return 1;
     }
 
     RI_newObject object_buffer[3] = {
-        {0, 0, 300,       0, 0, 0, -9999999,          100, 100, 100,  "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
+        {0, 0, 1000,       0, 0, 0, -9999999,          100, 100, 100,  "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
         {0, 0, 15,         0, 0, 0, -9999999,  1, 1, 1,     "objects/test_guy_hd.obj", "textures/test_guy_texture.png"},
         {0, 0, 300,      0, 0.0, 0, -9999999,          50, 50, 50,  "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
     };
 
-    RI_objects objects = RI_RequestObjects(object_buffer, 1);
+    //RI_objects objects = RI_RequestObjects(object_buffer, 1);
 
     while (RI_IsRunning() == RI_RUNNING){
-        objects[3] += 0.3;
-        objects[4] -= 0.4;
-        objects[5] += 0.3;
+        // objects[3] += 0.3;
+        // objects[4] -= 0.4;
+        // objects[5] += 0.3;
         
         RI_Tick();
     }