shithub: cstory

Download patch

ref: aa728979a33d11b65bf143c87c73dc66301041e1
parent: defe234ff2172793dda184854e5176d0a177f5cd
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Jul 24 20:39:03 EDT 2019

Fix the Texture backend not rendering text the accurate buggy way

A shame I have to fall back on the Surface fallback. Speaking of, I
really need to replace that fallback with my software renderer.

--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -391,24 +391,20 @@
 
 void Backend_DrawGlyph(Backend_Surface *surface, Backend_Glyph *glyph, long x, long y, const unsigned char *colours)
 {
-	// This is actually slightly imperfect: the SDL_Texture side of things uses alpha, not a colour-key,
-	// so the bug where the font is blended with the colour key doesn't occur. SDL_Textures don't support
-	// colour-keys, so the next best thing is relying on the software fallback, but I don't like the idea
-	// of uploading textures to the GPU every time a glyph is drawn.
+	// The SDL_Texture side of things uses alpha, not a colour-key, so the bug where the font is blended
+	// with the colour key doesn't occur. SDL_Textures don't support colour-keys, so the next best thing
+	// is relying on the software fallback.
 
 	if (glyph == NULL || surface == NULL)
 		return;
 
-	RECT rect;
-	rect.left = 0;
-	rect.top = 0;
-	rect.right = glyph->surface->sdl_surface->w;
-	rect.bottom = glyph->surface->sdl_surface->h;
+	SDL_Rect destination_rect = {x, y, glyph->surface->sdl_surface->w, glyph->surface->sdl_surface->h};
 
 	SDL_SetSurfaceColorMod(glyph->surface->sdl_surface, colours[0], colours[1], colours[2]);
-	SDL_SetTextureColorMod(glyph->surface->texture, colours[0], colours[1], colours[2]);
+	SDL_SetSurfaceBlendMode(glyph->surface->sdl_surface, SDL_BLENDMODE_BLEND);
+	SDL_BlitSurface(glyph->surface->sdl_surface, NULL, surface->sdl_surface, &destination_rect);
 
-	Backend_Blit(glyph->surface, &rect, surface, x, y, TRUE);
+	surface->needs_syncing = TRUE;
 }
 
 void Backend_DrawGlyphToScreen(Backend_Glyph *glyph, long x, long y, const unsigned char *colours)