kichikuou / xsystem35-sdl2

Multi-platform implementation of AliceSoft's System3.x game engine.
https://kichikuou.github.io/web/
GNU General Public License v2.0
63 stars 8 forks source link

SDL_ttf font device #12

Closed nunuhara closed 5 years ago

nunuhara commented 5 years ago

I've been working an a PS Vita port of xsystem35 recently. The first thing I noticed when I got it running was that text rendering using the freetype2 font device is extremely slow (it must be rendering on the CPU or something). So I fixed up the SDL_ttf font device (see here) hoping it would improve performance, and it did (at least 5x faster, if I had to guess). I think the main difference is that SDL_ttf keeps a cache of rendered glyphs.

Would you be interested in accepting a patch to add the SDL_ttf font device here as well?

kichikuou commented 5 years ago

Nice! I'd love to merge the patch here.

And your Vita port is really cool :)

nunuhara commented 5 years ago

Thanks :)

How should I set the defaults?

kichikuou commented 5 years ago

How about this?

i.e.:

#ifdef ENABLE_SDLTTF
#define DEFAULT_FONT_DEVICE FONT_SDLTTF
#elif defined(ENABLE_SDL)
#define DEFAULT_FONT_DEVICE FONT_FT2
#else
#define DEFAULT_FONT_DEVICE FONT_X11
#endif

static fontdev_t fontdev = DEFAULT_FONT_DEVICE;

...

static int check_fontdev(char *devname) {
#ifdef ENABLE_SDLTTF
    if (0 == strcmp(devname, "sdl")) {
        return FONT_SDLTTF;
    }
#endif
#ifdef ENABLE_FT2
    if (0 == strcmp(devname, "ft2")) {
        return FONT_FT2;
    }
#endif
#ifdef ENABLE_X11FONT
    if (0 == strcmp(devname, "x11")) {
        return FONT_X11;
    }
#endif
    return DEFAULT_FONT_DEVICE;
}