SDL_RenderGeometry: remove some warning "dereferencing type-punned pointer might break strict-aliasing"
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
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index b421c7b..9f8910b 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -545,6 +545,7 @@ QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int cou
const int num_indices = 6 * count;
const int size_indices = 4;
int cur_indice = 0;
+ int color = (renderer->color.r << 0) | (renderer->color.g << 8) | (renderer->color.b << 16) | ((Uint32)renderer->color.a << 24);
for (i = 0; i < count; ++i) {
float minx, miny, maxx, maxy;
@@ -573,7 +574,7 @@ QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int cou
}
retval = renderer->QueueGeometry(renderer, cmd, NULL,
- xy, xy_stride, (int *) &renderer->color, 0 /* color_stride */, NULL, 0,
+ xy, xy_stride, &color, 0 /* color_stride */, NULL, 0,
num_vertices, indices, num_indices, size_indices,
1.0f, 1.0f);
@@ -3339,6 +3340,7 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
const int size_indices = 4;
float minu, minv, maxu, maxv;
float minx, miny, maxx, maxy;
+ int color = (texture->color.r << 0) | (texture->color.g << 8) | (texture->color.b << 16) | ((Uint32)texture->color.a << 24);
minu = (float) (real_srcrect.x) / (float) texture->w;
minv = (float) (real_srcrect.y) / (float) texture->h;
@@ -3369,7 +3371,7 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
xy[7] = maxy;
retval = QueueCmdGeometry(renderer, texture,
- xy, xy_stride, (int *)&texture->color, 0 /* color_stride */, uv, uv_stride,
+ xy, xy_stride, &color, 0 /* color_stride */, uv, uv_stride,
num_vertices,
indices, num_indices, size_indices,
renderer->scale.x, renderer->scale.y);
@@ -3495,6 +3497,7 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture,
const float radian_angle = (float)((M_PI * angle) / 180.0);
const float s = SDL_sinf(radian_angle);
const float c = SDL_cosf(radian_angle);
+ int color = (texture->color.r << 0) | (texture->color.g << 8) | (texture->color.b << 16) | ((Uint32)texture->color.a << 24);
minu = (float) (real_srcrect.x) / (float) texture->w;
minv = (float) (real_srcrect.y) / (float) texture->h;
@@ -3554,7 +3557,7 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture,
xy[7] = (s_minx + c_maxy) + centery;
retval = QueueCmdGeometry(renderer, texture,
- xy, xy_stride, (int *)&texture->color, 0 /* color_stride */, uv, uv_stride,
+ xy, xy_stride, &color, 0 /* color_stride */, uv, uv_stride,
num_vertices,
indices, num_indices, size_indices,
renderer->scale.x, renderer->scale.y);