From c734c97210baaef01ea9732ff82ae5f885675570 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Wed, 22 May 2024 21:24:19 +0900 Subject: [PATCH] =?utf8?q?=E6=AE=86=E3=81=A9=E7=9B=B4=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- main.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index d380486..4c64587 100644 --- a/main.c +++ b/main.c @@ -75,16 +75,12 @@ void rotateWindow(int w, int h) { if (angle >= 360.0f) angle = 0.0f; else if (angle <= -360.0f) angle = 0.0f; - int newWindowWidth = h; - int newWindowHeight = w; - renderQuad.x = 10; - renderQuad.y = 10; - renderQuad.w = h; - renderQuad.h = w; - - SDL_SetWindowSize(window, newWindowWidth + 20, newWindowHeight + 20); + imgWidth = h; + imgHeight = w; + SDL_Rect renderQuad = { 10, 10, h, w }; SDL_RenderClear(renderer); + SDL_SetWindowSize(window, imgWidth + 20, imgHeight + 20); SDL_RenderCopyEx(renderer, texture, NULL, &renderQuad, angle, NULL, SDL_FLIP_NONE); SDL_RenderPresent(renderer); } @@ -103,10 +99,10 @@ void windowevent(SDL_Event e) { // GIFアニメーションの停止・続き、0.6.0から追加する予定 } else if (e.key.keysym.sym == SDLK_r) { angle -= 90.0f; - rotateWindow(windowWidth, windowHeight); + rotateWindow(imgWidth, imgHeight); } else if (e.key.keysym.sym == SDLK_t) { angle += 90.0f; - rotateWindow(windowWidth, windowHeight); + rotateWindow(imgWidth, imgHeight); } } else if (e.type == SDL_MOUSEBUTTONDOWN) { if (e.button.button == SDL_BUTTON_LEFT) { -- 2.43.0