.. index:: pair: class; EE::Graphics::TextureFactory .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory: class EE::Graphics::TextureFactory ================================== .. toctree:: :hidden: struct_EE_Graphics_TextureFactory_LiveTextureRecord.rst struct_EE_Graphics_TextureFactory_TextureDeleter.rst Overview ~~~~~~~~ Creates textures and weakly observes every live texture for diagnostics. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class TextureFactory: protected :ref:`EE::System::Mutex` { public: // structs struct :ref:`LiveTextureRecord`; struct :ref:`TextureDeleter`; // construction :target:`~TextureFactory`(); // methods :ref:`TexturePtr` :ref:`createEmptyTexture`( const unsigned int& Width, const unsigned int& Height, const unsigned int& Channels = 4, const :ref:`Color`& DefaultColor = :ref:`Color`(0, 0, 0, 255), const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const std::string& Filename = std::string("") ); :ref:`TexturePtr` :ref:`loadFromPixels`( const unsigned char* Pixels, const unsigned int& Width, const unsigned int& Height, const unsigned int& Channels, const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const std::string& FileName = std::string("") ); :ref:`TexturePtr` :ref:`loadFromPack`( :ref:`Pack`* Pack, const std::string& FilePackPath, const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const :ref:`Image::FormatConfiguration`& imageformatConfiguration = :ref:`Image::FormatConfiguration`() ); :ref:`TexturePtr` :ref:`loadFromMemory`( const unsigned char* ImagePtr, const unsigned int& Size, const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const :ref:`Image::FormatConfiguration`& imageformatConfiguration = :ref:`Image::FormatConfiguration`() ); :ref:`TexturePtr` :ref:`loadFromStream`(:ref:`IOStream`& Stream, const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const :ref:`Image::FormatConfiguration`& imageformatConfiguration = :ref:`Image::FormatConfiguration`()); :ref:`TexturePtr` :ref:`loadFromFile`(const std::string& Filepath, const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const :ref:`Image::FormatConfiguration`& imageformatConfiguration = :ref:`Image::FormatConfiguration`()); void :ref:`bind`(:ref:`ResourceId` textureId, :ref:`Texture::CoordinateType` coordinateType = :ref:`Texture::CoordinateType::Normalized`, const :ref:`Uint32`& textureUnit = 0, const bool& forceRebind = false); void :ref:`bind`(const :ref:`Texture`* Tex, :ref:`Texture::CoordinateType` coordinateType = :ref:`Texture::CoordinateType::Normalized`, const :ref:`Uint32`& TextureUnit = 0, const bool& forceRebind = false); int :ref:`getCurrentTexture`(const :ref:`Uint32`& TextureUnit = 0) const; void :ref:`setCurrentTexture`(const int& textureHandle, const :ref:`Uint32`& TextureUnit); void :ref:`invalidateTextureBindings`(); :ref:`Uint32` :ref:`getTextureCount`(); :ref:`TextureRegistrySnapshot` :ref:`snapshotTextures`(); void :ref:`purgeExpiredTextures`(); :ref:`Uint64` :ref:`getLiveTextureGeneration`() const; void :ref:`collectReleasedTextures`(); std::size_t :ref:`getPendingReleaseCount`(); void :ref:`setActiveTextureUnit`(const :ref:`Uint32`& Unit); unsigned int :ref:`getValidTextureSize`(const unsigned int& Size); bool :ref:`existsId`(:ref:`ResourceId` textureId); :ref:`TexturePtr` :ref:`getTexture`(:ref:`ResourceId` textureId); unsigned int :ref:`getTextureMemorySize`(); :ref:`TexturePtr` :ref:`pushTexture`( const std::string& Filepath, const :ref:`Uint32`& textureHandle, const unsigned int& Width, const unsigned int& Height, const unsigned int& ImgWidth, const unsigned int& ImgHeight, const bool& Mipmap, const unsigned int& Channels, const :ref:`Texture::ClampMode`& ClampMode, const bool& CompressTexture, const bool& LocalCopy = false, const :ref:`Uint32`& MemSize = 0 ); const :ref:`Texture::CoordinateType`& :target:`getLastCoordinateType`() const; }; Inherited Members ----------------- .. ref-code-block:: cpp :class: doxyrest-overview-inherited-code-block public: // methods void :ref:`lock`(); void :ref:`unlock`(); bool :ref:`tryLock`(); .. _details-class_e_e_1_1_graphics_1_1_texture_factory: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Creates textures and weakly observes every live texture for diagnostics. Methods ------- .. index:: pair: function; createEmptyTexture .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a4950dbccae4000008bd7532151ca11d6: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TexturePtr` createEmptyTexture( const unsigned int& Width, const unsigned int& Height, const unsigned int& Channels = 4, const :ref:`Color`& DefaultColor = :ref:`Color`(0, 0, 0, 255), const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const std::string& Filename = std::string("") ) Creates an empty texture .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Width - :ref:`Texture ` Width * - Height - :ref:`Texture ` Height * - Channels - :ref:`Texture ` Number of Channels (in bytes) * - DefaultColor - The background color for the texture * - Mipmap - Create Mipmap? * - ClampMode - Defines the CLAMP MODE * - CompressTexture - If use the DXT compression on the texture loading ( if the card can display them, will convert RGB to DXT1, RGBA to DXT5 ) * - KeepLocalCopy - Keep the array data copy. ( useful if want to reload the texture ) * - Filename - A filename to recognize the texture. .. rubric:: Returns: The created texture .. index:: pair: function; loadFromPixels .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a76679dc0e9d132994e66374481a9bad3: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TexturePtr` loadFromPixels( const unsigned char* Pixels, const unsigned int& Width, const unsigned int& Height, const unsigned int& Channels, const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const std::string& FileName = std::string("") ) Loads a RAW :ref:`Texture ` from Memory .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Pixels - The :ref:`Texture ` array * - Width - :ref:`Texture ` Width * - Height - :ref:`Texture ` Height * - Channels - :ref:`Texture ` Number of Channels (in bytes) * - Mipmap - Create Mipmap? * - ClampMode - Defines the CLAMP MODE * - CompressTexture - If use the DXT compression on the texture loading ( if the card can display them, will convert RGB to DXT1, RGBA to DXT5 ) * - KeepLocalCopy - Keep the array data copy. ( useful if want to reload the texture ) * - FileName - A filename to recognize the texture ( the path in case that was loaded from outside the texture factory ). .. rubric:: Returns: The texture loaded or null if error .. index:: pair: function; loadFromPack .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1aae555ab251c6e5f88d6ac1fbaf5a1af8: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TexturePtr` loadFromPack( :ref:`Pack`* Pack, const std::string& FilePackPath, const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const :ref:`Image::FormatConfiguration`& imageformatConfiguration = :ref:`Image::FormatConfiguration`() ) Load a texture from Pack file .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Pack - Pointer to the pack instance * - FilePackPath - The path of the file inside the pack * - Mipmap - Create Mipmap? * - ClampMode - Defines the CLAMP MODE * - CompressTexture - If use the DXT compression on the texture loading ( if the card can display them, will convert RGB to DXT1, RGBA to DXT5 ) * - KeepLocalCopy - Keep the array data copy. ( useful if want to reload the texture ) * - imageformatConfiguration - The specific image format configuration to use when decoding the image. .. rubric:: Returns: The texture loaded or null if error .. index:: pair: function; loadFromMemory .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a09bd10f512c9ab0e33f9d4a029f82a01: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TexturePtr` loadFromMemory( const unsigned char* ImagePtr, const unsigned int& Size, const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const :ref:`Image::FormatConfiguration`& imageformatConfiguration = :ref:`Image::FormatConfiguration`() ) Load a texture from memory .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ImagePtr - The image data in RAM just as if it were still in a file * - Size - The size of the texture ( Width \* Height \* BytesPerPixel ) * - Mipmap - Use mipmaps? * - ClampMode - Defines the CLAMP MODE * - CompressTexture - If use the DXT compression on the texture loading ( if the card can display them, will convert RGB to DXT1, RGBA to DXT5 ) * - KeepLocalCopy - Keep the array data copy. ( useful if want to reload the texture ) * - imageformatConfiguration - The specific image format configuration to use when decoding the image. .. rubric:: Returns: The texture loaded or null if error .. index:: pair: function; loadFromStream .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a5bdf45d16a6aa63ecc644bbfcce087e2: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TexturePtr` loadFromStream(:ref:`IOStream`& Stream, const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const :ref:`Image::FormatConfiguration`& imageformatConfiguration = :ref:`Image::FormatConfiguration`()) Load a :ref:`Texture ` from stream .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Stream - The IOStream instance * - Mipmap - Use mipmaps? * - ClampMode - Defines the CLAMP MODE * - CompressTexture - If use the DXT compression on the texture loading ( if the card can display them, will convert RGB to DXT1, RGBA to DXT5 ) * - KeepLocalCopy - Keep the array data copy. ( useful if want to reload the texture ) * - imageformatConfiguration - The specific image format configuration to use when decoding the image. .. rubric:: Returns: The texture loaded or null if error .. index:: pair: function; loadFromFile .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1aaef345eec6805c558788d9355501afb9: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TexturePtr` loadFromFile(const std::string& Filepath, const bool& Mipmap = false, const :ref:`Texture::ClampMode`& ClampMode = :ref:`Texture::ClampMode::ClampToEdge`, const bool& CompressTexture = false, const bool& KeepLocalCopy = false, const :ref:`Image::FormatConfiguration`& imageformatConfiguration = :ref:`Image::FormatConfiguration`()) Load a :ref:`Texture ` from a file path .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Filepath - The path for the texture * - Mipmap - Use mipmaps? * - ClampMode - Defines the CLAMP MODE * - CompressTexture - If use the DXT compression on the texture loading ( if the card can display them, will convert RGB to DXT1, RGBA to DXT5 ) * - KeepLocalCopy - Keep the array data copy. ( useful if want to reload the texture ) * - imageformatConfiguration - The specific image format configuration to use when decoding the image. .. rubric:: Returns: The texture loaded or null if error .. index:: pair: function; bind .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1af41b5272d74c2003b7a992dfba7806f3: .. ref-code-block:: cpp :class: doxyrest-title-code-block void bind(:ref:`ResourceId` textureId, :ref:`Texture::CoordinateType` coordinateType = :ref:`Texture::CoordinateType::Normalized`, const :ref:`Uint32`& textureUnit = 0, const bool& forceRebind = false) Binds the texture identity indicated. This is useful if you are rendering a texture outside this class. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - textureId - The process-wide texture identity. * - coordinateType - Use normalized or pixel coordinates * - textureUnit - The :ref:`Texture ` Unit binded * - forceRebind - Force the texture bind (even if is already binded ). .. index:: pair: function; bind .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1aa2d32888928a51e2cfeafb41afc3a111: .. ref-code-block:: cpp :class: doxyrest-title-code-block void bind(const :ref:`Texture`* Tex, :ref:`Texture::CoordinateType` coordinateType = :ref:`Texture::CoordinateType::Normalized`, const :ref:`Uint32`& TextureUnit = 0, const bool& forceRebind = false) Bind the the :ref:`Texture ` indicated. This is useful if you are rendering a texture outside this class. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Tex - The :ref:`Texture ` Pointer * - coordinateType - Selects the coordinate type to use with the binded texture. * - TextureUnit - The :ref:`Texture ` Unit binded * - forceRebind - Force the texture bind (even if is already binded ). .. index:: pair: function; getCurrentTexture .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a2b47949fa0e4fbe39159994196be3200: .. ref-code-block:: cpp :class: doxyrest-title-code-block int getCurrentTexture(const :ref:`Uint32`& TextureUnit = 0) const .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - TextureUnit - The bound texture unit. .. rubric:: Returns: The currently bound OpenGL texture handle. .. index:: pair: function; setCurrentTexture .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a1d6c27bfd2530e5e8b066f989c1dbdc2: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setCurrentTexture(const int& textureHandle, const :ref:`Uint32`& TextureUnit) Sets the currently bound OpenGL texture handle. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - textureHandle - The OpenGL texture handle. * - TextureUnit - The :ref:`Texture ` Unit binded .. index:: pair: function; invalidateTextureBindings .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1ad131abfbaadbad8c7fc7f5a7df9ccea8: .. ref-code-block:: cpp :class: doxyrest-title-code-block void invalidateTextureBindings() Invalidates cached OpenGL binding state after changing the current graphics context. .. index:: pair: function; getTextureCount .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a4009c625b2de4b5d7c45877d556f9425: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Uint32` getTextureCount() Returns the number of currently live textures. .. index:: pair: function; snapshotTextures .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a32d1fcf39c7f7e9aedab1a392163d2ee: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TextureRegistrySnapshot` snapshotTextures() .. rubric:: Returns: A non-owning diagnostic snapshot of every currently live texture. .. index:: pair: function; purgeExpiredTextures .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a3305220dd9ddcc628ecd95a3739cc349: .. ref-code-block:: cpp :class: doxyrest-title-code-block void purgeExpiredTextures() Removes expired records from the diagnostic live-texture registry. .. index:: pair: function; getLiveTextureGeneration .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a0640969587abb1f46201760688058114: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Uint64` getLiveTextureGeneration() const .. rubric:: Returns: The generation of the live-texture registry. It changes when a texture is created or its last owning handle is released. .. index:: pair: function; collectReleasedTextures .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a19c3fb6e5f57396f7fa86b01f458160d: .. ref-code-block:: cpp :class: doxyrest-title-code-block void collectReleasedTextures() Destroys textures whose final owning handle was released. Must run on the graphics thread after pending batches have been flushed and while a context is current. .. index:: pair: function; getPendingReleaseCount .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1aeeefbd2b141f91d5ce71df47423ff326: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::size_t getPendingReleaseCount() .. rubric:: Returns: The number of textures waiting for graphics-thread destruction. .. index:: pair: function; setActiveTextureUnit .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a94999e239a379b3b3906377bc38dbfd8: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setActiveTextureUnit(const :ref:`Uint32`& Unit) Active a texture unit .. index:: pair: function; getValidTextureSize .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1aab28adb167bf2d94cd4b9d590c2851b6: .. ref-code-block:: cpp :class: doxyrest-title-code-block unsigned int getValidTextureSize(const unsigned int& Size) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Size - .. rubric:: Returns: A valid texture size for the video card (checks if support non power of two textures) .. index:: pair: function; existsId .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1ae3eb1c44cb1237e37e0d42427b431d6f: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool existsId(:ref:`ResourceId` textureId) Determines whether the texture identity is currently live. .. index:: pair: function; getTexture .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a2d70c89bcc2cc9f7523f2edcee39cc80: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TexturePtr` getTexture(:ref:`ResourceId` textureId) .. rubric:: Returns: The live texture matching ``textureId``, or null if it has expired. .. index:: pair: function; getTextureMemorySize .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a7f5bcb6cbf1f72059214f8a54b83585e: .. ref-code-block:: cpp :class: doxyrest-title-code-block unsigned int getTextureMemorySize() .. rubric:: Returns: The memory used by the textures (in bytes) .. index:: pair: function; pushTexture .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1ac0650ff8f8a0fd160daed1b950d874b5: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`TexturePtr` pushTexture( const std::string& Filepath, const :ref:`Uint32`& textureHandle, const unsigned int& Width, const unsigned int& Height, const unsigned int& ImgWidth, const unsigned int& ImgHeight, const bool& Mipmap, const unsigned int& Channels, const :ref:`Texture::ClampMode`& ClampMode, const bool& CompressTexture, const bool& LocalCopy = false, const :ref:`Uint32`& MemSize = 0 ) It's possible to create textures outside the texture factory loader, but the library will need to know of this texture, so it's necessary to push the texture to the factory. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Filepath - The :ref:`Texture ` path ( if exists ) * - textureHandle - The OpenGL texture handle. * - Width - :ref:`Texture ` Width * - Height - :ref:`Texture ` Height * - ImgWidth - :ref:`Image ` Width. * - ImgHeight - :ref:`Image ` Height * - Mipmap - Tell if the texture has mipmaps * - Channels - :ref:`Texture ` number of Channels ( bytes per pixel ) * - ClampMode - The :ref:`Texture ` Clamp Mode * - CompressTexture - The texture is compressed? * - LocalCopy - If keep a local copy in memory of the texture * - MemSize - The size of the texture in memory ( just if you need to specify the real size in memory, just useful to calculate the total texture memory ).