.. index:: pair: class; EE::Graphics::TextureFactory .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory: class EE::Graphics::TextureFactory ================================== .. toctree:: :hidden: Overview ~~~~~~~~ The :ref:`Texture ` Manager Class. Here we do all the textures stuff. (Singleton Class) :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class TextureFactory: protected :ref:`EE::System::Mutex` { public: // construction :target:`~TextureFactory`(); // methods :ref:`Texture`* :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:`Texture`* :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:`Texture`* :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:`Texture`* :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:`Texture`* :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:`Texture`* :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`()); bool :ref:`remove`(:ref:`Uint32` TexId); bool :ref:`remove`(:ref:`Texture`* texture); void :ref:`reloadAllTextures`(); void :ref:`bind`(const :ref:`Uint32`& TexId, :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); :ref:`Uint32` :ref:`getTextureId`(const :ref:`Uint32`& TexId); int :ref:`getCurrentTexture`(const :ref:`Uint32`& TextureUnit = 0) const; void :ref:`setCurrentTexture`(const int& TexId, const :ref:`Uint32`& TextureUnit); :ref:`Uint32` :ref:`getTextureCount`() const; std::vector<:ref:`Texture`*> :ref:`getTextures`(); void :ref:`setActiveTextureUnit`(const :ref:`Uint32`& Unit); unsigned int :ref:`getValidTextureSize`(const unsigned int& Size); bool :ref:`existsId`(const :ref:`Uint32`& TexId); :ref:`Texture`* :ref:`getTexture`(const :ref:`Uint32`& TexId); void :ref:`grabTextures`(); void :ref:`ungrabTextures`(); void :ref:`allocate`(const unsigned int& size); unsigned int :ref:`getTextureMemorySize`(); :ref:`Texture`* :ref:`pushTexture`( const std::string& Filepath, const :ref:`Uint32`& TexId, 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 ); :ref:`Texture`* :ref:`getByName`(const std::string& Name); :ref:`Texture`* :ref:`getByHash`(const :ref:`String::HashType`& hash); 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`(); int :ref:`tryLock`(); .. _details-class_e_e_1_1_graphics_1_1_texture_factory: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ The :ref:`Texture ` Manager Class. Here we do all the textures stuff. (Singleton Class) Methods ------- .. index:: pair: function; createEmptyTexture .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a70cefe5cbbc77c97f9f911cf159b8520: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Texture`* 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_1a0e9d9ec4827b537a35de5ebac7db1551: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Texture`* 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_1a399defd625b08ed54c80c8f01413ac07: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Texture`* 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_1abacd02e3d2c8eb890afca9d008b786a8: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Texture`* 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_1a0b12b62c8e9b50a1fe91427517ef6b8a: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Texture`* 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_1a470282708ec30a966dcef20f0f589990: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Texture`* 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; remove .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1acf5a84e138007d2efe00c63d20c8119a: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool remove(:ref:`Uint32` TexId) Removes and Unload the :ref:`Texture ` Id .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - TexId - .. rubric:: Returns: True if was removed .. index:: pair: function; remove .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a84d9aa6f5c9bcb8e5fc135fdcbeffa01: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool remove(:ref:`Texture`* texture) Removes and Unload the :ref:`Texture ` .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - texture - The texture pointer .. rubric:: Returns: True if was removed .. index:: pair: function; reloadAllTextures .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1ac70e2ea0d99711de82eca4f1ef41c4db: .. ref-code-block:: cpp :class: doxyrest-title-code-block void reloadAllTextures() Reload all loaded textures to recover the OpenGL context .. index:: pair: function; bind .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1aa138d6b094d09a5b05d1e138a91db25a: .. ref-code-block:: cpp :class: doxyrest-title-code-block void bind(const :ref:`Uint32`& TexId, :ref:`Texture::CoordinateType` coordinateType = :ref:`Texture::CoordinateType::Normalized`, const :ref:`Uint32`& textureUnit = 0, const bool& forceRebind = false) Bind the the internal :ref:`Texture ` Id indicated. This is useful if you are rendering a texture outside this class. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - TexId - The internal :ref:`Texture ` Id * - 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; getTextureId .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a4ecb80cdf09cfe9bc6525eb883d0ff7b: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Uint32` getTextureId(const :ref:`Uint32`& TexId) .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - TexId - The internal :ref:`Texture ` Id .. rubric:: Returns: The OpenGL :ref:`Texture ` Id (texture handler) .. 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 :ref:`Texture ` Unit binded .. rubric:: Returns: The real current texture id (OpenGL :ref:`Texture ` Id) .. index:: pair: function; setCurrentTexture .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a786618eb8d43cb58a578d1694ed5bf59: .. ref-code-block:: cpp :class: doxyrest-title-code-block void setCurrentTexture(const int& TexId, const :ref:`Uint32`& TextureUnit) Set the current internal texture id. This will set the TexId as the current texture binded. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - TexId - The real current texture id (OpenGL :ref:`Texture ` Id) * - TextureUnit - The :ref:`Texture ` Unit binded .. index:: pair: function; getTextureCount .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a2b1c137d9f899859e776a9e1728ef134: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Uint32` getTextureCount() const Returns the number of textures loaded .. index:: pair: function; getTextures .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a580970b3d00386d26bf43940bff87bfd: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector<:ref:`Texture`*> getTextures() .. rubric:: Returns: All the active textures .. 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_1a4ee83f9cf6dbc54f99025c0fd89b3cfd: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool existsId(const :ref:`Uint32`& TexId) Determine if the TextureId passed exists .. index:: pair: function; getTexture .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1acb354889c6557817929fd6c1b7d67b38: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Texture`* getTexture(const :ref:`Uint32`& TexId) .. rubric:: Returns: A pointer to the :ref:`Texture ` .. index:: pair: function; grabTextures .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a9ce224e1a7f8df983c26da48ef82b940: .. ref-code-block:: cpp :class: doxyrest-title-code-block void grabTextures() Get a local copy for all the textures .. index:: pair: function; ungrabTextures .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1ab6b8cf96130854e0e558594680fa906b: .. ref-code-block:: cpp :class: doxyrest-title-code-block void ungrabTextures() Reload all the grabed textures .. index:: pair: function; allocate .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1ab6eef4128c2369ab007e3d4c8ebb10a6: .. ref-code-block:: cpp :class: doxyrest-title-code-block void allocate(const unsigned int& size) Allocate space for Textures (only works if EE_ALLOC_TEXTURES_ON_VECTOR is defined) .. 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_1a7fd108ee11cfd2980c88be3ed8695d17: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Texture`* pushTexture( const std::string& Filepath, const :ref:`Uint32`& TexId, 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 ) * - TexId - The OpenGL :ref:`Texture ` Id * - 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 ). .. index:: pair: function; getByName .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1a20dfea068b5289acbae4c833e511b964: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Texture`* getByName(const std::string& Name) Return a texture by it file path name .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Name - File path name .. rubric:: Returns: The texture, NULL if not exists. .. index:: pair: function; getByHash .. _doxid-class_e_e_1_1_graphics_1_1_texture_factory_1ac597d844de7bddba55bf33c557912d50: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`Texture`* getByHash(const :ref:`String::HashType`& hash) Return a texture by it hash path name .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Hash - The file path hash .. rubric:: Returns: The texture, NULL if not exists