From 7cd326960e8105f563ee3911dc5a0aafe7c0953b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Tue, 20 Mar 2018 20:36:54 -0300 Subject: [PATCH] Allow to force a texture bind. --HG-- branch : dev --- include/eepp/graphics/texturefactory.hpp | 6 ++++-- include/eepp/ui/uiwindow.hpp | 2 +- src/eepp/graphics/texturefactory.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/eepp/graphics/texturefactory.hpp b/include/eepp/graphics/texturefactory.hpp index 03ef5d1f1..b4380914f 100755 --- a/include/eepp/graphics/texturefactory.hpp +++ b/include/eepp/graphics/texturefactory.hpp @@ -97,15 +97,17 @@ class EE_API TextureFactory : protected Mutex { /** Bind the the internal Texture Id indicated. This is useful if you are rendering a texture outside this class. * @param TexId The internal Texture Id + * @param coordinateType Use normalized or pixel coordinates * @param TextureUnit The Texture Unit binded + * @param forceRebind Force the texture bind */ - void bind( const Uint32& TexId, Texture::CoordinateType coordinateType = Texture::CoordinateType::Normalized, const Uint32& textureUnit = 0 ); + void bind( const Uint32& TexId, Texture::CoordinateType coordinateType = Texture::CoordinateType::Normalized, const Uint32& textureUnit = 0, const bool& forceRebind = false ); /** Bind the the Texture indicated. This is useful if you are rendering a texture outside this class. * @param Tex The Texture Pointer * @param TextureUnit The Texture Unit binded */ - void bind( const Texture* Tex, Texture::CoordinateType coordinateType = Texture::CoordinateType::Normalized, const Uint32& TextureUnit = 0 ); + void bind( const Texture* Tex, Texture::CoordinateType coordinateType = Texture::CoordinateType::Normalized, const Uint32& TextureUnit = 0, const bool& forceRebind = false ); /** * @param TexId The internal Texture Id diff --git a/include/eepp/ui/uiwindow.hpp b/include/eepp/ui/uiwindow.hpp index 635d0927b..a2abce028 100644 --- a/include/eepp/ui/uiwindow.hpp +++ b/include/eepp/ui/uiwindow.hpp @@ -239,7 +239,7 @@ class EE_API UIWindow : public UIWidget { virtual void postDraw(); - Sizei getFrameBufferSize(); + virtual Sizei getFrameBufferSize(); UISceneNode * getUISceneNode(); }; diff --git a/src/eepp/graphics/texturefactory.cpp b/src/eepp/graphics/texturefactory.cpp index 1e2c3386a..fa616041d 100755 --- a/src/eepp/graphics/texturefactory.cpp +++ b/src/eepp/graphics/texturefactory.cpp @@ -109,9 +109,9 @@ Uint32 TextureFactory::findFreeSlot() { return (Uint32)mTextures.size() - 1; } -void TextureFactory::bind( const Texture* texture, Texture::CoordinateType coordinateType, const Uint32& TextureUnit ) { +void TextureFactory::bind( const Texture* texture, Texture::CoordinateType coordinateType, const Uint32& TextureUnit, const bool& forceRebind ) { if( NULL != texture ) { - if ( mCurrentTexture[ TextureUnit ] != (Int32)texture->getHandle() ) { + if ( mCurrentTexture[ TextureUnit ] != (Int32)texture->getHandle() || forceRebind ) { if ( TextureUnit && GLi->isExtension( EEGL_ARB_multitexture ) ) setActiveTextureUnit( TextureUnit ); @@ -153,8 +153,8 @@ void TextureFactory::bind( const Texture* texture, Texture::CoordinateType coord } } -void TextureFactory::bind( const Uint32& TexId, Texture::CoordinateType coordinateType, const Uint32& textureUnit ) { - bind( getTexture( TexId ), coordinateType, textureUnit ); +void TextureFactory::bind( const Uint32& TexId, Texture::CoordinateType coordinateType, const Uint32& textureUnit, const bool& forceRebind ) { + bind( getTexture( TexId ), coordinateType, textureUnit, forceRebind ); } void TextureFactory::unloadTextures() {