Kez
01-10-2009, 10:09 PM
Here are some classes to provide PhysFS (http://icculus.org/physfs/) support to ClanLib 0.8.
I'm switching to ClanLib 0.9 so I thought I'd better release this code while it might still be useful to someone.
Look, a thing (get the release here):
https://sourceforge.net/project/showfiles.php?group_id=169600&package_id=305797
And an example (not tested, so it might not compile):
#include <ClanLib/core.h>
#include <ClanLib/application.h>
#include "FusionPhysFS.h"
// The standard PhysFS header
#include "PhysFS.h"
class PhysFSTest : public CL_ClanApplication
{
virtual int main(int argc, char **argv)
{
CL_SetupCore setup_init;
SetupPhysFS physfs_setup(argv[0]);
CL_ConsoleWindow console("PhysFS Test");
console.redirect_stdio();
try
{
// Configure physFS for this app
SetupPhysFS::configure("Organization", "App", "ZIP");
SetupPhysFS::add_subdirectory("Data/", "ZIP", true);
// Get an instance of the custom inputsource
InputSourceProvider_PhysFS phys_provider("");
// Load some stuff...
// .. The PhysFS way
// (assuming there is a .zip file in 'Data/' which contains 'image_in_zip.png')
CL_PNGProvider phys_png("image_in_zip.png", &phys_provider);
CL_Surface surface(phys_png);
// ... The standard way
CL_PNGProvider png("image.png");
CL_Surface surface2(png);
// Output some general info
const PHYSFS_ArchiveInfo **i;
for (i = PHYSFS_supportedArchiveTypes(); *i != NULL; i++)
{
std::cout << "Supported archive: " << (*i)->extension << " which is "
<< (*i)->description << "." << std::endl;
}
// Display the current search path
std::cout << "PHYSFS search path:" << std::endl;
char **it ;
for (it = PHYSFS_getSearchPath(); *it != NULL; it++)
{
std::cout << "\t" + std::string(*it) << std::endl;
}
}
catch (CL_Error& e)
{
// Error
std::cout << e.message << std::endl;
console.wait_for_key();
}
// Zen
return 0;
}
} app;
I'm switching to ClanLib 0.9 so I thought I'd better release this code while it might still be useful to someone.
Look, a thing (get the release here):
https://sourceforge.net/project/showfiles.php?group_id=169600&package_id=305797
And an example (not tested, so it might not compile):
#include <ClanLib/core.h>
#include <ClanLib/application.h>
#include "FusionPhysFS.h"
// The standard PhysFS header
#include "PhysFS.h"
class PhysFSTest : public CL_ClanApplication
{
virtual int main(int argc, char **argv)
{
CL_SetupCore setup_init;
SetupPhysFS physfs_setup(argv[0]);
CL_ConsoleWindow console("PhysFS Test");
console.redirect_stdio();
try
{
// Configure physFS for this app
SetupPhysFS::configure("Organization", "App", "ZIP");
SetupPhysFS::add_subdirectory("Data/", "ZIP", true);
// Get an instance of the custom inputsource
InputSourceProvider_PhysFS phys_provider("");
// Load some stuff...
// .. The PhysFS way
// (assuming there is a .zip file in 'Data/' which contains 'image_in_zip.png')
CL_PNGProvider phys_png("image_in_zip.png", &phys_provider);
CL_Surface surface(phys_png);
// ... The standard way
CL_PNGProvider png("image.png");
CL_Surface surface2(png);
// Output some general info
const PHYSFS_ArchiveInfo **i;
for (i = PHYSFS_supportedArchiveTypes(); *i != NULL; i++)
{
std::cout << "Supported archive: " << (*i)->extension << " which is "
<< (*i)->description << "." << std::endl;
}
// Display the current search path
std::cout << "PHYSFS search path:" << std::endl;
char **it ;
for (it = PHYSFS_getSearchPath(); *it != NULL; it++)
{
std::cout << "\t" + std::string(*it) << std::endl;
}
}
catch (CL_Error& e)
{
// Error
std::cout << e.message << std::endl;
console.wait_for_key();
}
// Zen
return 0;
}
} app;