libpng question + bonus

Post Reply
Hohoo
Posts: 5
Joined: Thu Jan 07, 2010 1:38 pm

libpng question + bonus

Post by Hohoo » Sat Jan 09, 2010 11:20 pm

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?

StevenH
Posts: 133
Joined: Sun Feb 22, 2009 7:59 pm

Re: libpng question + bonus

Post by StevenH » Sat Jan 09, 2010 11:44 pm

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.

Hohoo
Posts: 5
Joined: Thu Jan 07, 2010 1:38 pm

Re: libpng question + bonus

Post by Hohoo » Sun Jan 10, 2010 10:16 pm

I'm just asking if it's possible.

How much slower would it be?

napco
Posts: 2
Joined: Sat Jan 09, 2010 11:34 am

Re: libpng question + bonus

Post by napco » Mon Jan 11, 2010 2:16 am

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.

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: libpng question + bonus

Post by vuurrobin » Mon Jan 11, 2010 9:08 am

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.

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: libpng question + bonus

Post by WinterMute » Mon Jan 11, 2010 12:21 pm

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.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Hohoo
Posts: 5
Joined: Thu Jan 07, 2010 1:38 pm

Re: libpng question + bonus

Post by Hohoo » Mon Jan 11, 2010 9:13 pm

I forgot to mention that I'm using NitroFS to store the files.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests