Fixups to Lakka fonts.

This commit is contained in:
Themaister 2014-06-09 12:44:48 +02:00
parent 186f5a9513
commit f118817fae
2 changed files with 19 additions and 14 deletions

View File

@ -199,19 +199,20 @@ static void update_tweens(float dt)
static void lakka_draw_text(const char *str, float x, float y, float scale, float alpha) static void lakka_draw_text(const char *str, float x, float y, float scale, float alpha)
{ {
gl_t *gl = (gl_t*)driver.video_data; gl_t *gl = (gl_t*)driver.video_data;
if (!gl)
return;
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
struct font_params params = {0}; struct font_params params = {0};
params.x = x / gl->win_width; params.x = x / gl->vp.width;
params.y = 1.0f - y / gl->win_height; params.y = 1.0f - y / gl->vp.height;
if (alpha > global_alpha) if (alpha > global_alpha)
alpha = global_alpha; alpha = global_alpha;
params.scale = scale; params.scale = scale;
params.color = FONT_COLOR_RGBA(0xff, 0xff, 0xff, (uint8_t)(255 * alpha)); params.color = FONT_COLOR_RGBA(255, 255, 255, (uint8_t)(255 * alpha));
params.drop_x = -2;
params.drop_y = -2;
params.drop_mod = 0.3f;
if (font_driver) if (font_driver)
font_driver->render_msg(font, str, &params); font_driver->render_msg(font, str, &params);
@ -225,8 +226,8 @@ void lakka_draw_background(void)
0.1, 0.74, 0.61, global_alpha, 0.1, 0.74, 0.61, global_alpha,
0.1, 0.74, 0.61, global_alpha, 0.1, 0.74, 0.61, global_alpha,
}; };
gl_t *gl = (gl_t*)driver.video_data;
gl_t *gl = (gl_t*)driver.video_data;
if (!gl) if (!gl)
return; return;
@ -238,6 +239,8 @@ void lakka_draw_background(void)
if (gl->shader && gl->shader->use) if (gl->shader && gl->shader->use)
gl->shader->use(gl, GL_SHADER_STOCK_BLEND); gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
gl->coords.vertices = 4;
gl_shader_set_coords(gl, &gl->coords, &gl->mvp_no_rot); gl_shader_set_coords(gl, &gl->coords, &gl->mvp_no_rot);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@ -291,6 +294,7 @@ void lakka_draw_icon(GLuint texture, float x, float y, float alpha, float rotati
matrix_scale(&mscal, scale, scale, 1); matrix_scale(&mscal, scale, scale, 1);
matrix_multiply(&mymat, &mscal, &mymat); matrix_multiply(&mymat, &mscal, &mymat);
gl->coords.vertices = 4;
gl_shader_set_coords(gl, &gl->coords, &mymat); gl_shader_set_coords(gl, &gl->coords, &mymat);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

View File

@ -111,9 +111,6 @@ static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, co
unsigned i; unsigned i;
gl_t *gl = font->gl; gl_t *gl = font->gl;
// Rebind shaders so attrib cache gets reset.
if (gl->shader && gl->shader->use)
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
glBindTexture(GL_TEXTURE_2D, font->tex); glBindTexture(GL_TEXTURE_2D, font->tex);
#define MAX_MSG_LEN_CHUNK 64 #define MAX_MSG_LEN_CHUNK 64
@ -136,6 +133,10 @@ static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, co
while (msg_len_full) while (msg_len_full)
{ {
// Rebind shaders so attrib cache gets reset.
if (gl->shader && gl->shader->use)
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
for (i = 0; i < msg_len; i++) for (i = 0; i < msg_len; i++)
{ {
const struct font_glyph *gly = font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]); const struct font_glyph *gly = font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]);
@ -207,10 +208,10 @@ static void gl_render_msg(void *data, const char *msg, const struct font_params
drop_y = params->drop_y; drop_y = params->drop_y;
drop_mod = params->drop_mod; drop_mod = params->drop_mod;
color[0] = FONT_COLOR_GET_RED(params->color); color[0] = FONT_COLOR_GET_RED(params->color) / 255.0f;
color[1] = FONT_COLOR_GET_GREEN(params->color); color[1] = FONT_COLOR_GET_GREEN(params->color) / 255.0f;
color[2] = FONT_COLOR_GET_BLUE(params->color); color[2] = FONT_COLOR_GET_BLUE(params->color) / 255.0f;
color[3] = FONT_COLOR_GET_ALPHA(params->color); color[3] = FONT_COLOR_GET_ALPHA(params->color) / 255.0f;
// If alpha is 0.0f, turn it into default 1.0f // If alpha is 0.0f, turn it into default 1.0f
if (color[3] <= 0.0f) if (color[3] <= 0.0f)