Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 07:17

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: 02.04.2013, 18:10 
Offline

Joined: 23.07.2012, 04:42
Posts: 8
Hi all,

I am using the Horde3D resource manager as a general purpose resource manager for my project. I load all my scripts (lua source code files) in it, but I am not sure how to get the scripts back. Specifically I need to get the string value of the scripts.

I looked into h3dGetResParamStr, but I was unable to get the string value of my code resource with that.

Any help is appreciated!


Top
 Profile  
Reply with quote  
PostPosted: 02.04.2013, 21:17 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
You should probably write a simple, one function extension for horde that will return the code from your resource.

Something like:

CodeResGetterExtension.h
Code:
#ifndef _CodeResGetterExtension_H_
#define _CodeResGetterExtension_H_

#include "egPrerequisites.h"
#include "egExtensions.h"

namespace Horde3DCodeResGetter
{
   using namespace Horde3D;
   
   class ExtGetter: public IExtension
   {
   public:
      virtual const char *getName();
      virtual bool init();
      virtual void release();
   };
}

#endif   // _CodeResGetterExtension_H_


CodeResGetterExtension.cpp
Code:
#include "utPlatform.h"
#include "egModules.h"
#include "egCom.h"
#include "egResource.h"
#include "egShader.h"
#include "CodeResGetterExtension.h"

#include "utDebug.h"


// Internal extension interface
namespace  Horde3DCodeResGetter
{
   using namespace Horde3D;


   const char *ExtGetter::getName()
   {
      return "CodeResGetter";
   }
   
   bool ExtGetter::init()
   {
      return true;
   }

   void ExtGetter::release()
   {
      
   }
}


// Public C API
namespace Horde3DCodeResGetter
{
DLLEXP const char *h3dextGetCodeResContent( int codeResId )
{
       Resource *codeRes =  Modules::resMan().resolveResHandle( codeResId );
       APIFUNC_VALIDATE_RES_TYPE( codeRes , ResourceTypes::Code, "h3dextGetCodeResContent", 0 );

       return ( CodeResource * )codeRes->getCode().c_str();
}

}


It is just a quick draft and may contain errors, but that's the idea. Just make it a separate project and link into the engine.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 23 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