Browse Source

Merge branch 'dev' of github.com:oxygine/oxygine-framework into dev

dmuratshin 9 years ago
parent
commit
78e3e6ed12

BIN
examples/Demo/data/res.xml.ox/atlas/1_0.png


BIN
examples/Demo/data/res.xml.ox/atlas/2_0.png


BIN
examples/Demo/data/res.xml.ox/atlas/3_0.png


BIN
examples/Demo/data/res.xml.ox/atlas/4_0.png


BIN
examples/Demo/data/res.xml.ox/atlas/5_0.png


File diff suppressed because it is too large
+ 0 - 0
examples/Demo/data/res.xml.ox/meta.xml


+ 0 - 112
examples/Demo/later.patch

@@ -1,112 +0,0 @@
-diff -r c6ab5032adf6 examples/Demo/data/light_fs.glsl
---- a/examples/Demo/data/light_fs.glsl	Tue Nov 25 14:09:04 2014 +0500
-+++ b/examples/Demo/data/light_fs.glsl	Tue Nov 25 14:09:14 2014 +0500
-@@ -3,10 +3,11 @@
- varying lowp vec4 result_color;
- varying mediump vec2 result_uv;
- varying mediump vec2 result_uv2;
-+varying mediump vec2 result_light;
- 
- uniform lowp sampler2D base_texture;
- uniform lowp sampler2D normal_texture;
--uniform mediump vec2 light;
-+//uniform mediump vec2 light;
- 
- void main()
- {	
-@@ -14,7 +15,7 @@
- 	lowp vec3 normal = texture2D(normal_texture, result_uv2).xyz * 2.0 - 1.0;
- 
- 
--	mediump vec3 dir = normalize(vec3(result_pos.xy, 0.0) - vec3(light, 40.0));
-+	mediump vec3 dir = normalize(vec3(result_pos.xy, 0.0) - vec3(result_light, 40.0));
- 
- 
- 	dir = vec3(-dir.x, dir.y, -dir.z);
-diff -r c6ab5032adf6 examples/Demo/data/light_vs.glsl
---- a/examples/Demo/data/light_vs.glsl	Tue Nov 25 14:09:04 2014 +0500
-+++ b/examples/Demo/data/light_vs.glsl	Tue Nov 25 14:09:14 2014 +0500
-@@ -3,6 +3,7 @@
- varying mediump vec2 result_uv;
- varying mediump vec2 result_uv2;
- varying mediump vec2 result_pos;
-+varying mediump vec2 result_light;
- 
- uniform mediump mat4 mat;
- 
-@@ -10,6 +11,7 @@
- attribute vec4 color;
- attribute vec2 uv;
- attribute vec2 uv2;
-+attribute vec2 light;
- 
- void main()
- {
-@@ -19,4 +21,5 @@
- 	result_uv2 = uv2;
- 
- 	result_pos = position.xy;
-+	result_light = light;
- }
-\ No newline at end of file
-diff -r c6ab5032adf6 examples/Demo/src/TestUserShader2.h
---- a/examples/Demo/src/TestUserShader2.h	Tue Nov 25 14:09:04 2014 +0500
-+++ b/examples/Demo/src/TestUserShader2.h	Tue Nov 25 14:09:14 2014 +0500
-@@ -23,7 +23,7 @@
- 	LightningRenderer() :_light(0, 0)
- 	{
- 		//vertex declaration with 2 pairs of UV
--		_vdecl = getDriver()->getVertexDeclaration(vertexPCT2T2::FORMAT);
-+		_vdecl = getDriver()->getVertexDeclaration(vertexPCT2T2T2::FORMAT);
- 
- 		//load vertex shader
- 		file::buffer vsdata;
-@@ -106,8 +106,27 @@
- 			_driver->setTexture(1, _normal);
- 		}
- 
--		vertexPCT2T2 v[4];		
-+		vertexPCT2T2T2 v[4];		
- 		fillQuadT2(v, srcRect, normalSrc, destRect, rs->transform, color.rgba());
-+		Vector2 light = _light;
-+		AffineTransform t = rs->transform;
-+		t.invert();
-+		t.x = 0;
-+		t.y = 0;
-+		light = t.transform(_light);
-+		Vector2 d1 = light;
-+		Vector2 d2 = light;
-+		Vector2 d3 = light;
-+		Vector2 d4 = light;
-+		v[0].u3 = d1.x;
-+		v[0].v3 = d1.y;
-+		v[1].u3 = d1.x;
-+		v[1].v3 = d1.y;
-+		v[2].u3 = d1.x;
-+		v[2].v3 = d1.y;
-+		v[3].u3 = d1.x;
-+		v[3].v3 = d1.y;
-+
- 		_vertices.insert(_vertices.end(), (unsigned char*)v, (unsigned char*)v + sizeof(v));
- 		_checkDrawBatch();
- 	}
-@@ -160,7 +179,9 @@
- 		AnimationFrame frame = resources.getResAnim("normal")->getFrame(0);
- 		spSprite spr = new Sprite2(frame);
- 		spr->setResAnim(resources.getResAnim("tiled"));
--		spr->setPosition(content->getSize() / 2 - spr->getSize() / 2);
-+		spr->setAnchor(Vector2(0.5f, 0.5f));
-+		spr->setPosition(content->getSize() / 2);
-+		spr->addTween(Actor::TweenRotation(MATH_PI * 2), 25000, -1);
- 		spr->attachTo(lightning);
- 		
- 
-@@ -170,7 +191,7 @@
- 		light->setResAnim(resources.getResAnim("light"));
- 		light->setAnchor(0.5f, 0.5f);
- 		drag.init(light.get());
--		light->setPosition(getSize() / 2);
-+		light->setPosition(getSize() / 2 - Vector2(100, 0));
- 
- 		lightning->addChild(light);
- 	}

