]> Nishi Git Mirror - mivfx.git/commitdiff
負荷を減らした 5/head 1718782721235279928/master 1718782721235279928/tmp_refs/heads/master 1718908096182280876/master 1718908096182280876/tmp_refs/heads/master 1718946804755956962/master 1718946804755956962/tmp_refs/heads/master 1718986098871237839/master 1718986098871237839/tmp_refs/heads/master 1719060598358064248/master 1719060598358064248/tmp_refs/heads/master 1719378213686474578/master 1719378213686474578/tmp_refs/heads/master 1719425945674810488/master 1719425945674810488/tmp_refs/heads/master 1719751550949367213/master 1719751550949367213/tmp_refs/heads/master 1719863149261115059/master 1719863149261115059/tmp_refs/heads/master 1723332978329637936/master 1723332978329637936/tmp_refs/heads/master
authortakashi <tak4noreply@example.com>
Wed, 14 Feb 2024 14:25:53 +0000 (14:25 +0000)
committertakashi <tak4noreply@example.com>
Wed, 14 Feb 2024 14:25:53 +0000 (14:25 +0000)
main.c

diff --git a/main.c b/main.c
index 65f0feb1645231f60aa4278142d1c9502dc18009..d950680980160c6582114122c7dd6251355f3b0c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -2,6 +2,7 @@
 #include <SDL2/SDL_image.h>
 #include <stdio.h>
 #include <stdbool.h>
+#define DELAY_MS 50
 
 int main(int argc, char* argv[]) {
   if (argc < 2) {
@@ -113,17 +114,22 @@ int main(int argc, char* argv[]) {
         // テキスチャーのれんダーリングサイズの設定
         SDL_Rect renderQuad = { (newWidth - scaledWidth) / 2, (newHeight - scaledHeight) / 2, scaledWidth, scaledHeight };
         SDL_RenderCopy(renderer, texture, NULL, &renderQuad);
-      }
-    }
+      } else if (e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_EXPOSED) {
+        // 再描画が必要な場合
+
+        // 画面の更新
+        SDL_RenderClear(renderer);
 
-    // 画面の更新
-    SDL_RenderClear(renderer);
+        // テキスチャーの表示
+        SDL_RenderCopy(renderer, texture, NULL, NULL);
 
-    // テキスチャーの表示
-    SDL_RenderCopy(renderer, texture, NULL, NULL);
+        // 画面の更新
+        SDL_RenderPresent(renderer);
+      }
+    }
 
-    // 画面の更新
-    SDL_RenderPresent(renderer);
+    // 休ませる
+    SDL_Delay(DELAY_MS);
   }
 
   // 掃除