-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support loading tileset images from memory. #69
Comments
Oh I neglected to mention this is with 1.15.1 on Ubuntu on WSL with g++ 9.3.0. |
You're using an old version. The latest versions moved to a C API which hasn't been ported to C++ yet. This version is likely missing the |
It wouldn't be hard to add support for this. You want to load a PNG file from memory? |
Thanks. How stable is the API in the latest versions? If you're still adjusting things I'd rather wait until you are done and try and fix up my 1.15.1. I like to compile all my games resources into the executable so the player doesn't have to worry about installing lots of fiddly files all over the place. So if you could add this feature it would be greatly appreciated. |
Made the character mappings public so that the new tileset API is realistically usable. Should help with issue #69.
The alpha versions have important bugfixes not in I've added changes to the develop branch. You can load a PNG file from memory with something similar to this: static unsigned char png_data[]; // dejavu10x10_gs_tc.png
TCOD_Tileset* tileset = TCOD_tileset_load_mem(
sizeof(png_data),
png_data,
32,
8,
sizeof(TCOD_CHARMAP_TCOD) / sizeof(*TCOD_CHARMAP_TCOD),
TCOD_CHARMAP_TCOD);
assert(tileset != NULL);
TCOD_set_default_tileset(tileset);
TCOD_tileset_delete(tileset);
// Then run TCOD_console_init_root, or the C++ version of that. It isn't tested yet but it shares most of its code with the existing loader. I just needed to swap This is the basic minimum, but I can work on the C++ API if you want something safer to use. |
I wanted to embed the tileset into my executable rather than load it from an external file. Although libtcod doesn't support this directly, lodepng which it uses internally does. So I created a function like this:
(font.h)
(font.cc)
This compiles but produces linker errors like this:
I don't understand what's going wrong. Can you enlighten me?
The text was updated successfully, but these errors were encountered: