2015-01-12 22:38:39 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-04-09 02:57:17 +00:00
|
|
|
#include "../drivers/gl_common.h"
|
2015-04-03 18:36:19 +00:00
|
|
|
#include "../font_driver.h"
|
2015-01-12 22:38:39 +00:00
|
|
|
#include "../video_shader_driver.h"
|
|
|
|
|
2015-03-26 17:07:39 +00:00
|
|
|
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
|
|
|
|
|
2015-04-03 01:27:34 +00:00
|
|
|
#define gl_raster_font_emit(c, vx, vy) do { \
|
2015-01-12 22:38:39 +00:00
|
|
|
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
|
|
|
|
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
|
|
|
|
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
|
|
|
|
font_tex_coords[ 2 * (6 * i + c) + 1] = (tex_y + vy * height) * inv_tex_size_y; \
|
|
|
|
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
|
|
|
|
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
|
|
|
|
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
|
|
|
|
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define MAX_MSG_LEN_CHUNK 64
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gl_t *gl;
|
|
|
|
GLuint tex;
|
|
|
|
unsigned tex_width, tex_height;
|
|
|
|
|
|
|
|
const font_renderer_driver_t *font_driver;
|
|
|
|
void *font_data;
|
2015-03-24 19:43:53 +00:00
|
|
|
|
2015-03-25 14:04:53 +00:00
|
|
|
gl_font_raster_block_t *block;
|
2015-01-12 22:38:39 +00:00
|
|
|
} gl_raster_t;
|
|
|
|
|
2015-04-21 15:13:55 +00:00
|
|
|
static void *gl_raster_font_init_font(void *data,
|
2015-01-12 22:38:39 +00:00
|
|
|
const char *font_path, float font_size)
|
|
|
|
{
|
|
|
|
unsigned width, height;
|
|
|
|
uint8_t *tmp_buffer;
|
|
|
|
const struct font_atlas *atlas = NULL;
|
|
|
|
gl_raster_t *font = (gl_raster_t*)calloc(1, sizeof(*font));
|
|
|
|
|
|
|
|
if (!font)
|
|
|
|
return NULL;
|
|
|
|
|
2015-04-21 15:13:55 +00:00
|
|
|
font->gl = (gl_t*)data;
|
2015-01-12 22:38:39 +00:00
|
|
|
|
|
|
|
if (!font_renderer_create_default(&font->font_driver,
|
|
|
|
&font->font_data, font_path, font_size))
|
|
|
|
{
|
|
|
|
RARCH_WARN("Couldn't init font renderer.\n");
|
|
|
|
free(font);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
glGenTextures(1, &font->tex);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, font->tex);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
|
|
|
|
atlas = font->font_driver->get_atlas(font->font_data);
|
|
|
|
|
|
|
|
width = next_pow2(atlas->width);
|
|
|
|
height = next_pow2(atlas->height);
|
|
|
|
|
|
|
|
/* Ideally, we'd use single component textures, but the
|
|
|
|
* difference in ways to do that between core GL and GLES/legacy GL
|
|
|
|
* is too great to bother going down that route. */
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height,
|
|
|
|
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
|
|
|
|
|
|
|
tmp_buffer = (uint8_t*)malloc(atlas->width * atlas->height * 4);
|
|
|
|
|
|
|
|
if (tmp_buffer)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
uint8_t *dst = tmp_buffer;
|
|
|
|
const uint8_t *src = atlas->buffer;
|
|
|
|
|
|
|
|
for (i = 0; i < atlas->width * atlas->height; i++)
|
|
|
|
{
|
|
|
|
*dst++ = 0xff;
|
|
|
|
*dst++ = 0xff;
|
|
|
|
*dst++ = 0xff;
|
|
|
|
*dst++ = *src++;
|
|
|
|
}
|
|
|
|
|
|
|
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, atlas->width,
|
|
|
|
atlas->height, GL_RGBA, GL_UNSIGNED_BYTE, tmp_buffer);
|
|
|
|
free(tmp_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
font->tex_width = width;
|
|
|
|
font->tex_height = height;
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, font->gl->texture[font->gl->tex_index]);
|
2015-04-21 15:13:55 +00:00
|
|
|
|
2015-01-12 22:38:39 +00:00
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gl_raster_font_free_font(void *data)
|
|
|
|
{
|
|
|
|
gl_raster_t *font = (gl_raster_t*)data;
|
|
|
|
if (!font)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (font->font_driver && font->font_data)
|
|
|
|
font->font_driver->free(font->font_data);
|
|
|
|
|
|
|
|
glDeleteTextures(1, &font->tex);
|
|
|
|
free(font);
|
|
|
|
}
|
|
|
|
|
2015-05-14 16:16:34 +00:00
|
|
|
static int get_message_width(gl_raster_t *font, const char *msg, float scale)
|
2015-01-23 00:54:17 +00:00
|
|
|
{
|
2015-04-21 15:13:55 +00:00
|
|
|
unsigned i;
|
|
|
|
unsigned msg_len_full = strlen(msg);
|
|
|
|
unsigned msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK);
|
|
|
|
int delta_x = 0;
|
2015-01-23 00:54:17 +00:00
|
|
|
|
|
|
|
while (msg_len_full)
|
|
|
|
{
|
|
|
|
for (i = 0; i < msg_len; i++)
|
|
|
|
{
|
|
|
|
const struct font_glyph *glyph =
|
2015-04-21 15:13:55 +00:00
|
|
|
font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]);
|
|
|
|
if (!glyph) /* Do something smarter here ... */
|
2015-04-22 21:33:43 +00:00
|
|
|
glyph = font->font_driver->get_glyph(font->font_data, '?');
|
2015-01-23 00:54:17 +00:00
|
|
|
if (!glyph)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
delta_x += glyph->advance_x;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg_len_full -= msg_len;
|
2015-04-21 15:13:55 +00:00
|
|
|
msg += msg_len;
|
|
|
|
msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK);
|
2015-01-23 00:54:17 +00:00
|
|
|
}
|
|
|
|
|
2015-05-14 16:16:34 +00:00
|
|
|
return delta_x * scale;
|
2015-01-23 00:54:17 +00:00
|
|
|
}
|
2015-01-12 22:38:39 +00:00
|
|
|
|
2015-04-03 01:27:34 +00:00
|
|
|
static void gl_raster_font_draw_vertices(gl_t *gl, const gl_coords_t *coords)
|
2015-03-24 18:00:46 +00:00
|
|
|
{
|
2015-04-21 15:13:55 +00:00
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
2015-03-24 18:00:46 +00:00
|
|
|
gl->shader->set_coords(coords);
|
|
|
|
gl->shader->set_mvp(gl, &gl->mvp_no_rot);
|
2015-03-24 19:43:53 +00:00
|
|
|
|
2015-03-24 18:00:46 +00:00
|
|
|
glDrawArrays(GL_TRIANGLES, 0, coords->vertices);
|
|
|
|
}
|
|
|
|
|
2015-04-21 15:13:55 +00:00
|
|
|
static void gl_raster_font_render_message(
|
|
|
|
gl_raster_t *font, const char *msg, GLfloat scale,
|
|
|
|
const GLfloat color[4], GLfloat pos_x, GLfloat pos_y,
|
|
|
|
unsigned text_align)
|
2015-01-12 22:38:39 +00:00
|
|
|
{
|
|
|
|
int x, y, delta_x, delta_y;
|
|
|
|
float inv_tex_size_x, inv_tex_size_y, inv_win_width, inv_win_height;
|
|
|
|
unsigned i, msg_len_full, msg_len;
|
|
|
|
GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK];
|
|
|
|
GLfloat font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK];
|
|
|
|
GLfloat font_color[4 * 6 * MAX_MSG_LEN_CHUNK];
|
2015-03-24 18:00:46 +00:00
|
|
|
struct gl_coords coords;
|
2015-04-21 15:13:55 +00:00
|
|
|
gl_t *gl = font ? font->gl : NULL;
|
|
|
|
|
|
|
|
if (!gl)
|
|
|
|
return;
|
2015-01-12 22:38:39 +00:00
|
|
|
|
|
|
|
msg_len_full = strlen(msg);
|
|
|
|
msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK);
|
|
|
|
|
|
|
|
x = roundf(pos_x * gl->vp.width);
|
|
|
|
y = roundf(pos_y * gl->vp.height);
|
|
|
|
delta_x = 0;
|
|
|
|
delta_y = 0;
|
|
|
|
|
2015-03-31 12:00:30 +00:00
|
|
|
switch (text_align)
|
|
|
|
{
|
|
|
|
case TEXT_ALIGN_RIGHT:
|
2015-05-14 16:16:34 +00:00
|
|
|
x -= get_message_width(font, msg, scale);
|
2015-03-31 12:00:30 +00:00
|
|
|
break;
|
|
|
|
case TEXT_ALIGN_CENTER:
|
2015-05-14 16:16:34 +00:00
|
|
|
x -= get_message_width(font, msg, scale) / 2.0;
|
2015-03-31 12:00:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-01-23 00:54:17 +00:00
|
|
|
|
2015-01-12 22:38:39 +00:00
|
|
|
inv_tex_size_x = 1.0f / font->tex_width;
|
|
|
|
inv_tex_size_y = 1.0f / font->tex_height;
|
|
|
|
inv_win_width = 1.0f / font->gl->vp.width;
|
|
|
|
inv_win_height = 1.0f / font->gl->vp.height;
|
|
|
|
|
|
|
|
while (msg_len_full)
|
|
|
|
{
|
|
|
|
for (i = 0; i < msg_len; i++)
|
|
|
|
{
|
|
|
|
int off_x, off_y, tex_x, tex_y, width, height;
|
2015-03-25 12:48:47 +00:00
|
|
|
const struct font_glyph *glyph =
|
2015-04-22 21:33:43 +00:00
|
|
|
font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]);
|
2015-04-21 15:13:55 +00:00
|
|
|
|
|
|
|
if (!glyph) /* Do something smarter here ... */
|
2015-04-22 21:33:43 +00:00
|
|
|
glyph = font->font_driver->get_glyph(font->font_data, '?');
|
2015-01-12 22:38:39 +00:00
|
|
|
if (!glyph)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
off_x = glyph->draw_offset_x;
|
|
|
|
off_y = glyph->draw_offset_y;
|
|
|
|
tex_x = glyph->atlas_offset_x;
|
|
|
|
tex_y = glyph->atlas_offset_y;
|
|
|
|
width = glyph->width;
|
|
|
|
height = glyph->height;
|
|
|
|
|
2015-04-03 01:27:34 +00:00
|
|
|
gl_raster_font_emit(0, 0, 1); /* Bottom-left */
|
|
|
|
gl_raster_font_emit(1, 1, 1); /* Bottom-right */
|
|
|
|
gl_raster_font_emit(2, 0, 0); /* Top-left */
|
2015-01-12 22:38:39 +00:00
|
|
|
|
2015-04-03 01:27:34 +00:00
|
|
|
gl_raster_font_emit(3, 1, 0); /* Top-right */
|
|
|
|
gl_raster_font_emit(4, 0, 0); /* Top-left */
|
|
|
|
gl_raster_font_emit(5, 1, 1); /* Bottom-right */
|
2015-01-12 22:38:39 +00:00
|
|
|
|
|
|
|
delta_x += glyph->advance_x;
|
|
|
|
delta_y -= glyph->advance_y;
|
|
|
|
}
|
|
|
|
|
2015-04-21 15:13:55 +00:00
|
|
|
coords.tex_coord = font_tex_coords;
|
|
|
|
coords.vertex = font_vertex;
|
|
|
|
coords.color = font_color;
|
|
|
|
coords.vertices = 6 * msg_len;
|
2015-03-24 18:00:46 +00:00
|
|
|
coords.lut_tex_coord = gl->coords.lut_tex_coord;
|
|
|
|
|
2015-03-25 12:48:47 +00:00
|
|
|
if (font->block)
|
|
|
|
gl_coord_array_add(&font->block->carr, &coords, coords.vertices);
|
2015-03-24 19:43:53 +00:00
|
|
|
else
|
2015-04-03 01:27:34 +00:00
|
|
|
gl_raster_font_draw_vertices(gl, &coords);
|
2015-01-12 22:38:39 +00:00
|
|
|
|
|
|
|
msg_len_full -= msg_len;
|
2015-04-21 15:13:55 +00:00
|
|
|
msg += msg_len;
|
|
|
|
msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK);
|
2015-01-12 22:38:39 +00:00
|
|
|
}
|
2015-03-24 18:00:46 +00:00
|
|
|
}
|
|
|
|
|
2015-04-03 01:27:34 +00:00
|
|
|
static void gl_raster_font_setup_viewport(gl_raster_t *font, bool full_screen)
|
2015-03-24 18:00:46 +00:00
|
|
|
{
|
2015-04-26 03:21:43 +00:00
|
|
|
gl_t *gl = font->gl;
|
|
|
|
global_t *global = global_get_ptr();
|
2015-03-24 18:00:46 +00:00
|
|
|
|
2015-04-21 15:13:55 +00:00
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
2015-04-26 17:46:59 +00:00
|
|
|
video_driver_set_viewport(global->video_data.width,
|
|
|
|
global->video_data.height, full_screen, false);
|
2015-03-24 18:00:46 +00:00
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
glBlendEquation(GL_FUNC_ADD);
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, font->tex);
|
|
|
|
|
|
|
|
if (gl->shader && gl->shader->use)
|
|
|
|
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
|
|
|
}
|
2015-01-12 22:38:39 +00:00
|
|
|
|
2015-04-03 01:27:34 +00:00
|
|
|
static void gl_raster_font_restore_viewport(gl_t *gl)
|
2015-03-24 18:00:46 +00:00
|
|
|
{
|
2015-04-26 03:21:43 +00:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
2015-01-12 22:38:39 +00:00
|
|
|
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
2015-03-24 18:00:46 +00:00
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
2015-04-26 17:46:59 +00:00
|
|
|
video_driver_set_viewport(global->video_data.width,
|
|
|
|
global->video_data.height, false, true);
|
2015-01-12 22:38:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gl_raster_font_render_msg(void *data, const char *msg,
|
2015-03-29 19:59:01 +00:00
|
|
|
const void *userdata)
|
2015-01-12 22:38:39 +00:00
|
|
|
{
|
|
|
|
GLfloat x, y, scale, drop_mod;
|
|
|
|
GLfloat color[4], color_dark[4];
|
|
|
|
int drop_x, drop_y;
|
|
|
|
bool full_screen;
|
2015-03-31 12:00:30 +00:00
|
|
|
enum text_alignment text_align;
|
2015-01-12 22:38:39 +00:00
|
|
|
gl_t *gl = NULL;
|
|
|
|
gl_raster_t *font = (gl_raster_t*)data;
|
2015-03-20 21:08:36 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-03-29 19:59:01 +00:00
|
|
|
const struct font_params *params = (const struct font_params*)userdata;
|
2015-01-12 22:38:39 +00:00
|
|
|
|
2015-03-29 20:28:17 +00:00
|
|
|
if (!font)
|
2015-01-12 22:38:39 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
gl = font->gl;
|
|
|
|
|
|
|
|
if (params)
|
|
|
|
{
|
2015-03-20 21:08:36 +00:00
|
|
|
x = params->x;
|
|
|
|
y = params->y;
|
|
|
|
scale = params->scale;
|
2015-01-12 22:38:39 +00:00
|
|
|
full_screen = params->full_screen;
|
2015-03-31 12:00:30 +00:00
|
|
|
text_align = params->text_align;
|
2015-03-20 21:08:36 +00:00
|
|
|
drop_x = params->drop_x;
|
|
|
|
drop_y = params->drop_y;
|
|
|
|
drop_mod = params->drop_mod;
|
2015-01-12 22:38:39 +00:00
|
|
|
|
2015-03-20 21:08:36 +00:00
|
|
|
color[0] = FONT_COLOR_GET_RED(params->color) / 255.0f;
|
|
|
|
color[1] = FONT_COLOR_GET_GREEN(params->color) / 255.0f;
|
|
|
|
color[2] = FONT_COLOR_GET_BLUE(params->color) / 255.0f;
|
|
|
|
color[3] = FONT_COLOR_GET_ALPHA(params->color) / 255.0f;
|
2015-01-12 22:38:39 +00:00
|
|
|
|
|
|
|
/* If alpha is 0.0f, turn it into default 1.0f */
|
|
|
|
if (color[3] <= 0.0f)
|
|
|
|
color[3] = 1.0f;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-03-20 21:08:36 +00:00
|
|
|
x = settings->video.msg_pos_x;
|
|
|
|
y = settings->video.msg_pos_y;
|
|
|
|
scale = 1.0f;
|
2015-01-12 22:38:39 +00:00
|
|
|
full_screen = false;
|
2015-03-31 12:00:30 +00:00
|
|
|
text_align = TEXT_ALIGN_LEFT;
|
2015-01-12 22:38:39 +00:00
|
|
|
|
2015-03-20 21:08:36 +00:00
|
|
|
color[0] = settings->video.msg_color_r;
|
|
|
|
color[1] = settings->video.msg_color_g;
|
|
|
|
color[2] = settings->video.msg_color_b;
|
2015-01-12 22:38:39 +00:00
|
|
|
color[3] = 1.0f;
|
|
|
|
|
|
|
|
drop_x = -2;
|
|
|
|
drop_y = -2;
|
|
|
|
drop_mod = 0.3f;
|
|
|
|
}
|
|
|
|
|
2015-03-25 12:48:47 +00:00
|
|
|
if (font->block)
|
2015-03-27 14:20:10 +00:00
|
|
|
font->block->fullscreen = full_screen;
|
2015-03-24 19:43:53 +00:00
|
|
|
else
|
2015-04-03 01:27:34 +00:00
|
|
|
gl_raster_font_setup_viewport(font, full_screen);
|
2015-01-12 22:38:39 +00:00
|
|
|
|
|
|
|
if (drop_x || drop_y)
|
|
|
|
{
|
|
|
|
color_dark[0] = color[0] * drop_mod;
|
|
|
|
color_dark[1] = color[1] * drop_mod;
|
|
|
|
color_dark[2] = color[2] * drop_mod;
|
|
|
|
color_dark[3] = color[3];
|
|
|
|
|
2015-04-03 01:27:34 +00:00
|
|
|
gl_raster_font_render_message(font, msg, scale, color_dark,
|
2015-01-12 22:38:39 +00:00
|
|
|
x + scale * drop_x / gl->vp.width, y +
|
2015-03-31 12:00:30 +00:00
|
|
|
scale * drop_y / gl->vp.height, text_align);
|
2015-01-12 22:38:39 +00:00
|
|
|
}
|
2015-03-24 18:00:46 +00:00
|
|
|
|
2015-04-03 01:27:34 +00:00
|
|
|
gl_raster_font_render_message(font, msg, scale, color, x, y, text_align);
|
2015-01-12 22:38:39 +00:00
|
|
|
|
2015-03-25 12:48:47 +00:00
|
|
|
if (!font->block)
|
2015-04-03 01:27:34 +00:00
|
|
|
gl_raster_font_restore_viewport(gl);
|
2015-01-12 22:38:39 +00:00
|
|
|
}
|
|
|
|
|
2015-04-22 21:33:43 +00:00
|
|
|
static const struct font_glyph *gl_raster_font_get_glyph(
|
2015-01-12 22:38:39 +00:00
|
|
|
void *data, uint32_t code)
|
|
|
|
{
|
|
|
|
gl_raster_t *font = (gl_raster_t*)data;
|
|
|
|
|
2015-04-22 21:38:42 +00:00
|
|
|
if (!font || !font->font_driver)
|
2015-01-12 22:38:39 +00:00
|
|
|
return NULL;
|
2015-04-22 21:38:42 +00:00
|
|
|
if (!font->font_driver->ident)
|
|
|
|
return NULL;
|
2015-01-12 22:38:39 +00:00
|
|
|
return font->font_driver->get_glyph((void*)font->font_driver, code);
|
|
|
|
}
|
|
|
|
|
2015-03-29 19:59:01 +00:00
|
|
|
static void gl_raster_font_flush_block(void *data)
|
2015-03-24 19:43:53 +00:00
|
|
|
{
|
2015-03-25 16:42:25 +00:00
|
|
|
gl_raster_t *font = (gl_raster_t*)data;
|
2015-03-25 14:04:53 +00:00
|
|
|
gl_font_raster_block_t *block = font->block;
|
2015-03-24 19:43:53 +00:00
|
|
|
|
2015-04-21 15:13:55 +00:00
|
|
|
if (font && block->carr.coords.vertices)
|
2015-03-24 19:43:53 +00:00
|
|
|
{
|
2015-04-03 01:27:34 +00:00
|
|
|
gl_raster_font_setup_viewport(font, block->fullscreen);
|
|
|
|
gl_raster_font_draw_vertices(font->gl, (gl_coords_t*)&block->carr.coords);
|
|
|
|
gl_raster_font_restore_viewport(font->gl);
|
2015-03-24 19:43:53 +00:00
|
|
|
}
|
2015-03-24 20:28:53 +00:00
|
|
|
}
|
|
|
|
|
2015-03-29 19:59:01 +00:00
|
|
|
static void gl_raster_font_bind_block(void *data, void *userdata)
|
2015-03-24 19:43:53 +00:00
|
|
|
{
|
|
|
|
gl_raster_t *font = (gl_raster_t*)data;
|
2015-03-29 19:59:01 +00:00
|
|
|
gl_font_raster_block_t *block = (gl_font_raster_block_t*)userdata;
|
2015-03-24 19:43:53 +00:00
|
|
|
|
2015-04-24 22:42:47 +00:00
|
|
|
if (font)
|
2015-03-29 19:59:01 +00:00
|
|
|
font->block = block;
|
2015-03-24 19:43:53 +00:00
|
|
|
}
|
|
|
|
|
2015-03-29 22:55:39 +00:00
|
|
|
font_renderer_t gl_raster_font = {
|
2015-01-12 22:38:39 +00:00
|
|
|
gl_raster_font_init_font,
|
|
|
|
gl_raster_font_free_font,
|
|
|
|
gl_raster_font_render_msg,
|
|
|
|
"GL raster",
|
2015-03-24 19:43:53 +00:00
|
|
|
gl_raster_font_get_glyph,
|
2015-03-29 19:59:01 +00:00
|
|
|
gl_raster_font_bind_block,
|
2015-05-16 14:32:16 +00:00
|
|
|
gl_raster_font_flush_block,
|
|
|
|
NULL /* get_message_width */
|
2015-01-12 22:38:39 +00:00
|
|
|
};
|