mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-20 15:51:07 +01:00
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:
@@ -32,7 +32,7 @@ typedef struct
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Texture *background;
|
||||
SDL_Texture *sprite;
|
||||
SDL_Rect sprite_rect;
|
||||
SDL_FRect sprite_rect;
|
||||
int scale_direction;
|
||||
} DrawState;
|
||||
|
||||
@@ -68,8 +68,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_RenderTexture(s->renderer, s->sprite, NULL, &s->sprite_rect);
|
||||
|
||||
@@ -122,6 +122,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];
|
||||
@@ -130,8 +131,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