1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00
OpenMW/components/resource/texturemanager.hpp

60 lines
1.4 KiB
C++
Raw Normal View History

#ifndef OPENMW_COMPONENTS_RESOURCE_TEXTUREMANAGER_H
#define OPENMW_COMPONENTS_RESOURCE_TEXTUREMANAGER_H
#include <string>
#include <map>
#include <osg/ref_ptr>
#include <osg/Image>
#include <osg/Texture2D>
2015-12-14 00:51:27 +00:00
namespace osgViewer
{
class Viewer;
}
namespace VFS
{
class Manager;
}
namespace Resource
{
/// @brief Handles loading/caching of Images and Texture StateAttributes.
class TextureManager
{
public:
TextureManager(const VFS::Manager* vfs);
2015-05-08 15:52:35 +00:00
~TextureManager();
/// Create or retrieve a Texture2D using the specified image filename, and wrap parameters.
/// Returns the dummy texture if the given texture is not found.
osg::ref_ptr<osg::Texture2D> getTexture2D(const std::string& filename, osg::Texture::WrapMode wrapS, osg::Texture::WrapMode wrapT);
/// Create or retrieve an Image
2015-11-16 22:26:43 +00:00
osg::ref_ptr<osg::Image> getImage(const std::string& filename);
const VFS::Manager* getVFS() { return mVFS; }
2015-06-19 18:55:04 +00:00
osg::Texture2D* getWarningTexture();
private:
const VFS::Manager* mVFS;
typedef std::pair<std::pair<int, int>, std::string> MapKey;
2015-11-16 22:26:43 +00:00
std::map<std::string, osg::ref_ptr<osg::Image> > mImages;
std::map<MapKey, osg::ref_ptr<osg::Texture2D> > mTextures;
osg::ref_ptr<osg::Texture2D> mWarningTexture;
2015-05-08 15:52:35 +00:00
TextureManager(const TextureManager&);
void operator = (const TextureManager&);
};
}
#endif