(XDK) Rewrote Xbox font code

This commit is contained in:
twinaphex 2012-12-15 03:35:04 +01:00
parent f412a0cda0
commit 4864adc7b1
7 changed files with 93 additions and 47 deletions

View File

@ -32,12 +32,11 @@
#include "../../screenshot.h"
#include "../fonts/d3d_fonts.h"
#if defined(_XBOX1)
#include "../fonts/xdk1_xfonts.h"
// for Xbox 1
#define XBOX_PRESENTATIONINTERVAL D3DRS_PRESENTATIONINTERVAL
#else
// for Xbox 360
#elif defined(_XBOX360)
#define XBOX_PRESENTATIONINTERVAL D3DRS_PRESENTINTERVAL
#endif

View File

@ -14,13 +14,25 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RARCH_360_FONTS_H
#define RARCH_360_FONTS_H
HRESULT d3d9_init_font(const char *font_path);
void d3d9_deinit_font(void);
void xdk_render_msg(void *driver, const char *str);
void xdk_render_msg_place(void *driver, float x, float y, const char *str_msg);
#include "d3d_font.h"
#include "../../general.h"
static const d3d_font_renderer_t *d3d_font_backends[] = {
#if defined(_XBOX1)
&d3d_xdk1_font,
#elif defined(_XBOX360
&d3d_xbox360_font,
#endif
};
const d3d_font_renderer_t *d3d_font_init_first(void *data, const char *font_path, unsigned font_size)
{
for (unsigned i = 0; i < ARRAY_SIZE(d3d_font_backends); i++)
{
if (d3d_font_backends[i]->init(data, font_path, font_size))
return d3d_font_backends[i];
}
return NULL;
}

View File

@ -1,6 +1,5 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - 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-
@ -14,10 +13,27 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RARCH_XDK1_FONTS_H
#define RARCH_XDK1_FONTS_H
#ifndef GL_FONT_H__
#define GL_FONT_H__
void xfonts_deinit_font(void);
void xfonts_render_msg_place(void *data, float x, float y, float scale, const char *msg);
#include <stdint.h>
#include "../../boolean.h"
typedef struct d3d_font_renderer
{
bool (*init)(void *data, const char *font_path, unsigned font_size);
void (*deinit)(void *data);
void (*render_msg)(void *data, const char *msg);
void (*render_msg_place)(void *data, float x, float y,
float scale, uint32_t color, const char *msg);
const char *ident;
} d3d_font_renderer_t;
extern const d3d_font_renderer_t d3d_xbox360_font;
extern const d3d_font_renderer_t d3d_xdk1_font;
const d3d_font_renderer_t *d3d_font_init_first(void *data,
const char *font_path, unsigned font_size);
#endif

View File

@ -1,5 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - 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-

View File

@ -15,25 +15,45 @@
*/
#include <xtl.h>
#include "xdk1_xfonts.h"
#include "d3d_font.h"
#include "../../general.h"
void xfonts_deinit_font(void)
static bool xfonts_init_font(void *data, const char *font_path, unsigned font_size)
{
(void)data;
(void)font_path;
(void)font_size;
return true;
}
void xfonts_render_msg_place(void *data, float x, float y, float scale, const char *msg)
static void xfonts_deinit_font(void *data)
{
(void)data;
}
static void xfonts_render_msg(void *data, const char *msg)
{
xfonts_render_msg_place(data, g_settings.video.msg_pos_x, g_settings.video.msg_pos_y, 0, msg);
}
static void xfonts_render_msg_place(void *data, float x, float y, float scale, const char *msg)
{
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data;
d3d->d3d_render_device->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &d3d->pFrontBuffer);
//d3d->d3d_render_device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &d3d->pBackBuffer);
wchar_t str[256];
convert_char_to_wchar(str, msg, sizeof(str));
d3d->debug_font->TextOut(d3d->pFrontBuffer, str, (unsigned)-1, x, y);
//d3d->debug_font->TextOut(d3d->pBackBuffer, str, (unsigned)-1, x, y);
d3d->pFrontBuffer->Release();
//d3d->pBackBuffer->Release();
}
const d3d_font_renderer_t d3d_xdk1_font = {
xfonts_init_font,
xfonts_deinit_font,
xfonts_render_msg,
xfonts_render_msg_place,
"XDK1 Xfonts",
};

