Skip to content

Commit f2f939d

Browse files
author
Jeffrey Clark
committed
replace SDL_DrawText with FC_FontCache
1 parent cf5d453 commit f2f939d

12 files changed

+3027
-356
lines changed

fonts/default.ttf

41.5 KB
Binary file not shown.

src/Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ EXE = ../$(EXE_BASE)$(EXE_EXT)
5656

5757
# ... by RDG2010
5858
ifeq ($(BUILD_SINGE),1)
59-
LIBS += $(shell ${PKG_CONFIG} --libs lua SDL2_mixer SDL2_image SDL2_ttf)
60-
PFLAGS += -DBUILD_SINGE $(shell ${PKG_CONFIG} --cflags SDL2_mixer SDL2_image SDL2_ttf)
59+
LIBS += $(shell ${PKG_CONFIG} --libs lua SDL2_mixer SDL2_image)
60+
PFLAGS += -DBUILD_SINGE $(shell ${PKG_CONFIG} --cflags SDL2_mixer SDL2_image)
6161
OBJS += game/singe/*.o
6262
endif
6363

@@ -67,7 +67,7 @@ LIBS += $(shell ${PKG_CONFIG} --libs libmpeg2 libmpeg2convert)
6767

6868
# Platform specific cflags defined in the Makefile.vars file
6969
export CFLAGS = $(shell ${SDL_CONFIG} --cflags) ${PFLAGS} -Werror
70-
LIBS += $(shell ${SDL_CONFIG} --libs)
70+
LIBS += $(shell ${SDL_CONFIG} --libs) $(shell ${PKG_CONFIG} --libs SDL2_ttf)
7171

7272
OBJS += ldp-out/*.o cpu/*.o game/*.o io/*.o timer/*.o ldp-in/*.o video/*.o \
7373
sound/*.o daphne.o cpu/x86/*.o scoreboard/*.o ${VLDP_OBJS}
@@ -110,7 +110,7 @@ clean: clean_deps
110110
testvldp: CFLAGS += -DVLDP_BENCHMARK
111111
testvldp: vldp testvldp.c
112112
$(CC_MSG)
113-
$(SILENT)${CC} ${CFLAGS} -DSHOW_FRAMES testvldp.c ${VLDP_OBJS} ${LIBS} -o ../testvldp$(EXE_EXT)
113+
$(SILENT)${CC} ${CFLAGS} -DSHOW_FRAMES testvldp.c video/SDL_FontCache.c ${VLDP_OBJS} ${LIBS} -o ../testvldp$(EXE_EXT)
114114

115115
%.d : %.cpp
116116
$(GEN_MSG)

src/testvldp.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#include <SDL.h>
22

3+
#include "video/SDL_FontCache.h"
34
#include "vldp/vldp.h" // VLDP stuff
4-
#include "io/dll.h" // for DLL stuff
5-
#include "video/yuv2rgb.h" // to bypass SDL's yuv overlay and do it ourselves ...
65

76
#ifndef WIN32
87
#include <unistd.h> // for chdir
@@ -39,6 +38,7 @@ unsigned int g_uQuitFlag = 0;
3938
SDL_Window *g_window = NULL;
4039
SDL_Renderer *g_renderer = NULL;
4140
SDL_Texture *g_texture = NULL;
41+
FC_Font *g_font = NULL;
4242
SDL_RendererInfo g_rendererinfo;
4343

4444
void printerror(const char *cpszErrMsg) { puts(cpszErrMsg); }
@@ -61,6 +61,7 @@ void display_frame_callback()
6161
#ifdef SHOW_FRAMES
6262
SDL_RenderClear(g_renderer);
6363
SDL_RenderCopy(g_renderer, g_texture, NULL, NULL);
64+
FC_Draw(g_font, g_renderer, 0, 0, "%d", g_uFrameCount);
6465
SDL_RenderPresent(g_renderer); // display it!
6566
#endif // SHOW_FRAMES
6667
}
@@ -140,8 +141,6 @@ void set_cur_dir(const char *exe_loc)
140141

141142
int main(int argc, char **argv)
142143
{
143-
// DLL_INSTANCE dll_instance = NULL;
144-
145144
set_cur_dir(argv[0]);
146145
#ifdef SHOW_FRAMES
147146
SDL_Init(SDL_INIT_VIDEO);
@@ -156,6 +155,10 @@ int main(int argc, char **argv)
156155

157156
SDL_GetRendererInfo(g_renderer, &g_rendererinfo);
158157
printf("Using %s rendering\n", g_rendererinfo.name);
158+
159+
g_font = FC_CreateFont();
160+
if (FC_LoadFont(g_font, g_renderer, "fonts/default.ttf", 18, FC_MakeColor(255,255,0,255), TTF_STYLE_NORMAL) == 0)
161+
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", SDL_GetError());
159162
#endif
160163

161164
pvldp_init = (initproc)&vldp_init;

src/video/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
| sed 's^\($*\)\.o[ :]*^\1.o $@ : ^g' > $@; \
77
[ -s $@ ] || rm -f $@
88

9-
OBJS = video.o tms9128nl.o SDL_DrawText.o \
9+
OBJS = video.o tms9128nl.o SDL_FontCache.o \
1010
led.o palette.o rgb2yuv.o blend.o
1111

1212
.SUFFIXES: .cpp

src/video/SDL_DrawText.cpp

-150
This file was deleted.

src/video/SDL_DrawText.h

-28
This file was deleted.

0 commit comments

Comments
 (0)