mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-30 14:53:39 +00:00
fd76a28a32
similar to XDK D3D driver now
83 lines
2.5 KiB
C++
83 lines
2.5 KiB
C++
/* RetroArch - A frontend for libretro.
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
* Copyright (C) 2011-2014 - 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 "../d3d9/d3d9.hpp"
|
|
#include "d3d_font.h"
|
|
#include "../gfx_common.h"
|
|
#include "../../general.h"
|
|
|
|
static bool d3dfonts_w32_init_font(void *data, const char *font_path, unsigned font_size)
|
|
{
|
|
(void)font_path;
|
|
|
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
|
D3DXFONT_DESC desc = {
|
|
static_cast<int>(font_size), 0, 400, 0,
|
|
false, DEFAULT_CHARSET,
|
|
OUT_TT_PRECIS,
|
|
CLIP_DEFAULT_PRECIS,
|
|
DEFAULT_PITCH,
|
|
"Verdana" // Hardcode ftl :(
|
|
};
|
|
|
|
uint32_t r = static_cast<uint32_t>(g_settings.video.msg_color_r * 255) & 0xff;
|
|
uint32_t g = static_cast<uint32_t>(g_settings.video.msg_color_g * 255) & 0xff;
|
|
uint32_t b = static_cast<uint32_t>(g_settings.video.msg_color_b * 255) & 0xff;
|
|
d3d->font_color = D3DCOLOR_XRGB(r, g, b);
|
|
|
|
return SUCCEEDED(D3DXCreateFontIndirect(d3d->dev, &desc, &d3d->font));
|
|
}
|
|
|
|
static void d3dfonts_w32_deinit_font(void *data)
|
|
{
|
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
|
if (d3d->font)
|
|
d3d->font->Release();
|
|
d3d->font = NULL;
|
|
}
|
|
|
|
static void d3dfonts_w32_render_msg(void *data, const char *msg, void *userdata)
|
|
{
|
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
|
font_params_t *params = (font_params_t*)userdata;
|
|
|
|
if (msg && SUCCEEDED(d3d->dev->BeginScene()))
|
|
{
|
|
d3d->font->DrawTextA(NULL,
|
|
msg,
|
|
-1,
|
|
&d3d->font_rect_shifted,
|
|
DT_LEFT,
|
|
((d3d->font_color >> 2) & 0x3f3f3f) | 0xff000000);
|
|
|
|
d3d->font->DrawTextA(NULL,
|
|
msg,
|
|
-1,
|
|
&d3d->font_rect,
|
|
DT_LEFT,
|
|
d3d->font_color | 0xff000000);
|
|
|
|
d3d->dev->EndScene();
|
|
}
|
|
}
|
|
|
|
const d3d_font_renderer_t d3d_win32_font = {
|
|
d3dfonts_w32_init_font,
|
|
d3dfonts_w32_deinit_font,
|
|
d3dfonts_w32_render_msg,
|
|
"d3d-fonts-w32",
|
|
};
|