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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user