diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 2ccf23b458..4271a7f152 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -941,6 +941,103 @@ static void gl_set_texture_enable(void *data, bool state, bool full_screen) gl->menu_texture_full_screen = full_screen; } +static void gl_render_osd_background( + gl_t *gl, video_frame_info_t *video_info, + const char *msg) +{ + if (!gl) + return; + + video_shader_ctx_mvp_t mvp; + video_shader_ctx_coords_t coords_data; + video_coords_t coords; + video_coord_array_t ca; + video_shader_ctx_info_t shader_info; + struct uniform_info uniform_param; + unsigned vertices_total = 6; + float *dummy = (float*)calloc(4 * vertices_total, sizeof(float)); + float *colors = (float*)malloc(4 * vertices_total * sizeof(float)); + float *verts = (float*)malloc(2 * vertices_total * sizeof(float)); + unsigned i; + + for (i = 0; i < 4 * vertices_total; i += 4) + { + colors[i+0] = 0; + colors[i+1] = 0; + colors[i+2] = 1; + colors[i+3] = 1; + } + + verts[0] = -1; + verts[1] = -1; // BL + + verts[2] = -1; + verts[3] = 1; // TL + + verts[4] = 1; + verts[5] = 1; // TR + + verts[6] = -1; + verts[7] = -1; // BL + + verts[8] = 1; + verts[9] = 1; // TR + + verts[10] = 1; + verts[11] = -1; // BR + + coords.color = colors; + coords.vertex = verts; + coords.tex_coord = dummy; + coords.lut_tex_coord = dummy; + coords.vertices = vertices_total; + + coords_data.handle_data = NULL; + coords_data.data = &coords; + + shader_info.data = NULL; + shader_info.idx = VIDEO_SHADER_STOCK_BLEND; + shader_info.set_active = true; + + video_driver_set_viewport(video_info->width, video_info->height, true, false); + + glDisable(GL_BLEND); + + video_shader_driver_use(shader_info); + video_shader_driver_set_coords(coords_data); + + mvp.data = gl; + mvp.matrix = &gl->mvp_no_rot; + + video_shader_driver_set_mvp(mvp); + + uniform_param.type = UNIFORM_4F; + uniform_param.enabled = true; + uniform_param.location = 0; + uniform_param.count = 0; + + uniform_param.lookup.type = SHADER_PROGRAM_FRAGMENT; + uniform_param.lookup.ident = "bgcolor"; + uniform_param.lookup.idx = shader_info.idx; + uniform_param.lookup.add_prefix = true; + uniform_param.lookup.enable = true; + + uniform_param.result.f.v0 = colors[0]; + uniform_param.result.f.v1 = colors[1]; + uniform_param.result.f.v2 = colors[2]; + uniform_param.result.f.v3 = colors[3]; + + video_shader_driver_set_parameter(uniform_param); + + glDrawArrays(GL_TRIANGLES, 0, coords.vertices); + + free(colors); + free(dummy); + free(verts); + + video_driver_set_viewport(video_info->width, video_info->height, false, true); +} + static void gl_set_osd_msg(void *data, video_frame_info_t *video_info, const char *msg, @@ -1244,7 +1341,10 @@ static bool gl_frame(void *data, const void *frame, #endif if (!string_is_empty(msg)) + { + gl_render_osd_background(gl, video_info, msg); font_driver_render_msg(video_info, NULL, msg, NULL); + } #ifdef HAVE_OVERLAY if (gl && gl->overlay_enable) diff --git a/gfx/drivers/gl_shaders/modern_alpha_blend.glsl.frag.h b/gfx/drivers/gl_shaders/modern_alpha_blend.glsl.frag.h index 447d99f1bf..2e8152e2e3 100644 --- a/gfx/drivers/gl_shaders/modern_alpha_blend.glsl.frag.h +++ b/gfx/drivers/gl_shaders/modern_alpha_blend.glsl.frag.h @@ -2,9 +2,17 @@ static const char *stock_fragment_modern_blend = GLSL( uniform sampler2D Texture; + uniform vec4 bgcolor; varying vec2 tex_coord; varying vec4 color; void main() { - gl_FragColor = color * texture2D(Texture, tex_coord); + if (bgcolor == vec4(0.0,0.0,1.0,1.0)) + { + gl_FragColor = bgcolor;//color * texture2D(Texture, tex_coord); + } + else + { + gl_FragColor = color * texture2D(Texture, tex_coord); + } } ); diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 444e8a25b6..d9b110378f 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -475,7 +475,7 @@ static void gl_raster_font_render_msg( else gl_raster_font_setup_viewport(width, height, font, full_screen); - if (!string_is_empty(msg) && font->gl + if (!string_is_empty(msg) && font->gl && font->font_data && font->font_driver) { if (drop_x || drop_y) diff --git a/gfx/video_coord_array.c b/gfx/video_coord_array.c index f1ead1ed5c..835b9ba967 100644 --- a/gfx/video_coord_array.c +++ b/gfx/video_coord_array.c @@ -75,7 +75,7 @@ bool video_coord_array_append(video_coord_array_t *ca, base_size = count * sizeof(float); offset = ca->coords.vertices; - /* XXX: I wish we used interlaced arrays so + /* XXX: I wish we used interlaced arrays so * we could call memcpy only once. */ memcpy(ca->coords.vertex + offset * 2, coords->vertex, base_size * 2);