+ 1 - 5
examples/Demo/src/TestUserShader2.h

@@ -80,11 +80,7 @@ public:
         size_t indices = (count * 3) / 2;
 
         driver->setTexture(0, _base);
-
-        if (indices <= STDRenderer::indices8.size())
-            driver->draw(IVideoDriver::PT_TRIANGLES, _vdecl, &_vertices.front(), (unsigned int)count, &STDRenderer::indices8.front(), (unsigned int)indices, false);
-        else
-            driver->draw(IVideoDriver::PT_TRIANGLES, _vdecl, &_vertices.front(), (unsigned int)count, &STDRenderer::indices16.front(), (unsigned int)indices, true);
+        driver->draw(IVideoDriver::PT_TRIANGLES, _vdecl, &_vertices.front(), (unsigned int)count, &STDRenderer::indices16.front(), (unsigned int)indices);
 
         _vertices.clear();
     }

+ 4 - 2
examples/Demo/src/example.cpp

@@ -27,6 +27,7 @@
 #include "TestColorFont.h"
 #include "TestSignedDistanceFont.h"
 #include "TestTweenPostProcessing.h"
+#include "TestEdges.h"
 
 #ifdef __S3E__
 #include "s3eKeyboard.h"
@@ -73,8 +74,8 @@ public:
         addButton("sliding", "Sliding Actor");
         addButton("box9sprite", "Box9 Sprite");
         addButton("cliprect", "ClipRect Actor");
-        addButton("usershader", "User Shader");
-        addButton("usershader2", "User Shader2");
+        addButton("usershader", "Extended UberShader");
+        addButton("usershader2", "Custom shaders and render");
         addButton("multicolorfont", "Outer Font Color");
         addButton("sdf", "Signed Distance Font");
         addButton("mask", "Mask");
@@ -134,6 +135,7 @@ public:
         if (id == "multicolorfont") showTest(new TestColorFont);
         if (id == "sdf") showTest(new TestSignedDistanceFont);
         if (id == "tweenpp") showTest(new TestTweenPostProcessing);
+        if (id == "edges") showTest(new TestEdges);
         if (id == "openbrowser")
         {
             core::execute("http://oxygine.org/");

+ 10 - 7
oxygine/src/Actor.h

@@ -65,14 +65,17 @@ namespace oxygine
         TweenOptions& ease(Tween::EASE ease) { _ease = ease; return *this; }
         TweenOptions& detach(bool detach_ = true) { _detach = detach_; return *this; }
         TweenOptions& globalEase(Tween::EASE ease) { _globalEase = ease; return *this; }
+        TweenOptions& doneCallback(const EventCallback& cb) { _callback = cb; return *this; }
 
-        timeMS  _duration;
-        timeMS  _delay;
-        Tween::EASE _ease;
-        Tween::EASE _globalEase;
-        int     _loops;
-        bool    _twoSides;
-        bool    _detach;
+
+        EventCallback   _callback;
+        timeMS          _duration;
+        timeMS          _delay;
+        Tween::EASE     _ease;
+        Tween::EASE     _globalEase;
+        int             _loops;
+        bool            _twoSides;
+        bool            _detach;
     };
 
     class Actor : public EventDispatcher, public intrusive_list_item<spActor>, public Serializable

+ 6 - 5
oxygine/src/Input.cpp

@@ -97,7 +97,7 @@ namespace oxygine
         // We can't be sure that SDL's fingerId is not 0,
         // but 0 is reserved for empty slot, so increment id by one:
         id += 1;
-        
+
         int firstEmptySlotIndex = -1;
         for (int i = 0; i < MAX_TOUCHES; ++i)
         {
@@ -105,16 +105,17 @@ namespace oxygine
 
             if (d == id)
                 return i + 1;
-            
+
             if (d == 0 && firstEmptySlotIndex == -1)
                 firstEmptySlotIndex = i;
         }
-        
-        if (firstEmptySlotIndex != -1) {
+
+        if (firstEmptySlotIndex != -1)
+        {
             _ids[firstEmptySlotIndex] = id;
             return firstEmptySlotIndex + 1;
         }
-        
+
         //log::warning("can't find touch id %d", id);
         return -1;
     }

+ 3 - 21
oxygine/src/STDRenderer.cpp

@@ -29,7 +29,6 @@ namespace oxygine
     spNativeTexture STDRenderer::white;
     spNativeTexture STDRenderer::invisible;
 
-    std::vector<unsigned char> STDRenderer::indices8;
     std::vector<unsigned short> STDRenderer::indices16;
     size_t STDRenderer::maxVertices = 0;
     UberShaderProgram STDRenderer::uberShader;
@@ -97,21 +96,8 @@ namespace oxygine
 
     void STDRenderer::initialize()
     {
-        indices8.reserve(60 * 4);
-        for (int t = 0; t < 60; t += 1)
-        {
-            int i = t * 4;
-            indices8.push_back(i + 0);
-            indices8.push_back(i + 1);
-            indices8.push_back(i + 2);
-
-            indices8.push_back(i + 2);
-            indices8.push_back(i + 1);
-            indices8.push_back(i + 3);
-        }
-
-        indices16.reserve(12000 * 6);
-        for (int t = 0; t < 12000; t += 1)
+        indices16.reserve(3000 * 6);
+        for (int t = 0; t < 3000; t += 1)
         {
             int i = t * 4;
             indices16.push_back(i + 0);
@@ -143,7 +129,6 @@ namespace oxygine
 
     void STDRenderer::release()
     {
-        indices8.clear();
         indices16.clear();
         uberShader.release();
         uberShaderBody.clear();
@@ -231,10 +216,7 @@ namespace oxygine
         size_t count = _vertices.size() / _vdecl->size;
         size_t indices = (count * 3) / 2;
 
-        if (indices <= indices8.size())
-            getDriver()->draw(IVideoDriver::PT_TRIANGLES, _vdecl, &_vertices.front(), (unsigned int)count, &indices8.front(), (unsigned int)indices, false);
-        else
-            getDriver()->draw(IVideoDriver::PT_TRIANGLES, _vdecl, &_vertices.front(), (unsigned int)count, &indices16.front(), (unsigned int)indices, true);
+        getDriver()->draw(IVideoDriver::PT_TRIANGLES, _vdecl, &_vertices.front(), (unsigned int)count, &indices16.front(), (unsigned int)indices);
 
         _vertices.clear();
     }

+ 0 - 2
oxygine/src/STDRenderer.h

@@ -30,8 +30,6 @@ namespace oxygine
 
         static UberShaderProgram uberShader;
         static std::vector<unsigned char> uberShaderBody;
-
-        static std::vector<unsigned char> indices8;
         static std::vector<unsigned short> indices16;
         static size_t maxVertices;
 

+ 1 - 0
oxygine/src/Tween.cpp

@@ -50,6 +50,7 @@ namespace oxygine
 		_delay = opt._delay;
 		_detach = opt._detach;
 		_globalEase = opt._globalEase;
+		_cbDone = opt._callback;
 
 		if (_duration <= 0)
 		{

+ 2 - 2
oxygine/src/core/VideoDriver.h

@@ -69,7 +69,7 @@ namespace oxygine
         virtual void clear(const Color& color) = 0;
         virtual void begin(const Rect& viewport, const Color* color) = 0;
         virtual void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize) = 0;
-        virtual void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize, const void* indicesData, unsigned int numIndices, bool indicesShortType) = 0;
+        virtual void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize, const unsigned short* indicesData, unsigned int numIndices) = 0;
 
         virtual void            getStats(Stats& s) const = 0;
         virtual void            getViewport(Rect& r) const = 0;
@@ -117,7 +117,7 @@ namespace oxygine
         const VertexDeclaration*    getVertexDeclaration(bvertex_format) const;
 
         void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize) {}
-        void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize, const void* indicesData, unsigned int indicesDataSize, bool indicesShortType) {}
+        void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize, const unsigned short* indicesData, unsigned int indicesDataSize) {}
 
 
         void setUniformInt(const char* id, int v) {}

+ 2 - 2
oxygine/src/core/gl/VideoDriverGLES20.cpp

@@ -133,7 +133,7 @@ namespace oxygine
         CHECKGL();
     }
 
-    void VideoDriverGLES20::draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl_, const void* vdata, unsigned int verticesDataSize, const void* indicesData, unsigned int numIndices, bool indicesShortType)
+    void VideoDriverGLES20::draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl_, const void* vdata, unsigned int verticesDataSize, const unsigned short* indicesData, unsigned int numIndices)
     {
         const VertexDeclarationGL* decl = static_cast<const VertexDeclarationGL*>(decl_);
 
@@ -147,7 +147,7 @@ namespace oxygine
             el++;
         }
 
-        glDrawElements(getPT(pt), numIndices, indicesShortType ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE, indicesData);
+        glDrawElements(getPT(pt), numIndices, GL_UNSIGNED_SHORT, indicesData);
 
         el = decl->elements;
         for (int i = 0; i < decl->numElements; ++i)

+ 1 - 1
oxygine/src/core/gl/VideoDriverGLES20.h

@@ -26,7 +26,7 @@ namespace oxygine
         ShaderProgram*  getShaderProgram() const OVERRIDE { return _p; }
 
         void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize);
-        void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize, const void* indicesData, unsigned int indicesDataSize, bool indicesShortType);
+        void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize, const unsigned short* indicesData, unsigned int numIndices);
         void setDefaultSettings();
 
         void setViewport(const Rect& viewport);

File diff suppressed because it is too large
+ 0 - 1
oxygine/src/core/system_data.cpp


+ 5 - 6
oxygine/src/dev_tools/TreeInspectorPreview.h

@@ -22,7 +22,7 @@ namespace oxygine
     public:
         struct cached_batch
         {
-            cached_batch(): program(0), vdecl(0), indicesShortType(false), numVertices(0), numIndices(0), blendSrc(IVideoDriver::BT_ONE), blendDest(IVideoDriver::BT_ONE)
+            cached_batch(): program(0), vdecl(0), numVertices(0), numIndices(0), blendSrc(IVideoDriver::BT_ONE), blendDest(IVideoDriver::BT_ONE)
             {
                 memset(states, 0, sizeof(states));
             }
@@ -34,12 +34,11 @@ namespace oxygine
             const VertexDeclaration* vdecl;
             PRIMITIVE_TYPE pt;
             std::vector<char> vertices;
-            std::vector<char> indices;
+            std::vector<unsigned short> indices;
             int numVertices;
             int numIndices;
             unsigned int states[STATE_NUM];
             BLEND_TYPE blendSrc, blendDest;
-            bool indicesShortType;
         };
 
         typedef std::vector<cached_batch> batches;
@@ -111,14 +110,14 @@ namespace oxygine
 
         }
 
-        void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData,  unsigned int numVertices, const void* indicesData, unsigned int numIndices, bool indicesShortType)
+        void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData,  unsigned int numVertices, const unsigned short* indicesData, unsigned int numIndices)
         {
             current().vdecl = decl;
             current().pt = pt;
             current().numVertices = numVertices;
             current().numIndices = numIndices;
             current().vertices.assign((const char*)verticesData, (const char*)verticesData + decl->size * numVertices);
-            current().indices.assign((const char*)indicesData, (const char*)indicesData + numIndices * (indicesShortType ? 2 : 1));
+            current().indices.assign(indicesData, indicesData + numIndices);
 
             const vertexPCT2* v = (const vertexPCT2*)(&current().vertices.front());
             if (_batches.size() == 1)
@@ -169,7 +168,7 @@ namespace oxygine
                 for (int i = 0; i < STATE_NUM; ++i)
                     instance->setState((STATE)i, b.states[i]);
                 if (b.numIndices)
-                    instance->draw(b.pt, b.vdecl, &modified.front(), b.numVertices, &b.indices.front(), b.numIndices, b.indicesShortType);
+                    instance->draw(b.pt, b.vdecl, &modified.front(), b.numVertices, &b.indices.front(), b.numIndices);
                 else
                     instance->draw(b.pt, b.vdecl, &modified.front(), b.numVertices);
             }

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

@@ -160,8 +160,10 @@ namespace oxygine
         spMemoryTexture mt = new MemoryTexture;
         Rect bounds = ad.atlas.getBounds();
 
-        int w = nextPOT(bounds.getRight());
-        int h = nextPOT(bounds.getBottom());
+        //int w = nextPOT(bounds.getRight());
+        //int h = nextPOT(bounds.getBottom());
+        int w = bounds.getRight();
+        int h = bounds.getBottom();
 
         mt->init(ad.mt.lock().getRect(Rect(0, 0, w, h)));
 #if 0

+ 1 - 1
oxygine/src/res/Resources.cpp

@@ -224,7 +224,7 @@ namespace oxygine
         if (!resources_meta.empty())
         {
             int metaVersion = resources_meta.attribute("version").as_int(0);
-            OX_ASSERT(metaVersion <= 2 && "Please rebuild xmls with latest 'oxyresbuild' tool");
+            OX_ASSERT(metaVersion <= 2 && "Incompatible atlas format. Please rebuild xmls with latest 'oxyresbuild' tool or delete .ox folder from data.");
         }
 
 

+ 2 - 2
oxygine/system_data/original/system/shader.glsl

@@ -104,9 +104,9 @@ lowp vec4 get_color()
 	lowp vec4 mask = texture2D(mask_texture, uv2);
 
 #ifdef MASK_R_CHANNEL
-	lowp float mask_alpha = mask.r;	
+	lowp float mask_alpha = mask.r + 0.001;	
 #else
-	lowp float mask_alpha = mask.a;
+	lowp float mask_alpha = mask.a + 0.001;
 #endif
 
 	base = base * mask_alpha;

+ 1 - 1
oxygine/third_party/win32_mingw/pthreads/include/pthread.h

@@ -315,7 +315,7 @@ enum {
 
 #if !defined(HAVE_STRUCT_TIMESPEC)
 #define HAVE_STRUCT_TIMESPEC
-#if !defined(_TIMESPEC_DEFINED)
+#if !defined(_TIMESPEC_DEFINED) && !defined(__struct_timespec_defined)
 #define _TIMESPEC_DEFINED
 struct timespec {
         time_t tv_sec;

+ 6 - 0
tools/others/gen_xml_resources.py

@@ -58,6 +58,12 @@ def gen_xml(args):
     if not args.atlasses:
         write("\t</atlas>\n")
 
+
+    filelist = glob.glob(path + "/*.ogg")
+    for file in filelist:
+        name = os.path.split(file)[1]
+        write("\t\t<sound file='%s'/>\n" % (name))
+
     write("</resources>\n")
     dest.close()
 

+ 1 - 0
tools/others/update_examples_entry.py

@@ -20,6 +20,7 @@ items = (
     parent + "oxygine-magicparticles/example/MPHello",
     parent + "oxygine-pipeline/example/game/project/",
     parent + "oxygine-sound/examples/SoundDemo/",
+    parent + "oxygine-flow/examples/HelloFlow/",
 )
 
 

Some files were not shown because too many files changed in this diff