Ver código fonte

Made SpriteTexture a resource

Marko Pintera 12 anos atrás
pai
commit
c49a862f37
30 arquivos alterados com 274 adições e 158 exclusões
  1. 1 0
      BansheeEngine/BansheeEngine.vcxproj
  2. 3 0
      BansheeEngine/BansheeEngine.vcxproj.filters
  3. 1 0
      BansheeEngine/Include/BsGUIButtonBase.h
  4. 6 6
      BansheeEngine/Include/BsGUIContent.h
  5. 2 2
      BansheeEngine/Include/BsGUIDropDownBox.h
  6. 1 1
      BansheeEngine/Include/BsGUIElementStyle.h
  7. 1 0
      BansheeEngine/Include/BsGUIInputBox.h
  8. 4 4
      BansheeEngine/Include/BsGUIManager.h
  9. 1 1
      BansheeEngine/Include/BsGUIScrollBarHandle.h
  10. 5 4
      BansheeEngine/Include/BsGUITexture.h
  11. 4 1
      BansheeEngine/Include/BsPrerequisites.h
  12. 18 6
      BansheeEngine/Include/BsSpriteTexture.h
  13. 45 0
      BansheeEngine/Include/BsSpriteTextureRTTI.h
  14. 54 54
      BansheeEngine/Source/BsEngineGUI.cpp
  15. 21 19
      BansheeEngine/Source/BsGUIButtonBase.cpp
  16. 4 4
      BansheeEngine/Source/BsGUIContent.cpp
  17. 14 11
      BansheeEngine/Source/BsGUIInputBox.cpp
  18. 2 1
      BansheeEngine/Source/BsGUIInputCaret.cpp
  19. 2 1
      BansheeEngine/Source/BsGUIInputSelection.cpp
  20. 3 3
      BansheeEngine/Source/BsGUIManager.cpp
  21. 7 2
      BansheeEngine/Source/BsGUIRenderTexture.cpp
  22. 5 1
      BansheeEngine/Source/BsGUIScrollBar.cpp
  23. 3 1
      BansheeEngine/Source/BsGUIScrollBarHandle.cpp
  24. 13 12
      BansheeEngine/Source/BsGUITexture.cpp
  25. 42 10
      BansheeEngine/Source/BsSpriteTexture.cpp
  26. 3 3
      CamelotClient/Source/BsGUIWindowDropArea.cpp
  27. 3 3
      CamelotClient/Source/BsGUIWindowFrame.cpp
  28. 1 3
      CamelotGLRenderer/Source/GLSL/src/CmGLSLExtSupport.cpp
  29. 3 3
      SBansheeEngine/Include/BsScriptSpriteTexture.h
  30. 2 2
      SBansheeEngine/Source/BsScriptSpriteTexture.cpp

+ 1 - 0
BansheeEngine/BansheeEngine.vcxproj

@@ -280,6 +280,7 @@
     <ClInclude Include="Include\BsSceneManager.h" />
     <ClInclude Include="Include\BsGUIScrollArea.h" />
     <ClInclude Include="Include\BsScriptManager.h" />
+    <ClInclude Include="Include\BsSpriteTextureRTTI.h" />
     <ClInclude Include="Include\BsSprite.h" />
     <ClInclude Include="Include\BsSpriteTexture.h" />
     <ClInclude Include="Include\BsTextSprite.h" />

+ 3 - 0
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -246,6 +246,9 @@
     <ClInclude Include="Include\BsScriptManager.h">
       <Filter>Header Files\Script</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsSpriteTextureRTTI.h">
+      <Filter>Header Files\RTTI</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsGUIElement.cpp">

+ 1 - 0
BansheeEngine/Include/BsGUIButtonBase.h

@@ -81,6 +81,7 @@ namespace BansheeEngine
 		TextSprite* mTextSprite;
 		GUIButtonState mActiveState;
 
+		HSpriteTexture mActiveTexture;
 		IMAGE_SPRITE_DESC mImageDesc;
 		GUIContent mContent;
 

+ 6 - 6
BansheeEngine/Include/BsGUIContent.h

@@ -9,19 +9,19 @@ namespace BansheeEngine
 		explicit GUIContent(const CM::HString& text);
 		GUIContent(const CM::HString& text, const CM::HString& tooltip);
 
-		explicit GUIContent(const SpriteTexturePtr& image);
-		GUIContent(const SpriteTexturePtr& image, const CM::HString& tooltip);
+		explicit GUIContent(const HSpriteTexture& image);
+		GUIContent(const HSpriteTexture& image, const CM::HString& tooltip);
 
-		GUIContent(const CM::HString& text, const SpriteTexturePtr& image);
-		GUIContent(const CM::HString& text, const SpriteTexturePtr& image, const CM::HString& tooltip);
+		GUIContent(const CM::HString& text, const HSpriteTexture& image);
+		GUIContent(const CM::HString& text, const HSpriteTexture& image, const CM::HString& tooltip);
 
 		const CM::HString& getText() const { return mText; }
-		const SpriteTexturePtr& getImage() const { return mImage; }
+		const HSpriteTexture& getImage() const { return mImage; }
 		const CM::HString& getTooltip() const { return mTooltipText; }
 
 	private:
 		CM::HString mText;
-		SpriteTexturePtr mImage;
+		HSpriteTexture mImage;
 		CM::HString mTooltipText;
 	};
 }

+ 2 - 2
BansheeEngine/Include/BsGUIDropDownBox.h

@@ -164,8 +164,8 @@ namespace BansheeEngine
 		const GUIElementStyle* mEntryExpBtnStyle;
 		const GUIElementStyle* mSeparatorStyle;
 		const GUIElementStyle* mBackgroundStyle;
-		SpriteTexturePtr mScrollUpBtnArrow;
-		SpriteTexturePtr mScrollDownBtnArrow;
+		HSpriteTexture mScrollUpBtnArrow;
+		HSpriteTexture mScrollDownBtnArrow;
 
 		DropDownSubMenu* mRootMenu;
 

+ 1 - 1
BansheeEngine/Include/BsGUIElementStyle.h

@@ -25,7 +25,7 @@ namespace BansheeEngine
 	{
 		struct BS_EXPORT GUIElementStateStyle
 		{
-			SpriteTexturePtr texture;
+			HSpriteTexture texture;
 			CM::Color textColor;
 		};
 

+ 1 - 0
BansheeEngine/Include/BsGUIInputBox.h

@@ -65,6 +65,7 @@ namespace BansheeEngine
 		CM::Vector2I mTextOffset;
 		bool mHasFocus;
 
+		HSpriteTexture mActiveTexture;
 		IMAGE_SPRITE_DESC mImageDesc;
 		CM::WString mText;
 

+ 4 - 4
BansheeEngine/Include/BsGUIManager.h

@@ -60,8 +60,8 @@ namespace BansheeEngine
 
 		void setCaretColor(const CM::Color& color) { mCaretColor = color; updateCaretTexture(); }
 		void setTextSelectionColor(const CM::Color& color) { mTextSelectionColor = color; updateTextSelectionTexture(); }
-		const SpriteTexturePtr& getCaretTexture() const { return mCaretTexture; }
-		const SpriteTexturePtr& getTextSelectionTexture() const { return mTextSelectionTexture; }
+		const HSpriteTexture& getCaretTexture() const { return mCaretTexture; }
+		const HSpriteTexture& getTextSelectionTexture() const { return mTextSelectionTexture; }
 		bool getCaretBlinkState() const { return mIsCaretOn; }
 
 		GUIInputCaret* getInputCaretTool() const { return mInputCaret; }
@@ -155,13 +155,13 @@ namespace BansheeEngine
 		GUITextInputEvent mTextInputEvent;
 		GUICommandEvent mCommandEvent;
 
-		SpriteTexturePtr mCaretTexture;
+		HSpriteTexture mCaretTexture;
 		CM::Color mCaretColor;
 		float mCaretBlinkInterval;
 		float mCaretLastBlinkTime;
 		bool mIsCaretOn;
 
-		SpriteTexturePtr mTextSelectionTexture;
+		HSpriteTexture mTextSelectionTexture;
 		CM::Color mTextSelectionColor;
 
 		// Selective input

+ 1 - 1
BansheeEngine/Include/BsGUIScrollBarHandle.h

@@ -63,7 +63,7 @@ namespace BansheeEngine
 	private:
 		ImageSprite* mImageSprite;
 		CM::UINT32 mHandleSize;
-		SpriteTexturePtr mCurTexture;
+		HSpriteTexture mCurTexture;
 		bool mHorizontal; // Otherwise its vertical
 		float mHandlePos;
 		CM::INT32 mDragStartPos;

+ 5 - 4
BansheeEngine/Include/BsGUITexture.h

@@ -19,20 +19,21 @@ namespace BansheeEngine
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUITexture* create(GUIWidget& parent, const SpriteTexturePtr& texture, GUIImageScaleMode scale = GUIImageScaleMode::StretchToFit, 
+		static GUITexture* create(GUIWidget& parent, const HSpriteTexture& texture, GUIImageScaleMode scale = GUIImageScaleMode::StretchToFit, 
 			const GUIElementStyle* style = nullptr);
-		static GUITexture* create(GUIWidget& parent, const GUIOptions& layoutOptions, const SpriteTexturePtr& texture, 
+		static GUITexture* create(GUIWidget& parent, const GUIOptions& layoutOptions, const HSpriteTexture& texture, 
 			GUIImageScaleMode scale = GUIImageScaleMode::StretchToFit, const GUIElementStyle* style = nullptr);
 		static GUITexture* create(GUIWidget& parent, GUIImageScaleMode scale = GUIImageScaleMode::StretchToFit, const GUIElementStyle* style = nullptr);
 		static GUITexture* create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIImageScaleMode scale = GUIImageScaleMode::StretchToFit, const GUIElementStyle* style = nullptr);
 
-		void setTexture(const SpriteTexturePtr& texture);
+		void setTexture(const HSpriteTexture& texture);
 	protected:
 		ImageSprite* mImageSprite;
+		HSpriteTexture mActiveTexture;
 		IMAGE_SPRITE_DESC mDesc;
 		GUIImageScaleMode mScaleMode;
 
-		GUITexture(GUIWidget& parent, const GUIElementStyle* style, const SpriteTexturePtr& texture, GUIImageScaleMode scale, const GUILayoutOptions& layoutOptions);
+		GUITexture(GUIWidget& parent, const GUIElementStyle* style, const HSpriteTexture& texture, GUIImageScaleMode scale, const GUILayoutOptions& layoutOptions);
 		virtual ~GUITexture();
 
 		/**

+ 4 - 1
BansheeEngine/Include/BsPrerequisites.h

@@ -84,10 +84,13 @@ namespace BansheeEngine
 	typedef CM::GameObjectHandle<Camera> HCamera;
 	typedef CM::GameObjectHandle<Renderable> HRenderable;
 
+	typedef CM::ResourceHandle<SpriteTexture> HSpriteTexture;
+
 	enum TypeID_Banshee
 	{
 		TID_Camera = 30000,
-		TID_Renderable = 30001
+		TID_Renderable = 30001,
+		TID_SpriteTexture = 30002
 	};
 }
 

+ 18 - 6
BansheeEngine/Include/BsSpriteTexture.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include "BsPrerequisites.h"
+#include "CmResource.h"
 #include "CmVector2.h"
 
 namespace BansheeEngine
@@ -10,21 +11,32 @@ namespace BansheeEngine
 	 * 			to create a sprite texture atlas, without requiring any of the sprite classes to directly
 	 * 			know about it.
 	 */
-	class BS_EXPORT SpriteTexture
+	class BS_EXPORT SpriteTexture : public CM::Resource
 	{
 	public:
-		SpriteTexture(const CM::HTexture& baseTexture);
-
 		const CM::HTexture& getTexture() const;
 		CM::Vector2 transformUV(const CM::Vector2& uv) const;
 
-		static SpriteTexturePtr dummy();
+		static HSpriteTexture dummy();
+		static HSpriteTexture create(const CM::HTexture& texture);
+		static HSpriteTexture create(const CM::Vector2& uvOffset, const CM::Vector2& uvScale, const CM::HTexture& texture);
 	private:
-		CM::HTexture mBaseTexture;
+		friend class SpriteTextureRTTI;
+
+		SpriteTexture(const CM::Vector2& uvOffset, const CM::Vector2& uvScale, const CM::HTexture& texture);
 
-		bool mUsingAtlas;
 		CM::HTexture mAtlasTexture;
 		CM::Vector2 mUVOffset;
 		CM::Vector2 mUVScale;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+
+		static SpriteTexturePtr createEmpty();
+	public:
+		friend class SpriteTextureRTTI;
+		static CM::RTTITypeBase* getRTTIStatic();
+		virtual CM::RTTITypeBase* getRTTI() const;	
 	};
 }

+ 45 - 0
BansheeEngine/Include/BsSpriteTextureRTTI.h

@@ -0,0 +1,45 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "CmRTTIType.h"
+#include "BsSpriteTexture.h"
+
+namespace BansheeEngine
+{
+	class BS_EXPORT SpriteTextureRTTI : public CM::RTTIType<SpriteTexture, CM::Resource, SpriteTextureRTTI>
+	{
+	private:
+		CM::HTexture& getAtlasTexture(SpriteTexture* obj) { return obj->mAtlasTexture; }
+		void setAtlasTexture(SpriteTexture* obj, CM::HTexture& val) { obj->mAtlasTexture = val; } 
+
+		CM::Vector2& getUVOffset(SpriteTexture* obj) { return obj->mUVOffset; }
+		void setUVOffset(SpriteTexture* obj, CM::Vector2& val) { obj->mUVOffset = val; } 
+
+		CM::Vector2& getUVScale(SpriteTexture* obj) { return obj->mUVScale; }
+		void setUVScale(SpriteTexture* obj, CM::Vector2& val) { obj->mUVScale = val; } 
+
+	public:
+		SpriteTextureRTTI()
+		{
+			addReflectableField("mAtlasTexture", 0, &SpriteTextureRTTI::getAtlasTexture, &SpriteTextureRTTI::setAtlasTexture);
+			addPlainField("mUVOffset", 1, &SpriteTextureRTTI::getUVOffset, &SpriteTextureRTTI::setUVOffset);
+			addPlainField("mUVScale", 2, &SpriteTextureRTTI::getUVScale, &SpriteTextureRTTI::setUVScale);
+		}
+
+		virtual const CM::String& getRTTIName()
+		{
+			static CM::String name = "SpriteTexture";
+			return name;
+		}
+
+		virtual CM::UINT32 getRTTIId()
+		{
+			return TID_SpriteTexture;
+		}
+
+		virtual std::shared_ptr<CM::IReflectable> newRTTIObject()
+		{
+			return SpriteTexture::createEmpty();
+		}
+	};
+}

+ 54 - 54
BansheeEngine/Source/BsEngineGUI.cpp

@@ -138,8 +138,8 @@ namespace BansheeEngine
 		HTexture windowFrameFocusedTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowFrameFocused));
 
 		GUIElementStyle windowFrameStyle;
-		windowFrameStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowFrameNormalTex));
-		windowFrameStyle.focused.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowFrameFocusedTex));
+		windowFrameStyle.normal.texture = SpriteTexture::create(windowFrameNormalTex);
+		windowFrameStyle.focused.texture = SpriteTexture::create(windowFrameFocusedTex);
 		windowFrameStyle.border.left = 1;
 		windowFrameStyle.border.right = 1;
 		windowFrameStyle.border.top = 1;
@@ -152,8 +152,8 @@ namespace BansheeEngine
 		HTexture buttonHoverTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ButtonHoverTex));
 
 		GUIElementStyle buttonStyle;
-		buttonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(buttonNormalTex));
-		buttonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(buttonHoverTex));
+		buttonStyle.normal.texture = SpriteTexture::create(buttonNormalTex);
+		buttonStyle.hover.texture = SpriteTexture::create(buttonHoverTex);
 		buttonStyle.active.texture = buttonStyle.hover.texture;
 		buttonStyle.border.left = 5;
 		buttonStyle.border.right = 5;
@@ -179,7 +179,7 @@ namespace BansheeEngine
 		HTexture windowBgTexture = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowBackgroundTexture));
 
 		GUIElementStyle windowBgStyle;
-		windowBgStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowBgTexture));
+		windowBgStyle.normal.texture = SpriteTexture::create(windowBgTexture);
 
 		mSkin.setStyle("WindowBackground", windowBgStyle);
 
@@ -187,7 +187,7 @@ namespace BansheeEngine
 		HTexture windowTitleBarBg = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowTitleBarBg));
 
 		GUIElementStyle titleBarBgStyle;
-		titleBarBgStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowTitleBarBg));
+		titleBarBgStyle.normal.texture = SpriteTexture::create(windowTitleBarBg);
 		titleBarBgStyle.fixedHeight = true;
 		titleBarBgStyle.height = 13;
 
@@ -198,8 +198,8 @@ namespace BansheeEngine
 		HTexture tabbedBarBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + TabbedBarBtnActive));
 
 		GUIElementStyle tabbedBarButton;
-		tabbedBarButton.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(tabbedBarBtnNormal));
-		tabbedBarButton.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(tabbedBarBtnActive));
+		tabbedBarButton.normal.texture = SpriteTexture::create(tabbedBarBtnNormal);
+		tabbedBarButton.hover.texture = SpriteTexture::create(tabbedBarBtnActive);
 		tabbedBarButton.active.texture = tabbedBarButton.hover.texture;
 		tabbedBarButton.normalOn.texture = tabbedBarButton.hover.texture;
 		tabbedBarButton.hoverOn.texture = tabbedBarButton.hover.texture;
@@ -229,8 +229,8 @@ namespace BansheeEngine
 		HTexture winMinBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowMinButtonHover));
 
 		GUIElementStyle winMinButtonStyle;
-		winMinButtonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winMinBtnNormal));
-		winMinButtonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winMinBtnHover));
+		winMinButtonStyle.normal.texture = SpriteTexture::create(winMinBtnNormal);
+		winMinButtonStyle.hover.texture = SpriteTexture::create(winMinBtnHover);
 		winMinButtonStyle.active.texture = winMinButtonStyle.hover.texture;
 		winMinButtonStyle.fixedHeight = true;
 		winMinButtonStyle.fixedWidth = true;
@@ -244,8 +244,8 @@ namespace BansheeEngine
 		HTexture winMaxBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowMaxButtonHover));
 
 		GUIElementStyle winMaxButtonStyle;
-		winMaxButtonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winMaxBtnNormal));
-		winMaxButtonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winMaxBtnHover));
+		winMaxButtonStyle.normal.texture = SpriteTexture::create(winMaxBtnNormal);
+		winMaxButtonStyle.hover.texture = SpriteTexture::create(winMaxBtnHover);
 		winMaxButtonStyle.active.texture = winMaxButtonStyle.hover.texture;
 		winMaxButtonStyle.fixedHeight = true;
 		winMaxButtonStyle.fixedWidth = true;
@@ -259,8 +259,8 @@ namespace BansheeEngine
 		HTexture winCloseBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowCloseButtonHover));
 
 		GUIElementStyle winCloseButtonStyle;
-		winCloseButtonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winCloseBtnNormal));
-		winCloseButtonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winCloseBtnHover));
+		winCloseButtonStyle.normal.texture = SpriteTexture::create(winCloseBtnNormal);
+		winCloseButtonStyle.hover.texture = SpriteTexture::create(winCloseBtnHover);
 		winCloseButtonStyle.active.texture = winCloseButtonStyle.hover.texture;
 		winCloseButtonStyle.fixedHeight = true;
 		winCloseButtonStyle.fixedWidth = true;
@@ -275,9 +275,9 @@ namespace BansheeEngine
 		HTexture inputBoxFocusedTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + InputBoxFocusedTex));
 
 		GUIElementStyle inputBoxStyle;
-		inputBoxStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxNormalTex));
-		inputBoxStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxHoverTex));
-		inputBoxStyle.focused.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxFocusedTex));
+		inputBoxStyle.normal.texture = SpriteTexture::create(inputBoxNormalTex);
+		inputBoxStyle.hover.texture = SpriteTexture::create(inputBoxHoverTex);
+		inputBoxStyle.focused.texture = SpriteTexture::create(inputBoxFocusedTex);
 		inputBoxStyle.active.texture = inputBoxStyle.normal.texture;
 		inputBoxStyle.border.left = 5;
 		inputBoxStyle.border.right = 5;
@@ -309,9 +309,9 @@ namespace BansheeEngine
 		HTexture scrollUpBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarUpActiveTex));
 
 		GUIElementStyle scrollUpBtnStyle;
-		scrollUpBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollUpBtnNormal));
-		scrollUpBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollUpBtnHover));
-		scrollUpBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollUpBtnActive));
+		scrollUpBtnStyle.normal.texture = SpriteTexture::create(scrollUpBtnNormal);
+		scrollUpBtnStyle.hover.texture = SpriteTexture::create(scrollUpBtnHover);
+		scrollUpBtnStyle.active.texture = SpriteTexture::create(scrollUpBtnActive);
 		scrollUpBtnStyle.fixedHeight = true;
 		scrollUpBtnStyle.fixedWidth = true;
 		scrollUpBtnStyle.height = 4;
@@ -325,9 +325,9 @@ namespace BansheeEngine
 		HTexture scrollDownBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarDownActiveTex));
 
 		GUIElementStyle scrollDownBtnStyle;
-		scrollDownBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollDownBtnNormal));
-		scrollDownBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollDownBtnHover));
-		scrollDownBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollDownBtnActive));
+		scrollDownBtnStyle.normal.texture = SpriteTexture::create(scrollDownBtnNormal);
+		scrollDownBtnStyle.hover.texture = SpriteTexture::create(scrollDownBtnHover);
+		scrollDownBtnStyle.active.texture = SpriteTexture::create(scrollDownBtnActive);
 		scrollDownBtnStyle.fixedHeight = true;
 		scrollDownBtnStyle.fixedWidth = true;
 		scrollDownBtnStyle.height = 4;
@@ -341,9 +341,9 @@ namespace BansheeEngine
 		HTexture scrollLeftBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarLeftActiveTex));
 
 		GUIElementStyle scrollLeftBtnStyle;
-		scrollLeftBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollLeftBtnNormal));
-		scrollLeftBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollLeftBtnHover));
-		scrollLeftBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollLeftBtnActive));
+		scrollLeftBtnStyle.normal.texture = SpriteTexture::create(scrollLeftBtnNormal);
+		scrollLeftBtnStyle.hover.texture = SpriteTexture::create(scrollLeftBtnHover);
+		scrollLeftBtnStyle.active.texture = SpriteTexture::create(scrollLeftBtnActive);
 		scrollLeftBtnStyle.fixedHeight = true;
 		scrollLeftBtnStyle.fixedWidth = true;
 		scrollLeftBtnStyle.height = 8;
@@ -357,9 +357,9 @@ namespace BansheeEngine
 		HTexture scrollRightBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarRightActiveTex));
 
 		GUIElementStyle scrollRightBtnStyle;
-		scrollRightBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollRightBtnNormal));
-		scrollRightBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollRightBtnHover));
-		scrollRightBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollRightBtnActive));
+		scrollRightBtnStyle.normal.texture = SpriteTexture::create(scrollRightBtnNormal);
+		scrollRightBtnStyle.hover.texture = SpriteTexture::create(scrollRightBtnHover);
+		scrollRightBtnStyle.active.texture = SpriteTexture::create(scrollRightBtnActive);
 		scrollRightBtnStyle.fixedHeight = true;
 		scrollRightBtnStyle.fixedWidth = true;
 		scrollRightBtnStyle.height = 8;
@@ -373,9 +373,9 @@ namespace BansheeEngine
 		HTexture scrollBarHorzBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarHandleHorzActiveTex));
 
 		GUIElementStyle scrollBarHorzBtnStyle;
-		scrollBarHorzBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarHorzBtnNormal));
-		scrollBarHorzBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarHorzBtnHover));
-		scrollBarHorzBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarHorzBtnActive));
+		scrollBarHorzBtnStyle.normal.texture = SpriteTexture::create(scrollBarHorzBtnNormal);
+		scrollBarHorzBtnStyle.hover.texture = SpriteTexture::create(scrollBarHorzBtnHover);
+		scrollBarHorzBtnStyle.active.texture = SpriteTexture::create(scrollBarHorzBtnActive);
 		scrollBarHorzBtnStyle.fixedHeight = true;
 		scrollBarHorzBtnStyle.fixedWidth = true;
 		scrollBarHorzBtnStyle.height = 6;
@@ -389,9 +389,9 @@ namespace BansheeEngine
 		HTexture scrollBarVertBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarHandleVertActiveTex));
 
 		GUIElementStyle scrollBarVertBtnStyle;
-		scrollBarVertBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarVertBtnNormal));
-		scrollBarVertBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarVertBtnHover));
-		scrollBarVertBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarVertBtnActive));
+		scrollBarVertBtnStyle.normal.texture = SpriteTexture::create(scrollBarVertBtnNormal);
+		scrollBarVertBtnStyle.hover.texture = SpriteTexture::create(scrollBarVertBtnHover);
+		scrollBarVertBtnStyle.active.texture = SpriteTexture::create(scrollBarVertBtnActive);
 		scrollBarVertBtnStyle.fixedHeight = true;
 		scrollBarVertBtnStyle.fixedWidth = true;
 		scrollBarVertBtnStyle.height = 4;
@@ -400,7 +400,7 @@ namespace BansheeEngine
 		mSkin.setStyle("ScrollBarVertBtn", scrollBarVertBtnStyle);
 
 		HTexture scrollBarBg = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarBgTex));
-		SpriteTexturePtr scrollBarBgPtr = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarBg));
+		HSpriteTexture scrollBarBgPtr = SpriteTexture::create(scrollBarBg);
 
 		// Vertical scroll bar
 		GUIElementStyle vertScrollBarStyle;
@@ -435,8 +435,8 @@ namespace BansheeEngine
 		HTexture dropDownListHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBtnHoverTex));
 
 		GUIElementStyle dropDownListStyle;
-		dropDownListStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownListNormal));
-		dropDownListStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownListHover));
+		dropDownListStyle.normal.texture = SpriteTexture::create(dropDownListNormal);
+		dropDownListStyle.hover.texture = SpriteTexture::create(dropDownListHover);
 		dropDownListStyle.active.texture = dropDownListStyle.hover.texture;
 		dropDownListStyle.normalOn.texture = dropDownListStyle.hover.texture;
 		dropDownListStyle.hoverOn.texture = dropDownListStyle.hover.texture;
@@ -464,7 +464,7 @@ namespace BansheeEngine
 		HTexture dropDownBtnScrollUpArrow = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnUpArrowTex));
 
 		GUIElementStyle dropDownScrollUpBtnArrowStyle;
-		dropDownScrollUpBtnArrowStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBtnScrollUpArrow));
+		dropDownScrollUpBtnArrowStyle.normal.texture = SpriteTexture::create(dropDownBtnScrollUpArrow);
 		dropDownScrollUpBtnArrowStyle.hover.texture = dropDownScrollUpBtnArrowStyle.normal.texture;
 		dropDownScrollUpBtnArrowStyle.active.texture = dropDownScrollUpBtnArrowStyle.hover.texture;
 		dropDownScrollUpBtnArrowStyle.fixedHeight = true;
@@ -485,8 +485,8 @@ namespace BansheeEngine
 		HTexture dropDownBtnScrollUpHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnUpHoverTex));
 
 		GUIElementStyle dropDownScrollUpBtnStyle;
-		dropDownScrollUpBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBtnScrollUpNormal));
-		dropDownScrollUpBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBtnScrollUpHover));
+		dropDownScrollUpBtnStyle.normal.texture = SpriteTexture::create(dropDownBtnScrollUpNormal);
+		dropDownScrollUpBtnStyle.hover.texture = SpriteTexture::create(dropDownBtnScrollUpHover);
 		dropDownScrollUpBtnStyle.active.texture = dropDownScrollUpBtnStyle.hover.texture;
 		dropDownScrollUpBtnStyle.fixedHeight = true;
 		dropDownScrollUpBtnStyle.fixedWidth = false;
@@ -505,7 +505,7 @@ namespace BansheeEngine
 		HTexture dropDownBtnScrollDownArrow = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnDownArrowTex));
 
 		GUIElementStyle dropDownScrollDownBtnArrowStyle;
-		dropDownScrollDownBtnArrowStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBtnScrollDownArrow));
+		dropDownScrollDownBtnArrowStyle.normal.texture = SpriteTexture::create(dropDownBtnScrollDownArrow);
 		dropDownScrollDownBtnArrowStyle.hover.texture = dropDownScrollDownBtnArrowStyle.normal.texture;
 		dropDownScrollDownBtnArrowStyle.active.texture = dropDownScrollDownBtnArrowStyle.hover.texture;
 		dropDownScrollDownBtnArrowStyle.fixedHeight = true;
@@ -526,8 +526,8 @@ namespace BansheeEngine
 		HTexture dropDownBtnScrollDownHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnDownHoverTex));
 
 		GUIElementStyle dropDownScrollDownBtnStyle;
-		dropDownScrollDownBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBtnScrollDownNormal));
-		dropDownScrollDownBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBtnScrollDownHover));
+		dropDownScrollDownBtnStyle.normal.texture = SpriteTexture::create(dropDownBtnScrollDownNormal);
+		dropDownScrollDownBtnStyle.hover.texture = SpriteTexture::create(dropDownBtnScrollDownHover);
 		dropDownScrollDownBtnStyle.active.texture = dropDownScrollDownBtnStyle.hover.texture;
 		dropDownScrollDownBtnStyle.fixedHeight = true;
 		dropDownScrollDownBtnStyle.fixedWidth = false;
@@ -547,8 +547,8 @@ namespace BansheeEngine
 		HTexture dropDownEntryBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxEntryHoverTex));
 
 		GUIElementStyle dropDownEntryBtnStyle;
-		dropDownEntryBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownEntryBtnNormal));
-		dropDownEntryBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownEntryBtnHover));
+		dropDownEntryBtnStyle.normal.texture = SpriteTexture::create(dropDownEntryBtnNormal);
+		dropDownEntryBtnStyle.hover.texture = SpriteTexture::create(dropDownEntryBtnHover);
 		dropDownEntryBtnStyle.active.texture = dropDownEntryBtnStyle.hover.texture;
 		dropDownEntryBtnStyle.fixedHeight = true;
 		dropDownEntryBtnStyle.fixedWidth = false;
@@ -572,8 +572,8 @@ namespace BansheeEngine
 		HTexture dropDownExpEntryBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxEntryExpHoverTex));
 
 		GUIElementStyle dropDownEntryExpBtnStyle;
-		dropDownEntryExpBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownExpEntryBtnNormal));
-		dropDownEntryExpBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownExpEntryBtnHover));
+		dropDownEntryExpBtnStyle.normal.texture = SpriteTexture::create(dropDownExpEntryBtnNormal);
+		dropDownEntryExpBtnStyle.hover.texture = SpriteTexture::create(dropDownExpEntryBtnHover);
 		dropDownEntryExpBtnStyle.active.texture = dropDownEntryExpBtnStyle.hover.texture;
 		dropDownEntryExpBtnStyle.fixedHeight = true;
 		dropDownEntryExpBtnStyle.fixedWidth = false;
@@ -596,7 +596,7 @@ namespace BansheeEngine
 		HTexture dropDownBoxBgTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBgTex));
 
 		GUIElementStyle dropDownBoxStyle;
-		dropDownBoxStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBoxBgTex));
+		dropDownBoxStyle.normal.texture = SpriteTexture::create(dropDownBoxBgTex);
 		dropDownBoxStyle.hover.texture = dropDownEntryBtnStyle.normal.texture;
 		dropDownBoxStyle.active.texture = dropDownEntryBtnStyle.hover.texture;
 		dropDownBoxStyle.fixedHeight = false;
@@ -618,7 +618,7 @@ namespace BansheeEngine
 		HTexture dropDownSeparatorTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownSeparatorTex));
 
 		GUIElementStyle dropDownSeparatorStyle;
-		dropDownSeparatorStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownSeparatorTex));
+		dropDownSeparatorStyle.normal.texture = SpriteTexture::create(dropDownSeparatorTex);
 		dropDownSeparatorStyle.fixedHeight = true;
 		dropDownSeparatorStyle.fixedWidth = false;
 		dropDownSeparatorStyle.height = 3;
@@ -640,7 +640,7 @@ namespace BansheeEngine
 		HTexture menuBarBgTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + MenuBarBgTex));
 
 		GUIElementStyle menuBarBgStyle;
-		menuBarBgStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(menuBarBgTex));
+		menuBarBgStyle.normal.texture = SpriteTexture::create(menuBarBgTex);
 		menuBarBgStyle.fixedHeight = false;
 		menuBarBgStyle.fixedWidth = false;
 		menuBarBgStyle.height = 4;
@@ -652,7 +652,7 @@ namespace BansheeEngine
 		HTexture menuBarBansheeLogoTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + MenuBarBansheeLogoTex));
 
 		GUIElementStyle menuBarBansheeLogoStyle;
-		menuBarBansheeLogoStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(menuBarBansheeLogoTex));
+		menuBarBansheeLogoStyle.normal.texture = SpriteTexture::create(menuBarBansheeLogoTex);
 		menuBarBansheeLogoStyle.fixedHeight = true;
 		menuBarBansheeLogoStyle.fixedWidth = true;
 		menuBarBansheeLogoStyle.height = 7;
@@ -665,8 +665,8 @@ namespace BansheeEngine
 		HTexture menuBarBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + MenuBarBtnHoverTex));
 
 		GUIElementStyle menuBarBtnStyle;
-		menuBarBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(menuBarBtnNormal));
-		menuBarBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(menuBarBtnHover));
+		menuBarBtnStyle.normal.texture = SpriteTexture::create(menuBarBtnNormal);
+		menuBarBtnStyle.hover.texture = SpriteTexture::create(menuBarBtnHover);
 		menuBarBtnStyle.active.texture = menuBarBtnStyle.hover.texture;
 		menuBarBtnStyle.normalOn.texture = menuBarBtnStyle.hover.texture;
 		menuBarBtnStyle.hoverOn.texture = menuBarBtnStyle.hover.texture;

+ 21 - 19
BansheeEngine/Source/BsGUIButtonBase.cpp

@@ -19,16 +19,15 @@ namespace BansheeEngine
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 		mTextSprite = cm_new<TextSprite, PoolAlloc>();
 
-		SpriteTexturePtr contentTex = content.getImage();
-		if(contentTex != nullptr)
+		HSpriteTexture contentTex = content.getImage();
+		if(contentTex != nullptr && contentTex.isLoaded())
 			mContentImageSprite = cm_new<ImageSprite, PoolAlloc>();
 
-		mImageDesc.texture = mStyle->normal.texture;
-
-		if(mImageDesc.texture != nullptr)
+		mActiveTexture = mStyle->normal.texture;
+		if(mActiveTexture != nullptr && mActiveTexture.isLoaded())
 		{
-			mImageDesc.width = mImageDesc.texture->getTexture()->getWidth();
-			mImageDesc.height = mImageDesc.texture->getTexture()->getHeight();
+			mImageDesc.width = mActiveTexture->getTexture()->getWidth();
+			mImageDesc.height = mActiveTexture->getTexture()->getHeight();
 		}
 
 		mImageDesc.borderLeft = mStyle->border.left;
@@ -118,6 +117,9 @@ namespace BansheeEngine
 		mImageDesc.width = mWidth;
 		mImageDesc.height = mHeight;
 
+		if(mActiveTexture != nullptr && mActiveTexture.isLoaded())
+			mImageDesc.texture = mActiveTexture.getInternalPtr();
+
 		mImageSprite->update(mImageDesc);
 
 		mTextSprite->update(getTextDesc());
@@ -125,7 +127,7 @@ namespace BansheeEngine
 		if(mContentImageSprite != nullptr)
 		{
 			IMAGE_SPRITE_DESC contentImgDesc;
-			contentImgDesc.texture = mContent.getImage();
+			contentImgDesc.texture = mContent.getImage().getInternalPtr();
 			contentImgDesc.width = mContent.getImage()->getTexture()->getWidth();
 			contentImgDesc.height = mContent.getImage()->getTexture()->getHeight();
 
@@ -144,10 +146,10 @@ namespace BansheeEngine
 	{
 		UINT32 imageWidth = 0;
 		UINT32 imageHeight = 0;
-		if(mImageDesc.texture != nullptr)
+		if(mActiveTexture != nullptr)
 		{
-			imageWidth = mImageDesc.texture->getTexture()->getWidth();
-			imageHeight = mImageDesc.texture->getTexture()->getHeight();
+			imageWidth = mActiveTexture->getTexture()->getWidth();
+			imageHeight = mActiveTexture->getTexture()->getHeight();
 		}
 
 		Vector2I contentSize = GUIHelper::calcOptimalContentsSize(mContent, *mStyle, _getLayoutOptions());
@@ -308,28 +310,28 @@ namespace BansheeEngine
 		switch(state)
 		{
 		case GUIButtonState::Normal:
-			mImageDesc.texture = mStyle->normal.texture;
+			mActiveTexture = mStyle->normal.texture;
 			break;
 		case GUIButtonState::Hover:
-			mImageDesc.texture = mStyle->hover.texture;
+			mActiveTexture = mStyle->hover.texture;
 			break;
 		case GUIButtonState::Active:
-			mImageDesc.texture = mStyle->active.texture;
+			mActiveTexture = mStyle->active.texture;
 			break;
 		case GUIButtonState::Focused:
-			mImageDesc.texture = mStyle->focused.texture;
+			mActiveTexture = mStyle->focused.texture;
 			break;
 		case GUIButtonState::NormalOn:
-			mImageDesc.texture = mStyle->normalOn.texture;
+			mActiveTexture = mStyle->normalOn.texture;
 			break;
 		case GUIButtonState::HoverOn:
-			mImageDesc.texture = mStyle->hoverOn.texture;
+			mActiveTexture = mStyle->hoverOn.texture;
 			break;
 		case GUIButtonState::ActiveOn:
-			mImageDesc.texture = mStyle->activeOn.texture;
+			mActiveTexture = mStyle->activeOn.texture;
 			break;
 		case GUIButtonState::FocusedOn:
-			mImageDesc.texture = mStyle->focusedOn.texture;
+			mActiveTexture = mStyle->focusedOn.texture;
 			break;
 		}
 

+ 4 - 4
BansheeEngine/Source/BsGUIContent.cpp

@@ -12,19 +12,19 @@ namespace BansheeEngine
 		:mText(text), mTooltipText(tooltip)
 	{ }
 
-	GUIContent::GUIContent(const SpriteTexturePtr& image)
+	GUIContent::GUIContent(const HSpriteTexture& image)
 		:mImage(image)
 	{ }
 
-	GUIContent::GUIContent(const SpriteTexturePtr& image, const CM::HString& tooltip)
+	GUIContent::GUIContent(const HSpriteTexture& image, const CM::HString& tooltip)
 		:mImage(image), mTooltipText(tooltip)
 	{ }
 
-	GUIContent::GUIContent(const CM::HString& text, const SpriteTexturePtr& image)
+	GUIContent::GUIContent(const CM::HString& text, const HSpriteTexture& image)
 		:mText(text), mImage(image)
 	{ }
 
-	GUIContent::GUIContent(const CM::HString& text, const SpriteTexturePtr& image, const CM::HString& tooltip)
+	GUIContent::GUIContent(const CM::HString& text, const HSpriteTexture& image, const CM::HString& tooltip)
 		:mText(text), mImage(image), mTooltipText(tooltip)
 	{ }
 }

+ 14 - 11
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -36,12 +36,12 @@ namespace BansheeEngine
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 		mTextSprite = cm_new<TextSprite, PoolAlloc>();
 
-		mImageDesc.texture = mStyle->normal.texture;
+		mActiveTexture = mStyle->normal.texture;
 
-		if(mImageDesc.texture != nullptr)
+		if(mActiveTexture != nullptr && mActiveTexture.isLoaded())
 		{
-			mImageDesc.width = mImageDesc.texture->getTexture()->getWidth();
-			mImageDesc.height = mImageDesc.texture->getTexture()->getHeight();
+			mImageDesc.width = mActiveTexture->getTexture()->getWidth();
+			mImageDesc.height = mActiveTexture->getTexture()->getHeight();
 		}
 
 		mImageDesc.borderLeft = mStyle->border.left;
@@ -116,6 +116,9 @@ namespace BansheeEngine
 
 	void GUIInputBox::updateRenderElementsInternal()
 	{		
+		if(mActiveTexture != nullptr && mActiveTexture.isLoaded())
+			mImageDesc.texture = mActiveTexture.getInternalPtr();
+
 		mImageDesc.width = mWidth;
 		mImageDesc.height = mHeight;
 
@@ -287,10 +290,10 @@ namespace BansheeEngine
 	{
 		UINT32 imageWidth = 0;
 		UINT32 imageHeight = 0;
-		if(mImageDesc.texture != nullptr)
+		if(mActiveTexture != nullptr && mActiveTexture.isLoaded())
 		{
-			imageWidth = mImageDesc.texture->getTexture()->getWidth();
-			imageHeight = mImageDesc.texture->getTexture()->getHeight();
+			imageWidth = mActiveTexture->getTexture()->getWidth();
+			imageHeight = mActiveTexture->getTexture()->getHeight();
 		}
 
 		Vector2I contentSize = GUIHelper::calcOptimalContentsSize(mText, *mStyle, _getLayoutOptions());
@@ -346,7 +349,7 @@ namespace BansheeEngine
 		{
 			if(!mHasFocus)
 			{
-				mImageDesc.texture = mStyle->hover.texture;
+				mActiveTexture = mStyle->hover.texture;
 				markContentAsDirty();
 			}
 
@@ -362,7 +365,7 @@ namespace BansheeEngine
 		{
 			if(!mHasFocus)
 			{
-				mImageDesc.texture = mStyle->normal.texture;
+				mActiveTexture = mStyle->normal.texture;
 				markContentAsDirty();
 			}
 
@@ -923,12 +926,12 @@ namespace BansheeEngine
 	{
 		if(focus)
 		{
-			mImageDesc.texture = mStyle->focused.texture;
+			mActiveTexture = mStyle->focused.texture;
 			markContentAsDirty();
 		}
 		else
 		{
-			mImageDesc.texture = mStyle->normal.texture;
+			mActiveTexture = mStyle->normal.texture;
 			hideCaret();
 			clearSelection();
 			markContentAsDirty();

+ 2 - 1
BansheeEngine/Source/BsGUIInputCaret.cpp

@@ -1,4 +1,5 @@
 #include "BsGUIInputCaret.h"
+#include "BsSpriteTexture.h"
 #include "BsGUIManager.h"
 #include "BsImageSprite.h"
 #include "BsGUIElement.h"
@@ -51,7 +52,7 @@ namespace BansheeEngine
 		IMAGE_SPRITE_DESC mCaretDesc;
 		mCaretDesc.width = 1;
 		mCaretDesc.height = getCaretHeight();
-		mCaretDesc.texture = GUIManager::instance().getCaretTexture();
+		mCaretDesc.texture = GUIManager::instance().getCaretTexture().getInternalPtr();
 
 		mCaretSprite->update(mCaretDesc);
 	}

+ 2 - 1
BansheeEngine/Source/BsGUIInputSelection.cpp

@@ -1,4 +1,5 @@
 #include "BsGUIInputSelection.h"
+#include "BsSpriteTexture.h"
 #include "BsImageSprite.h"
 #include "BsGUIElement.h"
 #include "BsGUIManager.h"
@@ -45,7 +46,7 @@ namespace BansheeEngine
 			IMAGE_SPRITE_DESC desc;
 			desc.width = mSelectionRects[idx].width;
 			desc.height = mSelectionRects[idx].height;
-			desc.texture = GUIManager::instance().getTextSelectionTexture();
+			desc.texture = GUIManager::instance().getTextSelectionTexture().getInternalPtr();
 
 			sprite->update(desc);
 			idx++;

+ 3 - 3
BansheeEngine/Source/BsGUIManager.cpp

@@ -64,7 +64,7 @@ namespace BansheeEngine
 	GUIManager::GUIManager()
 		:mElementUnderCursor(nullptr), mWidgetUnderCursor(nullptr), mSeparateMeshesByWidget(true), mActiveElement(nullptr), 
 		mActiveWidget(nullptr), mActiveMouseButton(GUIMouseButton::Left), mKeyboardFocusElement(nullptr), mKeyboardFocusWidget(nullptr),
-		mCaretTexture(nullptr), mCaretBlinkInterval(0.5f), mCaretLastBlinkTime(0.0f), mCaretColor(1.0f, 0.6588f, 0.0f), mIsCaretOn(false),
+		mCaretBlinkInterval(0.5f), mCaretLastBlinkTime(0.0f), mCaretColor(1.0f, 0.6588f, 0.0f), mIsCaretOn(false),
 		mTextSelectionColor(1.0f, 0.6588f, 0.0f), mInputCaret(nullptr), mInputSelection(nullptr), mSelectiveInputActive(false), mDragState(DragState::NoDrag)
 	{
 		mOnCursorMovedConn = gInput().onCursorMoved.connect(boost::bind(&GUIManager::onCursorMoved, this, _1));
@@ -537,7 +537,7 @@ namespace BansheeEngine
 		{
 			HTexture newTex = Texture::create(TEX_TYPE_2D, 1, 1, 0, PF_R8G8B8A8);
 			newTex->synchonize(); // TODO - Required due to a bug in allocateSubresourceBuffer
-			mCaretTexture = cm_shared_ptr<SpriteTexture>(newTex);
+			mCaretTexture = SpriteTexture::create(newTex);
 		}
 
 		const HTexture& tex = mCaretTexture->getTexture();
@@ -555,7 +555,7 @@ namespace BansheeEngine
 		{
 			HTexture newTex = Texture::create(TEX_TYPE_2D, 1, 1, 0, PF_R8G8B8A8);
 			newTex->synchonize(); // TODO - Required due to a bug in allocateSubresourceBuffer
-			mTextSelectionTexture = cm_shared_ptr<SpriteTexture>(newTex);
+			mTextSelectionTexture = SpriteTexture::create(newTex);
 		}
 
 		const HTexture& tex = mTextSelectionTexture->getTexture();

+ 7 - 2
BansheeEngine/Source/BsGUIRenderTexture.cpp

@@ -16,7 +16,7 @@ namespace BansheeEngine
 	}
 
 	GUIRenderTexture::GUIRenderTexture(GUIWidget& parent, const GUIElementStyle* style, const RenderTexturePtr& texture, const GUILayoutOptions& layoutOptions)
-		:GUITexture(parent, style, nullptr, GUIImageScaleMode::StretchToFit, layoutOptions), mSourceTexture(texture.get())
+		:GUITexture(parent, style, HSpriteTexture(), GUIImageScaleMode::StretchToFit, layoutOptions), mSourceTexture(texture.get())
 	{
 		if(mSourceTexture->requiresTextureFlipping())
 		{
@@ -24,7 +24,7 @@ namespace BansheeEngine
 			mDesc.uvScale = Vector2(1.0f, -1.0f);
 		}
 
-		setTexture(std::make_shared<SpriteTexture>(texture->getBindableColorTexture()));
+		setTexture(SpriteTexture::create(texture->getBindableColorTexture()));
 		GUIManager::instance().setInputBridge(mSourceTexture, this);
 	}
 
@@ -57,6 +57,11 @@ namespace BansheeEngine
 
 	void GUIRenderTexture::updateRenderElementsInternal()
 	{		
+		if(mActiveTexture != nullptr && mActiveTexture.isLoaded())
+		{
+			mDesc.texture = mActiveTexture.getInternalPtr();
+		}
+
 		mDesc.width = mWidth;
 		mDesc.height = mHeight;
 

+ 5 - 1
BansheeEngine/Source/BsGUIScrollBar.cpp

@@ -1,4 +1,5 @@
 #include "BsGUIScrollBar.h"
+#include "BsSpriteTexture.h"
 #include "BsGUIElementStyle.h"
 #include "BsGUISkin.h"
 #include "BsGUIWidget.h"
@@ -87,7 +88,10 @@ namespace BansheeEngine
 	void GUIScrollBar::updateRenderElementsInternal()
 	{
 		IMAGE_SPRITE_DESC desc;
-		desc.texture = mStyle->normal.texture;
+
+		if(mStyle->normal.texture != nullptr && mStyle->normal.texture.isLoaded())
+			desc.texture = mStyle->normal.texture.getInternalPtr();
+
 		desc.width = mWidth;
 		desc.height = mHeight;
 

+ 3 - 1
BansheeEngine/Source/BsGUIScrollBarHandle.cpp

@@ -103,7 +103,9 @@ namespace BansheeEngine
 	void GUIScrollBarHandle::updateRenderElementsInternal()
 	{		
 		IMAGE_SPRITE_DESC desc;
-		desc.texture = mCurTexture;
+
+		if(mCurTexture != nullptr && mCurTexture.isLoaded())
+			desc.texture = mCurTexture.getInternalPtr();
 
 		if(mHorizontal)
 		{

+ 13 - 12
BansheeEngine/Source/BsGUITexture.cpp

@@ -16,16 +16,16 @@ namespace BansheeEngine
 		return name;
 	}
 
-	GUITexture::GUITexture(GUIWidget& parent, const GUIElementStyle* style, const SpriteTexturePtr& texture, 
+	GUITexture::GUITexture(GUIWidget& parent, const GUIElementStyle* style, const HSpriteTexture& texture, 
 		GUIImageScaleMode scale, const GUILayoutOptions& layoutOptions)
 		:GUIElement(parent, style, layoutOptions), mScaleMode(scale)
 	{
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 
 		if(texture != nullptr)
-			mDesc.texture = texture;
+			mActiveTexture = texture;
 		else
-			mDesc.texture = style->normal.texture;
+			mActiveTexture = style->normal.texture;
 	
 		mDesc.borderLeft = mStyle->border.left;
 		mDesc.borderRight = mStyle->border.right;
@@ -38,7 +38,7 @@ namespace BansheeEngine
 		cm_delete<PoolAlloc>(mImageSprite);
 	}
 
-	GUITexture* GUITexture::create(GUIWidget& parent, const SpriteTexturePtr& texture, 
+	GUITexture* GUITexture::create(GUIWidget& parent, const HSpriteTexture& texture, 
 		GUIImageScaleMode scale, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
@@ -50,7 +50,7 @@ namespace BansheeEngine
 		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, texture, scale, GUILayoutOptions::create(style));
 	}
 
-	GUITexture* GUITexture::create(GUIWidget& parent, const GUIOptions& layoutOptions, const SpriteTexturePtr& texture, 
+	GUITexture* GUITexture::create(GUIWidget& parent, const GUIOptions& layoutOptions, const HSpriteTexture& texture, 
 		GUIImageScaleMode scale, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
@@ -70,7 +70,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, nullptr, scale, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, HSpriteTexture(), scale, GUILayoutOptions::create(style));
 	}
 
 	GUITexture* GUITexture::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIImageScaleMode scale, const GUIElementStyle* style)
@@ -81,12 +81,12 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, nullptr, scale, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, HTexture(), scale, GUILayoutOptions::create(layoutOptions, style));
 	}
 
-	void GUITexture::setTexture(const SpriteTexturePtr& texture)
+	void GUITexture::setTexture(const HSpriteTexture& texture)
 	{
-		mDesc.texture = texture;
+		mActiveTexture = texture;
 		markContentAsDirty();
 	}
 
@@ -112,8 +112,9 @@ namespace BansheeEngine
 
 		float optimalWidth = 0.0f;
 		float optimalHeight = 0.0f;
-		if(mDesc.texture != nullptr)
+		if(mActiveTexture != nullptr && mActiveTexture.isLoaded())
 		{
+			mDesc.texture = mActiveTexture.getInternalPtr();
 			optimalWidth = (float)mDesc.texture->getTexture()->getWidth();
 			optimalHeight = (float)mDesc.texture->getTexture()->getHeight();
 		}
@@ -175,9 +176,9 @@ namespace BansheeEngine
 
 	Vector2I GUITexture::_getOptimalSize() const
 	{
-		if(mDesc.texture != nullptr)
+		if(mActiveTexture != nullptr && mActiveTexture.isLoaded())
 		{
-			return Vector2I(mDesc.texture->getTexture()->getWidth(), mDesc.texture->getTexture()->getHeight());
+			return Vector2I(mActiveTexture->getTexture()->getWidth(), mActiveTexture->getTexture()->getHeight());
 		}
 
 		return Vector2I(0, 0);

+ 42 - 10
BansheeEngine/Source/BsSpriteTexture.cpp

@@ -1,39 +1,71 @@
 #include "BsSpriteTexture.h"
+#include "BsSpriteTextureRTTI.h"
 #include "CmTexture.h"
 
 using namespace CamelotFramework;
 
 namespace BansheeEngine
 {
-	SpriteTexture::SpriteTexture(const HTexture& baseTexture)
-		:mBaseTexture(baseTexture), mUsingAtlas(false)
+	SpriteTexture::SpriteTexture(const Vector2& uvOffset, const Vector2& uvScale, const HTexture& texture)
+		:Resource(false), mUVOffset(uvOffset), mUVScale(uvScale), mAtlasTexture(texture)
 	{
 
 	}
 
 	const HTexture& SpriteTexture::getTexture() const 
 	{ 
-		return mUsingAtlas ? mAtlasTexture : mBaseTexture; 
+		return mAtlasTexture; 
 	}
 
 	Vector2 SpriteTexture::transformUV(const Vector2& uv) const
 	{
-		if(mUsingAtlas)
-			return mUVOffset + uv * mUVScale;
-		else
-			return uv;
+		return mUVOffset + uv * mUVScale;
 	}
 
-	SpriteTexturePtr SpriteTexture::dummy()
+	HSpriteTexture SpriteTexture::dummy()
 	{
 		static bool initialized = false;
-		static SpriteTexturePtr dummyTex = nullptr;
+		static HSpriteTexture dummyTex;
 
 		if(!initialized)
 		{
-			dummyTex = cm_shared_ptr<SpriteTexture, PoolAlloc>(Texture::dummy());
+			dummyTex = create(Texture::dummy());
 		}
 
 		return dummyTex;
 	}
+
+	HSpriteTexture SpriteTexture::create(const HTexture& texture)
+	{
+		SpriteTexturePtr texturePtr = cm_core_ptr<SpriteTexture, PoolAlloc>
+			(new (cm_alloc<SpriteTexture, PoolAlloc>()) SpriteTexture(Vector2(0.0f, 0.0f), Vector2(1.0f, 1.0f), texture));
+
+		return static_resource_cast<SpriteTexture>(Resource::_createResourceHandle(texturePtr));
+	}
+
+	HSpriteTexture SpriteTexture::create(const Vector2& uvOffset, const Vector2& uvScale, const HTexture& texture)
+	{
+		SpriteTexturePtr texturePtr = cm_core_ptr<SpriteTexture, PoolAlloc>
+			(new (cm_alloc<SpriteTexture, PoolAlloc>()) SpriteTexture(uvOffset, uvScale, texture));
+
+		return static_resource_cast<SpriteTexture>(Resource::_createResourceHandle(texturePtr));
+	}
+
+	SpriteTexturePtr SpriteTexture::createEmpty()
+	{
+		SpriteTexturePtr texturePtr = cm_core_ptr<SpriteTexture, PoolAlloc>
+			(new (cm_alloc<SpriteTexture, PoolAlloc>()) SpriteTexture(Vector2(0.0f, 0.0f), Vector2(1.0f, 1.0f), Texture::dummy()));
+
+		return texturePtr;
+	}
+
+	RTTITypeBase* SpriteTexture::getRTTIStatic()
+	{
+		return SpriteTextureRTTI::instance();
+	}
+
+	RTTITypeBase* SpriteTexture::getRTTI() const
+	{
+		return SpriteTexture::getRTTIStatic();
+	}
 }

+ 3 - 3
CamelotClient/Source/BsGUIWindowDropArea.cpp

@@ -19,7 +19,7 @@ namespace BansheeEditor
 	}
 
 	GUIWindowDropArea::GUIWindowDropArea(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
-		:GUITexture(parent, style, nullptr, GUIImageScaleMode::ScaleToFit, layoutOptions)
+		:GUITexture(parent, style, HSpriteTexture(), GUIImageScaleMode::ScaleToFit, layoutOptions)
 	{ }
 
 	GUIWindowDropArea::~GUIWindowDropArea()
@@ -50,9 +50,9 @@ namespace BansheeEditor
 	void GUIWindowDropArea::setFocused(bool focused)
 	{
 		if(focused)
-			mDesc.texture = mStyle->focused.texture;
+			mActiveTexture = mStyle->focused.texture;
 		else
-			mDesc.texture = mStyle->normal.texture;
+			mActiveTexture = mStyle->normal.texture;
 
 		markContentAsDirty();
 	}

+ 3 - 3
CamelotClient/Source/BsGUIWindowFrame.cpp

@@ -22,7 +22,7 @@ namespace BansheeEditor
 	}
 
 	GUIWindowFrame::GUIWindowFrame(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
-		:GUITexture(parent, style, nullptr, GUIImageScaleMode::StretchToFit, layoutOptions)
+		:GUITexture(parent, style, HSpriteTexture(), GUIImageScaleMode::StretchToFit, layoutOptions)
 	{
 
 	}
@@ -55,9 +55,9 @@ namespace BansheeEditor
 	void GUIWindowFrame::setFocused(bool focused)
 	{
 		if(focused)
-			mDesc.texture = mStyle->focused.texture;
+			mActiveTexture = mStyle->focused.texture;
 		else
-			mDesc.texture = mStyle->normal.texture;
+			mActiveTexture = mStyle->normal.texture;
 
 		markContentAsDirty();
 	}

+ 1 - 3
CamelotGLRenderer/Source/GLSL/src/CmGLSLExtSupport.cpp

@@ -83,8 +83,6 @@ namespace CamelotFramework
 
 	bool logShaderInfo(String& msg, const GLuint obj)
 	{
-		String logMessage = msg;
-
 		if (obj > 0)
 		{
 			GLint infologLength = 0;
@@ -98,7 +96,7 @@ namespace CamelotFramework
 				GLchar* infoLog = (GLchar*)cm_alloc<ScratchAlloc>(sizeof(GLchar) * infologLength);
 
 				glGetShaderInfoLog(obj, infologLength, &charsWritten, infoLog);
-				logMessage += String(infoLog);
+				msg += String(infoLog);
 
 				cm_free<ScratchAlloc>(infoLog);
 

+ 3 - 3
SBansheeEngine/Include/BsScriptSpriteTexture.h

@@ -10,7 +10,7 @@ namespace BansheeEngine
 	public:
 		static void initMetaData();
 
-		const SpriteTexturePtr& getInternalValue() const { return mTexture; }
+		const HSpriteTexture& getInternalValue() const { return mTexture; }
 
 	private:
 		static void internal_createInstance(MonoObject* instance);
@@ -18,8 +18,8 @@ namespace BansheeEngine
 
 		static void initRuntimeData();
 
-		ScriptSpriteTexture(const SpriteTexturePtr& texture);
+		ScriptSpriteTexture(const HSpriteTexture& texture);
 
-		SpriteTexturePtr mTexture;
+		HSpriteTexture mTexture;
 	};
 }

+ 2 - 2
SBansheeEngine/Source/BsScriptSpriteTexture.cpp

@@ -9,7 +9,7 @@ using namespace CamelotFramework;
 
 namespace BansheeEngine
 {
-	ScriptSpriteTexture::ScriptSpriteTexture(const SpriteTexturePtr& texture)
+	ScriptSpriteTexture::ScriptSpriteTexture(const HSpriteTexture& texture)
 		:mTexture(texture)
 	{
 
@@ -30,7 +30,7 @@ namespace BansheeEngine
 
 	void ScriptSpriteTexture::internal_createInstance(MonoObject* instance)
 	{
-		ScriptSpriteTexture* nativeInstance = new (cm_alloc<ScriptSpriteTexture>()) ScriptSpriteTexture(nullptr); // TODO - DUMMY CODE!
+		ScriptSpriteTexture* nativeInstance = new (cm_alloc<ScriptSpriteTexture>()) ScriptSpriteTexture(SpriteTexture::dummy()); // TODO - DUMMY CODE!
 		nativeInstance->createInstance(instance);
 
 		metaData.thisPtrField->setValue(instance, nativeInstance);