diff --git a/src/Backends/Rendering.h b/src/Backends/Rendering.h index 4690575e..b9664c0f 100644 --- a/src/Backends/Rendering.h +++ b/src/Backends/Rendering.h @@ -27,7 +27,7 @@ void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBacken 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); diff --git a/src/Backends/Rendering/OpenGL3.cpp b/src/Backends/Rendering/OpenGL3.cpp index 9f6191f0..d7408bc0 100644 --- a/src/Backends/Rendering/OpenGL3.cpp +++ b/src/Backends/Rendering/OpenGL3.cpp @@ -916,7 +916,7 @@ void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t 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 @@ void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBa 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 @@ void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBa 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); diff --git a/src/Backends/Rendering/SDLSurface.cpp b/src/Backends/Rendering/SDLSurface.cpp index 5860f76c..87f067e9 100644 --- a/src/Backends/Rendering/SDLSurface.cpp +++ b/src/Backends/Rendering/SDLSurface.cpp @@ -248,14 +248,14 @@ void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t 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; 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()); } diff --git a/src/Backends/Rendering/SDLTexture.cpp b/src/Backends/Rendering/SDLTexture.cpp index d4cfa9b0..6a538462 100644 --- a/src/Backends/Rendering/SDLTexture.cpp +++ b/src/Backends/Rendering/SDLTexture.cpp @@ -364,7 +364,7 @@ void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t } } -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 @@ void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBa // 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) diff --git a/src/Backends/Rendering/Software.cpp b/src/Backends/Rendering/Software.cpp index 5a70996d..ca8125a5 100644 --- a/src/Backends/Rendering/Software.cpp +++ b/src/Backends/Rendering/Software.cpp @@ -291,7 +291,7 @@ void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t 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 @@ void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBa 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) diff --git a/src/Backends/Rendering/WiiU.cpp b/src/Backends/Rendering/WiiU.cpp index 24410d5d..995a7f43 100644 --- a/src/Backends/Rendering/WiiU.cpp +++ b/src/Backends/Rendering/WiiU.cpp @@ -196,7 +196,7 @@ static void CalculateViewport(size_t actual_screen_width, size_t actual_screen_h } } -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 @@ void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t 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,16 +800,16 @@ void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBa 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(); 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 @@ void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBa 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 diff --git a/src/Font.cpp b/src/Font.cpp index 07265b37..59b9db81 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -1138,9 +1138,7 @@ void DrawText(FontObject *font_object, RenderBackend_Surface *surface, int x, in { 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;