ref: 69f3fbcd5abc86bac1a966eb5646636fdad47b56
parent: 0fa538732d44ffd43627663f54e40a17ad0bf4b9
author: Clownacy <Clownacy@users.noreply.github.com>
date: Thu Sep 10 13:56:22 EDT 2020
Change a dumb parameter
--- a/src/Backends/Rendering.h
+++ b/src/Backends/Rendering.h
@@ -27,7 +27,7 @@
RenderBackend_GlyphAtlas* RenderBackend_CreateGlyphAtlas(size_t size);
void RenderBackend_DestroyGlyphAtlas(RenderBackend_GlyphAtlas *atlas);
void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t y, const unsigned char *pixels, size_t width, size_t height);
-void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, const unsigned char *colour_channels);
+void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue);
void RenderBackend_DrawGlyph(RenderBackend_GlyphAtlas *atlas, long x, long y, size_t glyph_x, size_t glyph_y, size_t glyph_width, size_t glyph_height);
void RenderBackend_FlushGlyphs(void);
void RenderBackend_HandleRenderTargetLoss(void);
--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -916,7 +916,7 @@
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
}
-void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, const unsigned char *colour_channels)
+void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)
{
(void)atlas;
@@ -930,7 +930,7 @@
glyph_destination_surface = destination_surface;
// Flush vertex data if a context-change is needed
- if (last_render_mode != MODE_DRAW_GLYPH || last_destination_texture != glyph_destination_surface->texture_id || last_source_texture != atlas->texture_id || last_red != colour_channels[0] || last_green != colour_channels[1] || last_blue != colour_channels[2])
+ if (last_render_mode != MODE_DRAW_GLYPH || last_destination_texture != glyph_destination_surface->texture_id || last_source_texture != atlas->texture_id || last_red != red || last_green != green || last_blue != blue)
{
FlushVertexBuffer();
@@ -942,7 +942,7 @@
last_blue = colour_channels[2];
glUseProgram(program_glyph);
- glUniform4f(program_glyph_uniform_colour, colour_channels[0] / 255.0f, colour_channels[1] / 255.0f, colour_channels[2] / 255.0f, 1.0f);
+ glUniform4f(program_glyph_uniform_colour, red / 255.0f, green / 255.0f, blue / 255.0f, 1.0f);
// Point our framebuffer to the destination texture
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glyph_destination_surface->texture_id, 0);
--- a/src/Backends/Rendering/SDLSurface.cpp
+++ b/src/Backends/Rendering/SDLSurface.cpp
@@ -248,7 +248,7 @@
SDL_UnlockSurface(atlas->sdlsurface);
}
-void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, const unsigned char *colour_channels)
+void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)
{
if (destination_surface == NULL)
return;
@@ -255,7 +255,7 @@
glyph_destination_sdlsurface = destination_surface->sdlsurface;
- if (SDL_SetSurfaceColorMod(atlas->sdlsurface, colour_channels[0], colour_channels[1], colour_channels[2]) < 0)
+ if (SDL_SetSurfaceColorMod(atlas->sdlsurface, red, green, blue) < 0)
Backend_PrintError("Couldn't set color value: %s", SDL_GetError());
}
--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -364,7 +364,7 @@
}
}
-void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, const unsigned char *colour_channels)
+void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)
{
(void)atlas;
@@ -376,7 +376,7 @@
// 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.
- if (SDL_SetTextureColorMod(atlas->texture, colour_channels[0], colour_channels[1], colour_channels[2]) < 0)
+ if (SDL_SetTextureColorMod(atlas->texture, red, green, blue) < 0)
Backend_PrintError("Couldn't set additional color value: %s", SDL_GetError());
if (SDL_SetTextureBlendMode(atlas->texture, SDL_BLENDMODE_BLEND) < 0)
--- a/src/Backends/Rendering/Software.cpp
+++ b/src/Backends/Rendering/Software.cpp
@@ -291,7 +291,7 @@
memcpy(&atlas->pixels[(y + i) * atlas->size + x], &pixels[i * width], width);
}
-void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, const unsigned char *colour_channels)
+void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)
{
(void)atlas;
@@ -300,7 +300,9 @@
glyph_destination_surface = destination_surface;
- memcpy(glyph_colour_channels, colour_channels, sizeof(glyph_colour_channels));
+ glyph_colour_channels[0] = red;
+ glyph_colour_channels[1] = green;
+ glyph_colour_channels[2] = blue;
}
void RenderBackend_DrawGlyph(RenderBackend_GlyphAtlas *atlas, long x, long y, size_t glyph_x, size_t glyph_y, size_t glyph_width, size_t glyph_height)
--- a/src/Backends/Rendering/WiiU.cpp
+++ b/src/Backends/Rendering/WiiU.cpp
@@ -196,7 +196,7 @@
}
}
-RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, bool fullscreen)
+RenderBackend_Surface* RenderBackend_Init(const char *window_title, size_t screen_width, size_t screen_height, bool fullscreen)
{
(void)window_title;
(void)fullscreen;
@@ -786,7 +786,7 @@
GX2RUnlockSurfaceEx(&atlas->texture.surface, 0, (GX2RResourceFlags)0);
}
-void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, const unsigned char *colour_channels)
+void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)
{
(void)atlas;
@@ -800,7 +800,7 @@
glyph_destination_surface = destination_surface;
// Flush vertex data if a context-change is needed
- if (last_render_mode != MODE_DRAW_GLYPH || last_destination_texture != &glyph_destination_surface->texture || last_source_texture != &atlas->texture || last_red != colour_channels[0] || last_green != colour_channels[1] || last_blue != colour_channels[2])
+ if (last_render_mode != MODE_DRAW_GLYPH || last_destination_texture != &glyph_destination_surface->texture || last_source_texture != &atlas->texture || last_red != red || last_green != green || last_blue != blue)
{
FlushVertexBuffer();
@@ -807,9 +807,9 @@
last_render_mode = MODE_DRAW_GLYPH;
last_destination_texture = &glyph_destination_surface->texture;
last_source_texture = &atlas->texture;
- last_red = colour_channels[0];
- last_green = colour_channels[1];
- last_blue = colour_channels[2];
+ last_red = red;
+ last_green = green;
+ last_blue = blue;
// Draw to the selected texture, instead of the screen
GX2SetColorBuffer(&glyph_destination_surface->colour_buffer, GX2_RENDER_TARGET_0);
@@ -817,7 +817,7 @@
GX2SetScissor(0, 0, glyph_destination_surface->colour_buffer.surface.width, glyph_destination_surface->colour_buffer.surface.height);
// Set the colour
- const float uniform_colours[4] = {colour_channels[0] / 255.0f, colour_channels[1] / 255.0f, colour_channels[2] / 255.0f, 1.0f};
+ const float uniform_colours[4] = {red / 255.0f, green / 255.0f, blue / 255.0f, 1.0f};
GX2SetPixelUniformReg(glyph_shader.pixelShader->uniformVars[0].offset, 4, (uint32_t*)&uniform_colours);
// Select glyph shader
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -1138,9 +1138,7 @@
{
if (font_object != NULL && surface != NULL)
{
- const unsigned char colour_channels[3] = {(unsigned char)colour, (unsigned char)(colour >> 8), (unsigned char)(colour >> 16)};
-
- RenderBackend_PrepareToDrawGlyphs(font_object->atlas, surface, colour_channels);
+ RenderBackend_PrepareToDrawGlyphs(font_object->atlas, surface, (unsigned char)colour, (unsigned char)(colour >> 8), (unsigned char)(colour >> 16));
size_t pen_x = 0;