RetroArch/gfx/drivers_font/xdk1_xfonts.c

123 lines
3.3 KiB
C
Raw Normal View History

/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
2017-01-22 13:40:32 +01:00
* Copyright (C) 2011-2017 - 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/>.
*/
#include <xtl.h>
2018-01-25 16:46:30 +01:00
#include <xfont.h>
2015-09-16 05:53:34 +02:00
2016-09-11 15:07:07 +02:00
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
2018-04-17 11:39:59 +02:00
#include "../common/d3d_common.h"
#include "../common/d3d8_common.h"
2016-12-02 01:03:14 +01:00
#include "../font_driver.h"
typedef struct
{
2018-05-03 22:03:12 +02:00
d3d8_video_t *d3d;
XFONT *debug_font;
2015-04-10 10:11:43 +02:00
D3DSurface *surf;
} xfonts_t;
static void *xfonts_init_font(void *video_data,
const char *font_path, float font_size,
bool is_threaded)
{
2015-03-30 02:10:17 +02:00
xfonts_t *xfont = (xfonts_t*)calloc(1, sizeof(*xfont));
2015-03-30 02:10:17 +02:00
if (!xfont)
return NULL;
2018-05-03 22:03:12 +02:00
xfont->d3d = (d3d8_video_t*)video_data;
2015-03-30 02:10:17 +02:00
XFONT_OpenDefaultFont(&xfont->debug_font);
2018-01-03 14:26:40 +01:00
#ifdef __cplusplus
2015-03-30 02:10:17 +02:00
xfont->debug_font->SetBkMode(XFONT_TRANSPARENT);
xfont->debug_font->SetBkColor(D3DCOLOR_ARGB(100,0,0,0));
xfont->debug_font->SetTextHeight(14);
2018-01-03 14:26:40 +01:00
xfont->debug_font->SetTextAntialiasLevel(
xfont->debug_font->GetTextAntialiasLevel());
#else
XFONT_SetBkMode(xfont->debug_font, XFONT_TRANSPARENT);
XFONT_SetBkColor(xfont->debug_font, D3DCOLOR_ARGB(100,0,0,0));
XFONT_SetTextHeight(xfont->debug_font, 14);
2018-01-03 14:28:07 +01:00
XFONT_SetTextAntialiasLevel(xfont->debug_font,
XFONT_GetTextAntialiasLevel(xfont->debug_font));
2018-01-03 14:26:40 +01:00
#endif
2015-03-30 02:10:17 +02:00
return xfont;
}
static void xfonts_free_font(void *data, bool is_threaded)
{
xfonts_t *font = (xfonts_t*)data;
if (font)
free(font);
font = NULL;
}
static void xfonts_render_msg(
2020-03-09 21:34:14 +01:00
void *userdata,
void *data,
const char *msg,
const struct font_params *params)
{
float x, y;
wchar_t str[PATH_MAX_LENGTH];
xfonts_t *xfonts = (xfonts_t*)data;
settings_t *settings = config_get_ptr();
float video_msg_pos_x = settings->floats.video_msg_pos_x;
float video_msg_pos_y = settings->floats.video_msg_pos_y;
if (params)
{
x = params->x;
y = params->y;
}
else
{
x = video_msg_pos_x;
y = video_msg_pos_y;
}
d3d8_device_get_backbuffer(xfonts->d3d->dev,
-1, 0, D3DBACKBUFFER_TYPE_MONO, &xfonts->surf);
mbstowcs(str, msg, sizeof(str) / sizeof(wchar_t));
2018-01-03 14:26:40 +01:00
#ifdef __cplusplus
2015-04-10 10:11:43 +02:00
xfonts->debug_font->TextOut(xfonts->surf, str, (unsigned)-1, x, y);
2018-01-03 14:26:40 +01:00
#else
XFONT_TextOut(xfonts->debug_font, xfonts->surf, str, (unsigned)-1, x, y);
#endif
d3d8_surface_free(xfonts->surf);
}
font_renderer_t d3d_xdk1_font = {
xfonts_init_font,
2015-03-29 22:01:52 +02:00
xfonts_free_font,
xfonts_render_msg,
2015-04-21 17:17:44 +02:00
"xfonts",
2015-04-21 17:13:55 +02:00
NULL, /* get_glyph */
NULL, /* bind_block */
NULL, /* flush */
NULL /* get_message_width */
};