Removed non-float versions of SDL render API drawing functions
This simplifies the API and removes a level of API translation between the int variants of the functions and the float implementation Fixes https://github.com/libsdl-org/SDL/issues/6656
This commit is contained in:
@@ -29,7 +29,7 @@ typedef struct
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Texture *background;
|
||||
SDL_Texture *sprite;
|
||||
SDL_Rect sprite_rect;
|
||||
SDL_FRect sprite_rect;
|
||||
int scale_direction;
|
||||
} DrawState;
|
||||
|
||||
@@ -48,8 +48,8 @@ void Draw(DrawState *s)
|
||||
{
|
||||
SDL_Rect viewport;
|
||||
SDL_Texture *target;
|
||||
SDL_Point *center = NULL;
|
||||
SDL_Point origin = { 0, 0 };
|
||||
SDL_FPoint *center = NULL;
|
||||
SDL_FPoint origin = { 0.0f, 0.0f };
|
||||
|
||||
SDL_GetRenderViewport(s->renderer, &viewport);
|
||||
|
||||
@@ -72,8 +72,8 @@ void Draw(DrawState *s)
|
||||
s->scale_direction = 1;
|
||||
}
|
||||
}
|
||||
s->sprite_rect.x = (viewport.w - s->sprite_rect.w) / 2;
|
||||
s->sprite_rect.y = (viewport.h - s->sprite_rect.h) / 2;
|
||||
s->sprite_rect.x = (float)((viewport.w - s->sprite_rect.w) / 2);
|
||||
s->sprite_rect.y = (float)((viewport.h - s->sprite_rect.h) / 2);
|
||||
|
||||
SDL_RenderTextureRotated(s->renderer, s->sprite, NULL, &s->sprite_rect, (double)s->sprite_rect.w, center, (SDL_RendererFlip)s->scale_direction);
|
||||
|
||||
@@ -132,6 +132,7 @@ int main(int argc, char *argv[])
|
||||
drawstates = SDL_stack_alloc(DrawState, state->num_windows);
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
DrawState *drawstate = &drawstates[i];
|
||||
int w, h;
|
||||
|
||||
drawstate->window = state->windows[i];
|
||||
drawstate->renderer = state->renderers[i];
|
||||
@@ -140,8 +141,9 @@ int main(int argc, char *argv[])
|
||||
if (!drawstate->sprite || !drawstate->background) {
|
||||
quit(2);
|
||||
}
|
||||
SDL_QueryTexture(drawstate->sprite, NULL, NULL,
|
||||
&drawstate->sprite_rect.w, &drawstate->sprite_rect.h);
|
||||
SDL_QueryTexture(drawstate->sprite, NULL, NULL, &w, &h);
|
||||
drawstate->sprite_rect.w = (float)w;
|
||||
drawstate->sprite_rect.h = (float)h;
|
||||
drawstate->scale_direction = 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user