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:
@@ -41,7 +41,7 @@
|
||||
#define MAX_TEXT_LENGTH 256
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
static SDL_Rect textRect, markedRect;
|
||||
static SDL_FRect textRect, markedRect;
|
||||
static SDL_Color lineColor = { 0, 0, 0, 255 };
|
||||
static SDL_Color backColor = { 255, 255, 255, 255 };
|
||||
static SDL_Color textColor = { 0, 0, 0, 255 };
|
||||
@@ -326,7 +326,7 @@ static int unifont_load_texture(Uint32 textureID)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_Rect *dstrect)
|
||||
static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_FRect *dst)
|
||||
{
|
||||
SDL_Texture *texture;
|
||||
const Uint32 textureID = codepoint / UNIFONT_GLYPHS_IN_TEXTURE;
|
||||
@@ -345,7 +345,7 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_Rect *dst
|
||||
const Uint32 cInTex = codepoint % UNIFONT_GLYPHS_IN_TEXTURE;
|
||||
srcrect.x = cInTex % UNIFONT_GLYPHS_IN_ROW * 16;
|
||||
srcrect.y = cInTex / UNIFONT_GLYPHS_IN_ROW * 16;
|
||||
SDL_RenderTexture(state->renderers[rendererID], texture, &srcrect, dstrect);
|
||||
SDL_RenderTexture(state->renderers[rendererID], texture, &srcrect, dst);
|
||||
}
|
||||
return unifontGlyph[codepoint].width;
|
||||
}
|
||||
@@ -453,9 +453,9 @@ static void usage(void)
|
||||
static void InitInput(void)
|
||||
{
|
||||
/* Prepare a rect for text input */
|
||||
textRect.x = textRect.y = 100;
|
||||
textRect.x = textRect.y = 100.0f;
|
||||
textRect.w = DEFAULT_WINDOW_WIDTH - 2 * textRect.x;
|
||||
textRect.h = 50;
|
||||
textRect.h = 50.0f;
|
||||
|
||||
text[0] = 0;
|
||||
markedRect = textRect;
|
||||
@@ -478,8 +478,8 @@ static void CleanupVideo(void)
|
||||
static void _Redraw(int rendererID)
|
||||
{
|
||||
SDL_Renderer *renderer = state->renderers[rendererID];
|
||||
SDL_Rect drawnTextRect, cursorRect, underlineRect;
|
||||
drawnTextRect = textRect;
|
||||
SDL_FRect drawnTextRect, cursorRect, underlineRect;
|
||||
drawnTextRect.x = textRect.x;
|
||||
drawnTextRect.w = 0;
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, backColor.r, backColor.g, backColor.b, backColor.a);
|
||||
@@ -504,7 +504,7 @@ static void _Redraw(int rendererID)
|
||||
char *utext = text;
|
||||
Uint32 codepoint;
|
||||
size_t len;
|
||||
SDL_Rect dstrect;
|
||||
SDL_FRect dstrect;
|
||||
|
||||
dstrect.x = textRect.x;
|
||||
dstrect.y = textRect.y + (textRect.h - 16 * UNIFONT_DRAW_SCALE) / 2;
|
||||
@@ -576,7 +576,7 @@ static void _Redraw(int rendererID)
|
||||
char *utext = markedText;
|
||||
Uint32 codepoint;
|
||||
size_t len;
|
||||
SDL_Rect dstrect;
|
||||
SDL_FRect dstrect;
|
||||
|
||||
dstrect.x = drawnTextRect.x;
|
||||
dstrect.y = textRect.y + (textRect.h - 16 * UNIFONT_DRAW_SCALE) / 2;
|
||||
@@ -614,7 +614,15 @@ static void _Redraw(int rendererID)
|
||||
SDL_SetRenderDrawColor(renderer, lineColor.r, lineColor.g, lineColor.b, lineColor.a);
|
||||
SDL_RenderFillRect(renderer, &cursorRect);
|
||||
|
||||
SDL_SetTextInputRect(&markedRect);
|
||||
{
|
||||
SDL_Rect inputrect;
|
||||
|
||||
inputrect.x = (int)markedRect.x;
|
||||
inputrect.y = (int)markedRect.y;
|
||||
inputrect.w = (int)markedRect.w;
|
||||
inputrect.h = (int)markedRect.h;
|
||||
SDL_SetTextInputRect(&inputrect);
|
||||
}
|
||||
}
|
||||
|
||||
static void Redraw(void)
|
||||
|
||||
Reference in New Issue
Block a user