summaryrefslogtreecommitdiff
path: root/src/ui/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/text.c')
-rw-r--r--src/ui/text.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index e0aafc33..34e20bf1 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -1445,20 +1445,27 @@ void init_TextBuf(iTextBuf *d, int font, int color, const char *text) {
1445 SDL_Renderer *render = text_.render; 1445 SDL_Renderer *render = text_.render;
1446 d->size = advance_Text(font, text); 1446 d->size = advance_Text(font, text);
1447 SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); 1447 SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
1448 d->texture = SDL_CreateTexture(render, 1448 if (d->size.x * d->size.y) {
1449 SDL_PIXELFORMAT_RGBA4444, 1449 d->texture = SDL_CreateTexture(render,
1450 SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET, 1450 SDL_PIXELFORMAT_RGBA4444,
1451 d->size.x, 1451 SDL_TEXTUREACCESS_STATIC | SDL_TEXTUREACCESS_TARGET,
1452 d->size.y); 1452 d->size.x,
1453 SDL_Texture *oldTarget = SDL_GetRenderTarget(render); 1453 d->size.y);
1454 SDL_SetRenderTarget(render, d->texture); 1454 }
1455 SDL_SetTextureBlendMode(text_.cache, SDL_BLENDMODE_NONE); /* blended when TextBuf is drawn */ 1455 else {
1456 SDL_SetRenderDrawColor(text_.render, 0, 0, 0, 0); 1456 d->texture = NULL;
1457 SDL_RenderClear(text_.render); 1457 }
1458 draw_Text_(font, zero_I2(), color | fillBackground_ColorId, range_CStr(text)); 1458 if (d->texture) {
1459 SDL_SetTextureBlendMode(text_.cache, SDL_BLENDMODE_BLEND); 1459 SDL_Texture *oldTarget = SDL_GetRenderTarget(render);
1460 SDL_SetRenderTarget(render, oldTarget); 1460 SDL_SetRenderTarget(render, d->texture);
1461 SDL_SetTextureBlendMode(d->texture, SDL_BLENDMODE_BLEND); 1461 SDL_SetTextureBlendMode(text_.cache, SDL_BLENDMODE_NONE); /* blended when TextBuf is drawn */
1462 SDL_SetRenderDrawColor(text_.render, 0, 0, 0, 0);
1463 SDL_RenderClear(text_.render);
1464 draw_Text_(font, zero_I2(), color | fillBackground_ColorId, range_CStr(text));
1465 SDL_SetTextureBlendMode(text_.cache, SDL_BLENDMODE_BLEND);
1466 SDL_SetRenderTarget(render, oldTarget);
1467 SDL_SetTextureBlendMode(d->texture, SDL_BLENDMODE_BLEND);
1468 }
1462} 1469}
1463 1470
1464void deinit_TextBuf(iTextBuf *d) { 1471void deinit_TextBuf(iTextBuf *d) {