openmw/components/resource/imagemanager.hpp
2025-07-11 11:40:50 -04:00

51 lines
1.3 KiB
C++

#ifndef OPENMW_COMPONENTS_RESOURCE_IMAGEMANAGER_H
#define OPENMW_COMPONENTS_RESOURCE_IMAGEMANAGER_H
#include <osg/Image>
#include <osg/Texture2D>
#include <osg/ref_ptr>
#include <components/vfs/pathutil.hpp>
#include "resourcemanager.hpp"
namespace osgDB
{
class Options;
}
namespace Resource
{
/// @brief Handles loading/caching of Images.
/// @note May be used from any thread.
class ImageManager : public ResourceManager
{
public:
explicit ImageManager(const VFS::Manager* vfs, double expiryDelay);
~ImageManager();
/// Create or retrieve an Image
/// Returns the dummy image if the given image is not found.
osg::ref_ptr<osg::Image> getImage(VFS::Path::NormalizedView path, bool disableFlip = false);
osg::Image* getWarningImage();
void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;
void attemptGlobalReload();
private:
osg::ref_ptr<osg::Image> mWarningImage;
osg::ref_ptr<osgDB::Options> mOptions;
osg::ref_ptr<osgDB::Options> mOptionsNoFlip;
ImageManager(const ImageManager&);
void operator=(const ImageManager&);
osg::ref_ptr<osg::Image> performLoad(VFS::Path::NormalizedView name, bool disableFlip = false);
};
}
#endif