#ifndef RESOURCE_MANAGER_H__ #define RESOURCE_MANAGER_H__ #include "LifeDebug.h" #include "Singleton.h" #include "LString.h" #include "vfs/IFileSystem.h" #include "vfs/RootFolder.h" #include "render/ITexture2D.h" #include "IMesh.h" #include "vfs/fs_win/IFSContentProvider.h" #include #include #include "CG.h" #include "Types.h" #include "TypesVideo.h" #include "Light.h" #include "IResourceCollection.h" #include "Skeleton.h" #include "AnimationTrack.h" #include "pugixml.hpp" #include "shaders/ShaderGraphCompilerHLSL.h" #include "shaders/IShaderGraphNodeFactory.h" #include "shaders/IShaderFactorySource.h" namespace LifeGraphics { class IMaterial; struct IBitmapInfo { int Width; int Height; int Bpp; }; enum EFFECT_FLAGS { EF_NONE = 0, EF_LIGHTING = 1 << 0, EF_NORMAL_MAP = 1 << 1, EF_PARALLAX_MAP = 1 << 2, EF_ENVIRONMENT_MAP = 1 << 3, EF_SPECULAR_MAP = 1 << 4, EF_EMISSIVE_MAP = 1 << 5, EF_G_BUFFER_PREPASS = 1 << 6, EF_SKINNING = 1 << 7, EF_LINEAR_DEPTH = 1 << 8, EF_ALPHA_TEST = 1 << 9 }; class ResourceManager; class ResourceManager : public Singleton { public: ResourceManager(); ~ResourceManager(); void SetCentralDirectory(const String& dir); void initialize(); LifeCore::IFileSystem* getFileSystem(); void MountContentProvider(LifeCore::IContentProvider* prov, const String& mountPoint); texture_ptr GetTexture(const String& path); IShader* GetPixelShader(int flags); IShader* GetVertexShader(int flags); IMesh* GetMesh(const String& path); Light* CreatePointLight(const LifeMath::float3& position, float range); Light* CreateDirectionalLight(const LifeMath::float3& direction); void setupMaterialShaders(int shaderFlags, IMaterial* material); Light* CreateSpotLight(const LifeMath::float3& position, const LifeMath::float3& direction, float range, float innerAngle, float outerAngle); IShader* CompileUserShaderPS(const String& path); IShader* CompileUserShaderVS(const String& path); IShader* CompileUserShaderPS(const char* pData, int length); IShader* CompileUserShaderVS(const char* pData, int length); AnimationTrack* LoadAnimatrionTrack(String& path); void ReleaseResources(); void ReadBitmap(String& path, void** pOut, IBitmapInfo** info); void CollectGarbage(float dt); IMaterial* getDefaultMaterial(); void getMaterial(String& path, IMaterial** material); IShader* getShader(IMaterial* material, int adFlags, SHADER_TYPE type); private: IShaderGraphCompiler* shaderCompiler; IShaderGraphNodeFactory* shaderFactory; IMaterial* defaultMaterial; float lastTimeUpdated; float updatePeriod; String centralDir; LifeCore::IFileSystem* fileSystem; IResourceCollection textureCache; IResourceCollection vsCache; IResourceCollection psCache; std::map shaderDefines; std::vector contentProviders; long lastId; long NextID(); }; } #endif