Page 1 of 1
libpng question + bonus
Posted: Sat Jan 09, 2010 11:20 pm
by Hohoo
Surprisingly, the bonus comes first: Hello! I'm Hohoo, yet another beginning NDS developer. I'm currently making my first game with libnds and I have one short and quick question...
I'm interested in using PNG files and libpng (or PNG++ in my case, as I'm using C++) for graphics. Are there any tutorials about using it with libnds?
Re: libpng question + bonus
Posted: Sat Jan 09, 2010 11:44 pm
by StevenH
Do you really need to read the png files at run time?
You can convert the images into pre-converted graphics ready for the nds files at compile time using grit.
Re: libpng question + bonus
Posted: Sun Jan 10, 2010 10:16 pm
by Hohoo
I'm just asking if it's possible.
How much slower would it be?
Re: libpng question + bonus
Posted: Mon Jan 11, 2010 2:16 am
by napco
It depends on how optimized is your code... It will be slow if you perform loading operations every frame, fast if you don't. I've found 2 methods to load external images (not in the NDS) and keep my game fast:
1-Loading every resource before starting the game (i don't use this anymore)
2-Writing a function that accepts filename as parameter and, if the selected resource hasn't already been loaded, loads it and stores it in an array (or map, or vector...) and returns its reference.
I'm looking forward to see the answer to your question, cause i'm interested too and i NEED to load resources outside the .nds file.
Re: libpng question + bonus
Posted: Mon Jan 11, 2010 9:08 am
by vuurrobin
unless the user needs to change the images themselves, pre convert the images on compile time. grit has an option to convert to *.bin files that you can put in fat or internal filesystem.
if loading files during the actual game is to slow, then load the right before the game, like when loading the level.
Re: libpng question + bonus
Posted: Mon Jan 11, 2010 12:21 pm
by WinterMute
grit has a file format for combining resources too, still need to get together a tutorial and example code for that though :/
See
http://www.coranac.com/man/grit/html/index.htm for some more details.
There are a few problems with using standard image formats for external resources - speed and memory requirements to start with. The biggie is the memory fragmentation caused by conversion.
If you want users to be able to manipulate your data then the best approach is to write tools to do it.
Re: libpng question + bonus
Posted: Mon Jan 11, 2010 9:13 pm
by Hohoo
I forgot to mention that I'm using NitroFS to store the files.