From e99175cc04ceb803decb73ab7127dd65cddfbd04 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sun, 18 Jun 2023 12:13:24 +0200
Subject: [PATCH] examples: fix 'conversion from float to int' warning
---
examples/showanim.c | 9 +++++----
examples/showimage.c | 9 +++++----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/examples/showanim.c b/examples/showanim.c
index 5e476ac8..3b59acb5 100644
--- a/examples/showanim.c
+++ b/examples/showanim.c
@@ -33,11 +33,12 @@ static void draw_background(SDL_Renderer *renderer, int w, int h)
};
int i, x, y;
SDL_FRect rect;
+ const int dx = 8, dy = 8;
- rect.w = 8.0f;
- rect.h = 8.0f;
- for (y = 0; y < h; y += rect.h) {
- for (x = 0; x < w; x += rect.w) {
+ rect.w = (float)dx;
+ rect.h = (float)dy;
+ for (y = 0; y < h; y += dy) {
+ for (x = 0; x < w; x += dx) {
/* use an 8x8 checkerboard pattern */
i = (((x ^ y) >> 3) & 1);
SDL_SetRenderDrawColor(renderer, col[i].r, col[i].g, col[i].b, col[i].a);
diff --git a/examples/showimage.c b/examples/showimage.c
index 372dd262..80d6fe3c 100644
--- a/examples/showimage.c
+++ b/examples/showimage.c
@@ -33,11 +33,12 @@ static void draw_background(SDL_Renderer *renderer, int w, int h)
};
int i, x, y;
SDL_FRect rect;
+ const int dx = 8, dy = 8;
- rect.w = 8.0f;
- rect.h = 8.0f;
- for (y = 0; y < h; y += rect.h) {
- for (x = 0; x < w; x += rect.w) {
+ rect.w = (float)dx;
+ rect.h = (float)dy;
+ for (y = 0; y < h; y += dy) {
+ for (x = 0; x < w; x += dx) {
/* use an 8x8 checkerboard pattern */
i = (((x ^ y) >> 3) & 1);
SDL_SetRenderDrawColor(renderer, col[i].r, col[i].g, col[i].b, col[i].a);