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.
This commit is contained in:
Clownacy 2019-07-25 00:39:03 +01:00
parent defe234ff2
commit aa728979a3

View file

@ -391,24 +391,20 @@ void Backend_UnloadGlyph(Backend_Glyph *glyph)
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)