SFML community forums
Help => Graphics => Topic started by: Ashenwraith on April 10, 2010, 07:41:56 am
-
Hi, first I'd like to say thanks to Laurent for creating SFML.
I haven't programmed in C++ in many years, but I'm converting my game from Actionscript 3. First I need to convert my tools though.
I have thousands of images that need to be processed so I load them by getting a directory list which returns an array of strings. Next I sort by 'png'.
For example, my code in AS3:
var imgs=[];
function Img_Load(path)
{
var f=new File();
f=File.documentsDirectory;
f=f.resolvePath(path);
var l=f.getDirectoryListing(),x=0;
for(var i=0;i<l.length;i++)
{
var s=l[i].nativePath,t=s;
s=s.split('.');
if(s[1]=='png')
{
imgs[x]=t;
x++;
}
}
}
I'm not really sure how I should start with this.
What's the recommended/cross-platform way to get directory listings/work with files?
Should this be a feature I write on my own or should I extend SFML/SOIL?
Shouldn't there be one cross-platform way for all file loading/handling?
EDIT: I just looked at your roadmap, does this do what I'm talking about:
"FS#83 - DataStream framework for resource loading "
http://www.sfml-dev.org/todo/index.php?do=details&task_id=83
-
What's the recommended/cross-platform way to get directory listings/work with files?
boost::filesystem.
Should this be a feature I write on my own or should I extend SFML/SOIL?
You shouldn't try to rewrite it, it requires low-level code that is specific to the operating system (ie. you will have to write at least 3 versions of the code).
Shouldn't there be one cross-platform way for all file loading/handling?
Listing files and loading them are two completely unrelated tasks, SFML only cares about loading.
Use boost::filesystem ;)
EDIT: I just looked at your roadmap, does this do what I'm talking about:
"FS#83 - DataStream framework for resource loading "
No, it is just a way to abstract the source of a resource (can be a file, an array of bytes in memory, a network resource, whatever...).
-
Hey thanks a lot, I'll get working with boost soon.
Yeah, I was just thinking about putting everything together if I had to write it myself.