mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-06 06:34:35 +00:00
Use floating point values for viewport, clip rectangle, and texture sizes
These are integer values internally, but the API has been changed to make it easier to mix other render code with querying those values. Fixes https://github.com/libsdl-org/SDL/issues/7519
This commit is contained in:
parent
463984ec20
commit
9fb5a9ccac
29 changed files with 624 additions and 585 deletions
|
|
@ -234,7 +234,7 @@ int SDL_AppIterate(void *appstate)
|
|||
SDL_SetRenderDrawColor(renderer, 0x99, 0x99, 0x99, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
int win_w, win_h, tw, th;
|
||||
float win_w, win_h, tw, th;
|
||||
SDL_FRect d;
|
||||
Uint64 timestampNS = 0;
|
||||
SDL_Surface *frame_next = camera ? SDL_AcquireCameraFrame(camera, ×tampNS) : NULL;
|
||||
|
|
@ -261,8 +261,8 @@ int SDL_AppIterate(void *appstate)
|
|||
|
||||
if (frame_current) {
|
||||
if (!texture ||
|
||||
SDL_QueryTexture(texture, NULL, NULL, &tw, &th) < 0 ||
|
||||
tw != frame_current->w || th != frame_current->h) {
|
||||
SDL_GetTextureSize(texture, &tw, &th) < 0 ||
|
||||
(int)tw != frame_current->w || (int)th != frame_current->h) {
|
||||
/* Resize the window to match */
|
||||
SDL_SetWindowSize(window, frame_current->w, frame_current->h);
|
||||
|
||||
|
|
@ -284,12 +284,12 @@ int SDL_AppIterate(void *appstate)
|
|||
texture_updated = SDL_TRUE;
|
||||
}
|
||||
|
||||
SDL_QueryTexture(texture, NULL, NULL, &tw, &th);
|
||||
SDL_GetTextureSize(texture, &tw, &th);
|
||||
SDL_GetRenderOutputSize(renderer, &win_w, &win_h);
|
||||
d.x = (float) ((win_w - tw) / 2);
|
||||
d.y = (float) ((win_h - th) / 2);
|
||||
d.w = (float) tw;
|
||||
d.h = (float) th;
|
||||
d.x = ((win_w - tw) / 2);
|
||||
d.y = ((win_h - th) / 2);
|
||||
d.w = tw;
|
||||
d.h = th;
|
||||
SDL_RenderTexture(renderer, texture, NULL, &d);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue