[client] remove other render modes from font ABI

This commit is contained in:
Geoffrey McRae 2018-11-20 05:50:22 +11:00
parent 90fc2a8164
commit 5b453d604e
3 changed files with 10 additions and 33 deletions

View File

@ -102,21 +102,10 @@ static void lgf_sdl_destroy(LG_FontObj opaque)
TTF_Quit(); TTF_Quit();
} }
static bool lgf_sdl_supports(LG_FontObj opaque, LG_FontMode mode) static LG_FontBitmap * lgf_sdl_render(LG_FontObj opaque, unsigned int fg_color, const char * text)
{
return (mode == LG_FONT_BITMAP);
}
static LG_FontOut lgf_sdl_render(LG_FontObj opaque, LG_FontMode mode, unsigned int fg_color, const char * text)
{ {
struct Inst * this = (struct Inst *)opaque; struct Inst * this = (struct Inst *)opaque;
if (mode != LG_FONT_BITMAP)
{
DEBUG_ERROR("Unsupported render mode");
return false;
}
SDL_Surface * surface; SDL_Surface * surface;
SDL_Color color; SDL_Color color;
color.r = (fg_color & 0xff000000) >> 24; color.r = (fg_color & 0xff000000) >> 24;
@ -144,13 +133,14 @@ static LG_FontOut lgf_sdl_render(LG_FontObj opaque, LG_FontMode mode, unsigned i
out->bpp = surface->format->BytesPerPixel; out->bpp = surface->format->BytesPerPixel;
out->pixels = surface->pixels; out->pixels = surface->pixels;
return (LG_FontOut*)out; return out;
} }
static void lgf_sdl_release(LG_FontObj opaque, LG_FontOut font) static void lgf_sdl_release(LG_FontObj opaque, LG_FontBitmap * font)
{ {
LG_FontBitmap * bitmap = (LG_FontBitmap *)font; LG_FontBitmap * bitmap = (LG_FontBitmap *)font;
SDL_FreeSurface(bitmap->reserved); SDL_FreeSurface(bitmap->reserved);
free(bitmap);
} }
struct LG_Font LGF_SDL = struct LG_Font LGF_SDL =
@ -158,7 +148,6 @@ struct LG_Font LGF_SDL =
.name = "SDL", .name = "SDL",
.create = lgf_sdl_create, .create = lgf_sdl_create,
.destroy = lgf_sdl_destroy, .destroy = lgf_sdl_destroy,
.supports = lgf_sdl_supports,
.render = lgf_sdl_render, .render = lgf_sdl_render,
.release = lgf_sdl_release .release = lgf_sdl_release
}; };

View File

@ -22,16 +22,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <stdint.h> #include <stdint.h>
typedef void * LG_FontObj; typedef void * LG_FontObj;
typedef void * LG_FontOut;
typedef enum LG_FontMode
{
LG_FONT_BITMAP,
LG_FONT_OPENGL,
LG_FONT_VULKAN
}
LG_FontMode;
typedef struct LG_FontBitmap typedef struct LG_FontBitmap
{ {
void * reserved; void * reserved;
@ -42,11 +32,10 @@ typedef struct LG_FontBitmap
} }
LG_FontBitmap; LG_FontBitmap;
typedef bool (* LG_FontCreate )(LG_FontObj * opaque, const char * font_name, unsigned int size); typedef bool (* LG_FontCreate )(LG_FontObj * opaque, const char * font_name, unsigned int size);
typedef void (* LG_FontDestroy )(LG_FontObj opaque); typedef void (* LG_FontDestroy )(LG_FontObj opaque);
typedef bool (* LG_FontSupports )(LG_FontObj opaque, LG_FontMode mode); typedef LG_FontBitmap * (* LG_FontRender )(LG_FontObj opaque, unsigned int fg_color, const char * text);
typedef LG_FontOut (* LG_FontRender )(LG_FontObj opaque, LG_FontMode mode, unsigned int fg_color, const char * text); typedef void (* LG_FontRelease )(LG_FontObj opaque, LG_FontBitmap * bitmap);
typedef void (* LG_FontRelease )(LG_FontObj opaque, LG_FontOut font);
typedef struct LG_Font typedef struct LG_Font
{ {
@ -54,7 +43,6 @@ typedef struct LG_Font
const char * name; const char * name;
LG_FontCreate create; LG_FontCreate create;
LG_FontDestroy destroy; LG_FontDestroy destroy;
LG_FontSupports supports;
LG_FontRender render; LG_FontRender render;
LG_FontRelease release; LG_FontRelease release;
} }

View File

@ -414,7 +414,7 @@ void opengl_on_alert(void * opaque, const LG_RendererAlert alert, const char * m
break; break;
} }
if (!(a->text = this->font->render(this->alertFontObj, LG_FONT_BITMAP, 0xffffff00, message))) if (!(a->text = this->font->render(this->alertFontObj, 0xffffff00, message)))
{ {
DEBUG_ERROR("Failed to render alert text: %s", TTF_GetError()); DEBUG_ERROR("Failed to render alert text: %s", TTF_GetError());
free(a); free(a);
@ -632,7 +632,7 @@ void opengl_update_fps(void * opaque, const float avgFPS, const float renderFPS)
snprintf(str, sizeof(str), "UPS: %8.4f, FPS: %8.4f", avgFPS, renderFPS); snprintf(str, sizeof(str), "UPS: %8.4f, FPS: %8.4f", avgFPS, renderFPS);
LG_FontBitmap *textSurface = NULL; LG_FontBitmap *textSurface = NULL;
if (!(textSurface = this->font->render(this->fontObj, LG_FONT_BITMAP, 0xffffff00, str))) if (!(textSurface = this->font->render(this->fontObj, 0xffffff00, str)))
DEBUG_ERROR("Failed to render text"); DEBUG_ERROR("Failed to render text");
bitmap_to_texture(textSurface, this->textures[FPS_TEXTURE]); bitmap_to_texture(textSurface, this->textures[FPS_TEXTURE]);