mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-03 18:37:40 +00: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:
parent
bf76fc6b05
commit
9c1a9ecb4b
29 changed files with 465 additions and 1119 deletions
|
@ -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,7 +48,8 @@ quit(int rc)
|
|||
SDL_bool
|
||||
DrawComposite(DrawState *s)
|
||||
{
|
||||
SDL_Rect viewport, R;
|
||||
SDL_Rect viewport;
|
||||
SDL_FRect R;
|
||||
SDL_Texture *target;
|
||||
|
||||
static SDL_bool blend_tested = SDL_FALSE;
|
||||
|
@ -103,8 +104,8 @@ DrawComposite(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);
|
||||
|
||||
|
@ -113,10 +114,10 @@ DrawComposite(DrawState *s)
|
|||
|
||||
SDL_SetRenderDrawBlendMode(s->renderer, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetRenderDrawColor(s->renderer, 0xff, 0x00, 0x00, 0x80);
|
||||
R.x = 0;
|
||||
R.y = 0;
|
||||
R.w = 100;
|
||||
R.h = 100;
|
||||
R.x = 0.0f;
|
||||
R.y = 0.0f;
|
||||
R.w = 100.0f;
|
||||
R.h = 100.0f;
|
||||
SDL_RenderFillRect(s->renderer, &R);
|
||||
SDL_SetRenderDrawBlendMode(s->renderer, SDL_BLENDMODE_NONE);
|
||||
|
||||
|
@ -158,8 +159,8 @@ 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);
|
||||
|
||||
|
@ -241,6 +242,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];
|
||||
|
@ -253,8 +255,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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue