SDL_RenderGeometry: remove some warning "dereferencing type-punned pointer might break strict-aliasing"

main
Sylvain 2021-12-11 17:19:00 +01:00
parent e2ade2bfc4
commit 3e43d6e34b
No known key found for this signature in database
GPG Key ID: 5F87E02E5BC0939E
1 changed files with 6 additions and 3 deletions

View File

@ -545,6 +545,7 @@ QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int cou
const int num_indices = 6 * count; const int num_indices = 6 * count;
const int size_indices = 4; const int size_indices = 4;
int cur_indice = 0; 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) { for (i = 0; i < count; ++i) {
float minx, miny, maxx, maxy; 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, 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, num_vertices, indices, num_indices, size_indices,
1.0f, 1.0f); 1.0f, 1.0f);
@ -3339,6 +3340,7 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
const int size_indices = 4; const int size_indices = 4;
float minu, minv, maxu, maxv; float minu, minv, maxu, maxv;
float minx, miny, maxx, maxy; 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; minu = (float) (real_srcrect.x) / (float) texture->w;
minv = (float) (real_srcrect.y) / (float) texture->h; minv = (float) (real_srcrect.y) / (float) texture->h;
@ -3369,7 +3371,7 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
xy[7] = maxy; xy[7] = maxy;
retval = QueueCmdGeometry(renderer, texture, 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, num_vertices,
indices, num_indices, size_indices, indices, num_indices, size_indices,
renderer->scale.x, renderer->scale.y); 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 radian_angle = (float)((M_PI * angle) / 180.0);
const float s = SDL_sinf(radian_angle); const float s = SDL_sinf(radian_angle);
const float c = SDL_cosf(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; minu = (float) (real_srcrect.x) / (float) texture->w;
minv = (float) (real_srcrect.y) / (float) texture->h; 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; xy[7] = (s_minx + c_maxy) + centery;
retval = QueueCmdGeometry(renderer, texture, 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, num_vertices,
indices, num_indices, size_indices, indices, num_indices, size_indices,
renderer->scale.x, renderer->scale.y); renderer->scale.x, renderer->scale.y);