diff --git a/gfx/fonts/xdk1_xfonts.c b/gfx/fonts/xdk1_xfonts.c index 6175a94094..25bdbd61c7 100644 --- a/gfx/fonts/xdk1_xfonts.c +++ b/gfx/fonts/xdk1_xfonts.c @@ -18,6 +18,9 @@ #include "d3d_font.h" #include "../../general.h" +static XFONT *debug_font; +static D3DSurface *pFrontBuffer; + static bool xfonts_init_font(void *data, const char *font_path, unsigned font_size) { (void)font_path; @@ -25,11 +28,11 @@ static bool xfonts_init_font(void *data, const char *font_path, unsigned font_si xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data; - XFONT_OpenDefaultFont(&d3d->debug_font); - d3d->debug_font->SetBkMode(XFONT_TRANSPARENT); - d3d->debug_font->SetBkColor(D3DCOLOR_ARGB(100,0,0,0)); - d3d->debug_font->SetTextHeight(14); - d3d->debug_font->SetTextAntialiasLevel(d3d->debug_font->GetTextAntialiasLevel()); + XFONT_OpenDefaultFont(&debug_font); + debug_font->SetBkMode(XFONT_TRANSPARENT); + debug_font->SetBkColor(D3DCOLOR_ARGB(100,0,0,0)); + debug_font->SetTextHeight(14); + debug_font->SetTextAntialiasLevel(debug_font->GetTextAntialiasLevel()); return true; } @@ -43,13 +46,13 @@ static void xfonts_render_msg_place(void *data, float x, float y, float scale, u { 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(-1, D3DBACKBUFFER_TYPE_MONO, &pFrontBuffer); wchar_t str[256]; convert_char_to_wchar(str, msg, sizeof(str)); - d3d->debug_font->TextOut(d3d->pFrontBuffer, str, (unsigned)-1, x, y); + debug_font->TextOut(pFrontBuffer, str, (unsigned)-1, x, y); - d3d->pFrontBuffer->Release(); + pFrontBuffer->Release(); } static void xfonts_render_msg(void *data, const char *msg) diff --git a/xdk/xdk_d3d.cpp b/xdk/xdk_d3d.cpp index 27c36b1b7a..e6bd4ea2b0 100644 --- a/xdk/xdk_d3d.cpp +++ b/xdk/xdk_d3d.cpp @@ -37,7 +37,6 @@ #include "../xdk/xdk_resources.h" #if defined(_XBOX1) -wchar_t strw_buffer[128]; unsigned font_x, font_y; #elif defined(_XBOX360) const DWORD g_MapLinearToSrgbGpuFormat[] = @@ -805,10 +804,12 @@ static bool xdk_d3d_frame(void *data, const void *frame, char buf[128]; snprintf(buf, sizeof(buf), "%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f)); + if (d3d->font_ctx) d3d->font_ctx->render_msg_place(d3d, mem_width, mem_height, 0, 0, buf); gfx_get_fps(fps_txt, sizeof(fps_txt), true); - d3d->font_ctx->render_msg_place(d3d, mem_width, mem_height + 30, 0, 0, fps_txt); + if (d3d->font_ctx) + d3d->font_ctx->render_msg_place(d3d, mem_width, mem_height + 30, 0, 0, fps_txt); } if (msg diff --git a/xdk/xdk_d3d.h b/xdk/xdk_d3d.h index 91c216eb45..06c4a95706 100644 --- a/xdk/xdk_d3d.h +++ b/xdk/xdk_d3d.h @@ -75,10 +75,6 @@ typedef struct xdk_d3d_video IDirect3DVertexDeclaration9* v_decl; #endif const d3d_font_renderer_t *font_ctx; -#if defined(_XBOX1) - XFONT *debug_font; - D3DSurface *pBackBuffer, *pFrontBuffer; -#endif D3DFORMAT internal_fmt; D3DFORMAT texture_fmt; unsigned base_size;