| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- #include "RsrcPtr.h"
- #include "RsrcContainer.h"
- #include "Texture.h"
- #include "Material.h"
- #include "ShaderProg.h"
- #include "Mesh.h"
- #include "Skeleton.h"
- #include "SkelAnim.h"
- #include "LightData.h"
- #include "ParticleEmitterProps.h"
- #include "Script.h"
- #include "Model.h"
- namespace RsrcContainers {
- extern RsrcContainer<Texture> textures;
- extern RsrcContainer<ShaderProg> shaderProgs;
- extern RsrcContainer<Material> materials;
- extern RsrcContainer<Mesh> meshes;
- extern RsrcContainer<Skeleton> skeletons;
- extern RsrcContainer<SkelAnim> skelAnims;
- extern RsrcContainer<LightData> lightProps;
- extern RsrcContainer<ParticleEmitterProps> particleEmitterProps;
- extern RsrcContainer<Script> scripts;
- extern RsrcContainer<Model> models;
- }
- #define LOAD_RSRC(container) \
- p = RsrcContainers::container.load(filename); \
- return p != NULL;
- #define UNLOAD_RSRC(container) \
- if(p) \
- { \
- RsrcContainers::container.unload(p); \
- p = NULL; \
- }
- //======================================================================================================================
- // loadRsrc <Texture> =
- //======================================================================================================================
- template<>
- bool RsrcPtr<Texture>::loadRsrc(const char* filename)
- {
- LOAD_RSRC(textures);
- }
- //======================================================================================================================
- // loadRsrc <ShaderProg> =
- //======================================================================================================================
- template<>
- bool RsrcPtr<ShaderProg>::loadRsrc(const char* filename)
- {
- LOAD_RSRC(shaderProgs);
- }
- //======================================================================================================================
- // loadRsrc <Material> =
- //======================================================================================================================
- template<>
- bool RsrcPtr<Material>::loadRsrc(const char* filename)
- {
- LOAD_RSRC(materials);
- }
- //======================================================================================================================
- // loadRsrc <Mesh> =
- //======================================================================================================================
- template<>
- bool RsrcPtr<Mesh>::loadRsrc(const char* filename)
- {
- LOAD_RSRC(meshes);
- }
- //======================================================================================================================
- // loadRsrc <Skeleton> =
- //======================================================================================================================
- template<>
- bool RsrcPtr<Skeleton>::loadRsrc(const char* filename)
- {
- LOAD_RSRC(skeletons);
- }
- //======================================================================================================================
- // loadRsrc <SkelAnim> =
- //======================================================================================================================
- template<>
- bool RsrcPtr<SkelAnim>::loadRsrc(const char* filename)
- {
- LOAD_RSRC(skelAnims);
- }
- //======================================================================================================================
- // loadRsrc <LightProp> =
- //======================================================================================================================
- template<>
- bool RsrcPtr<LightData>::loadRsrc(const char* filename)
- {
- LOAD_RSRC(lightProps);
- }
- //======================================================================================================================
- // loadRsrc <ParticleEmitterProps> =
- //======================================================================================================================
- template<>
- bool RsrcPtr<ParticleEmitterProps>::loadRsrc(const char* filename)
- {
- LOAD_RSRC(particleEmitterProps);
- }
- //======================================================================================================================
- // loadRsrc <Script> =
- //======================================================================================================================
- template<>
- bool RsrcPtr<Script>::loadRsrc(const char* filename)
- {
- LOAD_RSRC(scripts);
- }
- //======================================================================================================================
- // loadRsrc <Model> =
- //======================================================================================================================
- template<>
- bool RsrcPtr<Model>::loadRsrc(const char* filename)
- {
- LOAD_RSRC(models);
- }
- //======================================================================================================================
- // unload <Texture> =
- //======================================================================================================================
- template<>
- void RsrcPtr<Texture>::unload()
- {
- UNLOAD_RSRC(textures);
- }
- //======================================================================================================================
- // unload <ShaderProg> =
- //======================================================================================================================
- template<>
- void RsrcPtr<ShaderProg>::unload()
- {
- UNLOAD_RSRC(shaderProgs);
- }
- //======================================================================================================================
- // unload <Material> =
- //======================================================================================================================
- template<>
- void RsrcPtr<Material>::unload()
- {
- UNLOAD_RSRC(materials);
- }
- //======================================================================================================================
- // unload <Mesh> =
- //======================================================================================================================
- template<>
- void RsrcPtr<Mesh>::unload()
- {
- UNLOAD_RSRC(meshes);
- }
- //======================================================================================================================
- // unload <Skeleton> =
- //======================================================================================================================
- template<>
- void RsrcPtr<Skeleton>::unload()
- {
- UNLOAD_RSRC(skeletons);
- }
- //======================================================================================================================
- // unload <SkelAnim> =
- //======================================================================================================================
- template<>
- void RsrcPtr<SkelAnim>::unload()
- {
- UNLOAD_RSRC(skelAnims);
- }
- //======================================================================================================================
- // unload <LightProps> =
- //======================================================================================================================
- template<>
- void RsrcPtr<LightData>::unload()
- {
- UNLOAD_RSRC(lightProps);
- }
- //======================================================================================================================
- // unload <ParticleEmitterProps> =
- //======================================================================================================================
- template<>
- void RsrcPtr<ParticleEmitterProps>::unload()
- {
- UNLOAD_RSRC(particleEmitterProps);
- }
- //======================================================================================================================
- // unload <Script> =
- //======================================================================================================================
- template<>
- void RsrcPtr<Script>::unload()
- {
- UNLOAD_RSRC(scripts);
- }
- //======================================================================================================================
- // unload <Model> =
- //======================================================================================================================
- template<>
- void RsrcPtr<Model>::unload()
- {
- UNLOAD_RSRC(models);
- }
|