Browse Source

minor fixed
updated emscripten
added Polygon class

Denis Muratshin 11 years ago
parent
commit
225fee58cd
63 changed files with 593 additions and 187 deletions
  1. 2 2
      .hg_archival.txt
  2. BIN
      examples/Demo/data/images/tiled.png
  3. 4 0
      examples/Demo/data/xmls/res.xml
  4. 10 4
      examples/Demo/proj.emscripten/CMakeLists.txt
  5. 1 1
      examples/Demo/proj.emscripten/build.bat
  6. 1 1
      examples/Demo/proj.emscripten/build_release.bat
  7. 98 0
      examples/Demo/src/TestPolygon.h
  8. 9 48
      examples/Demo/src/TestTweens.h
  9. 7 0
      examples/Demo/src/example.cpp
  10. 11 3
      examples/DemoBox2D/proj.emscripten/CMakeLists.txt
  11. 1 1
      examples/DemoBox2D/proj.emscripten/build.bat
  12. 1 1
      examples/DemoBox2D/proj.emscripten/build_release.bat
  13. 9 3
      examples/Game/part1/proj.emscripten/CMakeLists.txt
  14. 1 1
      examples/Game/part1/proj.emscripten/build.bat
  15. 1 1
      examples/Game/part1/proj.emscripten/build_release.bat
  16. 9 3
      examples/Game/part2/proj.emscripten/CMakeLists.txt
  17. 1 1
      examples/Game/part2/proj.emscripten/build.bat
  18. 1 1
      examples/Game/part2/proj.emscripten/build_release.bat
  19. 9 3
      examples/Game/part3/proj.emscripten/CMakeLists.txt
  20. 1 1
      examples/Game/part3/proj.emscripten/build.bat
  21. 1 1
      examples/Game/part3/proj.emscripten/build_release.bat
  22. 9 3
      examples/Game/part4/proj.emscripten/CMakeLists.txt
  23. 1 1
      examples/Game/part4/proj.emscripten/build.bat
  24. 1 1
      examples/Game/part4/proj.emscripten/build_release.bat
  25. 9 3
      examples/HelloWorld/proj.emscripten/CMakeLists.txt
  26. 1 1
      examples/HelloWorld/proj.emscripten/build.bat
  27. 1 1
      examples/HelloWorld/proj.emscripten/build_release.bat
  28. 9 3
      examples/Match3/proj.emscripten/CMakeLists.txt
  29. 1 1
      examples/Match3/proj.emscripten/build.bat
  30. 1 1
      examples/Match3/proj.emscripten/build_release.bat
  31. 9 3
      examples/TutorialResources/proj.emscripten/CMakeLists.txt
  32. 1 1
      examples/TutorialResources/proj.emscripten/build.bat
  33. 1 1
      examples/TutorialResources/proj.emscripten/build_release.bat
  34. 8 0
      oxygine/SDL/ios/oxygine/oxygine_ios.xcodeproj/project.pbxproj
  35. 8 0
      oxygine/SDL/macosx/oxygine_macosx/oxygine_macosx.xcodeproj/project.pbxproj
  36. 2 0
      oxygine/SDL/win32/oxygine_vs2010.vcxproj
  37. 6 0
      oxygine/SDL/win32/oxygine_vs2010.vcxproj.filters
  38. 2 0
      oxygine/SDL/win32/oxygine_vs2013.vcxproj
  39. 6 0
      oxygine/SDL/win32/oxygine_vs2013.vcxproj.filters
  40. 6 3
      oxygine/src/Actor.cpp
  41. 6 5
      oxygine/src/InputText.cpp
  42. 2 2
      oxygine/src/InputText.h
  43. 81 0
      oxygine/src/Polygon.cpp
  44. 42 0
      oxygine/src/Polygon.h
  45. 1 1
      oxygine/src/ProgressBar.cpp
  46. 4 0
      oxygine/src/Sprite.cpp
  47. 78 49
      oxygine/src/Tweener.cpp
  48. 43 6
      oxygine/src/Tweener.h
  49. 1 1
      oxygine/src/core/FileSystem.cpp
  50. 29 6
      oxygine/src/core/Renderer.cpp
  51. 1 1
      oxygine/src/core/Renderer.h
  52. 10 2
      oxygine/src/core/ThreadMessages.cpp
  53. 1 0
      oxygine/src/core/ThreadMessages.h
  54. 2 2
      oxygine/src/core/UberShaderProgram.cpp
  55. 5 0
      oxygine/src/core/gl/ShaderProgramGL.cpp
  56. 4 1
      oxygine/src/core/oxygine.cpp
  57. 2 1
      oxygine/src/core/oxygine.h
  58. 7 4
      oxygine/src/core/vertex.h
  59. 2 2
      readme/emscripten.txt
  60. 1 0
      tools/others/gen_templates.py
  61. 9 3
      tools/templates/proj.emscripten/CMakeLists.txt
  62. 1 1
      tools/templates/proj.emscripten/build.bat
  63. 1 1
      tools/templates/proj.emscripten/build_release.bat

+ 2 - 2
.hg_archival.txt

@@ -1,5 +1,5 @@
 repo: b6d71054df5712e643a0685bc3ba54b123db5729
-node: 4c78fa96b703895db14e39fec36d8f1a958d6d1b
+node: af2151635b0568c36be7a428f8a240aec85acc0c
 branch: default
 latesttag: oldrender
-latesttagdistance: 396
+latesttagdistance: 412

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


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

@@ -19,6 +19,10 @@
 		<image file="box9.png"/>
 		<image file="box9a.png"/>
 	</atlas>
+
+	<atlas>
+		<image file="tiled.png"/>
+	</atlas>	
 	
 	<set load = "false" /> <!--do not load next atlasses by default-->
 	<atlas format="4444">

+ 10 - 4
examples/Demo/proj.emscripten/CMakeLists.txt

@@ -9,11 +9,17 @@ link_directories(${OXYGINE_LIBRARY_DIRS})
 SET(CMAKE_EXECUTABLE_SUFFIX ".html")
 set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wno-warn-absolute-paths")
 
-add_executable(Demo ../src/entry_point.cpp ../src/example.cpp ../src/test.cpp  ../src/TestBox9Sprite.h ../src/TestClipRect.h ../src/TestDrag.h ../src/TestInputText.h ../src/TestManageRes.h ../src/TestMask.h ../src/TestPerf.h ../src/TestProgressBar.h ../src/TestRender2Texture.h ../src/TestSliding.h ../src/TestTexel2Pixel.h ../src/TestText.h ../src/TestTextureFormat.h ../src/TestTweens.h ../src/TestUserShader.h ../src/example.h ../src/test.h )
+add_executable(Demo ../src/entry_point.cpp ../src/example.cpp ../src/test.cpp  ../src/TestBox9Sprite.h ../src/TestClipRect.h ../src/TestDrag.h ../src/TestInputText.h ../src/TestManageRes.h ../src/TestMask.h ../src/TestPerf.h ../src/TestPolygon.h ../src/TestProgressBar.h ../src/TestRender2Texture.h ../src/TestSliding.h ../src/TestTexel2Pixel.h ../src/TestText.h ../src/TestTextureFormat.h ../src/TestTweens.h ../src/TestUserShader.h ../src/example.h ../src/test.h )
 
-set_target_properties(Demo
-    PROPERTIES 
-    LINK_FLAGS "-s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 -s -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+if (CMAKE_BUILD_TYPE STREQUAL Debug)
+	SET(linkFlags "-g4 ")
+else() # Either MinSizeRel, RelWithDebInfo or Release, all which run with optimizations enabled.
+	SET(linkFlags "-O2 ")
+endif()
+
+set(linkFlags "${linkFlags} -s NO_EXIT_RUNTIME=1 -s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 --memory-init-file 0 -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+
+set_target_properties(Demo PROPERTIES LINK_FLAGS "${linkFlags}")
 
 target_link_libraries(Demo ${OXYGINE_CORE_LIBS})
 em_link_pre_js(Demo ${CMAKE_CURRENT_SOURCE_DIR}/data.js)

+ 1 - 1
examples/Demo/proj.emscripten/build.bat

@@ -2,6 +2,6 @@ python ../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 1 - 1
examples/Demo/proj.emscripten/build_release.bat

@@ -2,6 +2,6 @@ python ../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 98 - 0
examples/Demo/src/TestPolygon.h

@@ -0,0 +1,98 @@
+#pragma once
+#include "test.h"
+#include "Polygon.h"
+#include "res/ResAnim.h"
+#include "core/NativeTexture.h"
+#include "AnimationFrame.h"
+
+class TestPolygon: public Test
+{
+public:
+	spPolygon poly;
+	int _num;
+
+	TestPolygon() :_num(3)
+	{	
+		poly = new oxygine::Polygon;
+		poly->addTween(Actor::TweenRotation(MATH_PI * 2), 16000, -1);
+		poly->setPosition(content->getSize() / 2);
+
+		ResAnim *rs = resources.getResAnim("tiled");
+
+		//access to texture
+		//ResAnim "tiled" has only single frame and uses own separate atlas 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->setWrapMode(false);
+
+		poly->setResAnim(rs);
+
+		update(_num);
+
+		content->addChild(poly);
+
+		addButton("+1", "+1");
+	}
+
+	vertexPCT2 initVertex(const Vector2 &pos, unsigned int color)
+	{
+		vertexPCT2 v;
+		v.color = color;
+		v.x = pos.x;
+		v.y = pos.y;
+		v.z = 0;
+		v.u = v.x / 100;
+		v.v = v.y / 100;
+
+		return v;
+	}
+
+	vertexPCT2 getVertex(int i, int num)
+	{
+		float theta = 2.0f * MATH_PI / num * i;
+
+		Vector2 dir = Vector2(scalar::cos(theta), scalar::sin(theta));
+		float rad = getRoot()->getHeight() * 0.4f * (1 + scalar::sin(theta * 10)/10);
+		Vector2 p = dir * rad;
+		
+		Color c = interpolate(Color(Color::Lime), Color(Color::Red), scalar::abs(scalar::sin(theta * 3)));
+		return initVertex(p, c.rgba());
+	}
+
+	void update(int num)
+	{
+		int verticesCount = num * 4;
+
+		vertexPCT2 * vertices = new vertexPCT2[verticesCount];
+
+		vertexPCT2 *p = vertices;
+		for (int n = 0; n < num; ++n)
+		{
+			//add centered vertex
+			*p = initVertex(Vector2(0, 0), Color::White);
+			++p;
+
+			*p = getVertex(n, num);
+			++p;
+
+			*p = getVertex(n + 1, num);
+			++p;
+
+			//Oxygine uses "triangles strip" rendering mode 
+			//dublicate last vertex (degenerate triangles)
+			*p = getVertex(n + 1, num);
+			++p;
+		}
+
+		poly->setVertices(vertices, sizeof(vertexPCT2) * verticesCount, vertexPCT2::FORMAT, true);
+	}
+
+	void clicked(string id)
+	{
+		_num++;
+		update(_num);
+	}
+};

+ 9 - 48
examples/Demo/src/TestTweens.h

@@ -39,11 +39,11 @@ public:
 	spActor createEaseTest(Tween::EASE ease)
 	{
 		spColorRectSprite bg = new ColorRectSprite();
-		bg->setSize(230, 230);
+		bg->setSize(330, 230);
 		bg->setColor(Color::Gray);
 
 		spColorRectSprite parent = new ColorRectSprite();
-		parent->setSize(200, 200);
+		parent->setSize(300, 200);
 		parent->setColor(Color(230, 230, 230, 255));
 
 		float f = 0;
@@ -59,7 +59,7 @@ public:
 
 			cr->setPosition(x - 1, y - 1);
 
-			f += 0.005f;
+			f += 0.0025f;
 		}
 
 		parent->setPosition(10, 15);
@@ -78,7 +78,7 @@ public:
 		_easeGraph->setY(getHeight()/2 - _easeGraph->getHeight()/2);
 		content->addChild(_easeGraph);
 
-		updateText("ease", enum2string(_ease));
+		updateText("ease", "ease: " + ease2String(_ease));
 	}
 
 	void tweenDone(Event *event)
@@ -88,53 +88,11 @@ public:
 
 	void _addTween(spTween tween)
 	{
-		tween->setEase(_ease);
+		tween->setEase(_ease); 
 		_sprite->addTween(tween);
 		tween->addEventListener(TweenEvent::DONE, CLOSURE(this, &TweensTest::tweenDone));
 	}
-
-	string enum2string(Tween::EASE e)
-	{
-		string str = "unknown";
-		switch(_ease)
-		{
-        case Tween::ease_unknown:
-            str = "ease: unknown";
-            break;
-		case Tween::ease_linear:
-			str = "ease: linear";
-			break;
-		case Tween::ease_inExpo:
-			str = "ease: inExpo";
-			break;
-		case Tween::ease_outExpo:
-			str = "ease: outExpo";
-			break;
-		case Tween::ease_inSin:
-			str = "ease: inSin";
-			break;
-		case Tween::ease_outSin:
-			str = "ease: outSin";
-			break;
-		case Tween::ease_inCubic:
-			str = "ease: inCubic";
-			break;
-		case Tween::ease_outCubic:
-			str = "ease: outCubic";
-			break;
-		case Tween::ease_inOutBack:
-			str = "ease: inOutBack";
-			break;
-		case Tween::ease_inBack:
-			str = "ease: inBack";
-			break;
-		case Tween::ease_outBack:
-			str = "ease: outBack";
-			break;
-		}
-		return str;
-	}
-
+	
 	void clicked(string id)
 	{
 		if (id == "ease")
@@ -192,6 +150,8 @@ public:
 
 		if (id == "complete")
 		{
+			_sprite->removeTweens(true);
+			/*
 			spTween t = _sprite->getFirstTween();
 			while(t)
 			{
@@ -199,6 +159,7 @@ public:
 				t->complete();//removes self from actor
 				t = next;
 			}
+			*/
 		}
 
 	}

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

@@ -15,6 +15,7 @@
 #include "TestClipRect.h"
 #include "TestUserShader.h"
 #include "TestMask.h"
+#include "TestPolygon.h"
 #include "TestInputText.h"
 #include "core/STDFileSystem.h"
 
@@ -57,6 +58,7 @@ public:
 		addButton("cliprect", "ClipRect Actor");		
 		addButton("usershader", "User Shader");		
 		addButton("mask", "Mask");		
+		addButton("polygon", "Polygon");
 		addButton("inputtext", "Input Text");		
 		
 	}
@@ -134,6 +136,11 @@ public:
 			getStage()->addChild(new TestMask);
 		}
 
+		if (id == "polygon")
+		{
+			getStage()->addChild(new TestPolygon);
+		}
+
 		if (id == "inputtext")
 		{
 			getStage()->addChild(new TestInputText);

+ 11 - 3
examples/DemoBox2D/proj.emscripten/CMakeLists.txt

@@ -17,9 +17,17 @@ include_directories(../box2d)
 
 add_executable(DemoBox2D ${BOX2DSRC} ../src/Box2DDebugDraw.cpp ../src/entry_point.cpp ../src/example.cpp  ../src/Box2DDebugDraw.h ../src/example.h )
 
-set_target_properties(DemoBox2D
-    PROPERTIES 
-    LINK_FLAGS "-s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 -s -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+
+
+if (CMAKE_BUILD_TYPE STREQUAL Debug)
+	SET(linkFlags "-g4 ")
+else() # Either MinSizeRel, RelWithDebInfo or Release, all which run with optimizations enabled.
+	SET(linkFlags "-O2 ")
+endif()
+
+set(linkFlags "${linkFlags} -s NO_EXIT_RUNTIME=1 -s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 --memory-init-file 0 -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+
+set_target_properties(DemoBox2D PROPERTIES LINK_FLAGS "${linkFlags}")
 
 target_link_libraries(DemoBox2D ${OXYGINE_CORE_LIBS})
 em_link_pre_js(DemoBox2D ${CMAKE_CURRENT_SOURCE_DIR}/data.js)

+ 1 - 1
examples/DemoBox2D/proj.emscripten/build.bat

@@ -2,6 +2,6 @@ python ../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 1 - 1
examples/DemoBox2D/proj.emscripten/build_release.bat

@@ -2,6 +2,6 @@ python ../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 9 - 3
examples/Game/part1/proj.emscripten/CMakeLists.txt

@@ -11,9 +11,15 @@ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wno-warn-absolute-paths")
 
 add_executable(GamePart1 ../src/Game.cpp ../src/Joystick.cpp ../src/Player.cpp ../src/Unit.cpp ../src/entry_point.cpp ../src/example.cpp ../src/res.cpp  ../src/Game.h ../src/Joystick.h ../src/Player.h ../src/Unit.h ../src/example.h ../src/res.h )
 
-set_target_properties(GamePart1
-    PROPERTIES 
-    LINK_FLAGS "-s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 -s -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+if (CMAKE_BUILD_TYPE STREQUAL Debug)
+	SET(linkFlags "-g4 ")
+else() # Either MinSizeRel, RelWithDebInfo or Release, all which run with optimizations enabled.
+	SET(linkFlags "-O2 ")
+endif()
+
+set(linkFlags "${linkFlags} -s NO_EXIT_RUNTIME=1 -s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 --memory-init-file 0 -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+
+set_target_properties(GamePart1 PROPERTIES LINK_FLAGS "${linkFlags}")
 
 target_link_libraries(GamePart1 ${OXYGINE_CORE_LIBS})
 em_link_pre_js(GamePart1 ${CMAKE_CURRENT_SOURCE_DIR}/data.js)

+ 1 - 1
examples/Game/part1/proj.emscripten/build.bat

@@ -2,6 +2,6 @@ python ../../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 1 - 1
examples/Game/part1/proj.emscripten/build_release.bat

@@ -2,6 +2,6 @@ python ../../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 9 - 3
examples/Game/part2/proj.emscripten/CMakeLists.txt

@@ -11,9 +11,15 @@ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wno-warn-absolute-paths")
 
 add_executable(GamePart2 ../src/Enemy.cpp ../src/Game.cpp ../src/Joystick.cpp ../src/Player.cpp ../src/Rocket.cpp ../src/Unit.cpp ../src/entry_point.cpp ../src/example.cpp ../src/res.cpp  ../src/Enemy.h ../src/Game.h ../src/Joystick.h ../src/Player.h ../src/Rocket.h ../src/Unit.h ../src/example.h ../src/res.h )
 
-set_target_properties(GamePart2
-    PROPERTIES 
-    LINK_FLAGS "-s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 -s -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+if (CMAKE_BUILD_TYPE STREQUAL Debug)
+	SET(linkFlags "-g4 ")
+else() # Either MinSizeRel, RelWithDebInfo or Release, all which run with optimizations enabled.
+	SET(linkFlags "-O2 ")
+endif()
+
+set(linkFlags "${linkFlags} -s NO_EXIT_RUNTIME=1 -s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 --memory-init-file 0 -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+
+set_target_properties(GamePart2 PROPERTIES LINK_FLAGS "${linkFlags}")
 
 target_link_libraries(GamePart2 ${OXYGINE_CORE_LIBS})
 em_link_pre_js(GamePart2 ${CMAKE_CURRENT_SOURCE_DIR}/data.js)

+ 1 - 1
examples/Game/part2/proj.emscripten/build.bat

@@ -2,6 +2,6 @@ python ../../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 1 - 1
examples/Game/part2/proj.emscripten/build_release.bat

@@ -2,6 +2,6 @@ python ../../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 9 - 3
examples/Game/part3/proj.emscripten/CMakeLists.txt

@@ -11,9 +11,15 @@ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wno-warn-absolute-paths")
 
 add_executable(GamePart3 ../src/Enemy.cpp ../src/Game.cpp ../src/GameScene.cpp ../src/Joystick.cpp ../src/MainMenuScene.cpp ../src/MyButton.cpp ../src/Player.cpp ../src/Rocket.cpp ../src/Scene.cpp ../src/Unit.cpp ../src/entry_point.cpp ../src/example.cpp ../src/res.cpp  ../src/Enemy.h ../src/Game.h ../src/GameScene.h ../src/Joystick.h ../src/MainMenuScene.h ../src/MyButton.h ../src/Player.h ../src/Rocket.h ../src/Scene.h ../src/Unit.h ../src/example.h ../src/res.h )
 
-set_target_properties(GamePart3
-    PROPERTIES 
-    LINK_FLAGS "-s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 -s -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+if (CMAKE_BUILD_TYPE STREQUAL Debug)
+	SET(linkFlags "-g4 ")
+else() # Either MinSizeRel, RelWithDebInfo or Release, all which run with optimizations enabled.
+	SET(linkFlags "-O2 ")
+endif()
+
+set(linkFlags "${linkFlags} -s NO_EXIT_RUNTIME=1 -s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 --memory-init-file 0 -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+
+set_target_properties(GamePart3 PROPERTIES LINK_FLAGS "${linkFlags}")
 
 target_link_libraries(GamePart3 ${OXYGINE_CORE_LIBS})
 em_link_pre_js(GamePart3 ${CMAKE_CURRENT_SOURCE_DIR}/data.js)

+ 1 - 1
examples/Game/part3/proj.emscripten/build.bat

@@ -2,6 +2,6 @@ python ../../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 1 - 1
examples/Game/part3/proj.emscripten/build_release.bat

@@ -2,6 +2,6 @@ python ../../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 9 - 3
examples/Game/part4/proj.emscripten/CMakeLists.txt

@@ -11,9 +11,15 @@ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wno-warn-absolute-paths")
 
 add_executable(GamePart4 ../src/Enemy.cpp ../src/Game.cpp ../src/GameMenu.cpp ../src/GameScene.cpp ../src/Joystick.cpp ../src/MainMenuScene.cpp ../src/MyButton.cpp ../src/Player.cpp ../src/Rocket.cpp ../src/Scene.cpp ../src/Unit.cpp ../src/entry_point.cpp ../src/example.cpp ../src/res.cpp  ../src/Enemy.h ../src/Game.h ../src/GameMenu.h ../src/GameScene.h ../src/Joystick.h ../src/MainMenuScene.h ../src/MyButton.h ../src/Player.h ../src/Rocket.h ../src/Scene.h ../src/Unit.h ../src/example.h ../src/res.h )
 
-set_target_properties(GamePart4
-    PROPERTIES 
-    LINK_FLAGS "-s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 -s -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+if (CMAKE_BUILD_TYPE STREQUAL Debug)
+	SET(linkFlags "-g4 ")
+else() # Either MinSizeRel, RelWithDebInfo or Release, all which run with optimizations enabled.
+	SET(linkFlags "-O2 ")
+endif()
+
+set(linkFlags "${linkFlags} -s NO_EXIT_RUNTIME=1 -s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 --memory-init-file 0 -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+
+set_target_properties(GamePart4 PROPERTIES LINK_FLAGS "${linkFlags}")
 
 target_link_libraries(GamePart4 ${OXYGINE_CORE_LIBS})
 em_link_pre_js(GamePart4 ${CMAKE_CURRENT_SOURCE_DIR}/data.js)

+ 1 - 1
examples/Game/part4/proj.emscripten/build.bat

@@ -2,6 +2,6 @@ python ../../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 1 - 1
examples/Game/part4/proj.emscripten/build_release.bat

@@ -2,6 +2,6 @@ python ../../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 9 - 3
examples/HelloWorld/proj.emscripten/CMakeLists.txt

@@ -11,9 +11,15 @@ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wno-warn-absolute-paths")
 
 add_executable(HelloWorld ../src/entry_point.cpp ../src/example.cpp  ../src/example.h )
 
-set_target_properties(HelloWorld
-    PROPERTIES 
-    LINK_FLAGS "-s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 -s -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+if (CMAKE_BUILD_TYPE STREQUAL Debug)
+	SET(linkFlags "-g4 ")
+else() # Either MinSizeRel, RelWithDebInfo or Release, all which run with optimizations enabled.
+	SET(linkFlags "-O2 ")
+endif()
+
+set(linkFlags "${linkFlags} -s NO_EXIT_RUNTIME=1 -s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 --memory-init-file 0 -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+
+set_target_properties(HelloWorld PROPERTIES LINK_FLAGS "${linkFlags}")
 
 target_link_libraries(HelloWorld ${OXYGINE_CORE_LIBS})
 em_link_pre_js(HelloWorld ${CMAKE_CURRENT_SOURCE_DIR}/data.js)

+ 1 - 1
examples/HelloWorld/proj.emscripten/build.bat

@@ -2,6 +2,6 @@ python ../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 1 - 1
examples/HelloWorld/proj.emscripten/build_release.bat

@@ -2,6 +2,6 @@ python ../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 9 - 3
examples/Match3/proj.emscripten/CMakeLists.txt

@@ -11,9 +11,15 @@ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wno-warn-absolute-paths")
 
 add_executable(Match3 ../src/entry_point.cpp ../src/example.cpp ../src/gameframe.cpp ../src/jewels.cpp ../src/shared.cpp  ../src/example.h ../src/gameframe.h ../src/jewels.h ../src/shared.h )
 
-set_target_properties(Match3
-    PROPERTIES 
-    LINK_FLAGS "-s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 -s -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+if (CMAKE_BUILD_TYPE STREQUAL Debug)
+	SET(linkFlags "-g4 ")
+else() # Either MinSizeRel, RelWithDebInfo or Release, all which run with optimizations enabled.
+	SET(linkFlags "-O2 ")
+endif()
+
+set(linkFlags "${linkFlags} -s NO_EXIT_RUNTIME=1 -s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 --memory-init-file 0 -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+
+set_target_properties(Match3 PROPERTIES LINK_FLAGS "${linkFlags}")
 
 target_link_libraries(Match3 ${OXYGINE_CORE_LIBS})
 em_link_pre_js(Match3 ${CMAKE_CURRENT_SOURCE_DIR}/data.js)

+ 1 - 1
examples/Match3/proj.emscripten/build.bat

@@ -2,6 +2,6 @@ python ../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 1 - 1
examples/Match3/proj.emscripten/build_release.bat

@@ -2,6 +2,6 @@ python ../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 9 - 3
examples/TutorialResources/proj.emscripten/CMakeLists.txt

@@ -11,9 +11,15 @@ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wno-warn-absolute-paths")
 
 add_executable(TutorialResources ../src/entry_point.cpp ../src/example.cpp  ../src/example.h )
 
-set_target_properties(TutorialResources
-    PROPERTIES 
-    LINK_FLAGS "-s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 -s -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+if (CMAKE_BUILD_TYPE STREQUAL Debug)
+	SET(linkFlags "-g4 ")
+else() # Either MinSizeRel, RelWithDebInfo or Release, all which run with optimizations enabled.
+	SET(linkFlags "-O2 ")
+endif()
+
+set(linkFlags "${linkFlags} -s NO_EXIT_RUNTIME=1 -s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 --memory-init-file 0 -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+
+set_target_properties(TutorialResources PROPERTIES LINK_FLAGS "${linkFlags}")
 
 target_link_libraries(TutorialResources ${OXYGINE_CORE_LIBS})
 em_link_pre_js(TutorialResources ${CMAKE_CURRENT_SOURCE_DIR}/data.js)

+ 1 - 1
examples/TutorialResources/proj.emscripten/build.bat

@@ -2,6 +2,6 @@ python ../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 1 - 1
examples/TutorialResources/proj.emscripten/build_release.bat

@@ -2,6 +2,6 @@ python ../../..//tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 8 - 0
oxygine/SDL/ios/oxygine/oxygine_ios.xcodeproj/project.pbxproj

@@ -49,6 +49,8 @@
 		04B3A71A18A65668004C67E3 /* InputText.h in Headers */ = {isa = PBXBuildFile; fileRef = 04B3A71818A65668004C67E3 /* InputText.h */; };
 		04D6FB4C1851914000A5403A /* ThreadMessages.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 04D6FB4A1851914000A5403A /* ThreadMessages.cpp */; };
 		04D6FB4D1851914000A5403A /* ThreadMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 04D6FB4B1851914000A5403A /* ThreadMessages.h */; };
+		92214D6419F14A2F00A4459A /* Polygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 92214D6219F14A2F00A4459A /* Polygon.cpp */; };
+		92214D6519F14A2F00A4459A /* Polygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 92214D6319F14A2F00A4459A /* Polygon.h */; };
 		C38704A617C0C71700015CA8 /* VideoDriverGLES20.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C38704A417C0C71700015CA8 /* VideoDriverGLES20.cpp */; };
 		C38704A717C0C71700015CA8 /* VideoDriverGLES20.h in Headers */ = {isa = PBXBuildFile; fileRef = C38704A517C0C71700015CA8 /* VideoDriverGLES20.h */; };
 		C38EC22C1709600E00568283 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C38EC22B1709600E00568283 /* OpenGLES.framework */; };
@@ -246,6 +248,8 @@
 		04B3A71818A65668004C67E3 /* InputText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InputText.h; path = ../../../src/InputText.h; sourceTree = "<group>"; };
 		04D6FB4A1851914000A5403A /* ThreadMessages.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadMessages.cpp; sourceTree = "<group>"; };
 		04D6FB4B1851914000A5403A /* ThreadMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadMessages.h; sourceTree = "<group>"; };
+		92214D6219F14A2F00A4459A /* Polygon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Polygon.cpp; path = ../../../src/Polygon.cpp; sourceTree = "<group>"; };
+		92214D6319F14A2F00A4459A /* Polygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Polygon.h; path = ../../../src/Polygon.h; sourceTree = "<group>"; };
 		C38704A417C0C71700015CA8 /* VideoDriverGLES20.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VideoDriverGLES20.cpp; path = gl/VideoDriverGLES20.cpp; sourceTree = "<group>"; };
 		C38704A517C0C71700015CA8 /* VideoDriverGLES20.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VideoDriverGLES20.h; path = gl/VideoDriverGLES20.h; sourceTree = "<group>"; };
 		C38EC22B1709600E00568283 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
@@ -476,6 +480,8 @@
 		C3E86F5316EBC8C200052915 /* src */ = {
 			isa = PBXGroup;
 			children = (
+				92214D6219F14A2F00A4459A /* Polygon.cpp */,
+				92214D6319F14A2F00A4459A /* Polygon.h */,
 				048AD0C919B1FD74001963EF /* Stage.cpp */,
 				048AD0CA19B1FD74001963EF /* Stage.h */,
 				048AD0A8197D2444001963EF /* TextField.cpp */,
@@ -837,6 +843,7 @@
 				C3E8707916EBC8EB00052915 /* TextActor.h in Headers */,
 				C3E8707A16EBC8EB00052915 /* TextStyle.h in Headers */,
 				C3E8708416EBC8EB00052915 /* Tweener.h in Headers */,
+				92214D6519F14A2F00A4459A /* Polygon.h in Headers */,
 				C3E8708516EBC8EB00052915 /* UpdateState.h in Headers */,
 				C3E8708716EBC8EB00052915 /* AtlasTool.h in Headers */,
 				C3E8708916EBC8EB00052915 /* ImageUtils.h in Headers */,
@@ -983,6 +990,7 @@
 				C3E8709116EBC8EB00052915 /* winnie_alloc.cpp in Sources */,
 				048AD0AA197D2444001963EF /* TextField.cpp in Sources */,
 				C38EC26F1709649300568283 /* DeveloperMenu.cpp in Sources */,
+				92214D6419F14A2F00A4459A /* Polygon.cpp in Sources */,
 				C38EC2711709649300568283 /* TexturesInspector.cpp in Sources */,
 				C38EC2731709649300568283 /* TreeInspector.cpp in Sources */,
 				0467086E192796E500D71824 /* Serialize.cpp in Sources */,

+ 8 - 0
oxygine/SDL/macosx/oxygine_macosx/oxygine_macosx.xcodeproj/project.pbxproj

@@ -199,6 +199,8 @@
 		049B57241871F21E00EF3C66 /* winnie_alloc_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 049B56641871F21E00EF3C66 /* winnie_alloc_config.h */; };
 		04B3A71F18A6594D004C67E3 /* InputText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 04B3A71D18A6594D004C67E3 /* InputText.cpp */; };
 		04B3A72018A6594D004C67E3 /* InputText.h in Headers */ = {isa = PBXBuildFile; fileRef = 04B3A71E18A6594D004C67E3 /* InputText.h */; };
+		92214D5E19F149BC00A4459A /* Polygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 92214D5C19F149BC00A4459A /* Polygon.cpp */; };
+		92214D5F19F149BC00A4459A /* Polygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 92214D5D19F149BC00A4459A /* Polygon.h */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
@@ -403,6 +405,8 @@
 		049B56641871F21E00EF3C66 /* winnie_alloc_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = winnie_alloc_config.h; sourceTree = "<group>"; };
 		04B3A71D18A6594D004C67E3 /* InputText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InputText.cpp; path = ../../../src/InputText.cpp; sourceTree = "<group>"; };
 		04B3A71E18A6594D004C67E3 /* InputText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InputText.h; path = ../../../src/InputText.h; sourceTree = "<group>"; };
+		92214D5C19F149BC00A4459A /* Polygon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Polygon.cpp; path = ../../../src/Polygon.cpp; sourceTree = "<group>"; };
+		92214D5D19F149BC00A4459A /* Polygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Polygon.h; path = ../../../src/Polygon.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -435,6 +439,8 @@
 		049B55901871F21000EF3C66 /* src */ = {
 			isa = PBXGroup;
 			children = (
+				92214D5C19F149BC00A4459A /* Polygon.cpp */,
+				92214D5D19F149BC00A4459A /* Polygon.h */,
 				048AD0CF19B1FE96001963EF /* Stage.cpp */,
 				048AD0D019B1FE96001963EF /* Stage.h */,
 				048AD0A2197D238D001963EF /* TextField.cpp */,
@@ -831,6 +837,7 @@
 				049B56931871F21E00EF3C66 /* logging.h in Headers */,
 				049B56E81871F21E00EF3C66 /* Multithreading.h in Headers */,
 				049B56C71871F21E00EF3C66 /* TreeInspectorPage.h in Headers */,
+				92214D5F19F149BC00A4459A /* Polygon.h in Headers */,
 				049B56B31871F21E00EF3C66 /* ThreadMessages.h in Headers */,
 				049B568D1871F21E00EF3C66 /* ImageData.h in Headers */,
 				049B57211871F21E00EF3C66 /* system_alloc.h in Headers */,
@@ -977,6 +984,7 @@
 				049B569A1871F21E00EF3C66 /* NativeTexture.cpp in Sources */,
 				049B56FF1871F21E00EF3C66 /* Resource.cpp in Sources */,
 				049B56D61871F21E00EF3C66 /* AffineTransform.cpp in Sources */,
+				92214D5E19F149BC00A4459A /* Polygon.cpp in Sources */,
 				049B568A1871F21E00EF3C66 /* VideoDriverGLES20.cpp in Sources */,
 				04670867192795E700D71824 /* Serialize.cpp in Sources */,
 				049B56CD1871F21E00EF3C66 /* EventDispatcher.cpp in Sources */,

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

@@ -146,6 +146,7 @@
     <ClCompile Include="..\..\src\minizip\unzip.c" />
     <ClCompile Include="..\..\src\Multithreading.cpp" />
     <ClCompile Include="..\..\src\PointerState.cpp" />
+    <ClCompile Include="..\..\src\Polygon.cpp" />
     <ClCompile Include="..\..\src\ProgressBar.cpp" />
     <ClCompile Include="..\..\src\res\CreateResourceContext.cpp" />
     <ClCompile Include="..\..\src\res\ResAnim.cpp" />
@@ -242,6 +243,7 @@
     <ClInclude Include="..\..\src\Multithreading.h" />
     <ClInclude Include="..\..\src\oxygine-framework.h" />
     <ClInclude Include="..\..\src\PointerState.h" />
+    <ClInclude Include="..\..\src\Polygon.h" />
     <ClInclude Include="..\..\src\ProgressBar.h" />
     <ClInclude Include="..\..\src\RenderState.h" />
     <ClInclude Include="..\..\src\res\CreateResourceContext.h" />

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

@@ -291,6 +291,9 @@
     <ClCompile Include="..\..\src\Stage.cpp">
       <Filter>src</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\Polygon.cpp">
+      <Filter>src</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\closure\closure.h">
@@ -629,6 +632,9 @@
     <ClInclude Include="..\..\src\Stage.h">
       <Filter>src</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\Polygon.h">
+      <Filter>src</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="ReadMe.txt" />

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

@@ -148,6 +148,7 @@
     <ClCompile Include="..\..\src\minizip\unzip.c" />
     <ClCompile Include="..\..\src\Multithreading.cpp" />
     <ClCompile Include="..\..\src\PointerState.cpp" />
+    <ClCompile Include="..\..\src\Polygon.cpp" />
     <ClCompile Include="..\..\src\ProgressBar.cpp" />
     <ClCompile Include="..\..\src\res\CreateResourceContext.cpp" />
     <ClCompile Include="..\..\src\res\ResAnim.cpp" />
@@ -244,6 +245,7 @@
     <ClInclude Include="..\..\src\Multithreading.h" />
     <ClInclude Include="..\..\src\oxygine-framework.h" />
     <ClInclude Include="..\..\src\PointerState.h" />
+    <ClInclude Include="..\..\src\Polygon.h" />
     <ClInclude Include="..\..\src\ProgressBar.h" />
     <ClInclude Include="..\..\src\RenderState.h" />
     <ClInclude Include="..\..\src\res\CreateResourceContext.h" />

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

@@ -289,6 +289,9 @@
     <ClCompile Include="..\..\src\Stage.cpp">
       <Filter>src</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\Polygon.cpp">
+      <Filter>src</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\closure\closure.h">
@@ -622,6 +625,9 @@
     <ClInclude Include="..\..\src\Stage.h">
       <Filter>src</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\Polygon.h">
+      <Filter>src</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="ReadMe.txt" />

+ 6 - 3
oxygine/src/Actor.cpp

@@ -473,6 +473,9 @@ namespace oxygine
 
 	void Actor::setPriority(short zorder)
 	{
+		if (_zOrder == zorder) // fixed by Evgeniy Golovin
+			return;
+
 		_zOrder = zorder;
 		if (_parent)
 		{
@@ -1095,12 +1098,12 @@ namespace oxygine
 		while (t)
 		{			
 			spTween c = t;
+			t = t->getNextSibling();
 
 			if (callComplete)
 				c->complete();
-
-			t = t->getNextSibling();
-			removeTween(c);
+			else
+				removeTween(c);
 		}
 	}
 

+ 6 - 5
oxygine/src/InputText.cpp

@@ -3,7 +3,7 @@
 #include "utils/stringUtils.h"
 #include "Input.h"
 
-#ifdef OXYGINE_SDL
+#ifndef __S3E__
 #include "SDL_keyboard.h"
 #include "SDL_events.h"
 #endif
@@ -51,7 +51,7 @@ namespace oxygine
 
 		Input::instance.addEventListener(Input::event_platform, CLOSURE(this, &InputText::_onPlatform));
 
-#ifdef OXYGINE_SDL
+#ifndef __S3E__
 		SDL_StartTextInput();
 #endif
 		//log::messageln("InputText::start  %x", this);
@@ -86,7 +86,7 @@ namespace oxygine
 
 	void InputText::stop()
 	{
-#ifdef OXYGINE_SDL
+#ifndef __S3E__
 		SDL_StopTextInput();
 #endif
 		Input::instance.removeEventListeners(this);
@@ -99,7 +99,7 @@ namespace oxygine
 
 	void InputText::_onPlatform(Event *event)
 	{
-#ifdef OXYGINE_SDL
+#ifndef __S3E__
 		_onSDLEvent((SDL_Event*)event->userData);
 #endif
 	}
@@ -146,7 +146,7 @@ namespace oxygine
 		return (int)(prev - begin);
 	}
 
-#ifdef OXYGINE_SDL
+#ifndef __S3E__
 	int InputText::_onSDLEvent(SDL_Event *event)
 	{
 		switch(event->type)
@@ -166,6 +166,7 @@ namespace oxygine
 				}
 
 				SDL_TextInputEvent &te = event->text;
+				log::messageln("text: %d %d %d %d", (int)(te.text[0]), (int)(te.text[1]), (int)(te.text[2]), (int)(te.text[3]));
 
 				int newCode = 0;
 				getNextCode(newCode, te.text);

+ 2 - 2
oxygine/src/InputText.h

@@ -3,7 +3,7 @@
 #include "EventDispatcher.h"
 #include <string>
 
-#ifdef OXYGINE_SDL
+#ifndef __S3E__
 #include "SDL.h"
 #endif
 
@@ -44,7 +44,7 @@ namespace oxygine
 
 		void _onPlatform(Event *event);
 
-#ifdef OXYGINE_SDL
+#ifndef __S3E__
 		int _onSDLEvent(SDL_Event *event);
 #endif
 	};

+ 81 - 0
oxygine/src/Polygon.cpp

@@ -0,0 +1,81 @@
+#include "Polygon.h"
+#include "Serialize.h"
+#include "RenderState.h"
+#include "core/VertexDeclaration.h"
+#include <sstream>
+
+namespace oxygine
+{
+	Polygon::Polygon() :_verticesSize(0), _verticesData(0), _bformat(0), _own(false)
+	{
+
+	}
+
+	Polygon::~Polygon()
+	{
+		if (_own)
+			delete[] _verticesData;
+	}
+
+	void Polygon::copyFrom(const Polygon &src, cloneOptions opt)
+	{
+		Sprite::copyFrom(src, opt);
+	}
+
+	void Polygon::serialize(serializedata* data)	
+	{
+		Sprite::serialize(data);
+
+		pugi::xml_node node = data->node;
+		node.set_name("Polygon");
+	}
+
+	void Polygon::deserialize(const deserializedata* data)
+	{
+		Sprite::deserialize(data);
+	}
+
+	std::string Polygon::dump(const dumpOptions &options) const
+	{
+		stringstream stream;
+		stream << "{Polygon}\n";
+
+		if (_verticesSize)
+		{
+			const VertexDeclaration *decl = IVideoDriver::instance->getVertexDeclaration(_bformat);
+			stream << "vertices=" << _verticesSize/decl->size << " ";
+		}
+
+		stream << Sprite::dump(options);
+		return stream.str();
+	}
+	
+	void Polygon::setVertices(const void* data, int size, int bformat, bool own)
+	{
+		if (_own && data != _verticesData)
+		{
+			delete[] _verticesData;
+		}
+
+		_own = own;
+		_bformat = bformat;
+		_verticesData = reinterpret_cast<const unsigned char*>(data);
+		_verticesSize = size;
+	}
+	
+	void Polygon::doRender(const RenderState &rs)
+	{
+		if (!_verticesSize)
+			return;
+
+		//Sprite
+		_vstyle._apply(rs);
+		const Diffuse &df = _frame.getDiffuse();
+		
+		//if (df.base)
+		{
+			rs.renderer->setDiffuse(df);
+			rs.renderer->draw(_verticesData, _verticesSize, _bformat, true);
+		}
+	}
+}

+ 42 - 0
oxygine/src/Polygon.h

@@ -0,0 +1,42 @@
+#pragma once
+#include "oxygine_include.h"
+#include "Sprite.h"
+
+namespace oxygine
+{
+	class ResAnim;
+
+	DECLARE_SMART(Polygon, spPolygon);
+	class Polygon : public Sprite
+	{
+	public:		
+		DECLARE_COPYCLONE_NEW(Polygon);
+		typedef std::vector<vertexPCT2> vertices;
+
+		Polygon();
+		~Polygon();
+
+		/**Sets vertices for drawing*/
+		//void setVertices(const vertices &vert);
+		/**Sets vertices for drawing. You should control data and delete buffer youself.*/
+		//void setVertices(const vertexPCT2* data, int num);
+
+		void setVertices(const void* data, int size, int bformat, bool own);
+
+		/**sets vertices for drawing by using std::swap with argument.*/
+		//void setVerticesAndSwap(vertices &vert);
+
+		void serialize(serializedata* data);
+		void deserialize(const deserializedata* data);
+
+		std::string dump(const dumpOptions &) const;
+
+	protected:		
+		void doRender(const RenderState &rs);
+
+		bool _own;
+		const unsigned char *_verticesData;
+		int _verticesSize;
+		int _bformat;
+	};
+}

+ 1 - 1
oxygine/src/ProgressBar.cpp

@@ -298,7 +298,7 @@ namespace oxygine
 				fill_tex_coord(*pv, rgba, p2, u2, v2);			
 				pv++;
 
-				rs.renderer->draw(vertices, sizeof(vertices), VERTEX_PCT2);			
+				rs.renderer->draw(vertices, sizeof(vertices), vertexPCT2::FORMAT, false);			
 			}
 		}
 	}

+ 4 - 0
oxygine/src/Sprite.cpp

@@ -134,7 +134,11 @@ namespace oxygine
 	{		
 		_vstyle._apply(rs);
 		const Diffuse &df = _frame.getDiffuse();
+#ifdef EMSCRIPTEN
+		if (df.base && df.base->getHandle())
+#else
 		if (df.base)
+#endif
 		{
 			rs.renderer->setDiffuse(df);
 

+ 78 - 49
oxygine/src/Tweener.cpp

@@ -48,68 +48,97 @@ namespace oxygine
 		addEventListener(TweenEvent::DONE, cb);
 	}
 
-	float Tween::calcEase(EASE ease, float v)
+	static float outBounce(float t)
+	{
+		if (t < 0.363636363636f){
+			return 7.5625f * t * t;
+		}
+		if (t < 0.727272727273f) {
+			t = t - 0.545454545455f;
+			return 7.5625f * t * t + 0.75f;
+		}
+		if (t < 0.909090909091f) {
+			t = t - 0.818181818182f;
+			return 7.5625f * t * t + 0.9375f;
+		}
+		t = t - 0.954545454545f;
+		return 7.5625f * t * t + 0.984375f;
+	}
+
+
+	float Tween::calcEase(EASE ease, float t)
 	{
-		float vi;
-		float r = 0;
 		const float s = 1.70158f;
 
-		switch(ease)
+		switch (ease)
 		{
 		case ease_linear:
-			r = v;
-			break;
-		case ease_inExpo:
-			r = powf(2.0f, 10.0f * (v - 1.0f));
-			break;
-		case ease_outExpo:
-			r = 1.0f - powf(2.0f, -10.0f * v);
-			break;
-		case ease_inSin:
-			r = 1.0f - scalar::cos(v * (MATH_PI/2.0f));
-			break;
-		case ease_outSin:
-			r = scalar::sin(v * (MATH_PI/2.0f));
-			break;
-		case ease_inCubic:
-			r = v * v * v;
-			break;
-		case ease_outCubic:			
-			vi = v - 1.0f;
-			r = vi * vi * vi + 1.0f;
-			break;
-		case ease_inOutBack:		
-			{
-				const float s15 = s * 1.525f;
+			return t;
+
+#define DEF_EASY_FROM_IN(EasyPost, formula) \
+		case ease_in ## EasyPost: \
+			return (formula); \
+		case ease_out ## EasyPost: \
+			return 1 - calcEase(ease_in ## EasyPost, 1 - t); \
+		case ease_inOut ## EasyPost: \
+			return t <= 0.5f ? calcEase(ease_in ## EasyPost, t * 2) / 2 : 1 - calcEase(ease_in ## EasyPost, 2 - t * 2) / 2; \
+		case ease_outIn ## EasyPost: \
+			return t <= 0.5f ? calcEase(ease_in ## EasyPost, t * 2) / 2 : 1 - calcEase(ease_in ## EasyPost, 2 - t * 2) / 2; \
+
+			DEF_EASY_FROM_IN(Quad, t * t);
+			DEF_EASY_FROM_IN(Cubic, t * t * t);
+			DEF_EASY_FROM_IN(Quart, powf(t, 4));
+			DEF_EASY_FROM_IN(Quint, powf(t, 5));
+			DEF_EASY_FROM_IN(Sin, 1.0f - scalar::cos(t * (MATH_PI / 2.0f)));
+			DEF_EASY_FROM_IN(Expo, powf(2, 10 * (t - 1)));
+			DEF_EASY_FROM_IN(Circ, -1.0f * (sqrt(1 - t * t) - 1) );
+			DEF_EASY_FROM_IN(Back, t * t * ((s + 1) * t - s));
+			DEF_EASY_FROM_IN(Bounce, 1 - outBounce(1 - t));
 
-				v *= 2;
-				if (v < 1)
-				{
-					r = v * v * ((s15 + 1) * v - s15);
-				}
-				else
-				{				
-					v-=2;
-					r = v * v * ((s15 + 1) * v + s15) + 2;
-				}
-				r /= 2;
-			}
-			break;
-		case ease_inBack:
-			r = v * v * ((s + 1) * v - s);
-			break;
-		case ease_outBack:
-			v -= 1;
-			r = v * v *((s + 1)*v + s) + 1;
-			break;
 		default:
 			OX_ASSERT(!"unsupported ease");
 			break;
 		}
 
-		return r;
+#undef DEF_EASY_FROM_IN
+
+		return t;
 	}
 
+
+	string ease2String(Tween::EASE ease)
+	{
+#define STRINGIFY(x) #x
+#define S(x) STRINGIFY(x)
+
+		switch (ease)
+		{
+		case Tween::ease_linear:
+			return "linear";
+
+#define DEF_EASY_FROM_IN(EasyPost) \
+		case Tween::ease_in ## EasyPost: \
+			return  "in" S(EasyPost);\
+		case Tween::ease_out ## EasyPost: \
+			return "out" S(EasyPost); \
+		case Tween::ease_inOut ## EasyPost: \
+			return "inOut" S(EasyPost); \
+		case Tween::ease_outIn ## EasyPost: \
+			return "outIn" S(EasyPost);
+
+			DEF_EASY_FROM_IN(Quad);
+			DEF_EASY_FROM_IN(Cubic);
+			DEF_EASY_FROM_IN(Quart);
+			DEF_EASY_FROM_IN(Quint);
+			DEF_EASY_FROM_IN(Sin);
+			DEF_EASY_FROM_IN(Expo);
+			DEF_EASY_FROM_IN(Circ);
+			DEF_EASY_FROM_IN(Back);
+			DEF_EASY_FROM_IN(Bounce);
+		}
+
+		return "unknown";
+	}
 	
 	float Tween::_calcEase(float v)
 	{

+ 43 - 6
oxygine/src/Tweener.h

@@ -120,16 +120,51 @@ namespace oxygine
 		{
 			ease_unknown,
 			ease_linear,
-			ease_inExpo,
-			ease_outExpo,
-			ease_inSin,
-			ease_outSin,
+
+			ease_inQuad,
+			ease_outQuad,
+			ease_inOutQuad,
+			ease_outInQuad,
+
 			ease_inCubic,
 			ease_outCubic,
-			
-			ease_inOutBack,
+			ease_inOutCubic,
+			ease_outInCubic,
+
+			ease_inQuart,
+			ease_outQuart,
+			ease_inOutQuart,
+			ease_outInQuart,
+
+			ease_inQuint,
+			ease_outQuint,
+			ease_inOutQuint,
+			ease_outInQuint,
+
+			ease_inSin,
+			ease_outSin,
+			ease_inOutSin,
+			ease_outInSin,
+
+			ease_inExpo,
+			ease_outExpo,
+			ease_inOutExpo,
+			ease_outInExpo,
+
+			ease_inCirc,
+			ease_outCirc,
+			ease_inOutCirc,
+			ease_outInCirc,
+
 			ease_inBack,
 			ease_outBack,
+			ease_inOutBack,
+			ease_outInBack,
+
+			ease_inBounce,
+			ease_outBounce,
+			ease_inOutBounce,
+			ease_outInBounce,
 
 			ease_count
 		};
@@ -272,4 +307,6 @@ namespace oxygine
 		p->init(duration, loops, twoSides, delay, ease);
 		return p;
 	}
+
+	string ease2String(Tween::EASE ease);
 }

+ 1 - 1
oxygine/src/core/FileSystem.cpp

@@ -120,7 +120,7 @@ namespace oxygine
 
 			if (_readonly)
 			{
-				bool write = mode[0] == 'W' || mode[0] == 'w';
+				bool write = mode[0] == 'W' || mode[0] == 'w' || mode[0] == 'A' || mode[0] == 'a';
 				if (write)
 					return status_error;
 			}

+ 29 - 6
oxygine/src/core/Renderer.cpp

@@ -417,8 +417,8 @@ namespace oxygine
 			srcRect.getLeftBottom());
 
 		_mask = mask;
-		if (_vdecl->bformat != VERTEX_PCT2T2)
-			_vdecl = _driver->getVertexDeclaration(VERTEX_PCT2T2);		
+		if (_vdecl->bformat != vertexPCT2T2::FORMAT)
+			_vdecl = _driver->getVertexDeclaration(vertexPCT2T2::FORMAT);
 		_clipMask = srcRect;
 		Vector2 v(1.0f / mask->getWidth(), 1.0f / mask->getHeight());
 		_clipMask.expand(v, v);
@@ -435,7 +435,7 @@ namespace oxygine
 		_mask = 0;
 		_shaderFlags &= ~(UberShaderProgram::MASK | UberShaderProgram::MASK_R_CHANNEL);
 		_shaderFlags = 0;
-		_vdecl = _driver->getVertexDeclaration(VERTEX_PCT2);
+		_vdecl = _driver->getVertexDeclaration(vertexPCT2::FORMAT);
 	}
 
 	bool Renderer::isMasked() const
@@ -494,7 +494,14 @@ namespace oxygine
 			drawBatch();
 	}
 
-	void Renderer::draw(const void *data, int size, bvertex_format format)
+	template <class T>
+	void append(vector<unsigned char> &buff, const T &t)
+	{
+		const unsigned char *ptr = (const unsigned char *)&t;
+		buff.insert(buff.end(), ptr, ptr + sizeof(t));
+	}
+
+	void Renderer::draw(const void *data, int size, bvertex_format format, bool worldTransform)
 	{
 		if (_vdecl->bformat != format)
 		{
@@ -509,7 +516,23 @@ namespace oxygine
 			drawBatch();
 		}		
 
-		_vertices.insert(_vertices.end(), (unsigned char*)data, (unsigned char*)data + size);
+		if (worldTransform)
+		{
+			const unsigned char *ptr = (const unsigned char *)data;
+			for (int i = 0; i < num; ++i)
+			{
+				const Vector2 *pos = (Vector2 *)ptr;
+				Vector2 t = _transform.transform(*pos);
+
+				append(_vertices, t);
+				_vertices.insert(_vertices.end(), ptr + sizeof(t), ptr + sizeof(t) + _vdecl->size - sizeof(t));
+
+				ptr += _vdecl->size;
+			}
+			
+		}
+		else
+			_vertices.insert(_vertices.end(), (unsigned char*)data, (unsigned char*)data + size);
 	}
 
 	
@@ -580,7 +603,7 @@ namespace oxygine
 		_program = 0;
 
 		getDriver()->begin(viewport, clearColor);
-		_vdecl = _driver->getVertexDeclaration(VERTEX_PCT2);
+		_vdecl = _driver->getVertexDeclaration(vertexPCT2::FORMAT);
 		_base = 0;
 		_mask = 0;
 		_alpha = 0;

+ 1 - 1
oxygine/src/core/Renderer.h

@@ -199,7 +199,7 @@ namespace oxygine
 		void setPrimaryColor(const Color &);
 		/**Accumulates rectangles into batch or render it.*/
 		void draw(const RectF &srcRect, const RectF &destRect);		
-		void draw(const void *data, int size, bvertex_format format);
+		void draw(const void *data, int size, bvertex_format format, bool worldTransform = false);
 		/**Draws existing batch immediately.*/
 		void drawBatch();
 		/**Cleans existing accumulated batch.*/

+ 10 - 2
oxygine/src/core/ThreadMessages.cpp

@@ -94,7 +94,15 @@ namespace oxygine
 	bool ThreadMessages::empty()
 	{
 		MutexPthreadLock lock(_mutex);
-		return _events.empty();
+		bool v = _events.empty();
+		return v;
+	}
+
+	size_t ThreadMessages::size()
+	{
+		MutexPthreadLock lock(_mutex);
+		size_t v = _events.size();
+		return v;
 	}
 
 	void ThreadMessages::clear()
@@ -181,7 +189,7 @@ namespace oxygine
 			LOGDN("ThreadMessages::send msgid=%d already replied", msgid);	
 		}
 				
-		while (!_last._replied)		
+		while (!_last._replied || _last._id != _waitReplyID)
 		{
 			LOGDN("ThreadMessages::send msgid=%d waiting reply...", msgid);	
 			mywait(&_cond, &_mutex);

+ 1 - 0
oxygine/src/core/ThreadMessages.h

@@ -47,6 +47,7 @@ namespace oxygine
 		~ThreadMessages();
 
 		bool empty();
+		size_t size();
 		void wait();
 		void get(message &ev);
 		bool peek(message &ev, bool del);

+ 2 - 2
oxygine/src/core/UberShaderProgram.cpp

@@ -62,7 +62,7 @@ namespace oxygine
 
 		if (!s.program)
 		{
-			bvertex_format bformat = VERTEX_PCT2;
+			bvertex_format bformat = vertexPCT2::FORMAT;
 			s.flags = flags;
 			const char* data = (const char*)&_data.front();
 
@@ -84,7 +84,7 @@ namespace oxygine
 			if (flags & MASK)
 			{
 				strcat(prepend, "#define MASK\n");
-				bformat = VERTEX_PCT2T2;
+				bformat = vertexPCT2T2::FORMAT;
 			}
 
 			char *end = prepend + strlen(prepend);

+ 5 - 0
oxygine/src/core/gl/ShaderProgramGL.cpp

@@ -77,6 +77,11 @@ namespace oxygine
 		ptr++;
 #endif
 
+#ifdef EMSCRIPTEN
+		*ptr = "precision float mediump;";
+#endif
+
+
 		if (prepend)
 		{
 			*ptr = prepend;

+ 4 - 1
oxygine/src/core/oxygine.cpp

@@ -448,6 +448,9 @@ namespace oxygine
                 desc.h = 640;
             }
 
+			if (desc.fullscreen)
+				flags |= SDL_WINDOW_FULLSCREEN;
+
             log::messageln("creating window %d %d", desc.w, desc.h);
 
 			_window = SDL_CreateWindow(desc.title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, desc.w, desc.h, flags);
@@ -464,7 +467,7 @@ namespace oxygine
                 return;
             }
 
-			SDL_GL_SetSwapInterval(1);
+			SDL_GL_SetSwapInterval(desc.vsync ? 1 : 0);
 			
 	#else
 

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

@@ -79,11 +79,12 @@ namespace oxygine
 	{
 		struct init_desc
 		{
-			init_desc(): mode24bpp(true), w(-1), h(-1), fullscreen(false), title("Oxygine"){}
+			init_desc() : mode24bpp(true), w(-1), h(-1), fullscreen(false), title("Oxygine"), vsync(true){}
 
 			bool mode24bpp;
 			int w;
 			int h;
+			bool vsync;
 			bool fullscreen;
 			const char *title;
 		};

+ 7 - 4
oxygine/src/core/vertex.h

@@ -46,8 +46,7 @@ namespace oxygine
 		return (vertexFormat >> (TEX_COORD_SIZE_BIT + 3*stage) ) & 0x7;
 	}
 
-#define VERTEX_PCT2  (VERTEX_POSITION | VERTEX_COLOR | VERTEX_NUM_TEXCOORDS(1) | VERTEX_TEXCOORD_SIZE(0, 2))
-#define VERTEX_PCT2T2  (VERTEX_POSITION | VERTEX_COLOR | VERTEX_NUM_TEXCOORDS(2) | VERTEX_TEXCOORD_SIZE(0, 2) | VERTEX_TEXCOORD_SIZE(1, 2))
+
 
 	inline unsigned int getVertexSize(bvertex_format fmt)
 	{
@@ -78,8 +77,6 @@ namespace oxygine
 		return offset;
 	}
 
-
-
 	struct vertexP2T2
 	{
 		float x, y;		
@@ -99,6 +96,7 @@ namespace oxygine
 
 	struct vertexPCT2
 	{
+		enum { FORMAT = VERTEX_POSITION | VERTEX_COLOR | VERTEX_NUM_TEXCOORDS(1) | VERTEX_TEXCOORD_SIZE(0, 2) };
 		float x, y, z;
 		unsigned int color;
 		float u, v;				
@@ -106,6 +104,11 @@ namespace oxygine
 
 	struct vertexPCT2T2: public vertexPCT2
 	{	
+		enum { FORMAT = VERTEX_POSITION | VERTEX_COLOR | VERTEX_NUM_TEXCOORDS(2) | VERTEX_TEXCOORD_SIZE(0, 2) | VERTEX_TEXCOORD_SIZE(1, 2)};
 		float u2, v2;				
 	};
+
+#define VERTEX_PCT2 vertexPCT2::FORMAT
+#define VERTEX_PCT2T2 vertexPCT2T2::FORMAT
+
 }

+ 2 - 2
readme/emscripten.txt

@@ -11,13 +11,13 @@ how to build. Steps:
 
 - configure environment variables properly:
   EMSCRIPTEN points to Emscripten SDK folder with emcc
-  	example: d:\Emscripten\emscripten\1.16.0\   
+  	example: d:\Emscripten\emscripten\1.22.0\   
   JAVA_HOME points to JDK 
   	example: c:\Program Files (x86)\Java\jdk1.6.0_26\
 
 - add necessary paths to environment variable PATH:
   EMSCRIPTEN
-  	example: d:\Emscripten\emscripten\1.16.0\
+  	example: d:\Emscripten\emscripten\1.22.0\
   JDK 
   	example: "c:\Program Files (x86)\Java\jdk1.6.0_26\bin\"
 

+ 1 - 0
tools/others/gen_templates.py

@@ -8,6 +8,7 @@ def gen(path, project = ""):
 	projs = ("win32", "android", "macosx", "ios", "cmake", "emscripten")
 	projs = ("android", )
 	projs = ("ios", "macosx")
+	projs = ("emscripten", )
 
 	for platform in projs:
 		dest = "../../examples/" + path + "/proj." + platform

+ 9 - 3
tools/templates/proj.emscripten/CMakeLists.txt

@@ -11,9 +11,15 @@ set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wno-warn-absolute-paths")
 
 add_executable(${PROJECT} ${SRC} ${INCLUDE})
 
-set_target_properties(${PROJECT}
-    PROPERTIES 
-    LINK_FLAGS "-s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 -s -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+if (CMAKE_BUILD_TYPE STREQUAL Debug)
+	SET(linkFlags "-g4 ")
+else() # Either MinSizeRel, RelWithDebInfo or Release, all which run with optimizations enabled.
+	SET(linkFlags "-O2 ")
+endif()
+
+set(linkFlags "${linkFlags} -s NO_EXIT_RUNTIME=1 -s FULL_ES2=1 -s WARN_ON_UNDEFINED_SYMBOLS=1 --memory-init-file 0 -Wno-warn-absolute-paths -s TOTAL_MEMORY=64435456")
+
+set_target_properties(${PROJECT} PROPERTIES LINK_FLAGS "${linkFlags}")
 
 target_link_libraries(${PROJECT} ${OXYGINE_CORE_LIBS})
 em_link_pre_js(${PROJECT} ${CMAKE_CURRENT_SOURCE_DIR}/data.js)

+ 1 - 1
tools/templates/proj.emscripten/build.bat

@@ -2,6 +2,6 @@ python ${OXYGINE}/tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..

+ 1 - 1
tools/templates/proj.emscripten/build_release.bat

@@ -2,6 +2,6 @@ python ${OXYGINE}/tools/others/embed_folder_js.py -s ../data
 
 mkdir build
 cd build
-cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/platform/emscripten.cmake -G"Unix Makefiles" .. 
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/emscripten.cmake -G"Unix Makefiles" .. 
 make
 cd ..