2015-01-12 23:38:39 +01:00
|
|
|
/* 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
|
2017-12-11 23:55:31 -08:00
|
|
|
*
|
2015-01-12 23:38:39 +01:00
|
|
|
* 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
|
|
|
|
2015-04-03 20:36:19 +02:00
|
|
|
#include "../font_driver.h"
|
2015-01-12 23:38:39 +01:00
|
|
|
|
2015-03-30 00:29:02 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2018-05-03 22:03:12 +02:00
|
|
|
d3d8_video_t *d3d;
|
2015-03-30 00:29:02 +02:00
|
|
|
XFONT *debug_font;
|
2015-04-10 10:11:43 +02:00
|
|
|
D3DSurface *surf;
|
2015-03-30 00:29:02 +02:00
|
|
|
} xfonts_t;
|
|
|
|
|
2022-06-26 18:01:43 +02:00
|
|
|
static void *xfonts_init(void *video_data,
|
2017-01-25 14:47:24 +01:00
|
|
|
const char *font_path, float font_size,
|
|
|
|
bool is_threaded)
|
2015-01-12 23:38:39 +01:00
|
|
|
{
|
2015-03-30 02:10:17 +02:00
|
|
|
xfonts_t *xfont = (xfonts_t*)calloc(1, sizeof(*xfont));
|
2015-01-12 23:38:39 +01:00
|
|
|
|
2015-03-30 02:10:17 +02:00
|
|
|
if (!xfont)
|
2015-03-30 00:41:42 +02:00
|
|
|
return NULL;
|
2015-03-30 00:29:02 +02:00
|
|
|
|
2018-05-03 22:03:12 +02:00
|
|
|
xfont->d3d = (d3d8_video_t*)video_data;
|
2015-03-30 00:29:02 +02:00
|
|
|
|
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-01-12 23:38:39 +01:00
|
|
|
|
2015-03-30 02:10:17 +02:00
|
|
|
return xfont;
|
2015-01-12 23:38:39 +01:00
|
|
|
}
|
|
|
|
|
2022-06-26 18:01:43 +02:00
|
|
|
static void xfonts_free(void *data, bool is_threaded)
|
2015-01-12 23:38:39 +01:00
|
|
|
{
|
2017-01-14 21:02:30 +01:00
|
|
|
xfonts_t *font = (xfonts_t*)data;
|
|
|
|
|
2022-07-07 21:29:14 +02:00
|
|
|
if (!font)
|
|
|
|
return;
|
2017-12-11 23:55:31 -08:00
|
|
|
|
2022-07-07 21:29:14 +02:00
|
|
|
free(font);
|
2015-01-12 23:38:39 +01:00
|
|
|
}
|
|
|
|
|
2017-01-19 16:30:40 +01:00
|
|
|
static void xfonts_render_msg(
|
2020-03-09 21:34:14 +01:00
|
|
|
void *userdata,
|
2020-03-10 03:24:59 +01:00
|
|
|
void *data,
|
|
|
|
const char *msg,
|
2018-03-23 17:43:49 +01:00
|
|
|
const struct font_params *params)
|
2015-01-12 23:38:39 +01:00
|
|
|
{
|
|
|
|
float x, y;
|
2020-06-27 01:10:45 +02:00
|
|
|
wchar_t *wc = NULL;
|
2020-03-07 04:45:27 +01:00
|
|
|
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;
|
2022-05-15 05:48:09 +02:00
|
|
|
LPDIRECT3DDEVICE8 dev = xfonts->d3d->dev;
|
2015-03-30 00:29:02 +02:00
|
|
|
|
2015-01-12 23:38:39 +01:00
|
|
|
if (params)
|
|
|
|
{
|
|
|
|
x = params->x;
|
|
|
|
y = params->y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-03-07 04:45:27 +01:00
|
|
|
x = video_msg_pos_x;
|
|
|
|
y = video_msg_pos_y;
|
2015-01-12 23:38:39 +01:00
|
|
|
}
|
|
|
|
|
2022-05-15 05:48:09 +02:00
|
|
|
IDirect3DDevice8_GetBackBuffer(dev, -1,
|
|
|
|
D3DBACKBUFFER_TYPE_MONO,
|
|
|
|
(LPDIRECT3DSURFACE8*)&xfonts->surf);
|
2015-01-12 23:38:39 +01:00
|
|
|
|
2020-06-27 01:10:45 +02:00
|
|
|
wc = utf8_to_utf16_string_alloc(msg);
|
2018-01-03 14:26:40 +01:00
|
|
|
|
2020-06-27 01:10:45 +02:00
|
|
|
if (wc)
|
|
|
|
{
|
2018-01-03 14:26:40 +01:00
|
|
|
#ifdef __cplusplus
|
2020-06-27 01:10:45 +02:00
|
|
|
xfonts->debug_font->TextOut(xfonts->surf,
|
|
|
|
wc, (unsigned)-1, x, y);
|
2018-01-03 14:26:40 +01:00
|
|
|
#else
|
2020-06-27 01:10:45 +02:00
|
|
|
XFONT_TextOut(xfonts->debug_font, xfonts->surf,
|
|
|
|
wc, (unsigned)-1, x, y);
|
2018-01-03 14:26:40 +01:00
|
|
|
#endif
|
2020-06-27 01:10:45 +02:00
|
|
|
free(wc);
|
|
|
|
}
|
2022-05-15 05:48:09 +02:00
|
|
|
IDirect3DSurface8_Release((LPDIRECT3DSURFACE8)xfonts->surf);
|
2015-01-12 23:38:39 +01:00
|
|
|
}
|
|
|
|
|
2015-03-30 00:55:39 +02:00
|
|
|
font_renderer_t d3d_xdk1_font = {
|
2022-06-26 18:01:43 +02:00
|
|
|
xfonts_init,
|
|
|
|
xfonts_free,
|
2015-01-12 23:38:39 +01:00
|
|
|
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 */
|
2020-03-31 16:49:16 +01:00
|
|
|
NULL, /* get_message_width */
|
|
|
|
NULL /* get_line_metrics */
|
2015-01-12 23:38:39 +01:00
|
|
|
};
|