diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 1b524a23e4..3dd76a260a 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -72,6 +72,41 @@ static void gl_raster_font_free_font(void *data, free(font); } +#if 0 +static bool gl_raster_font_upload_atlas_components_4(gl_raster_t *font) +{ + unsigned i, j; + GLint gl_internal = GL_RGBA; + GLenum gl_format = GL_RGBA; + size_t ncomponents = 4; + uint8_t *tmp = NULL; + + tmp = (uint8_t*)calloc(font->tex_height, font->tex_width * ncomponents); + + for (i = 0; i < font->atlas->height; ++i) + { + const uint8_t *src = &font->atlas->buffer[i * font->atlas->width]; + uint8_t *dst = &tmp[i * font->tex_width * ncomponents]; + + for (j = 0; j < font->atlas->width; ++j) + { + *dst++ = 0xff; + *dst++ = 0xff; + *dst++ = 0xff; + *dst++ = *src++; + } + break; + } + + glTexImage2D(GL_TEXTURE_2D, 0, gl_internal, font->tex_width, font->tex_height, + 0, gl_format, GL_UNSIGNED_BYTE, tmp); + + free(tmp); + + return true; +} +#endif + static bool gl_raster_font_upload_atlas(gl_raster_t *font) { unsigned i, j; @@ -79,24 +114,9 @@ static bool gl_raster_font_upload_atlas(gl_raster_t *font) GLenum gl_format = GL_LUMINANCE_ALPHA; size_t ncomponents = 2; uint8_t *tmp = NULL; -#if 0 - bool ancient = false; /* add a check here if needed */ -#endif - #if defined(GL_VERSION_3_0) struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); -#endif -#if 0 - if (ancient) - { - gl_internal = GL_RGBA; - gl_format = GL_RGBA; - ncomponents = 4; - } -#endif - -#if defined(GL_VERSION_3_0) if (gl_query_core_context_in_use() || (hwr->context_type == RETRO_HW_CONTEXT_OPENGL && hwr->version_major >= 3)) @@ -112,43 +132,30 @@ static bool gl_raster_font_upload_atlas(gl_raster_t *font) tmp = (uint8_t*)calloc(font->tex_height, font->tex_width * ncomponents); - if (!tmp) - return false; - - for (i = 0; i < font->atlas->height; ++i) + switch (ncomponents) { - const uint8_t *src = &font->atlas->buffer[i * font->atlas->width]; - uint8_t *dst = &tmp[i * font->tex_width * ncomponents]; + case 1: + for (i = 0; i < font->atlas->height; ++i) + { + const uint8_t *src = &font->atlas->buffer[i * font->atlas->width]; + uint8_t *dst = &tmp[i * font->tex_width * ncomponents]; - switch (ncomponents) - { - case 1: memcpy(dst, src, font->atlas->width); - break; - case 2: + } + break; + case 2: + for (i = 0; i < font->atlas->height; ++i) + { + const uint8_t *src = &font->atlas->buffer[i * font->atlas->width]; + uint8_t *dst = &tmp[i * font->tex_width * ncomponents]; + for (j = 0; j < font->atlas->width; ++j) { *dst++ = 0xff; *dst++ = *src++; } - break; -#if 0 - case 4: - for (j = 0; j < font->atlas->width; ++j) - { - *dst++ = 0xff; - *dst++ = 0xff; - *dst++ = 0xff; - *dst++ = *src++; - } - break; -#endif - default: - RARCH_ERR("Unsupported number of components: %u\n", - (unsigned)ncomponents); - free(tmp); - return false; - } + } + break; } glTexImage2D(GL_TEXTURE_2D, 0, gl_internal, font->tex_width, font->tex_height,