45 moResourceFactory::~moResourceFactory() {
55 void moResourcePlugin::Load(
moText plugin_file)
65 DWORD dw = GetLastError();
66 sprintf(szBuf,
"%s failed: GetLastError returned %i\n",
67 (
char*)plugin_file, (
int)dw);
76 farp = GetProcAddress(handle,
"DestroyResourceFactory");
77 CreateResourceFactory = CreateResourceFactoryFunction(GetProcAddress(handle,
"CreateResourceFactory"));
78 DestroyResourceFactory = DestroyResourceFactoryFunction(GetProcAddress(handle,
"DestroyResourceFactory"));
80 CreateResourceFactory = CreateResourceFactoryFunction(dlsym(handle,
"CreateResourceFactory"));
81 DestroyResourceFactory = DestroyResourceFactoryFunction(dlsym(handle,
"DestroyResourceFactory"));
84 if(this->CreateResourceFactory!=NULL)
85 m_factory = this->CreateResourceFactory();
89 void moResourcePlugin::Unload()
91 this->DestroyResourceFactory();
93 CreateResourceFactory = NULL;
94 DestroyResourceFactory = NULL;
104 if(m_factory!=NULL) {
107 if(pfx==NULL)
return NULL;
113 for(
int i=0;i<n;i++) narray[i] = array[i];
125 bool moResourcePlugin::Destroy(
moResource *EfectoMaestro) {
130 if(m_factory!=NULL) {
133 if(array[j]==EfectoMaestro) {
134 m_factory->Destroy(EfectoMaestro);
140 for(i=0;i<j;i++) narray[i] = array[i];
141 for(i=j;i<(n-1);i++) narray[i] = array[i+1];
199 if(!stricmp(resource_name,
"nil"))
return NULL;
204 complete_name+=
moText(
"_d");
206 complete_name +=
moText(
".dll");
210 complete_name+=
moText(
"_d");
212 complete_name += moPluginExtension;
219 for(
MOuint i = 0; i < plugins.Count(); i++)
220 if(!stricmp(plugins[i]->GetName(), complete_name))
230 plg_index = plugins.Count();
231 moResourcePlugin *pplugin =
new moResourcePlugin(complete_name);
233 plugins.Add( pplugin );
241 if(plugins[plg_index]->m_factory!=NULL)
242 return plugins[plg_index]->Create();
258 complete_name+=
moText(
"_d");
260 complete_name +=
moText(
".dll");
264 complete_name+=
moText(
"_d");
266 complete_name += moPluginExtension;
273 for(
MOuint i = 0; i < plugins.Count(); i++)
274 if(!stricmp(plugins[i]->GetName(), complete_name))
286 bool res = plugins[plg_index]->Destroy(Resource);
289 if (res && plugins[plg_index]->n == 0) {
290 plugins[plg_index]->Unload();
291 plugins.Remove(plg_index);
Recurso ( objeto para cargar y manipular objetos físicos de datos de imágenes, audio, video, 3d, 2d, fuentes, shaders y de cualquier otro tipo extendible por un plugin )
static void Error(moText p_text)
Anuncia un error.
LIBMOLDEO_API bool moDeleteResource(moResource *Resource, moResourcePluginsArray &plugins)
const moText & GetName() const
clase de para manejar textos
void moUnloadPlugin(MOpluginHandle &handle)
static const moText & GetModulesDir()
moDefineDynamicArray(moResourcePluginsArray) moResourceFactory
LIBMOLDEO_API moResource * moNewResource(moText resource_name, moResourcePluginsArray &plugins)
MOpluginHandle moLoadPlugin(moText fn)