Horde3D

Next-Generation Graphics Engine
It is currently 29.03.2024, 07:00

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 19.01.2009, 12:08 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
I've been writing some C++ code to generate Horde resource files from within some of my tools lately, and I was wondering if this code would be useful to someone - like a library for Horde tool programmers?

I'm trying to keep this as simple as possible (no dependencies so far, not even Horde), so this is the kind of code I will be writing:
Code:
struct Material
{
   struct TexUnit
   {
      std::string name;
      ubyte       index;
      bool        cube;
      bool        useCompression;
      bool        useFiltering;
      bool        useMipMaps;
      bool        repeat;
   };
   struct Uniform
   {
      std::string name;
      float a,b,c,d;
   };
   std::string          className;
   std::string          link;
   std::string          shader;
   std::vector<TexUnit> textures;
   std::vector<Uniform> uniforms;
};

std::ostream& operator<<( std::ostream& xml, const Material m )
{
   xml << "<Material class=\""<<m.className<<"\" link=\""<<m.link<<"\">\n";
   xml << "   <Shader source=\""<<m.shader<<"\"/>\n";
   for( std::vector<Material::TexUnit>::const_iterator it = m.textures.begin();
        it != m.textures.end(); ++it )
   {
      xml << "   <TexUnit unit=\""<<it->index<<"\" map=\""<<it->name<<"\" />\n";
   }
   for( std::vector<Material::Uniform>::const_iterator it = m.uniforms.begin();
        it != m.uniforms.end(); ++it )
   {
      xml << "   <Uniform name=\""<<it->name<<"\" a=\""<<it->a<<"\" b=\""<<it->b<<"\" c=\""<<it->c<<"\" d=\""<<it->d<<"\" />\n";
   }
   xml << "</Material>\n";
}


Top
 Profile  
Reply with quote  
PostPosted: 20.01.2009, 20:22 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
I recall several requests on dynamic resources, so I think many people would profit from your work! The code looks really simple and straightforward to use.


Top
 Profile  
Reply with quote  
PostPosted: 20.01.2009, 20:40 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
It would definitely be useful - currently I just access the engine directly from C++, and use the internal classes, but that won't work on Windows, where DLL-hell will erupt.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 63 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group