shithub: cstory

Download patch

ref: eeed719c1687ea2e694761448c67afa683718f18
parent: 15cfad01af66eb9bbbf345fcea816e5d0f32228e
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Feb 1 17:47:13 EST 2020

Get the SDLTexture renderer working again

--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -78,8 +78,10 @@
 
 	for (int i = 0; i < count; ++i)
 	{
-		SDL_Rect destination_rect = {(int)sprites[i].x, (int)sprites[i].y, texture_w, texture_h};
+		Backend_Glyph *glyph = (Backend_Glyph*)sprites[i].image_id;
 
+		SDL_Rect destination_rect = {(int)sprites[i].x, (int)sprites[i].y, glyph->width, glyph->height};
+
 		SDL_RenderCopy(renderer, texture_atlas, NULL, &destination_rect);
 	}
 }
@@ -166,6 +168,7 @@
 				framebuffer.width = width;
 				framebuffer.height = height;
 
+				// Set-up glyph-batcher
 				spritebatch_config_t config;
 				spritebatch_set_default_config(&config);
 				config.batch_callback = GlyphBatch_Draw;
@@ -201,7 +204,7 @@
 
 void Backend_Deinit(void)
 {
-	spritebatch_term(glyph_batcher);
+	spritebatch_term(&glyph_batcher);
 	SDL_DestroyTexture(framebuffer.texture);
 	SDL_DestroyRenderer(renderer);
 	SDL_DestroyWindow(window);
@@ -359,7 +362,7 @@
 	return FALSE;	// SDL_Textures don't have per-component alpha
 }
 
-Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch, FontPixelMode pixel_mode)
+Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
 {
 	Backend_Glyph *glyph = (Backend_Glyph*)malloc(sizeof(Backend_Glyph));
 
@@ -376,44 +379,17 @@
 
 	unsigned char *destination_pointer = glyph->pixels;
 
-	switch (pixel_mode)
+	for (unsigned int y = 0; y < height; ++y)
 	{
-		case FONT_PIXEL_MODE_LCD:
-			// Unsupported
-			break;
+		const unsigned char *source_pointer = pixels + y * pitch;
 
-		case FONT_PIXEL_MODE_GRAY:
-
-			for (unsigned int y = 0; y < height; ++y)
-			{
-				const unsigned char *source_pointer = pixels + y * pitch;
-
-				for (unsigned int x = 0; x < width; ++x)
-				{
-					*destination_pointer++ = 0xFF;
-					*destination_pointer++ = 0xFF;
-					*destination_pointer++ = 0xFF;
-					*destination_pointer++ = *source_pointer++;
-				}
-			}
-
-			break;
-
-		case FONT_PIXEL_MODE_MONO:
-			for (unsigned int y = 0; y < height; ++y)
-			{
-				const unsigned char *source_pointer = pixels + y * pitch;
-
-				for (unsigned int x = 0; x < width; ++x)
-				{
-					*destination_pointer++ = 0xFF;
-					*destination_pointer++ = 0xFF;
-					*destination_pointer++ = 0xFF;
-					*destination_pointer++ = *source_pointer++ ? 0xFF : 0;
-				}
-			}
-
-			break;
+		for (unsigned int x = 0; x < width; ++x)
+		{
+			*destination_pointer++ = 0xFF;
+			*destination_pointer++ = 0xFF;
+			*destination_pointer++ = 0xFF;
+			*destination_pointer++ = *source_pointer++;
+		}
 	}
 
 	glyph->width = width;
--