mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-31 08:57:40 +00:00
Added SDL_GetRenderSafeArea()
This commit is contained in:
parent
eb09264076
commit
cf8b158ccb
7 changed files with 81 additions and 4 deletions
|
@ -81,7 +81,9 @@ static void MoveSprites(SDL_Renderer *renderer, SDL_Texture *sprite)
|
|||
SDL_FRect *position, *velocity;
|
||||
|
||||
/* Query the sizes */
|
||||
SDL_GetRenderViewport(renderer, &viewport);
|
||||
SDL_SetRenderViewport(renderer, NULL);
|
||||
SDL_GetRenderSafeArea(renderer, &viewport);
|
||||
SDL_SetRenderViewport(renderer, &viewport);
|
||||
|
||||
/* Cycle the color and alpha, if desired */
|
||||
if (cycle_color) {
|
||||
|
@ -424,6 +426,7 @@ int SDL_AppIterate(void *appstate)
|
|||
|
||||
int SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
{
|
||||
SDL_Rect safe_area;
|
||||
int i;
|
||||
Uint64 seed;
|
||||
const char *icon = "icon.bmp";
|
||||
|
@ -556,6 +559,8 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Position sprites and set their velocities using the fuzzer */
|
||||
/* Really we should be using per-window safe area, but this is fine for a simple test */
|
||||
SDL_GetRenderSafeArea(state->renderers[0], &safe_area);
|
||||
if (iterations >= 0) {
|
||||
/* Deterministic seed - used for visual tests */
|
||||
seed = (Uint64)iterations;
|
||||
|
@ -565,8 +570,8 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
|
|||
}
|
||||
SDLTest_FuzzerInit(seed);
|
||||
for (i = 0; i < num_sprites; ++i) {
|
||||
positions[i].x = (float)SDLTest_RandomIntegerInRange(0, (int)(state->window_w - sprite_w));
|
||||
positions[i].y = (float)SDLTest_RandomIntegerInRange(0, (int)(state->window_h - sprite_h));
|
||||
positions[i].x = (float)SDLTest_RandomIntegerInRange(0, (int)(safe_area.w - sprite_w));
|
||||
positions[i].y = (float)SDLTest_RandomIntegerInRange(0, (int)(safe_area.h - sprite_h));
|
||||
positions[i].w = sprite_w;
|
||||
positions[i].h = sprite_h;
|
||||
velocities[i].x = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue