SDL_RenderTexture() and SDL_RenderTextureRotated() take floating point source coordinates

See the discussion at https://discourse.libsdl.org/t/sdl-rendercopyf-uses-ints/36732/8
This commit is contained in:
Sam Lantinga
2023-03-02 08:56:54 -08:00
parent 199a7af296
commit bd2e2ee7aa
9 changed files with 82 additions and 75 deletions

View File

@@ -330,8 +330,8 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_FRect *ds
{
SDL_Texture *texture;
const Uint32 textureID = codepoint / UNIFONT_GLYPHS_IN_TEXTURE;
SDL_Rect srcrect;
srcrect.w = srcrect.h = 16;
SDL_FRect srcrect;
srcrect.w = srcrect.h = 16.0f;
if (codepoint > UNIFONT_MAX_CODEPOINT) {
return 0;
}
@@ -343,8 +343,8 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_FRect *ds
texture = unifontTexture[UNIFONT_NUM_TEXTURES * rendererID + textureID];
if (texture != NULL) {
const Uint32 cInTex = codepoint % UNIFONT_GLYPHS_IN_TEXTURE;
srcrect.x = cInTex % UNIFONT_GLYPHS_IN_ROW * 16;
srcrect.y = cInTex / UNIFONT_GLYPHS_IN_ROW * 16;
srcrect.x = (float)(cInTex % UNIFONT_GLYPHS_IN_ROW * 16);
srcrect.y = (float)(cInTex / UNIFONT_GLYPHS_IN_ROW * 16);
SDL_RenderTexture(state->renderers[rendererID], texture, &srcrect, dst);
}
return unifontGlyph[codepoint].width;