From bb11cd567d6c74ee2833421f64728f8c595575cc Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sun, 9 Feb 2020 13:44:02 +0000 Subject: [PATCH] Software renderer cleanup --- src/Backends/Rendering/Software.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Backends/Rendering/Software.cpp b/src/Backends/Rendering/Software.cpp index 4e544f68..8d22ab26 100644 --- a/src/Backends/Rendering/Software.cpp +++ b/src/Backends/Rendering/Software.cpp @@ -23,7 +23,7 @@ typedef struct Backend_Surface typedef struct Backend_Glyph { - void *pixels; + float *pixels; unsigned int width; unsigned int height; } Backend_Glyph; @@ -304,7 +304,7 @@ Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width if (glyph == NULL) return NULL; - glyph->pixels = malloc(width * height * sizeof(float)); + glyph->pixels = (float*)malloc(width * height * sizeof(float)); if (glyph->pixels == NULL) { @@ -312,11 +312,11 @@ Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width return NULL; } - float *destination_pointer = (float*)glyph->pixels; + float *destination_pointer = glyph->pixels; for (unsigned int y = 0; y < height; ++y) { - const unsigned char *source_pointer = pixels + y * pitch; + const unsigned char *source_pointer = &pixels[y * pitch]; for (unsigned int x = 0; x < width; ++x) *destination_pointer++ = *source_pointer++ / 255.0f; @@ -356,9 +356,9 @@ void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y) { for (unsigned int ix = MAX(-x, 0); x + ix < MIN(x + glyph->width, glyph_destination_surface->width); ++ix) { - const float alpha = ((float*)glyph->pixels)[iy * glyph->width + ix]; + const float alpha = glyph->pixels[iy * glyph->width + ix]; - if (alpha) + if (alpha != 0.0f) { unsigned char *bitmap_pixel = glyph_destination_surface->pixels + (y + iy) * glyph_destination_surface->pitch + (x + ix) * 3;