1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 05:09:43 +00:00
openmw/components/resource/texturemanager.hpp
scrawl e8662bea31 Change the way that image origin is converted to OpenGL's lower-left convention
Flip the texture coordinates instead of flipping textures.

This simplifies the TextureManager (no need to worry if the caller wants flipping or not), should make it easier to generalize & multithread it.
2016-02-05 21:03:11 +01:00

65 lines
1.5 KiB
C++

#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>
namespace osgViewer
{
class Viewer;
}
namespace VFS
{
class Manager;
}
namespace osgDB
{
class Options;
}
namespace Resource
{
/// @brief Handles loading/caching of Images and Texture StateAttributes.
class TextureManager
{
public:
TextureManager(const VFS::Manager* vfs);
~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
osg::ref_ptr<osg::Image> getImage(const std::string& filename);
const VFS::Manager* getVFS() { return mVFS; }
osg::Texture2D* getWarningTexture();
private:
const VFS::Manager* mVFS;
typedef std::pair<std::pair<int, int>, std::string> MapKey;
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;
osg::ref_ptr<osgDB::Options> mOptions;
TextureManager(const TextureManager&);
void operator = (const TextureManager&);
};
}
#endif