Drop useless win_width/height arguments to font init.
This commit is contained in:
parent
8ee747a12d
commit
54c7521bf8
9
driver.h
9
driver.h
|
@ -346,10 +346,15 @@ struct font_params
|
||||||
{
|
{
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
float alpha;
|
|
||||||
float scale;
|
float scale;
|
||||||
uint32_t color;
|
uint32_t color; // ABGR.
|
||||||
|
bool full_screen;
|
||||||
};
|
};
|
||||||
|
#define FONT_COLOR_RGBA(r, g, b, a) (((r) << 0) | ((g) << 8) | ((b) << 16) | ((a) << 24))
|
||||||
|
#define FONT_COLOR_GET_RED(col) (((col) >> 0) & 0xff)
|
||||||
|
#define FONT_COLOR_GET_GREEN(col) (((col) >> 8) & 0xff)
|
||||||
|
#define FONT_COLOR_GET_BLUE(col) (((col) >> 16) & 0xff)
|
||||||
|
#define FONT_COLOR_GET_ALPHA(col) (((col) >> 24) & 0xff)
|
||||||
|
|
||||||
// Optionally implemented interface to poke more deeply into video driver.
|
// Optionally implemented interface to poke more deeply into video driver.
|
||||||
typedef struct video_poke_interface
|
typedef struct video_poke_interface
|
||||||
|
|
|
@ -27,12 +27,12 @@ static const gl_font_renderer_t *gl_font_backends[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
bool gl_font_init_first(const gl_font_renderer_t **font_driver, void **font_handle,
|
bool gl_font_init_first(const gl_font_renderer_t **font_driver, void **font_handle,
|
||||||
void *gl_data, const char *font_path, float font_size, unsigned win_width, unsigned win_height)
|
void *gl_data, const char *font_path, float font_size)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; gl_font_backends[i]; i++)
|
for (i = 0; gl_font_backends[i]; i++)
|
||||||
{
|
{
|
||||||
void *data = gl_font_backends[i]->init(gl_data, font_path, font_size, win_width, win_height);
|
void *data = gl_font_backends[i]->init(gl_data, font_path, font_size);
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
*font_driver = gl_font_backends[i];
|
*font_driver = gl_font_backends[i];
|
||||||
|
|
|
@ -21,8 +21,7 @@
|
||||||
|
|
||||||
typedef struct gl_font_renderer
|
typedef struct gl_font_renderer
|
||||||
{
|
{
|
||||||
void *(*init)(void *data, const char *font_path, float font_size,
|
void *(*init)(void *data, const char *font_path, float font_size);
|
||||||
unsigned win_width, unsigned win_height);
|
|
||||||
void (*free)(void *data);
|
void (*free)(void *data);
|
||||||
void (*render_msg)(void *data, const char *msg, const struct font_params *parms);
|
void (*render_msg)(void *data, const char *msg, const struct font_params *parms);
|
||||||
const char *ident;
|
const char *ident;
|
||||||
|
@ -32,7 +31,7 @@ extern const gl_font_renderer_t gl_raster_font;
|
||||||
extern const gl_font_renderer_t libdbg_font;
|
extern const gl_font_renderer_t libdbg_font;
|
||||||
|
|
||||||
bool gl_font_init_first(const gl_font_renderer_t **font_driver, void **font_handle,
|
bool gl_font_init_first(const gl_font_renderer_t **font_driver, void **font_handle,
|
||||||
void *gl_data, const char *font_path, float font_size, unsigned win_width, unsigned win_height);
|
void *gl_data, const char *font_path, float font_size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,8 @@ typedef struct
|
||||||
void *font_data;
|
void *font_data;
|
||||||
} gl_raster_t;
|
} gl_raster_t;
|
||||||
|
|
||||||
static void *gl_init_font(void *gl_data, const char *font_path, float font_size, unsigned win_width, unsigned win_height)
|
static void *gl_init_font(void *gl_data, const char *font_path, float font_size)
|
||||||
{
|
{
|
||||||
(void)win_width;
|
|
||||||
(void)win_height;
|
|
||||||
|
|
||||||
gl_raster_t *font = (gl_raster_t*)calloc(1, sizeof(*font));
|
gl_raster_t *font = (gl_raster_t*)calloc(1, sizeof(*font));
|
||||||
if (!font)
|
if (!font)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -115,7 +112,7 @@ void gl_free_font(void *data)
|
||||||
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
|
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, const GLfloat color[4], GLfloat pos_x, GLfloat pos_y)
|
static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, const GLfloat color[4], GLfloat pos_x, GLfloat pos_y, bool full_screen)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
gl_t *gl = font->gl;
|
gl_t *gl = font->gl;
|
||||||
|
@ -123,7 +120,7 @@ static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, co
|
||||||
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_set_viewport(gl, gl->win_width, gl->win_height, true, false);
|
gl_set_viewport(gl, gl->win_width, gl->win_height, full_screen, false);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBindTexture(GL_TEXTURE_2D, font->tex);
|
glBindTexture(GL_TEXTURE_2D, font->tex);
|
||||||
|
@ -138,15 +135,15 @@ static void render_message(gl_raster_t *font, const char *msg, GLfloat scale, co
|
||||||
unsigned msg_len_full = strlen(msg);
|
unsigned msg_len_full = strlen(msg);
|
||||||
unsigned msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK);
|
unsigned msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK);
|
||||||
|
|
||||||
int x = roundf(pos_x * gl->win_width);
|
int x = roundf(pos_x * gl->vp.width);
|
||||||
int y = roundf(pos_y * gl->win_height);
|
int y = roundf(pos_y * gl->vp.height);
|
||||||
int delta_x = 0;
|
int delta_x = 0;
|
||||||
int delta_y = 0;
|
int delta_y = 0;
|
||||||
|
|
||||||
float inv_tex_size_x = 1.0f / font->tex_width;
|
float inv_tex_size_x = 1.0f / font->tex_width;
|
||||||
float inv_tex_size_y = 1.0f / font->tex_height;
|
float inv_tex_size_y = 1.0f / font->tex_height;
|
||||||
float inv_win_width = 1.0f / font->gl->win_width;
|
float inv_win_width = 1.0f / font->gl->vp.width;
|
||||||
float inv_win_height = 1.0f / font->gl->win_height;
|
float inv_win_height = 1.0f / font->gl->vp.height;
|
||||||
|
|
||||||
while (msg_len_full)
|
while (msg_len_full)
|
||||||
{
|
{
|
||||||
|
@ -213,6 +210,7 @@ static void gl_render_msg(void *data, const char *msg, const struct font_params
|
||||||
{
|
{
|
||||||
GLfloat x, y, scale;
|
GLfloat x, y, scale;
|
||||||
GLfloat color[4];
|
GLfloat color[4];
|
||||||
|
bool full_screen;
|
||||||
|
|
||||||
gl_raster_t *font = (gl_raster_t*)data;
|
gl_raster_t *font = (gl_raster_t*)data;
|
||||||
if (!font)
|
if (!font)
|
||||||
|
@ -223,11 +221,12 @@ static void gl_render_msg(void *data, const char *msg, const struct font_params
|
||||||
x = params->x;
|
x = params->x;
|
||||||
y = params->y;
|
y = params->y;
|
||||||
scale = params->scale;
|
scale = params->scale;
|
||||||
|
full_screen = params->full_screen;
|
||||||
|
|
||||||
color[0] = ((params->color >> 16) & 0xff) / 255.0f;
|
color[0] = FONT_COLOR_GET_RED(params->color);
|
||||||
color[1] = ((params->color >> 8) & 0xff) / 255.0f;
|
color[1] = FONT_COLOR_GET_GREEN(params->color);
|
||||||
color[2] = ((params->color >> 0) & 0xff) / 255.0f;
|
color[2] = FONT_COLOR_GET_BLUE(params->color);
|
||||||
color[3] = params->alpha;
|
color[3] = FONT_COLOR_GET_ALPHA(params->color);
|
||||||
|
|
||||||
// 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)
|
||||||
|
@ -238,6 +237,7 @@ static void gl_render_msg(void *data, const char *msg, const struct font_params
|
||||||
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 = 1.0f;
|
scale = 1.0f;
|
||||||
|
full_screen = false;
|
||||||
|
|
||||||
color[0] = g_settings.video.msg_color_r;
|
color[0] = g_settings.video.msg_color_r;
|
||||||
color[1] = g_settings.video.msg_color_g;
|
color[1] = g_settings.video.msg_color_g;
|
||||||
|
@ -245,7 +245,7 @@ static void gl_render_msg(void *data, const char *msg, const struct font_params
|
||||||
color[3] = 1.0f;
|
color[3] = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
render_message(font, msg, scale, color, x, y);
|
render_message(font, msg, scale, color, x, y, full_screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gl_font_renderer_t gl_raster_font = {
|
const gl_font_renderer_t gl_raster_font = {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
#include "../gfx_common.h"
|
#include "../gfx_common.h"
|
||||||
|
#include "../gl_common.h"
|
||||||
|
|
||||||
#if defined(SN_TARGET_PSP2)
|
#if defined(SN_TARGET_PSP2)
|
||||||
#include <libdbgfont.h>
|
#include <libdbgfont.h>
|
||||||
|
@ -32,19 +33,19 @@
|
||||||
#define DbgFontExit cellDbgFontExit
|
#define DbgFontExit cellDbgFontExit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void *gl_init_font(void *data, const char *font_path, float font_size,
|
static void *gl_init_font(void *gl_data, const char *font_path, float font_size)
|
||||||
unsigned win_width, unsigned win_height)
|
|
||||||
{
|
{
|
||||||
(void)font_path;
|
(void)font_path;
|
||||||
(void)font_size;
|
(void)font_size;
|
||||||
|
gl_t *gl = (gl_t*)gl_data;
|
||||||
|
|
||||||
DbgFontConfig cfg;
|
DbgFontConfig cfg;
|
||||||
#if defined(SN_TARGET_PSP2)
|
#if defined(SN_TARGET_PSP2)
|
||||||
cfg.fontSize = SCE_DBGFONT_FONTSIZE_LARGE;
|
cfg.fontSize = SCE_DBGFONT_FONTSIZE_LARGE;
|
||||||
#elif defined(__CELLOS_LV2__)
|
#elif defined(__CELLOS_LV2__)
|
||||||
cfg.bufSize = SCE_DBGFONT_BUFSIZE_LARGE;
|
cfg.bufSize = SCE_DBGFONT_BUFSIZE_LARGE;
|
||||||
cfg.screenWidth = win_width;
|
cfg.screenWidth = gl->win_width;
|
||||||
cfg.screenHeight = win_height;
|
cfg.screenHeight = gl->win_height;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DbgFontInit(&cfg);
|
DbgFontInit(&cfg);
|
||||||
|
@ -97,3 +98,4 @@ const gl_font_renderer_t libdbg_font = {
|
||||||
gl_render_msg,
|
gl_render_msg,
|
||||||
"GL raster",
|
"GL raster",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
3
gfx/gl.c
3
gfx/gl.c
|
@ -2354,8 +2354,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (!gl_font_init_first(&gl->font_driver, &gl->font_handle,
|
if (!gl_font_init_first(&gl->font_driver, &gl->font_handle,
|
||||||
gl, *g_settings.video.font_path ? g_settings.video.font_path : NULL, g_settings.video.font_size,
|
gl, *g_settings.video.font_path ? g_settings.video.font_path : NULL, g_settings.video.font_size))
|
||||||
gl->win_width, gl->win_height))
|
|
||||||
RARCH_ERR("[GL]: Failed to init font renderer.\n");
|
RARCH_ERR("[GL]: Failed to init font renderer.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue