Browse Source

- added new test edges to demo
- fixed gaps (for ResAtlasGeneric)

dmuratshin 10 years ago
parent
commit
a0266c630f

+ 1 - 0
.gitignore

@@ -54,3 +54,4 @@ oxygine/SDL/android/extension/bin/
 *.exp
 *.pdb
 */Debug_v*
+build

BIN
examples/Demo/data/images/edges.png


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

@@ -9,6 +9,7 @@
 		<image file="brush.png"/>
 		<image file="palette.png"/>		
 		<image file="snow.png"/>
+		<image file="edges.png"/>
 		
 		<image file="flower.png"/>
 		

+ 37 - 13
examples/Demo/proj.win32/Demo.vcxproj

@@ -17,8 +17,6 @@
     <ProjectName>Demo</ProjectName>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-
-
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
@@ -34,11 +32,8 @@
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
     <UseDebugLibraries>false</UseDebugLibraries>
-    
     <WholeProgramOptimization>false</WholeProgramOptimization>
     <WholeProgramOptimization Condition="'$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '14.0'">true</WholeProgramOptimization>
-    
-
     <CharacterSet>Unicode</CharacterSet>
     <PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
     <PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
@@ -58,15 +53,12 @@
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   </ImportGroup>
   <PropertyGroup Label="UserMacros" />
-
   <PropertyGroup>
     <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)_$(PlatformToolset)\</OutDir>
     <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)_$(PlatformToolset)\</IntDir>
     <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)_$(PlatformToolset)\</OutDir>
     <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)_$(PlatformToolset)\</IntDir>
   </PropertyGroup>
-
-
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>false</LinkIncremental>
   </PropertyGroup>
@@ -85,7 +77,8 @@
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies></AdditionalDependencies>
+      <AdditionalDependencies>
+      </AdditionalDependencies>
       <AdditionalLibraryDirectories>../../..//oxygine/third_party/win32/libraries;../../..//libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
     </Link>
@@ -107,20 +100,51 @@
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <AdditionalLibraryDirectories>../../..//oxygine/third_party/win32/libraries;../../..//libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
-      <AdditionalDependencies></AdditionalDependencies>
+      <AdditionalDependencies>
+      </AdditionalDependencies>
       <AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
     </Link>
   </ItemDefinitionGroup>
-  <ItemGroup>    
+  <ItemGroup>
     <ProjectReference Include="../../../\oxygine\SDL\win32\oxygine.vcxproj">
       <Project>{52411305-cfe1-4fa8-9885-5729bfc816cf}</Project>
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="../src/Counter.cpp" /><ClCompile Include="../src/entry_point.cpp" /><ClCompile Include="../src/example.cpp" /><ClCompile Include="../src/test.cpp" />
+    <ClCompile Include="../src/Counter.cpp" />
+    <ClCompile Include="../src/entry_point.cpp" />
+    <ClCompile Include="../src/example.cpp" />
+    <ClCompile Include="../src/test.cpp" />
   </ItemGroup>
   <ItemGroup>
-    <ClInclude Include="../src/Counter.h" /><ClInclude Include="../src/TestAlphaHitTest.h" /><ClInclude Include="../src/TestBox9Sprite.h" /><ClInclude Include="../src/TestClipRect.h" /><ClInclude Include="../src/TestColorFont.h" /><ClInclude Include="../src/TestCounter.h" /><ClInclude Include="../src/TestDrag.h" /><ClInclude Include="../src/TestHttp.h" /><ClInclude Include="../src/TestInputText.h" /><ClInclude Include="../src/TestManageRes.h" /><ClInclude Include="../src/TestMask.h" /><ClInclude Include="../src/TestPerf.h" /><ClInclude Include="../src/TestPolygon.h" /><ClInclude Include="../src/TestProgressBar.h" /><ClInclude Include="../src/TestRender2Texture.h" /><ClInclude Include="../src/TestSliding.h" /><ClInclude Include="../src/TestTexel2Pixel.h" /><ClInclude Include="../src/TestText.h" /><ClInclude Include="../src/TestTextureFormat.h" /><ClInclude Include="../src/TestTouches.h" /><ClInclude Include="../src/TestTweenShine.h" /><ClInclude Include="../src/TestTweenText.h" /><ClInclude Include="../src/TestTweens.h" /><ClInclude Include="../src/TestUserShader.h" /><ClInclude Include="../src/TestUserShader2.h" /><ClInclude Include="../src/example.h" /><ClInclude Include="../src/test.h" />
+    <ClInclude Include="../src/Counter.h" />
+    <ClInclude Include="../src/TestAlphaHitTest.h" />
+    <ClInclude Include="../src/TestBox9Sprite.h" />
+    <ClInclude Include="../src/TestClipRect.h" />
+    <ClInclude Include="../src/TestColorFont.h" />
+    <ClInclude Include="../src/TestCounter.h" />
+    <ClInclude Include="../src/TestDrag.h" />
+    <ClInclude Include="../src/TestHttp.h" />
+    <ClInclude Include="../src/TestInputText.h" />
+    <ClInclude Include="../src/TestManageRes.h" />
+    <ClInclude Include="../src/TestMask.h" />
+    <ClInclude Include="../src/TestPerf.h" />
+    <ClInclude Include="../src/TestPolygon.h" />
+    <ClInclude Include="../src/TestProgressBar.h" />
+    <ClInclude Include="../src/TestRender2Texture.h" />
+    <ClInclude Include="../src/TestSliding.h" />
+    <ClInclude Include="../src/TestTexel2Pixel.h" />
+    <ClInclude Include="../src/TestText.h" />
+    <ClInclude Include="../src/TestTextureFormat.h" />
+    <ClInclude Include="../src/TestTouches.h" />
+    <ClInclude Include="../src/TestTweenShine.h" />
+    <ClInclude Include="../src/TestTweenText.h" />
+    <ClInclude Include="../src/TestTweens.h" />
+    <ClInclude Include="../src/TestUserShader.h" />
+    <ClInclude Include="../src/TestUserShader2.h" />
+    <ClInclude Include="../src/example.h" />
+    <ClInclude Include="../src/test.h" />
+    <ClInclude Include="..\src\TestEdges.h" />
     <ClInclude Include="..\src\TestTweenAlphaFade.h" />
     <ClInclude Include="..\src\TestTweenGlow.h" />
   </ItemGroup>

+ 36 - 18
examples/Demo/proj.win32/Demo.vcxproj.filters

@@ -1,23 +1,41 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
+    <ClCompile Include="../src/Counter.cpp" />
+    <ClCompile Include="../src/entry_point.cpp" />
+    <ClCompile Include="../src/example.cpp" />
+    <ClCompile Include="../src/test.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="../src/Counter.h" />
+    <ClInclude Include="../src/TestAlphaHitTest.h" />
+    <ClInclude Include="../src/TestBox9Sprite.h" />
+    <ClInclude Include="../src/TestClipRect.h" />
+    <ClInclude Include="../src/TestColorFont.h" />
+    <ClInclude Include="../src/TestCounter.h" />
+    <ClInclude Include="../src/TestDrag.h" />
+    <ClInclude Include="../src/TestHttp.h" />
+    <ClInclude Include="../src/TestInputText.h" />
+    <ClInclude Include="../src/TestManageRes.h" />
+    <ClInclude Include="../src/TestMask.h" />
+    <ClInclude Include="../src/TestPerf.h" />
+    <ClInclude Include="../src/TestPolygon.h" />
+    <ClInclude Include="../src/TestProgressBar.h" />
+    <ClInclude Include="../src/TestRender2Texture.h" />
+    <ClInclude Include="../src/TestSliding.h" />
+    <ClInclude Include="../src/TestTexel2Pixel.h" />
+    <ClInclude Include="../src/TestText.h" />
+    <ClInclude Include="../src/TestTextureFormat.h" />
+    <ClInclude Include="../src/TestTouches.h" />
+    <ClInclude Include="../src/TestTweenShine.h" />
+    <ClInclude Include="../src/TestTweenText.h" />
+    <ClInclude Include="../src/TestTweens.h" />
+    <ClInclude Include="../src/TestUserShader.h" />
+    <ClInclude Include="../src/TestUserShader2.h" />
+    <ClInclude Include="../src/example.h" />
+    <ClInclude Include="../src/test.h" />
+    <ClInclude Include="..\src\TestTweenAlphaFade.h" />
+    <ClInclude Include="..\src\TestTweenGlow.h" />
+    <ClInclude Include="..\src\TestEdges.h" />
   </ItemGroup>
-    <ClInclude Include="..\src\TestTweenGlow.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="..\src\TestTweenAlphaFade.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
 </Project>

+ 31 - 0
examples/Demo/src/TestEdges.h

@@ -0,0 +1,31 @@
+#pragma once
+#include "test.h"
+class TestEdges : public Test
+{
+public:
+    TestEdges()
+    {
+
+        spSprite parent = new Sprite;
+
+        for (int y = 0; y < 3; ++y)
+            for (int x = 0; x < 3; ++x)
+            {
+                //spSprite sp = new ColorRectSprite;
+                spSprite sp = new Sprite;
+                sp->setResAnim(resources.getResAnim("edges"));
+
+                sp->setSize(100.0f, 100.0f);
+                sp->setPosition(x * 100.0f, y * 100.0f);
+                sp->attachTo(parent);
+            }
+
+        content->addChild(parent);
+        parent->setPosition(100.0f, 100.0f);
+        parent->setAnchor(0.5f, 0.5f);
+        parent->setSize(300.0f, 300.0f);
+        parent->addTween(Actor::TweenPosition(1000.0f, 1000.0f), 30000, -1);
+        parent->addTween(Actor::TweenRotationDegrees(360.0f), 10000, -1);
+        parent->addTween(Actor::TweenScale(1.5f), 3000, -1, true);
+    }
+};

+ 6 - 0
examples/Demo/src/example.cpp

@@ -26,6 +26,7 @@
 #include "TestTouches.h"
 #include "TestColorFont.h"
 #include "TestTweenAlphaFade.h"
+#include "TestEdges.h"
 
 #ifdef __S3E__
 #include "s3eKeyboard.h"
@@ -67,6 +68,7 @@ public:
         addButton("texture_format", "Textures Format");
         addButton("r2t", "Render to Texture");
         addButton("t2p", "Texel to Pixel");
+        addButton("edges", "Edges");
         addButton("touches", "Touches");
         addButton("sliding", "Sliding Actor");
         addButton("box9sprite", "Box9 Sprite");
@@ -156,6 +158,10 @@ public:
         {
             showTest(new TestTexel2Pixel);
         }
+        if (id == "edges")
+        {
+            showTest(new TestEdges);
+        }
 
         if (id == "touches")
         {

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

@@ -488,18 +488,24 @@ namespace oxygine
                 {
                     for (int x = 0; x < columns; ++x)
                     {
-                        Rect src;
-                        src.pos = Point(x * frame_width, y * frame_height);
-                        src.size = Point(frame_width, frame_height);
+                        Rect frameRect;
+                        frameRect.pos = Point(x * frame_width, y * frame_height);
+                        frameRect.size = Point(frame_width, frame_height);
 
-                        ImageData srcImage_ = im.getRect(src);
+                        ImageData srcImage_ = im.getRect(frameRect);
 
 
                         HitTestData adata;
-                        ImageData trimmedImage;
+                        ImageData src;
                         Rect bounds;
                         makeAlpha(srcImage_, bounds, _hitTestBuffer, adata, walker.getAlphaHitTest());
-                        trimmedImage = srcImage_.getRect(bounds);
+                        src = srcImage_.getRect(bounds);
+
+
+                        //mt.init(src.w + 4, src.h + 4, src.format);
+                        //mt.fill_zero();
+
+
 
                         Rect dest(0, 0, 0, 0);
 
@@ -509,15 +515,22 @@ namespace oxygine
                             next_atlas(w, h, tf, ad, atlas_id.c_str());
                         }
 
-                        bool s = ad.atlas.add(&ad.mt, trimmedImage, dest);
+                        bool s = ad.atlas.add(&ad.mt, src, dest);
                         if (s == false)
                         {
                             apply_atlas(ad);
                             next_atlas(w, h, tf, ad, walker.getCurrentFolder().c_str());
-                            s = ad.atlas.add(&ad.mt, trimmedImage, dest);
+                            s = ad.atlas.add(&ad.mt, src, dest);
                             OX_ASSERT(s);
                         }
 
+                        //duplicate image edges
+                        MemoryTexture& mt = ad.mt;
+                        operations::copy(src.getRect(Rect(0, 0, src.w, 1)),         mt.lock(&Rect(dest.pos.x, dest.pos.y - 1,    src.w, 1)));
+                        operations::copy(src.getRect(Rect(0, src.h - 1, src.w, 1)), mt.lock(&Rect(dest.pos.x, dest.pos.y + src.h, src.w, 1)));
+                        operations::copy(src.getRect(Rect(0, 0, 1, src.h)),         mt.lock(&Rect(dest.pos.x - 1, dest.pos.y,    1, src.h)));
+                        operations::copy(src.getRect(Rect(src.w - 1, 0, 1, src.h)), mt.lock(&Rect(dest.pos.x + src.w, dest.pos.y, 1, src.h)));
+
 
                         float iw = 1.0f;
                         float ih = 1.0f;

+ 6 - 4
oxygine/src/utils/AtlasTool.cpp

@@ -1,5 +1,7 @@
 #include "AtlasTool.h"
 #include "core/Texture.h"
+#include "MemoryTexture.h"
+#include "core/ImageDataOperations.h"
 
 namespace oxygine
 {
@@ -163,8 +165,8 @@ namespace oxygine
                 offset.y = 0;
         }
 
-        int w = src.w + offset.x;
-        int h = src.h + offset.y;
+        int w = src.w + offset.x * 2;
+        int h = src.h + offset.y * 2;
 
         Point size(w, h);
 
@@ -175,13 +177,13 @@ namespace oxygine
             {
                 Rect rect = rect_;
 
-                srcRect.pos = rect.pos;
+                srcRect.pos = rect.pos + offset;
                 srcRect.size = Point(src.w, src.h);
 
                 _bounds.unite(srcRect);
 
                 if (dest)
-                    dest->updateRegion(rect.pos.x, rect.pos.y, src);
+                    dest->updateRegion(srcRect.pos.x, srcRect.pos.y, src);
 
                 _free.erase(_free.begin() + i);