mirror of
				https://github.com/gnif/LookingGlass.git
				synced 2025-11-04 14:41:55 +00:00 
			
		
		
		
	[client] remove other render modes from font ABI
This commit is contained in:
		@@ -102,21 +102,10 @@ static void lgf_sdl_destroy(LG_FontObj opaque)
 | 
			
		||||
    TTF_Quit();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool lgf_sdl_supports(LG_FontObj opaque, LG_FontMode mode)
 | 
			
		||||
{
 | 
			
		||||
  return (mode == LG_FONT_BITMAP);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static LG_FontOut lgf_sdl_render(LG_FontObj opaque, LG_FontMode mode, unsigned int fg_color, const char * text)
 | 
			
		||||
static LG_FontBitmap * lgf_sdl_render(LG_FontObj opaque, unsigned int fg_color, const char * text)
 | 
			
		||||
{
 | 
			
		||||
  struct Inst * this = (struct Inst *)opaque;
 | 
			
		||||
 | 
			
		||||
  if (mode != LG_FONT_BITMAP)
 | 
			
		||||
  {
 | 
			
		||||
    DEBUG_ERROR("Unsupported render mode");
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  SDL_Surface * surface;
 | 
			
		||||
  SDL_Color     color;
 | 
			
		||||
  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->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;
 | 
			
		||||
  SDL_FreeSurface(bitmap->reserved);
 | 
			
		||||
  free(bitmap);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct LG_Font LGF_SDL =
 | 
			
		||||
@@ -158,7 +148,6 @@ struct LG_Font LGF_SDL =
 | 
			
		||||
  .name         = "SDL",
 | 
			
		||||
  .create       = lgf_sdl_create,
 | 
			
		||||
  .destroy      = lgf_sdl_destroy,
 | 
			
		||||
  .supports     = lgf_sdl_supports,
 | 
			
		||||
  .render       = lgf_sdl_render,
 | 
			
		||||
  .release      = lgf_sdl_release
 | 
			
		||||
};
 | 
			
		||||
@@ -22,16 +22,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
{
 | 
			
		||||
  void * reserved;
 | 
			
		||||
@@ -42,11 +32,10 @@ typedef struct LG_FontBitmap
 | 
			
		||||
}
 | 
			
		||||
LG_FontBitmap;
 | 
			
		||||
 | 
			
		||||
typedef bool       (* LG_FontCreate      )(LG_FontObj * opaque, const char * font_name, unsigned int size);
 | 
			
		||||
typedef void       (* LG_FontDestroy     )(LG_FontObj opaque);
 | 
			
		||||
typedef bool       (* LG_FontSupports    )(LG_FontObj opaque, LG_FontMode mode);
 | 
			
		||||
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_FontOut font);
 | 
			
		||||
typedef bool            (* LG_FontCreate      )(LG_FontObj * opaque, const char * font_name, unsigned int size);
 | 
			
		||||
typedef void            (* LG_FontDestroy     )(LG_FontObj opaque);
 | 
			
		||||
typedef LG_FontBitmap * (* LG_FontRender      )(LG_FontObj opaque, unsigned int fg_color, const char * text);
 | 
			
		||||
typedef void            (* LG_FontRelease     )(LG_FontObj opaque, LG_FontBitmap * bitmap);
 | 
			
		||||
 | 
			
		||||
typedef struct LG_Font
 | 
			
		||||
{
 | 
			
		||||
@@ -54,7 +43,6 @@ typedef struct LG_Font
 | 
			
		||||
  const char *        name;
 | 
			
		||||
  LG_FontCreate       create;
 | 
			
		||||
  LG_FontDestroy      destroy;
 | 
			
		||||
  LG_FontSupports     supports;
 | 
			
		||||
  LG_FontRender       render;
 | 
			
		||||
  LG_FontRelease      release;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -414,7 +414,7 @@ void opengl_on_alert(void * opaque, const LG_RendererAlert alert, const char * m
 | 
			
		||||
      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());
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
  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");
 | 
			
		||||
 | 
			
		||||
  bitmap_to_texture(textSurface, this->textures[FPS_TEXTURE]);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user