Move remaining FREETYPE/font code from gl.c to font files

This commit is contained in:
Twinaphex 2012-05-27 04:21:54 +02:00
parent 503f01867a
commit 7f13257d1b
5 changed files with 57 additions and 44 deletions

View File

@ -266,3 +266,21 @@ void gl_render_msg(gl_t *gl, const char *msg)
(void)msg;
#endif
}
void gl_render_msg_pre(gl_t *gl)
{
#ifdef HAVE_FREETYPE
#ifdef HAVE_CG
gl_shader_use(0);
#endif
set_viewport(gl, gl->win_width, gl->win_height, false, false);
glEnable(GL_BLEND);
#endif
}
void gl_render_msg_post(gl_t *gl)
{
#ifdef HAVE_FREETYPE
gl_old_render_path(gl);
#endif
}

View File

@ -40,3 +40,9 @@ void gl_render_msg(gl_t *gl, const char *msg)
cellDbgFontPrintf(g_settings.video.msg_pos_x, g_settings.video.msg_pos_y, 1.10f, WHITE, msg);
}
void gl_render_msg_pre(gl_t *gl) { }
void gl_render_msg_post(gl_t *gl)
{
cellDbgFontDraw();
}

View File

@ -445,7 +445,7 @@ static void set_projection(gl_t *gl, bool allow_rotate)
gl_shader_set_proj_matrix();
}
static void set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate)
void set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate)
{
if (gl->keep_aspect && !force_full)
{
@ -836,15 +836,7 @@ static void gl_next_texture_index(gl_t *gl, const struct gl_tex_info *tex_info)
gl->tex_index = (gl->tex_index + 1) & TEXTURES_MASK;
}
#ifdef HAVE_FREETYPE
static inline void gl_render_msg_pre(gl_t *gl)
{
gl_shader_use(0);
set_viewport(gl, gl->win_width, gl->win_height, false, false);
glEnable(GL_BLEND);
}
static inline void gl_render_msg_post(gl_t *gl)
void gl_old_render_path (gl_t *gl)
{
// Go back to old rendering path.
glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords);
@ -855,17 +847,6 @@ static inline void gl_render_msg_post(gl_t *gl)
glDisable(GL_BLEND);
set_projection(gl, true);
}
#elif defined(__CELLOS_LV2__)
static inline void gl_render_msg_pre(gl_t *gl) { }
static inline void gl_render_msg_post(gl_t *gl)
{
cellDbgFontDraw();
}
#else
#define gl_render_msg_pre(...)
#define gl_render_msg_post(...)
#endif
static bool gl_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg)
{

View File

@ -23,9 +23,8 @@ void gl_deinit_font(gl_t *gl);
void gl_render_msg(gl_t *gl, const char *msg);
extern void gl_init_font_ctx(gl_t *gl, const char *font_path, unsigned font_size);
extern void gl_deinit_font_ctx(gl_t *gl);
extern void gl_render_msg_ctx(gl_t *gl, const char *msg);
void gl_render_msg_post(gl_t *gl);
void gl_render_msg_pre(gl_t *gl);
#endif

View File

@ -222,6 +222,17 @@ static void gl_shader_deinit(void)
#endif
}
static void gl_shader_set_proj_matrix(void)
{
#ifdef HAVE_CG
gl_cg_set_proj_matrix();
#endif
#ifdef HAVE_XML
gl_glsl_set_proj_matrix();
#endif
}
static void gl_shader_set_params(unsigned width, unsigned height,
unsigned tex_width, unsigned tex_height,
unsigned out_width, unsigned out_height,
@ -473,6 +484,23 @@ error:
RARCH_ERR("Failed to set up frame buffer objects. Multi-pass shading will not work.\n");
}
////////////
static void set_projection(gl_t *gl, bool allow_rotate)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (allow_rotate)
glRotatef(gl->rotation, 0, 0, 1);
glOrtho(0, 1, 0, 1, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gl_shader_set_proj_matrix();
}
static inline void gl_compute_fbo_geometry(gl_t *gl, unsigned width, unsigned height,
unsigned vp_width, unsigned vp_height)
{
@ -753,15 +781,7 @@ static void gl_init_textures(gl_t *gl)
}
#endif
#ifdef HAVE_FREETYPE
static inline void gl_render_msg_pre(gl_t *gl)
{
gl_shader_use(0);
set_viewport(gl, gl->win_width, gl->win_height, false, false);
glEnable(GL_BLEND);
}
static inline void gl_render_msg_post(gl_t *gl)
void gl_old_render_path (gl_t *gl)
{
// Go back to old rendering path.
glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords);
@ -772,17 +792,6 @@ static inline void gl_render_msg_post(gl_t *gl)
glDisable(GL_BLEND);
set_projection(gl, true);
}
#elif defined(__CELLOS_LV2__)
static inline void gl_render_msg_pre(gl_t *gl) { }
static inline void gl_render_msg_post(gl_t *gl)
{
cellDbgFontDraw();
}
#else
#define gl_render_msg_pre(...)
#define gl_render_msg_post(...)
#endif
static bool gl_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg)
{