Fixed bug #5071 - Float conversion warnings in SDL_render.c (see also #5003)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index e2c539c..7879392 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -356,10 +356,11 @@ QueueCmdSetViewport(SDL_Renderer *renderer)
if (cmd != NULL) {
cmd->command = SDL_RENDERCMD_SETVIEWPORT;
cmd->data.viewport.first = 0; /* render backend will fill this in. */
- cmd->data.viewport.rect.x = renderer->viewport.x;
- cmd->data.viewport.rect.y = renderer->viewport.y;
- cmd->data.viewport.rect.w = renderer->viewport.w;
- cmd->data.viewport.rect.h = renderer->viewport.h;
+ /* Convert SDL_FRect to SDL_Rect */
+ cmd->data.viewport.rect.x = (int)SDL_floor(renderer->viewport.x);
+ cmd->data.viewport.rect.y = (int)SDL_floor(renderer->viewport.y);
+ cmd->data.viewport.rect.w = (int)SDL_floor(renderer->viewport.w);
+ cmd->data.viewport.rect.h = (int)SDL_floor(renderer->viewport.h);
retval = renderer->QueueSetViewport(renderer, cmd);
if (retval < 0) {
cmd->command = SDL_RENDERCMD_NO_OP;
@@ -385,10 +386,11 @@ QueueCmdSetClipRect(SDL_Renderer *renderer)
} else {
cmd->command = SDL_RENDERCMD_SETCLIPRECT;
cmd->data.cliprect.enabled = renderer->clipping_enabled;
- cmd->data.cliprect.rect.x = renderer->clip_rect.x;
- cmd->data.cliprect.rect.y = renderer->clip_rect.y;
- cmd->data.cliprect.rect.w = renderer->clip_rect.w;
- cmd->data.cliprect.rect.h = renderer->clip_rect.h;
+ /* Convert SDL_FRect to SDL_Rect */
+ cmd->data.cliprect.rect.x = (int)SDL_floor(renderer->clip_rect.x);
+ cmd->data.cliprect.rect.y = (int)SDL_floor(renderer->clip_rect.y);
+ cmd->data.cliprect.rect.w = (int)SDL_floor(renderer->clip_rect.w);
+ cmd->data.cliprect.rect.h = (int)SDL_floor(renderer->clip_rect.h);
SDL_memcpy(&renderer->last_queued_cliprect, &renderer->clip_rect, sizeof (SDL_Rect));
renderer->last_queued_cliprect_enabled = renderer->clipping_enabled;
renderer->cliprect_queued = SDL_TRUE;
@@ -2423,10 +2425,10 @@ SDL_RenderGetViewport(SDL_Renderer * renderer, SDL_Rect * rect)
CHECK_RENDERER_MAGIC(renderer, );
if (rect) {
- rect->x = renderer->viewport.x / renderer->scale.x;
- rect->y = renderer->viewport.y / renderer->scale.y;
- rect->w = renderer->viewport.w / renderer->scale.x;
- rect->h = renderer->viewport.h / renderer->scale.y;
+ rect->x = (int)SDL_floor(renderer->viewport.x / renderer->scale.x);
+ rect->y = (int)SDL_floor(renderer->viewport.y / renderer->scale.y);
+ rect->w = (int)SDL_floor(renderer->viewport.w / renderer->scale.x);
+ rect->h = (int)SDL_floor(renderer->viewport.h / renderer->scale.y);
}
}
@@ -2466,10 +2468,10 @@ SDL_RenderGetClipRect(SDL_Renderer * renderer, SDL_Rect * rect)
CHECK_RENDERER_MAGIC(renderer, )
if (rect) {
- rect->x = renderer->clip_rect.x / renderer->scale.x;
- rect->y = renderer->clip_rect.y / renderer->scale.y;
- rect->w = renderer->clip_rect.w / renderer->scale.x;
- rect->h = renderer->clip_rect.h / renderer->scale.y;
+ rect->x = (int)SDL_floor(renderer->clip_rect.x / renderer->scale.x);
+ rect->y = (int)SDL_floor(renderer->clip_rect.y / renderer->scale.y);
+ rect->w = (int)SDL_floor(renderer->clip_rect.w / renderer->scale.x);
+ rect->h = (int)SDL_floor(renderer->clip_rect.h / renderer->scale.y);
}
}
@@ -4078,10 +4080,10 @@ SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
format = SDL_GetWindowPixelFormat(renderer->window);
}
- real_rect.x = renderer->viewport.x;
- real_rect.y = renderer->viewport.y;
- real_rect.w = renderer->viewport.w;
- real_rect.h = renderer->viewport.h;
+ real_rect.x = (int)SDL_floor(renderer->viewport.x);
+ real_rect.y = (int)SDL_floor(renderer->viewport.y);
+ real_rect.w = (int)SDL_floor(renderer->viewport.w);
+ real_rect.h = (int)SDL_floor(renderer->viewport.h);
if (rect) {
if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
return 0;