(GL raster font) Make it possible to set alpha levels. By

implementing this, we can get rid of the copy-pasta gl raster
font code in Lakka
This commit is contained in:
twinaphex 2014-05-27 04:22:08 +02:00
parent ebfb104986
commit 0e679d4309
2 changed files with 24 additions and 4 deletions

View File

@ -258,7 +258,7 @@ static void setup_font(void *data, const char *msg, GLfloat scale, GLfloat pos_x
if (!gl->font) if (!gl->font)
return; return;
if (gl->shader) if (gl->shader && gl->shader->use)
gl->shader->use(gl, GL_SHADER_STOCK_BLEND); gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
@ -319,24 +319,43 @@ static void setup_font(void *data, const char *msg, GLfloat scale, GLfloat pos_x
static void gl_render_msg(void *data, const char *msg, void *parms) static void gl_render_msg(void *data, const char *msg, void *parms)
{ {
GLfloat x, y, scale, alpha;
gl_t *gl;
font_params_t *params;
int i;
(void)data; (void)data;
(void)msg; (void)msg;
GLfloat x, y, scale;
gl_t *gl = (gl_t*)data; gl = (gl_t*)data;
font_params_t *params = (font_params_t*)parms; params = (font_params_t*)parms;
if (!gl)
return;
if (params) if (params)
{ {
x = params->x; x = params->x;
y = params->y; y = params->y;
scale = params->scale; scale = params->scale;
alpha = params->alpha;
// If alpha is 0.0f, turn it into default 1.0f
if (alpha <= 0.0f)
alpha = 1.0f;
} }
else else
{ {
x = g_settings.video.msg_pos_x; x = g_settings.video.msg_pos_x;
y = g_settings.video.msg_pos_y; y = g_settings.video.msg_pos_y;
scale = g_settings.video.font_scale ? (GLfloat)gl->vp.width / (GLfloat)gl->full_x : 1.0f; scale = g_settings.video.font_scale ? (GLfloat)gl->vp.width / (GLfloat)gl->full_x : 1.0f;
alpha = 1.0f;
}
for (i = 0; i < 4; i++)
{
gl->font_color[4 * i + 3] = alpha;
gl->font_color_dark[4 * i + 3] = alpha;
} }
setup_font(data, msg, scale, x, y); setup_font(data, msg, scale, x, y);

View File

@ -44,6 +44,7 @@ typedef struct
float x; float x;
float y; float y;
float scale; float scale;
float alpha;
unsigned color; unsigned color;
} font_params_t; } font_params_t;