From 8927d73b1cd1ae8d62817c5e69d22bdd2b485260 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Sun, 12 Dec 2021 09:55:23 +0100 Subject: [PATCH] RenderGeometry: simplify casting (Thanks Daniel Gibson) --- src/render/SDL_render.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 9f8910b42..64c2a3b2d 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -3576,19 +3576,17 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture, return retval < 0 ? retval : FlushRenderCommandsIfNotBatching(renderer); } - -#define SDL_OFFSETOF(_TYPE,_MEMBER) ((intptr_t)&(((_TYPE*)0)->_MEMBER)) int SDL_RenderGeometry(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Vertex *vertices, int num_vertices, const int *indices, int num_indices) { - const float *xy = (const float *)((const Uint8 *)vertices + SDL_OFFSETOF(SDL_Vertex, position)); + const float *xy = &vertices[0].position.x; int xy_stride = sizeof (SDL_Vertex); - const int *color = (const int *) ((const Uint8 *)vertices + SDL_OFFSETOF(SDL_Vertex, color)); + const int *color = (int *)&vertices[0].color.r; int color_stride = sizeof (SDL_Vertex); - const float *uv = (const float *)((const Uint8 *)vertices + SDL_OFFSETOF(SDL_Vertex, tex_coord)); + const float *uv = &vertices[0].tex_coord.x; int uv_stride = sizeof (SDL_Vertex); int size_indices = 4;