RenderGeometry: simplify casting (Thanks Daniel Gibson)

This commit is contained in:
Sylvain 2021-12-12 09:55:23 +01:00
parent d7f66ba1ec
commit 8927d73b1c
No known key found for this signature in database
GPG Key ID: 5F87E02E5BC0939E
1 changed files with 3 additions and 5 deletions

View File

@ -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;