dmuratshin 8 vuotta sitten
vanhempi
sitoutus
b6c74504d8

+ 2 - 2
oxygine/SDL/win32/oxygine.vcxproj

@@ -206,7 +206,7 @@
     <ClCompile Include="..\..\src\utils\stringUtils.cpp" />
     <ClCompile Include="..\..\src\math\AffineTransform.cpp" />
     <ClCompile Include="..\..\src\pugixml\pugixml.cpp" />
-    <ClCompile Include="..\..\src\utils\AtlasTool.cpp" />
+    <ClCompile Include="..\..\src\utils\AtlasBuilder.cpp" />
     <ClCompile Include="..\..\src\utils\ImageUtils.cpp" />
     <ClCompile Include="..\..\src\VisualStyle.cpp" />
     <ClCompile Include="..\..\src\WebImage.cpp" />
@@ -339,7 +339,7 @@
     <ClInclude Include="..\..\src\math\vector4.h" />
     <ClInclude Include="..\..\src\pugixml\pugiconfig.hpp" />
     <ClInclude Include="..\..\src\pugixml\pugixml.hpp" />
-    <ClInclude Include="..\..\src\utils\AtlasTool.h" />
+    <ClInclude Include="..\..\src\utils\AtlasBuilder.h" />
     <ClInclude Include="..\..\src\utils\ImageUtils.h" />
     <ClInclude Include="..\..\src\utils\intrusive_list.h" />
     <ClInclude Include="..\..\src\VisualStyle.h" />

+ 6 - 6
oxygine/SDL/win32/oxygine.vcxproj.filters

@@ -54,9 +54,6 @@
     <ClCompile Include="..\..\src\pugixml\pugixml.cpp">
       <Filter>src\pugi</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\src\utils\AtlasTool.cpp">
-      <Filter>src\utils</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\src\utils\ImageUtils.cpp">
       <Filter>src\utils</Filter>
     </ClCompile>
@@ -348,6 +345,9 @@
     <ClCompile Include="..\..\src\res\SingleResAnim.cpp">
       <Filter>src\res</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\utils\AtlasBuilder.cpp">
+      <Filter>src\utils</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\closure\closure.h">
@@ -386,9 +386,6 @@
     <ClInclude Include="..\..\src\pugixml\pugixml.hpp">
       <Filter>src\pugi</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\utils\AtlasTool.h">
-      <Filter>src\utils</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\src\utils\ImageUtils.h">
       <Filter>src\utils</Filter>
     </ClInclude>
@@ -749,6 +746,9 @@
     <ClInclude Include="..\..\src\oxygine-include.h">
       <Filter>src</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\utils\AtlasBuilder.h">
+      <Filter>src\utils</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="ReadMe.txt" />

+ 10 - 10
oxygine/src/STDRenderer.cpp

@@ -215,7 +215,7 @@ namespace oxygine
     }
 
 
-    void STDRenderer::_drawBatch()
+    void STDRenderer::xdrawBatch()
     {
         size_t count = _vertices.size() / _vdecl->size;
         size_t indices = (count * 3) / 2;
@@ -230,7 +230,7 @@ namespace oxygine
         if (!_vertices.empty())
         {
             preDrawBatch();
-            _drawBatch();
+            xdrawBatch();
         }
     }
 
@@ -271,7 +271,7 @@ namespace oxygine
 
     void STDRenderer::resetSettings()
     {
-        _resetSettings();
+        xresetSettings();
         _driver->setState(IVideoDriver::STATE_BLEND, 0);
         _blend = blend_disabled;
         _program = 0;
@@ -286,7 +286,7 @@ namespace oxygine
         _transform.identity();
         resetSettings();
 
-        _begin();
+        xbegin();
 
         _drawing = true;
 
@@ -321,16 +321,16 @@ namespace oxygine
 
     void STDRenderer::addVertices(const void* data, unsigned int size)
     {
-        _addVertices(data, size);
-        _checkDrawBatch();
+        xaddVertices(data, size);
+        checkDrawBatch();
     }
 
-    void STDRenderer::_addVertices(const void* data, unsigned int size)
+    void STDRenderer::xaddVertices(const void* data, unsigned int size)
     {
         _vertices.insert(_vertices.end(), (const unsigned char*)data, (const unsigned char*)data + size);
     }
 
-    void STDRenderer::_checkDrawBatch()
+    void STDRenderer::checkDrawBatch()
     {
         if (_vertices.size() / sizeof(_vdecl->size) >= maxVertices)
             drawBatch();
@@ -501,7 +501,7 @@ namespace oxygine
         _transform = tr;
     }
 
-    void STDRenderer::_begin()
+    void STDRenderer::xbegin()
     {
         _base = 0;
         _alpha = 0;
@@ -528,7 +528,7 @@ namespace oxygine
         begin();
     }
 
-    void STDRenderer::_resetSettings()
+    void STDRenderer::xresetSettings()
     {
     }
 

+ 6 - 6
oxygine/src/STDRenderer.h

@@ -67,7 +67,7 @@ namespace oxygine
 
         /**Begins rendering into RenderTexture or into primary framebuffer if rt is null*/
         void begin();
-        void begin(spNativeTexture nt, const Rect* viewport = 0);
+        void begin(spNativeTexture renderTarget, const Rect* viewport = 0);
         /**Completes started rendering and restores previous Frame Buffer.*/
         void end();
         /**initializes View + Projection matrices where TopLeft is (0,0) and RightBottom is (width, height). use flipU = true for render to texture*/
@@ -94,11 +94,11 @@ namespace oxygine
         STDRenderer* _previous;
         void setShader(ShaderProgram* prog);
 
-        void _drawBatch();
+        void xdrawBatch();
 
 
-        void _addVertices(const void* data, unsigned int size);
-        void _checkDrawBatch();
+        void xaddVertices(const void* data, unsigned int size);
+        void checkDrawBatch();
 
         std::vector<unsigned char> _vertices;
 
@@ -109,8 +109,8 @@ namespace oxygine
         Matrix _vp;
 
         virtual void preDrawBatch();
-        virtual void _begin();
-        virtual void _resetSettings();
+        virtual void xbegin();
+        virtual void xresetSettings();
         //virtual
         spNativeTexture _base;
         spNativeTexture _alpha;

+ 1 - 1
oxygine/src/oxygine-framework.h

@@ -122,7 +122,7 @@
 //tree_inspector/internal/
 
 //utils/
-#include "utils/AtlasTool.h"
+#include "utils/AtlasBuilder.h"
 #include "utils/ImageUtils.h"
 #include "utils/intrusive_list.h"
 #include "utils/stringUtils.h"

+ 2 - 2
oxygine/src/res/ResAtlasGeneric.cpp

@@ -1,7 +1,7 @@
 #include "ResAtlasGeneric.h"
 #include "core/ImageDataOperations.h"
 #include "Image.h"
-#include "utils/AtlasTool.h"
+#include "utils/AtlasBuilder.h"
 #include "core/VideoDriver.h"
 #include "Resources.h"
 #include <stdint.h>
@@ -19,7 +19,7 @@ namespace oxygine
     {
         spNativeTexture texture;
         Image mt;
-        Atlas2 atlas;
+        AtlasBuilder atlas;
     };
 
 

+ 5 - 126
oxygine/src/utils/AtlasTool.cpp → oxygine/src/utils/AtlasBuilder.cpp

@@ -1,142 +1,21 @@
-#include "AtlasTool.h"
+#include "AtlasBuilder.h"
 #include "core/Texture.h"
 #include "Image.h"
 #include "core/ImageDataOperations.h"
 
 namespace oxygine
 {
-    AtlasNode::AtlasNode(AtlasNode* parent, const Rect& rect): _parent(parent), _rc(rect), _id(0)
-    {
-        _child[0] = 0;
-        _child[1] = 0;
-    }
-
-    AtlasNode::~AtlasNode()
-    {
-        delete _child[0];
-        delete _child[1];
-    }
-
-    AtlasNode* AtlasNode::insert(int width, int height)
-    {
-        AtlasNode* new_node = 0;
-        if (_child[0] || _child[1])
-        {
-            new_node = _child[0]->insert(width, height);
-            if (new_node)
-                return new_node;
-
-            new_node = _child[1]->insert(width, height);
-            if (new_node)
-                return new_node;
-
-            return 0;
-        }
-
-        if (_id)
-            return 0;
-
-        if (width > _rc.getWidth())
-            return 0;
-
-        if (height > _rc.getHeight())
-            return 0;
-
-        if (width == _rc.getWidth() && height == _rc.getHeight())
-            return this;
-
-        _child[0] = new AtlasNode(this, _rc);
-        _child[1] = new AtlasNode(this, _rc);
-
-        int dw = _rc.getWidth() - width;
-        int dh = _rc.getHeight() - height;
-
-        _child[0]->_rc = _rc;
-        _child[1]->_rc = _rc;
-
-        if (dw > dh)
-        {
-            _child[0]->_rc.setWidth(width);
-
-            _child[1]->_rc.setX(_rc.getX() + width);
-            _child[1]->_rc.setWidth(_rc.getWidth() - width);
-        }
-        else
-        {
-            _child[0]->_rc.setHeight(height);
-
-            _child[1]->_rc.setY(_rc.getY() + height);
-            _child[1]->_rc.setHeight(_rc.getHeight() - height);
-
-        }
-
-        return _child[0]->insert(width, height);
-    }
-
-
-    Atlas::Atlas(): _tree(0), _bounds(0, 0, 0, 0)
-    {
-
-    }
-
-    Atlas::~Atlas()
-    {
-        clean();
-    }
-
-    void Atlas::clean()
-    {
-        delete _tree;
-        _tree = 0;
-    }
-
-    void Atlas::init(int w, int h)
-    {
-        delete _tree;
-        _tree = new AtlasNode(0, Rect(0, 0, w, h));
-    }
-
-    bool Atlas::add(Texture* dest, const ImageData& src, Rect& srcRect)
-    {
-        AnimationFrame af;
-        Point offset(2, 2);
-        if (src.w == dest->getWidth())
-            offset.x = 0;
-        if (src.h == dest->getHeight())
-            offset.y = 0;
-
-        int w = src.w + offset.x;
-        int h = src.h + offset.y;
-
-        AtlasNode* node = _tree->insert(w, h);
-        if (node)
-        {
-            node->setID(1);
-            srcRect = Rect(node->getRect());
-
-            srcRect.size = srcRect.size - offset;
-            dest->updateRegion(srcRect.pos.x, srcRect.pos.y, src);
-
-            _bounds.unite(srcRect);
-
-            return true;
-        }
-
-        return false;
-    }
-
-
-    Atlas2::Atlas2() : _bounds(0, 0, 0, 0), _skipSize(3)
+    AtlasBuilder::AtlasBuilder() : _bounds(0, 0, 0, 0), _skipSize(3)
     {
 
     }
 
-    void Atlas2::clean()
+    void AtlasBuilder::clean()
     {
         _free.clear();
     }
 
-    void Atlas2::init(int w, int h, int skipSize)
+    void AtlasBuilder::init(int w, int h, int skipSize)
     {
         _skipSize = skipSize;
         _bounds = Rect(0, 0, 0, 0);
@@ -154,7 +33,7 @@ namespace oxygine
         //return a.size.y < b.size.y;
     }
 
-    bool Atlas2::add(Texture* dest, const ImageData& src, Rect& srcRect, const Point& offset_)
+    bool AtlasBuilder::add(Texture* dest, const ImageData& src, Rect& srcRect, const Point& offset_)
     {
         Point offset = offset_;
         if (dest)

+ 3 - 43
oxygine/src/utils/AtlasTool.h → oxygine/src/utils/AtlasBuilder.h

@@ -3,59 +3,19 @@
 #include "math/Rect.h"
 #include "AnimationFrame.h"
 #include <deque>
-#include <list>
+
 
 namespace oxygine
 {
-    class AtlasNode
-    {
-    public:
-        AtlasNode(AtlasNode* parent, const Rect& rect);
-        ~AtlasNode();
-
-        AtlasNode* insert(int width, int height);
-
-        const Rect& getRect()const {return _rc;}
-        void setID(int id) {_id = id;}
-
-    private:
-        AtlasNode* _parent;
-        AtlasNode* _child[2];
-        Rect _rc;
-
-        int _id;
-    };
-
     DECLARE_SMART(Texture, spTexture);
 
     class AnimationFrame;
     typedef std::vector<AnimationFrame> frames;
 
-    class Atlas
-    {
-    public:
-        Atlas();
-        ~Atlas();
-
-        void init(int w, int h);
-        bool add(Texture* dest, const ImageData& src, Rect& srcRect);
-
-        spTexture   getTexture();
-        const Rect& getBounds() const {return _bounds;}
-
-        void clean();
-
-    private:
-        Rect _bounds;
-        AtlasNode* _tree;
-    };
-
-
-
-    class Atlas2
+    class AtlasBuilder
     {
     public:
-        Atlas2();
+        AtlasBuilder();
 
         void init(int w, int h, int skipSize = 3);
         void clean();