瀏覽代碼

If sprite texture has the default wrap address mode, set to clamp. It's also possible to configure the texture to border address mode (via the XML parameters file), but that requires choosing a good border color. Closes #1096.

Lasse Öörni 10 年之前
父節點
當前提交
01857f5149
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      Source/Urho3D/Urho2D/Sprite2D.cpp

+ 9 - 0
Source/Urho3D/Urho2D/Sprite2D.cpp

@@ -106,6 +106,15 @@ bool Sprite2D::EndLoad()
 void Sprite2D::SetTexture(Texture2D* texture)
 {
     texture_ = texture;
+    // Ensure the texture doesn't have wrap addressing as that will cause bleeding bugs on the edges.
+    // Could also choose border mode, but in that case a universally good border color (without alpha bugs)
+    // would be hard to choose. Ideal is for the user to configure the texture parameters in its parameter
+    // XML file.
+    if (texture_->GetAddressMode(COORD_U) == ADDRESS_WRAP)
+    {
+        texture_->SetAddressMode(COORD_U, ADDRESS_CLAMP);
+        texture_->SetAddressMode(COORD_V, ADDRESS_CLAMP);
+    }
 }
 
 void Sprite2D::SetRectangle(const IntRect& rectangle)