Skip to content

Commit

Permalink
Update hardcoded value of pi to use SDL constant SDL_PI_F for improve…
Browse files Browse the repository at this point in the history
…d consistency and readability.
  • Loading branch information
Nour Fouad authored and slouken committed Mar 9, 2024
1 parent fcb132b commit b6c5ad0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/testgeometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@

/* Simple program: draw a RGB triangle, with texture */

#include <SDL3/SDL_test_common.h>
#include <SDL3/SDL_main.h>
#include "testutils.h"
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <SDL3/SDL_test_common.h>

#ifdef SDL_PLATFORM_EMSCRIPTEN
#include <emscripten/emscripten.h>
Expand Down Expand Up @@ -136,23 +137,23 @@ static void loop(void)
cx += translate_cx;
cy += translate_cy;

a = (angle * 3.1415f) / 180.0f;
a = (angle * SDL_PI_F) / 180.0f;
verts[0].position.x = cx + d * SDL_cosf(a);
verts[0].position.y = cy + d * SDL_sinf(a);
verts[0].color.r = 1.0f;
verts[0].color.g = 0;
verts[0].color.b = 0;
verts[0].color.a = 1.0f;

a = ((angle + 120) * 3.1415f) / 180.0f;
a = ((angle + 120) * SDL_PI_F) / 180.0f;
verts[1].position.x = cx + d * SDL_cosf(a);
verts[1].position.y = cy + d * SDL_sinf(a);
verts[1].color.r = 0;
verts[1].color.g = 1.0f;
verts[1].color.b = 0;
verts[1].color.a = 1.0f;

a = ((angle + 240) * 3.1415f) / 180.0f;
a = ((angle + 240) * SDL_PI_F) / 180.0f;
verts[2].position.x = cx + d * SDL_cosf(a);
verts[2].position.y = cy + d * SDL_sinf(a);
verts[2].color.r = 0;
Expand Down

0 comments on commit b6c5ad0

Please sign in to comment.