From e184304ec55a08776dec72d84a36acbe52798699 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Thu, 4 Jan 2018 14:21:05 -0600 Subject: [PATCH] A little more documentation post-rwops changes --- src/vm_bitfont.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/vm_bitfont.c b/src/vm_bitfont.c index 646663c..b2cb441 100644 --- a/src/vm_bitfont.c +++ b/src/vm_bitfont.c @@ -25,6 +25,9 @@ vm_bitfont_create(vm_screen *screen, SDL_RWops *rw; vm_bitfont *font; + // Build the RWops object from the given fontdata; we have to use + // FromConstMem because we passed a const pointer into this + // function. rw = SDL_RWFromConstMem(fontdata, fontsize); if (rw == NULL) { log_critical("Failed to create RWops from font data: %s", @@ -32,6 +35,8 @@ vm_bitfont_create(vm_screen *screen, return NULL; } + // And here we build a surface from the RWops, which is a nifty way + // of getting a bitmap from memory rather than loading from a file. surf = SDL_LoadBMP_RW(rw, 0); if (surf == NULL) { log_critical("Failed to create bitmap from RWops: %s", @@ -45,7 +50,9 @@ vm_bitfont_create(vm_screen *screen, return NULL; } + // The texture is what we can use to blit onto the renderer font->texture = SDL_CreateTextureFromSurface(screen->render, surf); + font->width = width; font->height = height; font->cmask = cmask;