mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-05 19:31:04 +00:00
Clean up TextureSource and related code
This commit is contained in:
parent
0bdd5f294e
commit
b841c23701
5 changed files with 43 additions and 67 deletions
|
@ -25,10 +25,10 @@ class ISimpleTextureSource
|
|||
{
|
||||
public:
|
||||
ISimpleTextureSource() = default;
|
||||
|
||||
virtual ~ISimpleTextureSource() = default;
|
||||
|
||||
virtual video::ITexture* getTexture(
|
||||
/// @brief Generates and gets a texture
|
||||
virtual video::ITexture *getTexture(
|
||||
const std::string &name, u32 *id = nullptr) = 0;
|
||||
};
|
||||
|
||||
|
@ -36,24 +36,38 @@ class ITextureSource : public ISimpleTextureSource
|
|||
{
|
||||
public:
|
||||
ITextureSource() = default;
|
||||
|
||||
virtual ~ITextureSource() = default;
|
||||
|
||||
using ISimpleTextureSource::getTexture;
|
||||
|
||||
/// @brief Generates and gets ID of a texture
|
||||
virtual u32 getTextureId(const std::string &name)=0;
|
||||
|
||||
/// @brief Returns name of existing texture by ID
|
||||
virtual std::string getTextureName(u32 id)=0;
|
||||
virtual video::ITexture* getTexture(u32 id)=0;
|
||||
virtual video::ITexture* getTexture(
|
||||
const std::string &name, u32 *id = nullptr)=0;
|
||||
virtual video::ITexture* getTextureForMesh(
|
||||
|
||||
/// @brief Returns existing texture by ID
|
||||
virtual video::ITexture *getTexture(u32 id)=0;
|
||||
|
||||
/**
|
||||
* @brief Generates and gets a texture
|
||||
* Filters will be applied to make the texture suitable for mipmapping and
|
||||
* linear filtering during rendering.
|
||||
*/
|
||||
virtual video::ITexture *getTextureForMesh(
|
||||
const std::string &name, u32 *id = nullptr) = 0;
|
||||
/*!
|
||||
/**
|
||||
* Returns a palette from the given texture name.
|
||||
* The pointer is valid until the texture source is
|
||||
* destructed.
|
||||
* Should be called from the main thread.
|
||||
* Must be called from the main thread.
|
||||
*/
|
||||
virtual Palette* getPalette(const std::string &name) = 0;
|
||||
virtual Palette *getPalette(const std::string &name) = 0;
|
||||
|
||||
/// @brief Check if given image name exists
|
||||
virtual bool isKnownSourceImage(const std::string &name)=0;
|
||||
|
||||
/// @brief Return average color of a texture string
|
||||
virtual video::SColor getTextureAverageColor(const std::string &name)=0;
|
||||
};
|
||||
|
||||
|
@ -61,20 +75,19 @@ class IWritableTextureSource : public ITextureSource
|
|||
{
|
||||
public:
|
||||
IWritableTextureSource() = default;
|
||||
|
||||
virtual ~IWritableTextureSource() = default;
|
||||
|
||||
virtual u32 getTextureId(const std::string &name)=0;
|
||||
virtual std::string getTextureName(u32 id)=0;
|
||||
virtual video::ITexture* getTexture(u32 id)=0;
|
||||
virtual video::ITexture* getTexture(
|
||||
const std::string &name, u32 *id = nullptr)=0;
|
||||
virtual bool isKnownSourceImage(const std::string &name)=0;
|
||||
|
||||
/// @brief Fulfil texture requests from other threads
|
||||
virtual void processQueue()=0;
|
||||
|
||||
/**
|
||||
* @brief Inserts a source image. Must be called from the main thread.
|
||||
* Takes ownership of @p img
|
||||
*/
|
||||
virtual void insertSourceImage(const std::string &name, video::IImage *img)=0;
|
||||
|
||||
/// @brief rebuilds all textures (in case-source images have changed)
|
||||
virtual void rebuildImagesAndTextures()=0;
|
||||
virtual video::SColor getTextureAverageColor(const std::string &name)=0;
|
||||
};
|
||||
|
||||
IWritableTextureSource *createTextureSource();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue