Fixed compiling IME test program with HAVE_SDL_TTF on C89 compilers.

Philipp Wiesemann 2016-03-10 21:00:27 +01:00
parent 43594e3f3d
commit b82f48bad3
1 changed files with 16 additions and 6 deletions

View File

@ -110,7 +110,6 @@ void CleanupVideo()
#endif #endif
} }
void _Redraw(SDL_Renderer * renderer) { void _Redraw(SDL_Renderer * renderer) {
int w = 0, h = textRect.h; int w = 0, h = textRect.h;
SDL_Rect cursorRect, underlineRect; SDL_Rect cursorRect, underlineRect;
@ -122,9 +121,14 @@ void _Redraw(SDL_Renderer * renderer) {
if (*text) if (*text)
{ {
SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, text, textColor); SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, text, textColor);
SDL_Rect dest = {textRect.x, textRect.y, textSur->w, textSur->h }; SDL_Rect dest;
SDL_Texture *texture;
dest.x = textRect.x;
dest.y = textRect.y;
dest.w = textSur->w;
dest.h = textSur->h;
SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer,textSur); texture = SDL_CreateTextureFromSurface(renderer,textSur);
SDL_FreeSurface(textSur); SDL_FreeSurface(textSur);
SDL_RenderCopy(renderer,texture,NULL,&dest); SDL_RenderCopy(renderer,texture,NULL,&dest);
@ -156,6 +160,9 @@ void _Redraw(SDL_Renderer * renderer) {
if (markedText[0]) if (markedText[0])
{ {
#ifdef HAVE_SDL_TTF #ifdef HAVE_SDL_TTF
SDL_Surface *textSur;
SDL_Rect dest;
SDL_Texture *texture;
if (cursor) if (cursor)
{ {
char *p = utf8_advance(markedText, cursor); char *p = utf8_advance(markedText, cursor);
@ -169,10 +176,13 @@ void _Redraw(SDL_Renderer * renderer) {
cursorRect.x += w; cursorRect.x += w;
*p = c; *p = c;
} }
SDL_Surface *textSur = TTF_RenderUTF8_Blended(font, markedText, textColor); textSur = TTF_RenderUTF8_Blended(font, markedText, textColor);
SDL_Rect dest = {markedRect.x, markedRect.y, textSur->w, textSur->h }; dest.x = markedRect.x;
dest.y = markedRect.y;
dest.w = textSur->w;
dest.h = textSur->h;
TTF_SizeUTF8(font, markedText, &w, &h); TTF_SizeUTF8(font, markedText, &w, &h);
SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer,textSur); texture = SDL_CreateTextureFromSurface(renderer,textSur);
SDL_FreeSurface(textSur); SDL_FreeSurface(textSur);
SDL_RenderCopy(renderer,texture,NULL,&dest); SDL_RenderCopy(renderer,texture,NULL,&dest);