View File

@ -15,6 +15,7 @@
*/
#include <xtl.h>
#include "d3d_font.h"
#include "../../general.h"
#include "../../xdk/xdk_resources.h"
@ -175,7 +176,7 @@ static HRESULT xdk360_video_font_create_shaders (xdk360_video_font_t * font)
return hr;
}
HRESULT d3d9_init_font(const char *path)
static bool xdk_init_font(void *data, const char *font_path, unsigned font_size)
{
// Create the font
xdk360_video_font_t *font = &m_Font;
@ -238,7 +239,7 @@ error:
return E_FAIL;
}
void d3d9_deinit_font(void)
static void xdk_deinit_font(void *data)
{
xdk360_video_font_t *font = &m_Font;
@ -261,18 +262,15 @@ void d3d9_deinit_font(void)
void xdk_render_msg_post(xdk360_video_font_t * font)
{
// Restore state
{
// Cache the global pointer into a register
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
D3DDevice *pD3dDevice = d3d->d3d_render_device;
// Cache the global pointer into a register
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
D3DDevice *pD3dDevice = d3d->d3d_render_device;
pD3dDevice->SetTexture(0, NULL);
pD3dDevice->SetVertexDeclaration(NULL);
D3DDevice_SetVertexShader(pD3dDevice, NULL );
D3DDevice_SetPixelShader(pD3dDevice, NULL );
pD3dDevice->SetRenderState( D3DRS_VIEWPORTENABLE, font->m_dwSavedState );
}
pD3dDevice->SetTexture(0, NULL);
pD3dDevice->SetVertexDeclaration(NULL);
D3DDevice_SetVertexShader(pD3dDevice, NULL );
D3DDevice_SetPixelShader(pD3dDevice, NULL );
pD3dDevice->SetRenderState( D3DRS_VIEWPORTENABLE, font->m_dwSavedState );
}
static void xdk_render_msg_pre(xdk360_video_font_t * font)
@ -430,7 +428,7 @@ static void xdk_video_font_draw_text(xdk360_video_font_t *font,
pd3dDevice->EndVertices();
}
void xdk_render_msg_place(void *driver, float x, float y, const char *str_msg)
static void xdk_render_msg_place(void *driver, float x, float y, const char *str_msg)
{
xdk_d3d_video_t *vid = (xdk_d3d_video_t*)driver;
@ -445,14 +443,20 @@ void xdk_render_msg_place(void *driver, float x, float y, const char *str_msg)
}
}
void xdk_render_msg(void *driver, const char *str_msg)
static void xdk_render_msg(void *driver, const char *msg)
{
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver;
float x = g_extern.console.rmenu.state.rmenu_hd.enable ? 160 : 100;
float y = 120;
xdk_render_msg_place(d3d, x, y, str_msg);
xdk_render_msg_place(d3d, x, y, msg);
}
const d3d_font_renderer_t d3d_xbox360_font = {
xdk_init_font,
xdk_deinit_font,
xdk_render_msg,
xdk_render_msg_place,
"Xbox 360 fonts",
};

View File

@ -26,10 +26,6 @@
#include "../gfx/shader_hlsl.h"
#endif
#ifdef _XBOX1
#include "./../gfx/fonts/xdk1_xfonts.h"
#endif
#include "./../gfx/gfx_context.h"
#include "../general.h"
#include "../message.h"
@ -38,9 +34,7 @@
#include "config.h"
#endif
#ifdef _XBOX360
#include "../gfx/fonts/xdk360_fonts.h"
#endif
#include "../gfx/fonts/d3d_fonts.h"
#include "../xdk/xdk_resources.h"