Implemented support for explicit mipmap generation in sf::Texture and sf::RenderTexture. (#123)
This commit is contained in:
parent
2c7b58f406
commit
259811d59c
6 changed files with 168 additions and 24 deletions
|
@ -131,6 +131,22 @@ public:
|
|||
////////////////////////////////////////////////////////////
|
||||
bool isRepeated() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Generate a mipmap using the current texture data
|
||||
///
|
||||
/// This function is similar to Texture::generateMipmap and operates
|
||||
/// on the texture used as the target for drawing.
|
||||
/// Be aware that any draw operation may modify the base level image data.
|
||||
/// For this reason, calling this function only makes sense after all
|
||||
/// drawing is completed and display has been called. Not calling display
|
||||
/// after subsequent drawing will lead to undefined behavior if a mipmap
|
||||
/// had been previously generated.
|
||||
///
|
||||
/// \return True if mipmap generation was successful, false if unsuccessful
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool generateMipmap();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Activate or deactivate the render-texture for rendering
|
||||
///
|
||||
|
|
|
@ -445,6 +445,31 @@ public:
|
|||
////////////////////////////////////////////////////////////
|
||||
bool isRepeated() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Generate a mipmap using the current texture data
|
||||
///
|
||||
/// Mipmaps are pre-computed chains of optimized textures. Each
|
||||
/// level of texture in a mipmap is generated by halving each of
|
||||
/// the previous level's dimensions. This is done until the final
|
||||
/// level has the size of 1x1. The textures generated in this process may
|
||||
/// make use of more advanced filters which might improve the visual quality
|
||||
/// of textures when they are applied to objects much smaller than they are.
|
||||
/// This is known as minification. Because fewer texels (texture elements)
|
||||
/// have to be sampled from when heavily minified, usage of mipmaps
|
||||
/// can also improve rendering performance in certain scenarios.
|
||||
///
|
||||
/// Mipmap generation relies on the necessary OpenGL extension being
|
||||
/// available. If it is unavailable or generation fails due to another
|
||||
/// reason, this function will return false. Mipmap data is only valid from
|
||||
/// the time it is generated until the next time the base level image is
|
||||
/// modified, at which point this function will have to be called again to
|
||||
/// regenerate it.
|
||||
///
|
||||
/// \return True if mipmap generation was successful, false if unsuccessful
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool generateMipmap();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Overload of assignment operator
|
||||
///
|
||||
|
@ -532,6 +557,15 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
static unsigned int getValidSize(unsigned int size);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Invalidate the mipmap if one exists
|
||||
///
|
||||
/// This also resets the texture's minifying function.
|
||||
/// This function is mainly for internal use by RenderTexture.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void invalidateMipmap();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -543,6 +577,7 @@ private:
|
|||
bool m_isRepeated; ///< Is the texture in repeat mode?
|
||||
mutable bool m_pixelsFlipped; ///< To work around the inconsistency in Y orientation
|
||||
bool m_fboAttachment; ///< Is this texture owned by a framebuffer object?
|
||||
bool m_hasMipmap; ///< Has the mipmap been generated?
|
||||
Uint64 m_cacheId; ///< Unique number that identifies the texture to the render target's cache
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue