Răsfoiți Sursa

clamp2edge added to <atlas>

dmuratshin 10 ani în urmă
părinte
comite
3f89dd8671

+ 1 - 1
examples/Demo/data/xmls/res.xml

@@ -42,7 +42,7 @@
 		<image file="score_table.png"/>
 	</atlas>
 
-	<atlas> 
+	<atlas clamp2edge="false"> 
 		<image file="tiled.png" trim="false" extend="false"/>
 	</atlas>	
 	

+ 5 - 14
examples/Demo/src/TestPolygon.h

@@ -17,25 +17,16 @@ public:
         poly->addTween(Actor::TweenRotation(MATH_PI * 2), 16000, -1);
         poly->setPosition(content->getSize() / 2);
 
-        ResAnim* rs = resources.getResAnim("tiled");
-
-
         //ResAnim "tiled" has only single frame and uses own separate atlas texture
-        //also it should have options trim=extend=false
+        //it should have options trim=extend=false
+        //and atlas with option clamp2edge=false to allow tiling
         /*
-        <atlas>
-            <image file="tiled.png" trim="false" extend="false"/>
+        <atlas clamp2edge="false">
+        <image file="tiled.png" trim="false" extend="false"/>
         </atlas>
         */
 
-        //need access to texture
-        AnimationFrame frame = rs->getFrame(0);
-        spNativeTexture texture = frame.getDiffuse().base;
-
-        //by default all textures has mode "clamp to edge"
-        //disable it and allow tiling
-        texture->setClamp2Edge(false);
-
+        ResAnim* rs = resources.getResAnim("tiled");
         poly->setResAnim(rs);
 
         update(_num);

+ 1 - 1
oxygine/src/TweenAlphaFade.h

@@ -22,7 +22,7 @@ namespace oxygine
         enum options
         {
             opt_singleR2T = 1,
-            opt_fullscreen = 1,
+            opt_fullscreen = 1 << 1,
         };
 
         int _options;

+ 8 - 7
oxygine/src/res/ResAtlas.cpp

@@ -79,7 +79,7 @@ namespace oxygine
         _hook = hook;
     }
 
-    void load_texture_internal(const std::string& file, spNativeTexture nt, bool linearFilter, LoadResourcesContext* load_context)
+    void load_texture_internal(const std::string& file, spNativeTexture nt, bool linearFilter, bool clamp2edge, LoadResourcesContext* load_context)
     {
         ImageData im;
         spMemoryTexture mt = new MemoryTexture;
@@ -96,10 +96,11 @@ namespace oxygine
         opt.src = mt;
         opt.dest = nt;
         opt.linearFilter = linearFilter;
+        opt.clamp2edge = clamp2edge;
         load_context->createTexture(opt);
     }
 
-    void load_texture(const std::string& file, spNativeTexture nt, bool linearFilter, LoadResourcesContext* load_context)
+    void load_texture(const std::string& file, spNativeTexture nt, bool linearFilter, bool clamp2edge, LoadResourcesContext* load_context)
     {
         if (_hook)
         {
@@ -107,7 +108,7 @@ namespace oxygine
             return;
         }
 
-        load_texture_internal(file, nt, linearFilter, load_context);
+        load_texture_internal(file, nt, linearFilter, clamp2edge, load_context);
     }
 
 
@@ -194,14 +195,14 @@ namespace oxygine
             atlas& atl = *i;
             if (atl.base.get() == texture)
             {
-                load_texture(atl.base_path, atl.base, _linearFilter , &RestoreResourcesContext::instance);
+                load_texture(atl.base_path, atl.base, _linearFilter, _clamp2edge, &RestoreResourcesContext::instance);
                 atl.base->reg(CLOSURE(this, &ResAtlas::_restore), 0);
                 break;
             }
 
             if (atl.alpha.get() == texture)
             {
-                load_texture(atl.alpha_path, atl.alpha, _linearFilter, &RestoreResourcesContext::instance);
+                load_texture(atl.alpha_path, atl.alpha, _linearFilter, _clamp2edge, &RestoreResourcesContext::instance);
                 atl.alpha->reg(CLOSURE(this, &ResAtlas::_restore), 0);
                 break;
             }
@@ -216,12 +217,12 @@ namespace oxygine
             if (!load_context->isNeedProceed(atl.base))
                 continue;
 
-            load_texture(atl.base_path, atl.base, _linearFilter, load_context);
+            load_texture(atl.base_path, atl.base, _linearFilter, _clamp2edge, load_context);
             atl.base->reg(CLOSURE(this, &ResAtlas::_restore), 0);
 
             if (atl.alpha)
             {
-                load_texture(atl.alpha_path, atl.alpha, _linearFilter, load_context);
+                load_texture(atl.alpha_path, atl.alpha, _linearFilter, _clamp2edge, load_context);
                 atl.alpha->reg(CLOSURE(this, &ResAtlas::_restore), 0);
             }
         }

+ 3 - 3
oxygine/src/res/ResStarlingAtlas.cpp

@@ -156,11 +156,11 @@ namespace oxygine
 
     }
 
-    void load_texture(const std::string& file, spNativeTexture nt, bool linearFilter, LoadResourcesContext* load_context);
+    void load_texture(const std::string& file, spNativeTexture nt, bool linearFilter, bool clamp2edge, LoadResourcesContext* load_context);
 
     void ResStarlingAtlas::_restore(Restorable* r, void*)
     {
-        load_texture(_imagePath, _texture, true, &RestoreResourcesContext::instance);
+        load_texture(_imagePath, _texture, true, true, &RestoreResourcesContext::instance);
         _texture->reg(CLOSURE(this, &ResStarlingAtlas::_restore), 0);
     }
 
@@ -169,7 +169,7 @@ namespace oxygine
         if (!load_context->isNeedProceed(_texture))
             return;
 
-        load_texture(_imagePath, _texture, true, load_context);
+        load_texture(_imagePath, _texture, true, true, load_context);
         _texture->reg(CLOSURE(this, &ResStarlingAtlas::_restore), 0);
     }