Horde3D http://horde3d.org/forums/ |
|
How to get a code resource's string value? http://horde3d.org/forums/viewtopic.php?f=2&t=1874 |
Page 1 of 1 |
Author: | kirilz [ 02.04.2013, 18:10 ] |
Post subject: | How to get a code resource's string value? |
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! |
Author: | Irdis [ 02.04.2013, 21:17 ] |
Post subject: | Re: How to get a code resource's string value? |
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. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |