Browse Source

updated to latest version

Denis Muratshin 12 years ago
parent
commit
3713ee2406
54 changed files with 849 additions and 578 deletions
  1. 2 2
      .hg_archival.txt
  2. 1 0
      .hgignore
  3. BIN
      doc.zip
  4. 1 1
      examples/Demo/src/TestManageRes.h
  5. 1 1
      examples/Demo/src/TestTexel2Pixel.h
  6. 12 9
      examples/Demo/src/TestText.h
  7. 4 10
      examples/Demo/src/TestTweens.h
  8. 24 30
      examples/Demo/src/entry_point.cpp
  9. 21 20
      examples/Demo/src/example.cpp
  10. 1 4
      examples/Demo/src/example.h
  11. 7 17
      examples/Demo/src/test.cpp
  12. 1 1
      examples/Demo/src/test.h
  13. 3 1
      examples/DemoBox2D/CMakeLists.txt
  14. 165 0
      examples/DemoBox2D/src/Box2DDebugDraw.cpp
  15. 54 0
      examples/DemoBox2D/src/Box2DDebugDraw.h
  16. 24 30
      examples/DemoBox2D/src/entry_point.cpp
  17. 49 28
      examples/DemoBox2D/src/example.cpp
  18. 2 0
      examples/GameTemplate/CMakeLists.txt
  19. 1 1
      examples/GameTemplate/src/GameMenu.cpp
  20. 1 1
      examples/GameTemplate/src/GameResult.cpp
  21. 3 3
      examples/GameTemplate/src/MainMenu.cpp
  22. 2 2
      examples/GameTemplate/src/OptionsMenu.cpp
  23. 100 91
      examples/GameTemplate/src/entry_point.cpp
  24. 75 0
      examples/GameTemplate/src/example.cpp
  25. 3 0
      examples/GameTemplate/src/example.h
  26. 2 2
      examples/GameTemplate/src/shared.cpp
  27. 24 30
      examples/HelloWorld/src/entry_point.cpp
  28. 21 32
      examples/HelloWorld/src/example.cpp
  29. 0 4
      examples/HelloWorld/src/example.h
  30. BIN
      examples/Match3/data/images/jewels/air.png
  31. BIN
      examples/Match3/data/images/jewels/coin.png
  32. BIN
      examples/Match3/data/images/jewels/earth.png
  33. BIN
      examples/Match3/data/images/jewels/fire.png
  34. BIN
      examples/Match3/data/images/jewels/skull.png
  35. BIN
      examples/Match3/data/images/jewels/water.png
  36. 13 12
      examples/Match3/data/resources.xml
  37. 24 30
      examples/Match3/src/entry_point.cpp
  38. 1 1
      examples/Match3/src/example.cpp
  39. 1 3
      examples/Match3/src/example.h
  40. 75 95
      examples/Match3/src/gameframe.cpp
  41. 6 8
      examples/Match3/src/gameframe.h
  42. 6 6
      examples/Match3/src/jewels.cpp
  43. 3 3
      examples/Match3/src/jewels.h
  44. 8 8
      oxygine/src/Actor.cpp
  45. 2 2
      oxygine/src/Button.cpp
  46. 12 12
      oxygine/src/DebugActor.cpp
  47. 3 3
      oxygine/src/Draggable.cpp
  48. 3 3
      oxygine/src/Input.cpp
  49. 1 1
      oxygine/src/RootActor.h
  50. 3 1
      oxygine/src/core/Renderer.h
  51. 8 0
      oxygine/src/core/VideoDriver.h
  52. 61 56
      oxygine/src/core/gl/VideoDriverGLES20.cpp
  53. 4 3
      oxygine/src/core/gl/VideoDriverGLES20.h
  54. 11 11
      tools/main.wpu

+ 2 - 2
.hg_archival.txt

@@ -1,5 +1,5 @@
 repo: b6d71054df5712e643a0685bc3ba54b123db5729
-node: d474fe7716d319473a38a0f11d4fdc7dbd973a12
+node: bc13d0178e86dc16a27550b5de8cdcf92f632aa2
 branch: default
 latesttag: null
-latesttagdistance: 247
+latesttagdistance: 258

+ 1 - 0
.hgignore

@@ -83,5 +83,6 @@ examples/Demo/data/ext/res_ui.xml.ox/
 examples/Demo/data/ext/res.xml.ox/
 oxygine/system_data/data/
 examples/Demo/win32/My Inspector XE Results *
+examples/DemoBox2D/build_box2d_vc11/
 syntax: regexp
 ^build/

BIN
doc.zip


+ 1 - 1
examples/Demo/src/TestManageRes.h

@@ -91,7 +91,7 @@ public:
 			l->add(&resources);
 			if (id == "mt_slow")
 				l->setUpdateSize(128);
-			l->start(RootActor::instance);
+			l->start(getRoot());
 		}
 	}
 };

+ 1 - 1
examples/Demo/src/TestTexel2Pixel.h

@@ -10,7 +10,7 @@ public:
 		sprite->setPosition(pos);
 		sprite->setAnimFrame(resources.getResAnim("t2p"));
 		sprite->attachTo(content);
-		float scale = 1.0f/RootActor::instance->getScaleX();
+		float scale = 1.0f/getRoot()->getScaleX();
 		sprite->setScale(scale);
 		Vector2 displaySpriteSize = sprite->getSize() * scale;
 		sprite->setPosition((content->getSize() - displaySpriteSize)/2.0f);

+ 12 - 9
examples/Demo/src/TestText.h

@@ -73,10 +73,11 @@ public:
 
 		Vector2 size(420, 300);
 
+
 		tests.push_back(text_test( "It is html style tagged text. <div c='ffff00'>It could be colored.  It <div c='0000ff'>supports</div> <div c='00ff00AA'>nested tags</div> and  <br/> broken lines.</div><br/>It supports CDATA and xml escape sequences:\n<![CDATA[<div c='00ffff'>it is CDATA</div>]]>", 
 			TextStyle::HALIGN_CENTER, TextStyle::VALIGN_MIDDLE, size, true));
 
-		for (int h = 0; h < 3; ++h)
+		for (int h = TextStyle::HALIGN_LEFT; h <= TextStyle::HALIGN_RIGHT; ++h)
 		{
 			tests.push_back(text_test( "<div c='00ff00'>Scaled Font test<br/></div> The quick brown fox jumps over the lazy dog. 1234567890. The quick brown fox jumps over the lazy dog. 1234567890. The quick brown fox jumps over the lazy dog. 1234567890. The quick brown fox jumps over the lazy dog. 1234567890. ", TextStyle::HALIGN_CENTER, TextStyle::VALIGN_MIDDLE, size, true, 10 * h  + 20));
 		}
@@ -84,37 +85,39 @@ public:
 
 		tests.push_back(text_test( "<div c='00ff00'>Using '\\n' new line test</div>\nnew line\nnew line\nnew line", TextStyle::HALIGN_CENTER, TextStyle::VALIGN_TOP, size));
 		
-		for (int h = 0; h < 3; ++h)
+		for (int h = TextStyle::HALIGN_LEFT; h <= TextStyle::HALIGN_RIGHT; ++h)
 		{
 			tests.push_back(text_test( "<div c='00ff00'>Singleline Test</div> The quick brown fox.", TextStyle::HorizontalAlign(h), TextStyle::VALIGN_TOP, size, false));
 		}
 
-		for (int h = 0; h < 3; ++h)
+		for (int h = TextStyle::HALIGN_LEFT; h <= TextStyle::HALIGN_RIGHT; ++h)
 		{
 			tests.push_back(text_test( "<div c='00ff00'>Multiline Test with spaces inside</div> The   quick    brown    fox   jumps    over   the    lazy dog.", TextStyle::HorizontalAlign(h), TextStyle::VALIGN_TOP, size));
 		}
 
 		
 
-		for (int v = 0; v < 4; ++v)
+		for (int v = TextStyle::VALIGN_BASELINE; v <= TextStyle::VALIGN_BOTTOM; ++v)
 		{
-			for (int h = 0; h < 3; ++h)
+			for (int h = TextStyle::HALIGN_LEFT; h <= TextStyle::HALIGN_RIGHT; ++h)
 			{
-				tests.push_back(text_test( "<div c='00ff00'>Aligment Test</div> The quick brown fox jumps over the lazy dog. 1234567890. The quick brown fox jumps over the lazy dog. 1234567890. ", TextStyle::HorizontalAlign(h), TextStyle::VerticalAlign(v), size));
+				tests.push_back(text_test( "It is html style tagged text. <div c='ffff00'>It could be colored.  It <div c='0000ff'>supports</div> <div c='00ff00AA'>nested tags</div> and  <br/> broken lines.</div><br/>It supports CDATA and xml escape sequences:\n<![CDATA[<div c='00ffff'>it is CDATA</div>]]>", 
+					TextStyle::HorizontalAlign(h), TextStyle::VerticalAlign(v), size, true));
+				//tests.push_back(text_test( "<div c='00ff00'>Aligment Test</div> The quick brown fox jumps over the lazy dog. 1234567890. The quick brown fox jumps over the lazy dog. 1234567890. ", TextStyle::HorizontalAlign(h), TextStyle::VerticalAlign(v), size));
 			}
 		}
 
 		size = Vector2(200, 100);
-		for (int v = 0; v < 4; ++v)
+		for (int v = TextStyle::VALIGN_BASELINE; v <= TextStyle::VALIGN_BOTTOM; ++v)
 		{
-			for (int h = 0; h < 3; ++h)
+			for (int h = TextStyle::HALIGN_LEFT; h <= TextStyle::HALIGN_RIGHT; ++h)
 			{
 				tests.push_back(text_test( "<div c='00ff00'>Aligment Test with limited size</div> The quick brown fox jumps over the lazy dog. 1234567890.", TextStyle::HorizontalAlign(h), TextStyle::VerticalAlign(v), size));
 			}
 		}
 
 		size = Vector2(380, 300);
-		for (int h = 0; h < 3; ++h)
+		for (int h = TextStyle::HALIGN_LEFT; h <= TextStyle::HALIGN_RIGHT; ++h)
 		{
 			tests.push_back(text_test( "<div c='00ff00'>Long string and aligment test</div> The_quick_brownfox_jumps_over_the lazy dog. 1234567890.", TextStyle::HorizontalAlign(h), TextStyle::VALIGN_TOP, size));
 		}	

+ 4 - 10
examples/Demo/src/TestTweens.h

@@ -3,12 +3,6 @@
 #include "ColorRectSprite.h"
 #include <typeinfo>
 
-template <class T>
-class dummy
-{
-
-};
-
 class TweensTest: public Test
 {
 public:
@@ -46,11 +40,11 @@ public:
 	spActor createEaseTest(Tween::EASE ease)
 	{
 		spColorRectSprite bg = new ColorRectSprite();
-		bg->setSize(Vector2(230, 230));
+		bg->setSize(230, 230);
 		bg->setColor(Color(128, 128, 128, 255));
 
 		spColorRectSprite parent = new ColorRectSprite();
-		parent->setSize(Vector2(200, 200));
+		parent->setSize(200, 200);
 		parent->setColor(Color(230, 230, 230, 255));
 
 		float f = 0;
@@ -69,7 +63,7 @@ public:
 			f += 0.005f;
 		}
 
-		parent->setPosition(15, 15);
+		parent->setPosition(10, 15);
 		bg->addChild(parent);
 
 		return bg;
@@ -82,7 +76,7 @@ public:
 
 		_easeGraph = createEaseTest(_ease);
 		_easeGraph->setPriority(-1);
-		_easeGraph->setY(150);
+		_easeGraph->setY(getHeight()/2 - _easeGraph->getHeight()/2);
 		content->addChild(_easeGraph);
 
 		updateText("ease", enum2string(_ease));

+ 24 - 30
examples/Demo/src/entry_point.cpp

@@ -40,14 +40,14 @@ int mainloop()
 	example_update();
 	//update our rootActor
 	//Actor::update would be called also for children
-	RootActor::instance->update();
+	getRoot()->update();
 
 	Color clear(33, 33, 33, 255);
 	//start rendering and clear viewport
 	if (renderer.begin(0, viewport, &clear))
 	{
 		//begin rendering from RootActor. 
-		RootActor::instance->render(renderer);
+		getRoot()->render(renderer);
 		//rendering done
 		renderer.end();
 
@@ -67,34 +67,32 @@ int mainloop()
 void run()
 {	
 	//initialize oxygine's internal stuff
-	core::init();
-	
-	
-	//create RootActor. RootActor is a root node
-	RootActor::instance = new ExampleRootActor();
+	core::init_desc desc;
 
+#if OXYGINE_SDL
+	//we could setup initial window size on SDL builds
+	//desc.w = 960;
+	//desc.h = 660;
+	//marmalade settings could be changed from emulator's menu
+#endif
+
+	core::init(&desc);	
 	
+	//create RootActor. RootActor is a root node
+	RootActor::instance = new ExampleRootActor();	
 	Point size = core::getDisplaySize();
-
-	//initialize it
-	//first argument is real display size of device.
-	//second is your "virtual" preferred size. You could change it to any size you need
-	//VirtualWidth and VirtualHeight are defined in example.h	
-	RootActor::instance->init(size, 
-		Point(VirtualWidth, VirtualHeight));
+	getRoot()->init(size, size);
 	
-
-	//DebugActor is a helper node it shows FPS and memory usage
+	//DebugActor is a helper node it shows FPS and memory usage and other useful stuff
 	DebugActor::initialize();
 
-
 	//create and add new DebugActor to root actor as child
-	RootActor::instance->addChild(new DebugActor());
+	getRoot()->addChild(new DebugActor());
 
 
-	//it is view and projection matrix  initialization stuff
-	
-	Matrix view = makeViewMatrix(size.x, size.y); //Returns View matrix where Left Top corner is (0,0), and right bottom is (w,h)
+	//initialization view and projection matrix 	
+	//makeViewMatrix returns View matrix where Left Top corner is (0,0), and right bottom is (w,h)
+	Matrix view = makeViewMatrix(size.x, size.y); 
 
 	viewport = Rect(0, 0, size.x, size.y);
 
@@ -110,11 +108,9 @@ void run()
 	renderer.setViewTransform(view);
 	renderer.setProjTransform(proj);
 
-
-	//initialize this example stuff. check example.cpp
+	//initialize this example stuff. see example.cpp
 	example_init();
 
-
 	bool done = false;	
 
 	//here is main game loop
@@ -124,17 +120,16 @@ void run()
 		if (done)
 			break;
     }
-	//so user closed application
+	//so user want to leave application...
 	
-	//lets dump all created objects into Output
+	//lets dump all created objects into log
 	//all created and not freed resources would be displayed
 	ObjectBase::dumpCreatedObjects();
 
-
 	//lets cleanup everything right now and call ObjectBase::dumpObjects() again
 	//we need to free all allocated resources and delete all created actors
-	//yes, actor is smart pointer and actually you don't need it remove by hands
-	//but now we want delete it forcedly
+	//all actors/sprites are smart pointer objects and actually you don't need it remove them by hands
+	//but now we want delete it by hands
 
 	//check example.cpp
 	example_destroy();	
@@ -148,7 +143,6 @@ void run()
 	//dump list should be empty now
 	//we deleted everything and could be sure that there aren't any memory leaks
 	ObjectBase::dumpCreatedObjects();
-
 	//end
 }
 

+ 21 - 20
examples/Demo/src/example.cpp

@@ -21,7 +21,8 @@
 #endif
 
 using namespace oxygine;
-Actor *_tests = 0;
+
+spActor _tests;
 
 //it is our resources
 //in real project you would have more than one Resources declarations. It is important on mobile devices with limited memory and you would load/unload them
@@ -35,9 +36,8 @@ public:
 
 	TestActor()
 	{	
-		_tests = this;
-		_x = RootActor::instance->getWidth()/2.0f;
-		_y = 0;
+		_x = 90;//getRoot()->getWidth()/2.0f;
+		_y = 80;
 
 
 		addButton("tweens", "Tweens");
@@ -63,71 +63,71 @@ public:
 
 		if (id == "perf")
 		{
-			RootActor::instance->addChild(new PerfTest);
+			getRoot()->addChild(new PerfTest);
 		}
 		if (id == "tweens")
 		{
-			RootActor::instance->addChild(new TweensTest);
+			getRoot()->addChild(new TweensTest);
 		}
 		if (id == "drag")
 		{
-			RootActor::instance->addChild(new DragTest);
+			getRoot()->addChild(new DragTest);
 		}
 		if (id == "drag2")
 		{
-			RootActor::instance->addChild(new Drag2Test);
+			getRoot()->addChild(new Drag2Test);
 		}
 		if (id == "manage_res")
 		{
-			RootActor::instance->addChild(new ManageResTest);
+			getRoot()->addChild(new ManageResTest);
 		}
 		if (id == "r2t")
 		{
-			RootActor::instance->addChild(new TestRender2Texture);
+			getRoot()->addChild(new TestRender2Texture);
 		}
 		if (id == "text")
 		{
-			RootActor::instance->addChild(new TestText);
+			getRoot()->addChild(new TestText);
 		}
 
 		if (id == "progress_bar")
 		{
-			RootActor::instance->addChild(new TestProgressBar);
+			getRoot()->addChild(new TestProgressBar);
 		}
 
 		if (id == "texture_format")
 		{
-			RootActor::instance->addChild(new TestTextureFormat);
+			getRoot()->addChild(new TestTextureFormat);
 		}
 
 		if (id == "complex_drag")
 		{
-			RootActor::instance->addChild(new TestComplexDrag);
+			getRoot()->addChild(new TestComplexDrag);
 		}
 
 		if (id == "t2p")
 		{
-			RootActor::instance->addChild(new TestTexel2Pixel);
+			getRoot()->addChild(new TestTexel2Pixel);
 		}
 
 		if (id == "box9sprite")
 		{
-			RootActor::instance->addChild(new TestBox9Sprite);
+			getRoot()->addChild(new TestBox9Sprite);
 		}
 
 		if (id == "cliprect")
 		{
-			RootActor::instance->addChild(new TestClipRect);
+			getRoot()->addChild(new TestClipRect);
 		}
 
 		if (id == "usershader")
 		{
-			RootActor::instance->addChild(new TestUserShader);
+			getRoot()->addChild(new TestUserShader);
 		}
 
 		if (id == "mask")
 		{
-			RootActor::instance->addChild(new TestMask);
+			getRoot()->addChild(new TestMask);
 		}
 	}
 };
@@ -143,6 +143,7 @@ void example_init()
 
 	spSprite sp = initActor(new Sprite, 
 		arg_resAnim = resourcesUI.getResAnim("logo2"),
+		arg_input = false,
 		arg_attachTo = getRoot(),
 		arg_priority = 10,
 		arg_alpha = 128
@@ -152,7 +153,7 @@ void example_init()
 	sp->setY(getRoot()->getHeight() - sp->getHeight());
 
 	_tests = new TestActor;
-	RootActor::instance->addChild(_tests);
+	getRoot()->addChild(_tests);
 }
 
 void example_update()

+ 1 - 4
examples/Demo/src/example.h

@@ -1,6 +1,3 @@
 void example_init();
 void example_destroy();
-void example_update();
-
-const int VirtualWidth = 960;
-const int VirtualHeight = 640;
+void example_update();

+ 7 - 17
examples/Demo/src/test.cpp

@@ -8,7 +8,6 @@ spTextActor createText(string txt)
 	TextStyle style;
 	style.font = resourcesUI.getResFont("main")->getFont();
 	style.color = Color(72, 61, 139, 255);
-	//style.color = Color(255, 255, 255, 255);
 	style.vAlign = TextStyle::VALIGN_MIDDLE;
 	style.hAlign = TextStyle::HALIGN_CENTER;
 	style.multiline = true;
@@ -17,8 +16,8 @@ spTextActor createText(string txt)
 	text->setText(txt.c_str());
 
 	return text;
-
 }
+
 spButton createButtonHelper(string txt, EventCallback cb)
 {
 	spButton button = new Button();
@@ -27,14 +26,10 @@ spButton createButtonHelper(string txt, EventCallback cb)
 	button->setResAnim(resourcesUI.getResAnim("button"));
 	button->addEventListener(TouchEvent::CLICK, cb);
 
-
 	//create Actor with Text and it to button as child
 	spTextActor text = createText(txt);
-	//text->setPosition(button->getSize()/2);
 	text->setSize(button->getSize());
 	text->attachTo(button);
-	//text->setScale(0.8f);
-
 
 	return button;
 }
@@ -42,24 +37,22 @@ spButton createButtonHelper(string txt, EventCallback cb)
 
 Test::Test()
 {
-	setSize(RootActor::instance->getSize());
+	setSize(getRoot()->getSize());
 
 	_x = getWidth() - 100;
 	_y = 2;
 	
-
 	ui = new Actor;
 	content = new Content;
 	content->setSize(getSize());
 
-
 	addChild(content);
 	addChild(ui);
 
 	if (_tests)
 	{
 		spButton button = createButtonHelper("back", CLOSURE(this, &Test::back));
-		button->setY((float)getHeight() - button->getHeight());
+		button->setY(getHeight() - button->getHeight());
 		ui->addChild(button);
 	}	
 }
@@ -67,7 +60,6 @@ Test::Test()
 
 Test::~Test()
 {
-	int q=0;
 }
 
 
@@ -82,14 +74,13 @@ void Test::addButton(string id, string txt)
 	button->setAnchor(Vector2(0.5f, 0.0f));
 
 	//center button at screen		
-	button->setPosition(Vector2((float)_x, (float)_y));
-	//button->setPosition(Vector2(150, _y));
+	button->setPosition(_x, _y);
 	_y += button->getHeight() + 2.0f;
 
-	if (_y >= getHeight())
+	if (_y  + button->getHeight() >= getHeight())
 	{
 		_y = 0;
-		_x += button->getWidth() + 10;
+		_x += button->getWidth() + 70;
 	}
 }
 
@@ -99,7 +90,7 @@ void Test::updateText(string id, string txt)
 	if (!child)
 		return;
 
-	TextActor *t = safeCast<TextActor*>(child->getFirstChild().get());
+	spTextActor t = safeSpCast<TextActor>(child->getFirstChild());
 	if (!t)
 		return;
 	t->setText(txt);
@@ -139,7 +130,6 @@ void Test::showPopup(string txt, int time)
 	sprite->addTween(tq);
 	sprite->attachTo(ui);
 	sprite->setPosition(0.0f, getHeight() - 150.0f);
-	
 
 	spTextActor text = createText(txt);
 	text->attachTo(sprite);

+ 1 - 1
examples/Demo/src/test.h

@@ -50,6 +50,6 @@ protected:
 	Content *content;
 };
 
-extern Actor *_tests;
+extern spActor _tests;
 extern Resources resources;
 extern Resources resourcesUI;

+ 3 - 1
examples/DemoBox2D/CMakeLists.txt

@@ -11,7 +11,9 @@ add_executable(DemoBox2D
 	${BOX2DSRC}
 	src/entry_point.cpp
 	src/example.h 
-	src/example.cpp)
+	src/example.cpp
+	src/Box2DDebugDraw.h
+	src/Box2DDebugDraw.cpp)
 
 source_group(box2d FILES ${BOX2DSRC})
 

+ 165 - 0
examples/DemoBox2D/src/Box2DDebugDraw.cpp

@@ -0,0 +1,165 @@
+#include "Box2DDebugDraw.h"
+#include "core/VideoDriver.h"
+#include "RenderState.h"
+#include "core/gl/VideoDriverGLES20.h"
+
+Box2DDraw::Box2DDraw(): _worldScale(1.0f), _world(0)
+{
+	m_drawFlags = 0xffffffff;
+
+	const char* vertexShaderData = "\
+									uniform mediump mat4 projection;\
+									attribute vec2 a_position;\
+									void main() {\
+									vec4 position = vec4(a_position, 0.0, 1.0);\
+									gl_Position = projection * position;\
+									}\
+									";
+
+	const char* fragmentShaderData = "\
+									  uniform mediump vec4 color;\
+									  void main() { \
+									  gl_FragColor = color; \
+									  } \
+									  ";
+
+	_program = new ShaderProgramGL();
+
+
+	int vs = ShaderProgramGL::createShader(GL_VERTEX_SHADER, vertexShaderData, 0, 0);
+	int fs = ShaderProgramGL::createShader(GL_FRAGMENT_SHADER, fragmentShaderData, 0, 0);
+
+	int pr = ShaderProgramGL::createProgram(vs, fs, (VertexDeclarationGL*)IVideoDriver::instance->getVertexDeclaration(VERTEX_POSITION));
+	_program->init(pr);
+}
+
+Box2DDraw::~Box2DDraw()
+{
+	delete _program;
+}
+
+void Box2DDraw::doRender(const RenderState &rs)
+{
+	rs.renderer->drawBatch();	
+	
+	_world->SetDebugDraw(this);
+
+	_program->bind();
+	Matrix m = Matrix(rs.transform) * rs.renderer->getView() * rs.renderer->getProjection();
+	_program->setUniform("projection", &m);
+
+	glEnable(GL_BLEND);
+	glBlendFunc  (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+	_world->DrawDebugData();
+	_world->SetDebugDraw(0);
+	rs.renderer->getDriver()->setDefaultSettings();	
+}
+
+void Box2DDraw::DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
+{
+	createPolygonVertices(vertices, vertexCount);
+	drawPrimitives(false, true, vertexCount, color);
+}
+
+/// Draw a solid closed polygon provided in CCW order.
+void Box2DDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
+{
+	createPolygonVertices(vertices, vertexCount);
+	drawPrimitives(true, true, vertexCount, color);
+}
+
+/// Draw a circle.
+void Box2DDraw::DrawCircle(const b2Vec2& center, float32 aRadius, const b2Color& color)
+{
+	createCircleVertices(center, aRadius);
+	drawPrimitives(false, true, CIRCLE_SEGMENTS, color);
+}
+
+/// Draw a solid circle.
+void Box2DDraw::DrawSolidCircle(const b2Vec2& center, float32 aRadius, const b2Vec2& aAxis,
+									 const b2Color& color)
+{
+	createCircleVertices(center, aRadius);
+	drawPrimitives(true, true, CIRCLE_SEGMENTS, color);
+	// Draw the axis line
+	DrawSegment(center, center + aRadius * aAxis, color);
+}
+
+/// Draw a line segment.
+void Box2DDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color)
+{
+	mVertices[0].x = p1.x * _worldScale;
+	mVertices[0].y = p1.y * _worldScale;
+	mVertices[1].x = p2.x * _worldScale;
+	mVertices[1].y = p2.y * _worldScale;
+	drawPrimitives(false, true, 2, color);
+}
+
+/// Draw a transform. Choose your own length scale.
+/// @param xf a transform.
+void Box2DDraw::DrawTransform(const b2Transform& xf)
+{
+	b2Vec2 p1 = xf.p, p2;
+	const float32 k_axisScale = 0.4f;
+
+	p2 = p1 + k_axisScale * xf.q.GetXAxis();
+	DrawSegment(p1, p2, b2Color(1, 0, 0));
+
+	p2 = p1 + k_axisScale * xf.q.GetYAxis();
+	DrawSegment(p1, p2, b2Color(0, 1, 0));
+}
+
+void Box2DDraw::createCircleVertices(const b2Vec2& center, float32 aRadius)
+{
+	int vertexCount = 16;
+	const float32 k_increment = 2.0f * b2_pi / CIRCLE_SEGMENTS;
+	float32 theta = 0.0f;
+
+	for (int32 i = 0; i < CIRCLE_SEGMENTS; ++i)
+	{
+		b2Vec2 v = center + aRadius * b2Vec2(scalar::cos(theta), scalar::sin(theta));
+		mVertices[i].x = _worldScale * v.x;
+		mVertices[i].y = _worldScale * v.y;
+		theta += k_increment;
+	}
+}
+
+void Box2DDraw::createPolygonVertices(const b2Vec2* vertices, int32 vertexCount)
+{
+	if (vertexCount > MAX_VERTICES)
+	{
+		log::warning("need more vertices");
+		return;
+	}
+
+	// convert vertices to screen resolution
+	for (int i = 0; i < vertexCount; i++)
+	{
+		mVertices[i].x= _worldScale * vertices[i].x;
+		mVertices[i].y = _worldScale * vertices[i].y;
+	}
+}
+
+
+//------------------------------------------------------------------------
+void Box2DDraw::drawPrimitives(bool drawTriangles, bool drawLines, int count, const b2Color& color)
+{
+	glEnableVertexAttribArray(0);
+	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, (GLfloat*) mVertices);
+
+	if (drawTriangles)
+	{
+		Vector4 c(color.r, color.g, color.b, 0.5f);
+		_program->setUniform("color", &c, 1);
+		glDrawArrays(GL_TRIANGLE_FAN, 0, count);
+	}
+
+	if (drawLines)
+	{
+		Vector4 c(color.r, color.g, color.b, 1.0f);
+		_program->setUniform("color", &c, 1);
+		glDrawArrays(GL_LINE_LOOP, 0, count);
+	}
+	 
+	glDisableVertexAttribArray(0);
+}

+ 54 - 0
examples/DemoBox2D/src/Box2DDebugDraw.h

@@ -0,0 +1,54 @@
+#pragma once
+#include "Actor.h"
+#include "Box2D/Box2D.h"
+
+using namespace oxygine;
+namespace oxygine
+{
+	class ShaderProgramGL;
+}
+
+DECLARE_SMART(Box2DDraw, spBox2DDraw);
+
+class Box2DDraw: public Actor, public b2Draw
+{
+public:
+	Box2DDraw();
+	~Box2DDraw();
+
+	void setWorld(float worldScale, b2World *world){_worldScale = worldScale; _world = world;}
+
+	/// Draw a closed polygon provided in CCW order.
+	void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color);
+
+	/// Draw a solid closed polygon provided in CCW order.
+	void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color);
+
+	/// Draw a circle.
+	void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color);
+
+	/// Draw a solid circle.
+	void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color);
+
+	/// Draw a line segment.
+	void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color);
+
+	/// Draw a transform. Choose your own length scale.
+	/// @param xf a transform.
+	void DrawTransform(const b2Transform& xf);
+
+protected:
+	b2World *_world;
+	float _worldScale; 
+
+	void doRender(const RenderState &rs);
+	static const int MAX_VERTICES = 64;
+	static const int CIRCLE_SEGMENTS = 16;
+
+	Vector2 mVertices[MAX_VERTICES];
+	void createCircleVertices(const b2Vec2& aCenter, float32 aRadius);
+	void createPolygonVertices(const b2Vec2* aVertices, int32 aVertexCount);
+	void drawPrimitives(bool drawTriangles, bool drawLines, int aCount, const b2Color& aColor);
+
+	ShaderProgramGL *_program;
+};

+ 24 - 30
examples/DemoBox2D/src/entry_point.cpp

@@ -40,14 +40,14 @@ int mainloop()
 	example_update();
 	//update our rootActor
 	//Actor::update would be called also for children
-	RootActor::instance->update();
+	getRoot()->update();
 
 	Color clear(33, 33, 33, 255);
 	//start rendering and clear viewport
 	if (renderer.begin(0, viewport, &clear))
 	{
 		//begin rendering from RootActor. 
-		RootActor::instance->render(renderer);
+		getRoot()->render(renderer);
 		//rendering done
 		renderer.end();
 
@@ -67,34 +67,32 @@ int mainloop()
 void run()
 {	
 	//initialize oxygine's internal stuff
-	core::init();
-	
-	
-	//create RootActor. RootActor is a root node
-	RootActor::instance = new ExampleRootActor();
+	core::init_desc desc; 
 
+#if OXYGINE_SDL
+	//we could setup initial window size on SDL builds
+	//desc.w = 640;
+	//desc.h = 480;
+	//marmalade settings could be changed from emulator's menu
+#endif
+
+	core::init(&desc);	
 	
+	//create RootActor. RootActor is a root node
+	RootActor::instance = new ExampleRootActor();	
 	Point size = core::getDisplaySize();
-
-	//initialize it
-	//first argument is real display size of device.
-	//second is your "virtual" preferred size. You could change it to any size you need
-	//VirtualWidth and VirtualHeight are defined in example.h	
-	RootActor::instance->init(size, 
-		Point(VirtualWidth, VirtualHeight));
+	getRoot()->init(size, size);
 	
-
-	//DebugActor is a helper node it shows FPS and memory usage
+	//DebugActor is a helper node it shows FPS and memory usage and other useful stuff
 	DebugActor::initialize();
 
-
 	//create and add new DebugActor to root actor as child
-	RootActor::instance->addChild(new DebugActor());
+	getRoot()->addChild(new DebugActor());
 
 
-	//it is view and projection matrix  initialization stuff
-	
-	Matrix view = makeViewMatrix(size.x, size.y); //Returns View matrix where Left Top corner is (0,0), and right bottom is (w,h)
+	//initialization view and projection matrix 	
+	//makeViewMatrix returns View matrix where Left Top corner is (0,0), and right bottom is (w,h)
+	Matrix view = makeViewMatrix(size.x, size.y); 
 
 	viewport = Rect(0, 0, size.x, size.y);
 
@@ -110,11 +108,9 @@ void run()
 	renderer.setViewTransform(view);
 	renderer.setProjTransform(proj);
 
-
-	//initialize this example stuff. check example.cpp
+	//initialize this example stuff. see example.cpp
 	example_init();
 
-
 	bool done = false;	
 
 	//here is main game loop
@@ -124,17 +120,16 @@ void run()
 		if (done)
 			break;
     }
-	//so user closed application
+	//so user want to leave application...
 	
-	//lets dump all created objects into Output
+	//lets dump all created objects into log
 	//all created and not freed resources would be displayed
 	ObjectBase::dumpCreatedObjects();
 
-
 	//lets cleanup everything right now and call ObjectBase::dumpObjects() again
 	//we need to free all allocated resources and delete all created actors
-	//yes, actor is smart pointer and actually you don't need it remove by hands
-	//but now we want delete it forcedly
+	//all actors/sprites are smart pointer objects and actually you don't need it remove them by hands
+	//but now we want delete it by hands
 
 	//check example.cpp
 	example_destroy();	
@@ -148,7 +143,6 @@ void run()
 	//dump list should be empty now
 	//we deleted everything and could be sure that there aren't any memory leaks
 	ObjectBase::dumpCreatedObjects();
-
 	//end
 }
 

+ 49 - 28
examples/DemoBox2D/src/example.cpp

@@ -1,5 +1,6 @@
 #include "oxygine-framework.h"
 #include "Box2D/Box2D.h"
+#include "Box2DDebugDraw.h"
 
 using namespace oxygine;
 
@@ -10,6 +11,7 @@ Resources gameResources;
 //DECLARE_SMART is helper, it does forward declaration and declares intrusive_ptr typedef for your class
 DECLARE_SMART(MainActor, spMainActor);
 
+
 const float SCALE = 100.0f;
 b2Vec2 convert(const Vector2 &pos)
 {
@@ -23,39 +25,41 @@ Vector2 convert(const b2Vec2 &pos)
 
 class MainActor: public Actor
 {
-public:
-	
+public:	
 	b2World *_world;
+	spBox2DDraw _debugDraw;
 
 	MainActor():_world(0)
 	{	
-		setSize(RootActor::instance->getSize());
-
+		setSize(getRoot()->getSize());
 
-		spClock clock = new Clock();
-		clock->setFixedStep(1000.0f / 60.0f);
-		setClock(clock);
+		spButton btn = new Button;
+		btn->setResAnim(gameResources.getResAnim("button"));
+		btn->setX(getWidth() - btn->getWidth());
+		btn->attachTo(this);
+		btn->addEventListener(TouchEvent::CLICK, CLOSURE(this, &MainActor::showHideDebug));
 
-		addEventListener(TouchEvent::CLICK, CLOSURE(this, &MainActor::clicked));
+		addEventListener(TouchEvent::CLICK, CLOSURE(this, &MainActor::displayClicked));
 
 
 		_world = new b2World(b2Vec2(0, 10), false);
 
-
+		
 		b2BodyDef groundBodyDef;
-		groundBodyDef.position = convert(Vector2(0.0f, getHeight() + 0.1f * SCALE));
+		groundBodyDef.position = convert(Vector2(getWidth()/2, getHeight() - 10));
 		b2Body* groundBody = _world->CreateBody(&groundBodyDef);
 
 		b2PolygonShape groundBox;
-		groundBox.SetAsBox(getWidth()/SCALE, 0.1f);		
+		groundBox.SetAsBox((getWidth() - 100)/2/SCALE, 10/SCALE);		
 		groundBody->CreateFixture(&groundBox, 0.0f);
 	}
-
 	
 	void doUpdate(const UpdateState &us)
 	{
+		//in real project you should make steps with fixed dt, check box2d documentation
 		_world->Step(us.dt / 1000.0f, 6, 2);
 
+		//update each body position on display
 		b2Body *body = _world->GetBodyList();
 		while(body)
 		{
@@ -67,54 +71,73 @@ public:
 				actor->setPosition(convert(pos));
 				actor->setRotation(body->GetAngle());
 
-				if (actor->getX() < -50 || actor->getX() > getWidth() + 50)
+				//remove fallen bodies
+				if (actor->getY() > getHeight() + 50)
 				{
 					body->SetUserData(0);
 					_world->DestroyBody(body);
 
 					actor->detach();					
 				}
-			}
-			
+			}			
 
 			body = next;
 		}
 	}
 
+	void showHideDebug(Event *event)
+	{
+		TouchEvent *te = safeCast<TouchEvent*>(event);
+		te->stopsImmediatePropagation = true;
+		if (_debugDraw)
+		{
+			_debugDraw->detach();
+			_debugDraw = 0;
+			return;
+		}
+
+		_debugDraw = new Box2DDraw;		
+		_debugDraw->SetFlags(b2Draw::e_shapeBit | b2Draw::e_jointBit | b2Draw::e_pairBit | b2Draw::e_centerOfMassBit);
+		_debugDraw->attachTo(this);
+		_debugDraw->setWorld(SCALE, _world);
+		_debugDraw->setPriority(1);
+	}
+
 	void circleClicked(Event *event)
 	{
 		TouchEvent *te = safeCast<TouchEvent*>(event);
+		te->stopImmediatePropagation();
+
 		spActor actor = safeSpCast<Actor>(event->currentTarget);
 		b2Body *body = (b2Body *)actor->getUserData();
 		
 		Vector2 dir = actor->getPosition() - actor->local2global(te->localPosition);
-		dir.normalize();
-		dir *= body->GetMass() * 200;
+		dir = dir / dir.length() * body->GetMass() * 200;
 
 		body->ApplyForceToCenter(b2Vec2(dir.x, dir.y));
 
-
 		//show click pos
 		spSprite sprite = new Sprite();		
 		sprite->setAnimFrame(gameResources.getResAnim("circle"));
-		addChild(sprite);
-		sprite->setScale(0.1f);
+		sprite->setColor(Color(0xff00ffff));
+		sprite->setScale(0.2f);
 		sprite->setPosition(te->localPosition);
 		sprite->setAnchor(Vector2(0.5f, 0.5f));
-		actor->addChild(sprite);
+		sprite->attachTo(actor);
 	}
 
-	void clicked(Event *event)
+	void displayClicked(Event *event)
 	{
 		TouchEvent *te = safeCast<TouchEvent*>(event);
 
 		spSprite sprite = new Sprite();		
-		sprite->setAnimFrame(gameResources.getResAnim("circle"));
-		addChild(sprite);
+		sprite->setResAnim(gameResources.getResAnim("circle"));
+		sprite->attachTo(this);
 		sprite->setAnchor(Vector2(0.5f, 0.5f));
 		sprite->setPosition(te->localPosition);
+		sprite->setInputChildrenEnabled(false);
 
-		sprite->addEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this, &MainActor::circleClicked));
+		sprite->addEventListener(TouchEvent::CLICK, CLOSURE(this, &MainActor::circleClicked));
 		
 		b2BodyDef bodyDef;
 		bodyDef.type = b2_dynamicBody;
@@ -130,8 +153,6 @@ public:
 		b2CircleShape shape;
 		shape.m_radius = sprite->getWidth() / SCALE / 2 * scale;
 
-		
-
 		b2FixtureDef fixtureDef;
 		fixtureDef.shape = &shape;
 		fixtureDef.density = 1.0f;
@@ -153,7 +174,7 @@ void example_init()
 	//it would be deleted automatically when you lost ref to it	
 	spMainActor actor = new MainActor;
 	//and add it to RootActor as child
-	RootActor::instance->addChild(actor);
+	getRoot()->addChild(actor);
 }
 
 void example_destroy()

+ 2 - 0
examples/GameTemplate/CMakeLists.txt

@@ -4,6 +4,8 @@ project (GAMETEMPLATE)
 
 file(GLOB SRC
 	src/entry_point.cpp
+	src/example.cpp
+	src/example.h
 	src/GameActor.cpp
 	src/GameActor.h
 	src/GameMenu.cpp

+ 1 - 1
examples/GameTemplate/src/GameMenu.cpp

@@ -8,7 +8,7 @@ spGameMenu GameMenu::instance;
 
 GameMenu::GameMenu()
 {
-	_actor->setSize(RootActor::instance->getSize());
+	_actor->setSize(getRoot()->getSize());
 
 	Vector2 size(_actor->getSize());
 

+ 1 - 1
examples/GameTemplate/src/GameResult.cpp

@@ -17,7 +17,7 @@ void GameResult::init()
 {
 	ColorRectSprite *p = new ColorRectSprite;
 	_bg = p;
-	_bg->setSize(RootActor::instance->getSize());
+	_bg->setSize(getRoot()->getSize());
 	_bg->setColor(Color(30, 30, 30, (int)(255 * 0.9f)));
 	_actor->addChild(_bg);
 

+ 3 - 3
examples/GameTemplate/src/MainMenu.cpp

@@ -50,7 +50,7 @@ MainMenu::MainMenu()
 	clock->setFixedStep(1000/50.0f);
 	_actor->setClock(clock);
 			
-	_actor->setSize(RootActor::instance->getSize());
+	_actor->setSize(getRoot()->getSize());
 
 
 	spSprite bg = new Sprite();
@@ -100,7 +100,7 @@ void MainMenu::doLoop()
 			spActor parent = _actor->detach();
 
 			spGameActor game = new GameActor();
-			RootActor::instance->addChild(game->_actor);
+			getRoot()->addChild(game->_actor);
 								
 			game->loop();
 
@@ -121,7 +121,7 @@ void MainMenu::doLoop()
 			_menu->setInputEnabled(true);				
 
 			spOptionsMenu opt = OptionsMenu::instance;
-			RootActor::instance->addChild(opt->_actor);
+			getRoot()->addChild(opt->_actor);
 
 			opt->loop();
 			opt->_actor->detach();

+ 2 - 2
examples/GameTemplate/src/OptionsMenu.cpp

@@ -56,9 +56,9 @@ OptionsMenu::OptionsMenu()
 
 	OptionsApply();
 
-	_actor->setSize(RootActor::instance->getSize());
+	_actor->setSize(getRoot()->getSize());
 	_actor->setAnchor(Vector2(0.5f, 0.5f));
-	_actor->setPosition(RootActor::instance->getSize()/2);
+	_actor->setPosition(getRoot()->getSize()/2);
 }
 
 OptionsMenu::~OptionsMenu()

+ 100 - 91
examples/GameTemplate/src/entry_point.cpp

@@ -1,29 +1,18 @@
-#include "oxygine-framework.h"
-
-#include "GameActor.h"
-#include "shared.h"
-
-#include "MainMenu.h"
-#include "GameMenu.h"
-#include "Options.h"
-#include "GameResult.h"
-
-#include "Options.h"
-#include "OptionsMenu.h"
-
 #include <stdio.h>
 
+#include "core/Renderer.h"
+#include "RootActor.h"
+#include "DebugActor.h"
 
-class Exit
-{
-public:
+#include "example.h"
 
-};
 
+using namespace oxygine;
 
-Renderer mainRenderer;
+Renderer renderer;
 Rect viewport;
 
+
 class ExampleRootActor: public RootActor
 {
 public:
@@ -46,115 +35,126 @@ public:
 	}
 };
 
-int updateLoop()
+int mainloop() 
 {
-	RootActor::instance->update();
-
-	Color c(30, 30, 30, 255);
-	if (mainRenderer.begin(0, viewport, &c))
+	example_update();
+	//update our rootActor
+	//Actor::update would be called also for children
+	getRoot()->update();
+
+	Color clear(33, 33, 33, 255);
+	//start rendering and clear viewport
+	if (renderer.begin(0, viewport, &clear))
 	{
-		RootActor::instance->render(mainRenderer);
-		mainRenderer.end();
+		//begin rendering from RootActor. 
+		getRoot()->render(renderer);
+		//rendering done
+		renderer.end();
+
 		core::swapDisplayBuffers();
 	}
 	
 
+	//update internal components
+	//all input events would be passed to RootActor::instance.handleEvent
+	//if done is true then User requests quit from app.
 	bool done = core::update();
-	if (done)
-		throw Exit();	
 
-	return 0;
+	return done ? 1 : 0;
 }
 
+//it is application entry point
 void run()
-{
-	//initialize oxygine
-	core::init();
-
-	//mainRenderer is static object 
-	//VideoDriver wasn't available in mainRenderer ctor's
-	mainRenderer.setDriver(IVideoDriver::instance);
-
-	Point size = core::getDisplaySize();
-	
-	int width = size.x;
-	int height = size.y;
+{	
+	//initialize oxygine's internal stuff
+	core::init_desc desc;
+
+#if OXYGINE_SDL
+	//we could setup initial window size on SDL builds
+	//desc.w = 960;
+	//desc.h = 660;
+	//marmalade settings could be changed from emulator's menu
+#endif
 
+	core::init(&desc);	
 	
-	RootActor::instance = new ExampleRootActor();
-	RootActor::instance->init(size, Point(480, 320));	
-
-	bool high_quality = true;
+	//create RootActor. RootActor is a root node
+	RootActor::instance = new ExampleRootActor();	
+	Point size = core::getDisplaySize();
+	getRoot()->init(size, size);
 	
-	//init default options
-	Options::instance.init("1");
-	Options::instance.addValue("high_quality").set_value(high_quality);
-	Options::instance.addValue("sounds").set_value(100);
-	Options::instance.addValue("music").set_value(100);
+	//DebugActor is a helper node it shows FPS and memory usage and other useful stuff
+	DebugActor::initialize();
 
-	initResources();	
+	//create and add new DebugActor to root actor as child
+	getRoot()->addChild(new DebugActor());
 
-	GameActor::initialize();
 
-	GameMenu::instance = new GameMenu();
-	MainMenu::instance = new MainMenu();
-	OptionsMenu::instance = new OptionsMenu();
+	//initialization view and projection matrix 	
+	//makeViewMatrix returns View matrix where Left Top corner is (0,0), and right bottom is (w,h)
+	Matrix view = makeViewMatrix(size.x, size.y); 
 
-	RootActor::instance->addChild(new DebugActor);
-	
-	bool done = false;
-
-	Matrix view = makeViewMatrix(width, height);
-	viewport = Rect(0, 0, width, height);
+	viewport = Rect(0, 0, size.x, size.y);
 
 	Matrix proj;
-	Matrix::orthoLH(proj, (float)width, (float)height, 0, 1);
-
-
-	mainRenderer.setViewTransform(view);
-	mainRenderer.setProjTransform(proj);
+	//initialize projection matrix
+	Matrix::orthoLH(proj, (float)size.x, (float)size.y, 0, 1);
 	
+	//initialize Renderer
+	//Renderer is class helper for rendering primitives and batching them
+	//Renderer is lightweight class you could create it many of times
+	//for example if you need to render something into RenderTarget (FBO)
+	renderer.setDriver(IVideoDriver::instance);
+	renderer.setViewTransform(view);
+	renderer.setProjTransform(proj);
+
+	//initialize this example stuff. see example.cpp
+	example_init();
+
+	bool done = false;	
+
+	//here is main game loop
+    while (1)
+    {
+		int done = mainloop();
+		if (done)
+			break;
+    }
+	//so user want to leave application...
+	
+	//lets dump all created objects into log
+	//all created and not freed resources would be displayed
+	ObjectBase::dumpCreatedObjects();
 
-	blocking::setYieldCallback(updateLoop);
-
-	try
-	{
-		spMainMenu mm = MainMenu::instance;
-		RootActor::instance->addChild(mm->_actor);
-
-		mm->loop();
-	}
-	catch(const Exit &)
-	{
-		printf("exit\n");
-	}
-
+	//lets cleanup everything right now and call ObjectBase::dumpObjects() again
+	//we need to free all allocated resources and delete all created actors
+	//all actors/sprites are smart pointer objects and actually you don't need it remove them by hands
+	//but now we want delete it by hands
 
-	mainRenderer.cleanup();
+	//check example.cpp
+	example_destroy();	
 	
-	GameActor::clean();
 
-	MainMenu::instance = 0;
-	GameMenu::instance = 0;
-	GameActor::instance = 0;
-	OptionsMenu::instance = 0;
-	
-	freeResources();
+	renderer.cleanup();
 
+	/**releases all internal components and RootActor*/
 	core::release();
 
+	//dump list should be empty now
+	//we deleted everything and could be sure that there aren't any memory leaks
 	ObjectBase::dumpCreatedObjects();
+	//end
 }
 
-
-#ifdef MARMALADE
+#ifdef __S3E__
 int main(int argc, char* argv[])
 {
-	run();
-	return 0;
+    run();
+    return 0;
 }
 #endif
 
+
 #ifdef OXYGINE_SDL
 #include "SDL_main.h"
 extern "C"
@@ -165,4 +165,13 @@ extern "C"
 		return 0;
 	}
 };
+#endif
+
+#ifdef __FLASHPLAYER__
+int main(int argc, char* argv[])
+{
+	printf("test\n");
+	run();
+	return 0;
+}
 #endif

+ 75 - 0
examples/GameTemplate/src/example.cpp

@@ -0,0 +1,75 @@
+#include "oxygine-framework.h"
+#include "Options.h"
+#include "shared.h"
+#include "GameActor.h"
+#include "GameMenu.h"
+#include "MainMenu.h"
+#include "OptionsMenu.h"
+using namespace oxygine;
+
+int mainloop();//declared in entry_point.cpp
+
+class Exit
+{
+public:
+
+};
+
+
+void example_init()
+{
+	Point size = core::getDisplaySize();
+
+	//getRoot()->init(size, Point(480, 320));	
+
+	bool high_quality = true;
+
+	//init default options
+	Options::instance.init("1");
+	Options::instance.addValue("high_quality").set_value(high_quality);
+	Options::instance.addValue("sounds").set_value(100);
+	Options::instance.addValue("music").set_value(100);
+
+	initResources();	
+
+	GameActor::initialize();
+
+	GameMenu::instance = new GameMenu();
+	MainMenu::instance = new MainMenu();
+	OptionsMenu::instance = new OptionsMenu();
+
+	blocking::setYieldCallback(mainloop);
+
+	try
+	{
+		spMainMenu mm = MainMenu::instance;
+		getRoot()->addChild(mm->_actor);
+
+		mm->loop();
+	}
+	catch(const Exit &)
+	{
+		printf("exit\n");
+	}
+
+}
+
+
+
+void example_update()
+{
+
+
+}
+
+void example_destroy()
+{
+	GameActor::clean();
+
+	MainMenu::instance = 0;
+	GameMenu::instance = 0;
+	GameActor::instance = 0;
+	OptionsMenu::instance = 0;
+
+	freeResources();
+}

+ 3 - 0
examples/GameTemplate/src/example.h

@@ -0,0 +1,3 @@
+void example_init();
+void example_destroy();
+void example_update();

+ 2 - 2
examples/GameTemplate/src/shared.cpp

@@ -17,7 +17,7 @@ pugi::xml_document doc;
 
 void initResources()
 {	
-	float scale = RootActor::instance->getScaleX();
+	float scale = getRoot()->getScaleX();
 	/*
 	bool hd = scale > 1.5f;
 
@@ -38,7 +38,7 @@ void initResources()
 	//if (hd)	
 	//	basicStyle.font->setScaleFactor(2.0f);
 
-	const char *locale_ = "unknown";
+	const char *locale_ = "en_GB";
 
 #ifdef MARMALADE
 	locale_ = s3eDeviceGetString(S3E_DEVICE_LOCALE);

+ 24 - 30
examples/HelloWorld/src/entry_point.cpp

@@ -40,14 +40,14 @@ int mainloop()
 	example_update();
 	//update our rootActor
 	//Actor::update would be called also for children
-	RootActor::instance->update();
+	getRoot()->update();
 
 	Color clear(33, 33, 33, 255);
 	//start rendering and clear viewport
 	if (renderer.begin(0, viewport, &clear))
 	{
 		//begin rendering from RootActor. 
-		RootActor::instance->render(renderer);
+		getRoot()->render(renderer);
 		//rendering done
 		renderer.end();
 
@@ -67,34 +67,32 @@ int mainloop()
 void run()
 {	
 	//initialize oxygine's internal stuff
-	core::init();
-	
-	
-	//create RootActor. RootActor is a root node
-	RootActor::instance = new ExampleRootActor();
+	core::init_desc desc;
 
+#if OXYGINE_SDL
+	//we could setup initial window size on SDL builds
+	//desc.w = 960;
+	//desc.h = 660;
+	//marmalade settings could be changed from emulator's menu
+#endif
+
+	core::init(&desc);	
 	
+	//create RootActor. RootActor is a root node
+	RootActor::instance = new ExampleRootActor();	
 	Point size = core::getDisplaySize();
-
-	//initialize it
-	//first argument is real display size of device.
-	//second is your "virtual" preferred size. You could change it to any size you need
-	//VirtualWidth and VirtualHeight are defined in example.h	
-	RootActor::instance->init(size, 
-		Point(VirtualWidth, VirtualHeight));
+	getRoot()->init(size, size);
 	
-
-	//DebugActor is a helper node it shows FPS and memory usage
+	//DebugActor is a helper node it shows FPS and memory usage and other useful stuff
 	DebugActor::initialize();
 
-
 	//create and add new DebugActor to root actor as child
-	RootActor::instance->addChild(new DebugActor());
+	getRoot()->addChild(new DebugActor());
 
 
-	//it is view and projection matrix  initialization stuff
-	
-	Matrix view = makeViewMatrix(size.x, size.y); //Returns View matrix where Left Top corner is (0,0), and right bottom is (w,h)
+	//initialization view and projection matrix 	
+	//makeViewMatrix returns View matrix where Left Top corner is (0,0), and right bottom is (w,h)
+	Matrix view = makeViewMatrix(size.x, size.y); 
 
 	viewport = Rect(0, 0, size.x, size.y);
 
@@ -110,11 +108,9 @@ void run()
 	renderer.setViewTransform(view);
 	renderer.setProjTransform(proj);
 
-
-	//initialize this example stuff. check example.cpp
+	//initialize this example stuff. see example.cpp
 	example_init();
 
-
 	bool done = false;	
 
 	//here is main game loop
@@ -124,17 +120,16 @@ void run()
 		if (done)
 			break;
     }
-	//so user closed application
+	//so user want to leave application...
 	
-	//lets dump all created objects into Output
+	//lets dump all created objects into log
 	//all created and not freed resources would be displayed
 	ObjectBase::dumpCreatedObjects();
 
-
 	//lets cleanup everything right now and call ObjectBase::dumpObjects() again
 	//we need to free all allocated resources and delete all created actors
-	//yes, actor is smart pointer and actually you don't need it remove by hands
-	//but now we want delete it forcedly
+	//all actors/sprites are smart pointer objects and actually you don't need it remove them by hands
+	//but now we want delete it by hands
 
 	//check example.cpp
 	example_destroy();	
@@ -148,7 +143,6 @@ void run()
 	//dump list should be empty now
 	//we deleted everything and could be sure that there aren't any memory leaks
 	ObjectBase::dumpCreatedObjects();
-
 	//end
 }
 

+ 21 - 32
examples/HelloWorld/src/example.cpp

@@ -2,7 +2,8 @@
 using namespace oxygine;
 
 //it is our resources
-//in real project you would have more than one Resources declarations. It is important on mobile devices with limited memory and you would load/unload them
+//in real project you would have more than one Resources declarations. 
+//It is important on mobile devices with limited memory and you would load/unload them
 Resources gameResources;
 
 //DECLARE_SMART is helper, it does forward declaration and declares intrusive_ptr typedef for your class
@@ -23,22 +24,22 @@ public:
 		//you will find 'button' resource definition in res.xml
 		//button has 3 columns for each state: Normal, Pressed, Overed
 		button->setResAnim(gameResources.getResAnim("button"));
-		//center button at screen		
-		//button->setPosition(Vector2(480, 320)/2 - button->getSize()/2);		
-		button->setPosition(Vector2(480, 320)/2);		
-		button->setAnchor(Vector2(0.5,0.5));
+		//centered button at screen	
+		Vector2 pos = getRoot()->getSize()/2 - button->getSize()/2;
+		button->setPosition(pos);
 		button->setInputChildrenEnabled(false);
 
-		//how to handle click
-		//find out more about CLOSUREs here: http://dobrokot.nm.ru/cpp/CppMethodsCallback.html
-		EventCallback cb = CLOSURE(this, &MainActor::clicked);
+		//handle click to button
+		EventCallback cb = CLOSURE(this, &MainActor::displayClicked);
 		button->addEventListener(TouchEvent::CLICK, cb);
 
 		//second part
 
 		//create Actor with Text and it to button as child
 		spTextActor text = new TextActor();
-		button->addChild(text);
+		text->attachTo(button);
+		//centered in button
+		text->setPosition(button->getSize()/2);
 
 		//initialize text style
 		//it would be centered and colored
@@ -48,20 +49,14 @@ public:
 		style.vAlign = TextStyle::VALIGN_MIDDLE;
 		style.hAlign = TextStyle::HALIGN_CENTER;
 
-		text->setStyle(style);;		
+		text->setStyle(style);
 		text->setText("click\nme!");
 
-		//default size is (0,0)
-		//set button size to text
-		//align would work properly now
-		text->setSize(button->getSize());	
-
-		//_text is MainActor member
-		//we will use it later
+		//we will change text later
 		_text = text; 
 	}
 
-	void clicked(Event *event)
+	void displayClicked(Event *event)
 	{
 		//user clicked to button
 		_text->setText("clicked!");
@@ -78,15 +73,14 @@ public:
 		int duration = 500;//500 ms 
 		int loops = -1;//infinity loops
 
-		//animation has 7 cols, check res.xml
+		//animation has 7 columns, check res.xml
 		ResAnim *animation = gameResources.getResAnim("anim");
 
-		//create animation tween and add it to sprite
+		//add animation tween to sprite
 		//TweenAnim would change animation frames
-		spTween tween = createTween(TweenAnim(animation), duration, loops);
-		sprite->addTween(tween);
+		sprite->addTween(TweenAnim(animation), duration, loops);
 
-		Vector2 destPos = RootActor::instance->getSize() - sprite->getSize();
+		Vector2 destPos = getRoot()->getSize() - sprite->getSize();
 		Vector2 srcPos = Vector2(0, destPos.y);
 		//set sprite initial position
 		sprite->setPosition(srcPos);		
@@ -99,13 +93,11 @@ public:
 		tweenQueue->add(Sprite::TweenPosition(destPos), 1500, 1);
 		//then fade it out smoothly
 		tweenQueue->add(Sprite::TweenAlpha(0), 1000, 1);
-
-
-
+		
 		sprite->addTween(tweenQueue);
 
-		//and remove sprite from actor when tweenQueue is empty
-		//sprite would be deleted automatically
+		//and remove sprite from tree when tweenQueue is empty
+		//if you don't hold any references to sprite it would be deleted automatically
 		tweenQueue->setDetachActor(true);		
 	}
 };
@@ -115,16 +107,13 @@ void example_init()
 	//load xml file with resources definition
 	gameResources.loadXML("res.xml");
 
-	file::handle h = file::open("test", "wb");
-	file::close(h);
-
 
 	//lets create our client code simple actor
 	//prefix 'sp' here means it is intrusive Smart Pointer
 	//it would be deleted automatically when you lost ref to it	
 	spMainActor actor = new MainActor;
 	//and add it to RootActor as child
-	RootActor::instance->addChild(actor);
+	getRoot()->addChild(actor);
 }
 
 void example_update()

+ 0 - 4
examples/HelloWorld/src/example.h

@@ -1,7 +1,3 @@
 void example_init();
 void example_destroy();
 void example_update();
-
-
-const int VirtualWidth = 480;
-const int VirtualHeight = 320;

BIN
examples/Match3/data/images/jewels/air.png


BIN
examples/Match3/data/images/jewels/coin.png


BIN
examples/Match3/data/images/jewels/earth.png


BIN
examples/Match3/data/images/jewels/fire.png


BIN
examples/Match3/data/images/jewels/skull.png


BIN
examples/Match3/data/images/jewels/water.png


+ 13 - 12
examples/Match3/data/resources.xml

@@ -1,18 +1,19 @@
 <?xml version="1.0"?>
 <resources>
+	<set path = "fonts" />
+	<font file="main.fnt" />	
+
 	<set path = "images\" />
 	<atlas>
-		<image file="bg.png"/>	
-		
-	<set path = "images\jewels" />	
-		<image file="jewel1.png"/>
-		<image file="jewel2.png"/>
-		<image file="jewel3.png"/>
-		<image file="jewel4.png"/>
-		<image file="jewel5.png"/>
-		<image file="jewel6.png"/>
+		<image file="bg.png"/>			
+
+		<set path = "images\jewels" scale_factor="0.5"/>	
+
+		<image id="jewel1" file="air.png" />
+		<image id="jewel2" file="coin.png" />
+		<image id="jewel3" file="earth.png" />
+		<image id="jewel4" file="fire.png" />
+		<image id="jewel5" file="water.png" />
+		<image id="jewel6" file="skull.png" />
 	</atlas>
-	
-	<set path = "fonts" />
-	<font file="main.fnt" />	
 </resources>

+ 24 - 30
examples/Match3/src/entry_point.cpp

@@ -40,14 +40,14 @@ int mainloop()
 	example_update();
 	//update our rootActor
 	//Actor::update would be called also for children
-	RootActor::instance->update();
+	getRoot()->update();
 
 	Color clear(33, 33, 33, 255);
 	//start rendering and clear viewport
 	if (renderer.begin(0, viewport, &clear))
 	{
 		//begin rendering from RootActor. 
-		RootActor::instance->render(renderer);
+		getRoot()->render(renderer);
 		//rendering done
 		renderer.end();
 
@@ -67,34 +67,32 @@ int mainloop()
 void run()
 {	
 	//initialize oxygine's internal stuff
-	core::init();
-	
-	
-	//create RootActor. RootActor is a root node
-	RootActor::instance = new ExampleRootActor();
+	core::init_desc desc;
 
+#if OXYGINE_SDL
+	//we could setup initial window size on SDL builds
+	//desc.w = 960;
+	//desc.h = 660;
+	//marmalade settings could be changed from emulator's menu
+#endif
+
+	core::init(&desc);	
 	
+	//create RootActor. RootActor is a root node
+	RootActor::instance = new ExampleRootActor();	
 	Point size = core::getDisplaySize();
-
-	//initialize it
-	//first argument is real display size of device.
-	//second is your "virtual" preferred size. You could change it to any size you need
-	//VirtualWidth and VirtualHeight are defined in example.h	
-	RootActor::instance->init(size, 
-		Point(VirtualWidth, VirtualHeight));
+	getRoot()->init(size, size);
 	
-
-	//DebugActor is a helper node it shows FPS and memory usage
+	//DebugActor is a helper node it shows FPS and memory usage and other useful stuff
 	DebugActor::initialize();
 
-
 	//create and add new DebugActor to root actor as child
-	RootActor::instance->addChild(new DebugActor());
+	getRoot()->addChild(new DebugActor());
 
 
-	//it is view and projection matrix  initialization stuff
-	
-	Matrix view = makeViewMatrix(size.x, size.y); //Returns View matrix where Left Top corner is (0,0), and right bottom is (w,h)
+	//initialization view and projection matrix 	
+	//makeViewMatrix returns View matrix where Left Top corner is (0,0), and right bottom is (w,h)
+	Matrix view = makeViewMatrix(size.x, size.y); 
 
 	viewport = Rect(0, 0, size.x, size.y);
 
@@ -110,11 +108,9 @@ void run()
 	renderer.setViewTransform(view);
 	renderer.setProjTransform(proj);
 
-
-	//initialize this example stuff. check example.cpp
+	//initialize this example stuff. see example.cpp
 	example_init();
 
-
 	bool done = false;	
 
 	//here is main game loop
@@ -124,17 +120,16 @@ void run()
 		if (done)
 			break;
     }
-	//so user closed application
+	//so user want to leave application...
 	
-	//lets dump all created objects into Output
+	//lets dump all created objects into log
 	//all created and not freed resources would be displayed
 	ObjectBase::dumpCreatedObjects();
 
-
 	//lets cleanup everything right now and call ObjectBase::dumpObjects() again
 	//we need to free all allocated resources and delete all created actors
-	//yes, actor is smart pointer and actually you don't need it remove by hands
-	//but now we want delete it forcedly
+	//all actors/sprites are smart pointer objects and actually you don't need it remove them by hands
+	//but now we want delete it by hands
 
 	//check example.cpp
 	example_destroy();	
@@ -148,7 +143,6 @@ void run()
 	//dump list should be empty now
 	//we deleted everything and could be sure that there aren't any memory leaks
 	ObjectBase::dumpCreatedObjects();
-
 	//end
 }
 

+ 1 - 1
examples/Match3/src/example.cpp

@@ -9,7 +9,7 @@ void example_init()
 	//load xml file with resources definition
 	res.loadXML("resources.xml");
 
-	RootActor::instance->addChild(new GameFrame());
+	getRoot()->addChild(new GameFrame());
 }
 
 void example_destroy()

+ 1 - 3
examples/Match3/src/example.h

@@ -1,5 +1,3 @@
 void example_init();
 void example_destroy();
-void example_update();
-const int VirtualWidth = 480;
-const int VirtualHeight = 320;
+void example_update();

+ 75 - 95
examples/Match3/src/gameframe.cpp

@@ -2,12 +2,6 @@
 #include "shared.h"
 
 
-void Field::MakeTurn(bool changePlayer)
-{
-
-
-}
-
 int Field::StartAnimation(Point ind)
 {
 	spTween tween = At(ind)->PlayAnimation();
@@ -67,7 +61,6 @@ int Field::goRight(Point ind, bool scoreit)
 
 int Field::goLeft(Point ind, bool scoreit)
 {
-	//if (At(ind)->getState()!=jsNormal) return 0;
 	Point next_ind = ind;
 	next_ind.x-=1;
 	int sum=1;
@@ -82,10 +75,6 @@ int Field::goLeft(Point ind, bool scoreit)
 
 int Field::CheckJewel(Point ind, bool donotscore)
 {
-	//if (!At(ind)->IsID(jsNormal)) return 0;
-
-
-	//îïðåäåëÿåì êîëè÷åñòâî ðÿäîì ñòîÿùèõ îäèíàêîâûõ êàìíåé
 	int s1=goLeft(ind);
 	s1+=goRight(ind)-1;
 
@@ -95,10 +84,11 @@ int Field::CheckJewel(Point ind, bool donotscore)
 	int bs=0;
 
 
-	if (s2>2 && s1>2) {//ñîáèðàíèå êàìíåé ïî âåðòèêàëè è ãîðèçîíòàëè
+	if (s2>2 && s1>2)
+	{
 		bs=s1+s2-1;
-		if (donotscore) return bs;
-		//Attack(stones[i][j].type,bs);
+		if (donotscore)
+			return bs;
 
 		At(ind)->LockUnlock();
 		goLeft(ind,true); 
@@ -109,10 +99,11 @@ int Field::CheckJewel(Point ind, bool donotscore)
 		return bs;
 	}
 
-	if (s1>s2 && s1>2) {//ñîáèðàíèå êàìíåé ïî ãîðèçîíòàëè
+	if (s1>s2 && s1>2)
+	{
 		bs=s1-2;
-		if (donotscore) return s1;
-		//	Attack(stones[i][j].type,s1);
+		if (donotscore) 
+			return s1;
 
 		At(ind)->LockUnlock();
 		goLeft(ind,true); 
@@ -121,10 +112,11 @@ int Field::CheckJewel(Point ind, bool donotscore)
 		return bs;
 	}
 
-	if (s2>s1 && s2>2) {//ñîáèðàíèå êàìíåé ïî âåðòèêàëè
+	if (s2>s1 && s2>2)
+	{
 		bs=s2-2;
-		if (donotscore) return s2;
-		//	Attack(stones[i][j].type,s2);
+		if (donotscore) 
+			return s2;
 		At(ind)->LockUnlock();
 		goUp(ind,true); 
 		At(ind)->LockUnlock();
@@ -134,17 +126,13 @@ int Field::CheckJewel(Point ind, bool donotscore)
 	return bs;
 }
 
-bool compareSolutions(const TFieldSolutions* left, const TFieldSolutions* right)
-{
-	return left->jewel_count > right->jewel_count;
-};
-
 
 bool Field::FindSolutions()
 {
-	std::vector<TFieldSolutions*> solutions;
+	std::vector<TFieldSolutions> solutions;
 
 	for(int i=0; i<FIELD_SIZE-1; i++)
+	{
 		for(int j=0; j<FIELD_SIZE; j++)
 		{
 			int points;
@@ -152,17 +140,19 @@ bool Field::FindSolutions()
 			points = CheckJewel(Point(i,j),true);
 			if (points>0) 
 			{	
-				solutions.push_back(new TFieldSolutions(Point(i,j),Point(i+1,j),points));
+				solutions.push_back(TFieldSolutions(Point(i,j),Point(i+1,j),points));
 			}
 			points += CheckJewel(Point(i+1,j),true);
 			if (points>0) 
 			{	
-				solutions.push_back(new TFieldSolutions(Point(i+1,j),Point(i,j),points));
+				solutions.push_back(TFieldSolutions(Point(i+1,j),Point(i,j),points));
 			}
 			ForceSwap(jewels[i][j],jewels[i+1][j]);
 		}
+	}
 
-		for(int i=0; i<FIELD_SIZE; i++)
+	for(int i=0; i<FIELD_SIZE; i++)
+	{
 			for(int j=0; j<FIELD_SIZE-1; j++)
 			{
 				int points;
@@ -170,36 +160,24 @@ bool Field::FindSolutions()
 				points = CheckJewel(Point(i,j),true);
 				if (points>0) 
 				{	
-					solutions.push_back(new TFieldSolutions(Point(i,j),Point(i,j+1),points));
+					solutions.push_back(TFieldSolutions(Point(i,j),Point(i,j+1),points));
 				}
 				points += CheckJewel(Point(i,j+1),true);
 				if (points>0) 
 				{	
-					solutions.push_back(new TFieldSolutions(Point(i,j+1),Point(i,j),points));
+					solutions.push_back(TFieldSolutions(Point(i,j+1),Point(i,j),points));
 				}
 				ForceSwap(jewels[i][j],jewels[i][j+1]);
 			}
+	}
 
-			if (solutions.size()==0)
-			{
-				return false;
-			}
-			else
-			{
-				std::sort(solutions.begin(),solutions.end(), &compareSolutions);
-				solutions.clear();
-				return true;
-			}
-
-
+	if (solutions.empty())	
+		return false;
+	
+	return true;
 }
 
 
-int compareVariants(const TFieldVariants* left, const TFieldVariants* right)
-{
-	return left->points > right->points;
-}
-
 void Field::FillField(bool first_time)
 {
 	for (int i=0; i<FIELD_SIZE; i++)
@@ -235,39 +213,30 @@ void Field::CleanField()
 				}	
 			}
 	}while(!ex);
-
 }
 
 bool Field::CheckField()
 {
-
-	std::vector<TFieldVariants *> variants;
+	std::vector<TFieldVariants> variants;
 	for (int i=0; i<FIELD_SIZE; i++)
 		for (int j=0; j<FIELD_SIZE; j++)
 		{
 			int points = CheckJewel(Point(i,j),true);
 			if (points>0)
 			{
-				variants.push_back(new TFieldVariants(Point(i,j),points));
+				variants.push_back(TFieldVariants(Point(i,j),points));
 			}
 		}
 
-		if (variants.size()==0) 
+		if (variants.empty()) 
 		{
-			variants.clear();
 			return false;
-
 		}
 		else
 		{
-			//ñîðòèðîâêà ìàññèâà ïî óáûâàíèþ
-			std::sort(variants.begin(),variants.end(), &compareVariants);
-
-			//ñîáèðàåì â ïîëå ñàìûå ëó÷øèå âàðèàíòû
 			for (size_t i=0; i<variants.size(); i++)
 			{
-				CheckJewel(variants.at(i)->index);
-				delete variants.at(i);
+				CheckJewel(variants.at(i).index);
 			}
 			variants.clear();
 			return true;
@@ -277,7 +246,8 @@ bool Field::CheckField()
 
 bool Field::BackSwap()
 {
-	if (back_swap) return false;
+	if (back_swap) 
+		return false;
 	back_swap = true;
 	Swap( At(jewel_drag_ind), At(jewel_new_ind));
 	return true;
@@ -296,20 +266,23 @@ void Field::DropEndCallback(Event *ev)
 		{
 			if (FindSolutions())
 				state = fsWaiting;
-			else RefreshField();
+			else 
+				RefreshField();
 		}
 	}
 }
 
 
-bool Field::Swap(spTJewel First, spTJewel Second, bool skip_animation)
+bool Field::Swap(spJewel First, spJewel Second, bool skip_animation)
 {
-	Point diff = getCellIndex( First->getPosition()) -  getCellIndex( Second->getPosition());
-	if (abs(diff.x)>1 || (abs(diff.y)>1) || abs(diff.x)==abs(diff.y) || Second==First || !( Second->getState()==jsNormal && First->getState()==jsNormal)) return false;
+	Point diff = getCellIndex(First->getPosition()) - getCellIndex(Second->getPosition());
+	if (abs(diff.x)>1 || (abs(diff.y)>1) || 
+		abs(diff.x)==abs(diff.y) || Second==First || 
+		!(Second->getState()==jsNormal && First->getState()==jsNormal)) 
+		return false;
 
 	ForceSwap(First, Second);
 
-
 	if (!skip_animation)
 	{
 		state = fsAnimation;
@@ -322,6 +295,7 @@ bool Field::Swap(spTJewel First, spTJewel Second, bool skip_animation)
 		tween->setDoneCallback(CLOSURE(this, &Field::EndSwapCallback));
 		Second->addTween(tween);
 	}
+
 	return true;
 }
 
@@ -369,7 +343,7 @@ int Field::FindFreeCell(int column, int limit)
 		return free;
 }
 
-void Field::ForceSwap(spTJewel First, spTJewel Second)
+void Field::ForceSwap(spJewel First, spJewel Second)
 {
 	Point first_index = First->index;
 	Point second_index = Second->index;
@@ -381,35 +355,39 @@ void Field::ForceSwap(spTJewel First, spTJewel Second)
 	jewels[second_index.x][second_index.y]->index = second_index;
 }
 
-void  Field::DropJewel(spTJewel Target, spTJewel Jewel)
+void  Field::DropJewel(spJewel Target, spJewel Jewel)
 {
-	if (Jewel->getState()!=jsNormal) return;
-	if (Target->getState()!=jsScored) return;
+	if (Jewel->getState()!=jsNormal)
+		return;
 
+	if (Target->getState()!=jsScored) 
+		return;
 
 	spTween tween = Jewel->DropTo(Target->getPosition());
 	tween->setDoneCallback(CLOSURE(this, &Field::DropEndCallback));		
-	Target->setPosition( getCellPosition(Jewel->index.x, Jewel->index.y));
+	Target->setPosition(getCellPosition(Jewel->index.x, Jewel->index.y));
 	ForceSwap(Target,Jewel);
 	droped_count++;
 }
 
 void Field::RefreshField()
-{	for (int i=0; i<FIELD_SIZE; i++)
-{
-	for (int j=FIELD_SIZE-1; j>=0; j--) 
+{	
+	for (int i=0; i<FIELD_SIZE; i++)
 	{
-		jewels[i][j]->setState(jsScored);
+		for (int j=FIELD_SIZE-1; j>=0; j--) 
+		{
+			jewels[i][j]->setState(jsScored);
+		}
+		GenerateNewJewels(i);
 	}
-	GenerateNewJewels(i);
-}
-CleanField();
+	CleanField();
 }
 
 int Field::GenerateNewJewels(int column)
 {
 	int count = 0;
 	for (int j=FIELD_SIZE-1; j>=0; j--) 
+	{
 		if (jewels[column][j]->getState()==jsScored)
 		{
 			Vector2 pos = jewels[column][j]->getPosition();
@@ -422,7 +400,9 @@ int Field::GenerateNewJewels(int column)
 			count++;
 
 		}
-		return 0;
+	}
+
+	return 0;
 }
 
 bool Field::DropField()
@@ -439,14 +419,12 @@ bool Field::DropField()
 					DropJewel(jewels[i][free],jewels[i][j]);
 				}
 			}
-
-
-
 		}
 		GenerateNewJewels(i);
 	}
 
-	if (droped_count>0) state = fsAnimation;
+	if (droped_count>0)
+		state = fsAnimation;
 	return true;
 }
 
@@ -455,7 +433,8 @@ void Field::EndAnimationCallback(Event *ev)
 	safeSpCast<Jewel>(ev->currentTarget)->AnimationEnd();
 	animated_count--;
 
-	if (animated_count==0) DropField();
+	if (animated_count==0) 
+		DropField();
 }
 
 void Field::EndSwapCallback(Event *ev)
@@ -470,7 +449,7 @@ void Field::EndSwapCallback(Event *ev)
 	}
 }
 
-Field::Field(Vector2 pos, Vector2 jewelsIndent)
+Field::Field()
 {
 	animated_count=0;
 	droped_count=0;
@@ -480,15 +459,13 @@ Field::Field(Vector2 pos, Vector2 jewelsIndent)
 	addEventListener(TouchEvent::TOUCH_DOWN, cb);
 	state = fsWaiting;
 
-	jewels_indent = jewelsIndent;
-	setPosition(pos);
-	setSize(Vector2(jewelsIndent.x*JEWEL_SIZE*FIELD_SIZE,jewelsIndent.y*JEWEL_SIZE*FIELD_SIZE));
+	setSize(JEWEL_SIZE * FIELD_SIZE, JEWEL_SIZE * FIELD_SIZE);
 
 	FillField(true);
 	RefreshField();
 }
 
-spTJewel Field::At(Point index)
+spJewel Field::At(Point index)
 {
 	if (index.x>-1 && index.y>-1 && index.x<FIELD_SIZE && index.y<FIELD_SIZE)
 		return jewels[index.x][index.y];
@@ -499,21 +476,24 @@ spTJewel Field::At(Point index)
 
 Point Field::getCellIndex(Vector2 position)
 {
-	return Point((position.x)/(JEWEL_SIZE+jewels_indent.x),(position.y)/(JEWEL_SIZE+jewels_indent.y));
+	return Point(position.x/JEWEL_SIZE, position.y/JEWEL_SIZE);
 }
 
 Vector2	Field::getCellPosition(int i, int j)
 {
-	return Vector2(((i*(JEWEL_SIZE+jewels_indent.x))),(j*(JEWEL_SIZE+jewels_indent.y)));
+	return Vector2(i * JEWEL_SIZE + JEWEL_SIZE/2, j * JEWEL_SIZE + JEWEL_SIZE/2);
 }
 
-
 //////////////////////////////////////////////////////////////////////////////////////////
 
 GameFrame::GameFrame()
 {		
-	setAnimFrame(res.getResAnim("bg"));
+	setResAnim(res.getResAnim("bg"));
+
+	spTField field = new Field();
+	float scale = getRoot()->getHeight() * 0.9f / field->getHeight();
+	field->setScale(scale);
 
-	spTField field = new Field(Vector2(107,42),Vector2(3,2));
+	field->setPosition(getRoot()->getSize()/2 - field->getSize() * scale/2);
 	addChild(field);
 }

+ 6 - 8
examples/Match3/src/gameframe.h

@@ -47,22 +47,21 @@ class Field : public Actor
 public:
 	TFieldState getState() {return state;}
 
-	spTJewel jewels[FIELD_SIZE][FIELD_SIZE];
+	spJewel jewels[FIELD_SIZE][FIELD_SIZE];
 
-	Field(Vector2 pos, Vector2 jewelsIndent);
-	spTJewel At(Point index);
+	Field();
+	spJewel At(Point index);
 
 	Vector2	getCellPosition(int i, int j);
 	Point getCellIndex(Vector2 position);
 
 	void JewelClick(Event *event);
-	bool Swap(spTJewel First, spTJewel Second, bool skip_animation = false);
+	bool Swap(spJewel First, spJewel Second, bool skip_animation = false);
 	bool BackSwap();
 
 private:
 	TFieldState state;
 	Vector2 size;
-	Vector2 jewels_indent;
 
 	Point jewel_drag_ind;
 	Point jewel_new_ind;
@@ -81,8 +80,8 @@ private:
 
 	bool back_swap;
 	bool DropField();
-	void DropJewel(spTJewel Target, spTJewel Jewel);
-	void ForceSwap(spTJewel First, spTJewel Second);
+	void DropJewel(spJewel Target, spJewel Jewel);
+	void ForceSwap(spJewel First, spJewel Second);
 	int FindFreeCell(int column, int limit = 0);
 	int StartAnimation(Point ind);
 	int GenerateNewJewels(int column);
@@ -91,7 +90,6 @@ private:
 	void FillField(bool first_time = false);
 	bool FindSolutions();
 	void RefreshField();
-	void MakeTurn(bool changePlayer = true);
 };
 
 

+ 6 - 6
examples/Match3/src/jewels.cpp

@@ -7,11 +7,12 @@ Jewel::Jewel(int jewel_id)
 	state = jsNormal;
 	Set(jewel_id);
 	setInputEnabled(false);
+	setAnchor(0.5f, 0.5f);
 }
 
 void Jewel::Set(int id)
 {
-	setAnimFrame(res.getResAnim(jewels_ids[id]));
+	setResAnim(res.getResAnim(jewels_ids[id]));
 	_id = id;
 	setAlpha(255);
 }
@@ -23,7 +24,6 @@ void Jewel::UnSelect()
 		return;
 
 	state = jsNormal;
-	setAnchor(Vector2(0.0f,0.0f));
 	setRotation(0);
 	setPosition(old_position);
 	removeTweens();
@@ -31,13 +31,13 @@ void Jewel::UnSelect()
 
 void Jewel::SetSelected()
 {
-	if (state!=jsNormal) return;
+	if (state != jsNormal)
+		return;
 
 	state = jsSelected;
 	spTweenQueue tween = new TweenQueue();
 	old_position = getPosition();
-	setPosition(Vector2(getPosition().x+JEWEL_SIZE/2, getPosition().y+JEWEL_SIZE/2));
-	setAnchor(Vector2(0.5f,0.5f));
+	//setPosition(getX() + JEWEL_SIZE/2, getY() + JEWEL_SIZE/2);
 
 	tween->add(Sprite::TweenRotation(MATH_PI * 0.1f), 100);
 	tween->add(Sprite::TweenRotation(MATH_PI  * (-0.1f)), 400,-1,true);
@@ -49,7 +49,7 @@ void Jewel::SetSelected()
 
 spTween Jewel::PlayAnimation()
 {
-	if (! (state==jsNormal && locked) )
+	if (!(state==jsNormal && locked) )
 		return 0;
 
 	state = jsAnimation;

+ 3 - 3
examples/Match3/src/jewels.h

@@ -2,11 +2,11 @@
 
 #include "oxygine-framework.h"
 
-#define JEWEL_SIZE 42
+#define JEWEL_SIZE 50
 
 using namespace oxygine;
 
-DECLARE_SMART(Jewel, spTJewel);
+DECLARE_SMART(Jewel, spJewel);
 
 typedef enum {jsNormal, jsAnimation, jsSelected, jsScored, jsDropped} TJewelState;
 
@@ -32,7 +32,7 @@ public:
 	void SetSelected();
 	void UnSelect();
 	spTween DropTo(Vector2 pos);
-	bool IsID(spTJewel spJewel) {return spJewel->GetId()==_id;}
+	bool IsID(spJewel spJewel) {return spJewel->GetId()==_id;}
 	void Set(int id);
 
 	spTween PlayAnimation();

+ 8 - 8
oxygine/src/Actor.cpp

@@ -90,8 +90,8 @@ namespace oxygine
 		removeTweens();
 		//removeEventHandlers();
 		removeChildren();
-		if (RootActor::instance)
-			RootActor::instance->removeEventListeners(this);
+		if (getRoot())
+			getRoot()->removeEventListeners(this);
 	}	
 
 	std::string Actor::dump(const dumpOptions &opt) const
@@ -207,11 +207,11 @@ namespace oxygine
 
 		if (v)
 		{
-			RootActor::instance->addEventListener( TouchEvent::TOUCH_UP, CLOSURE(this, &Actor::_onMouseEvent));
+			getRoot()->addEventListener( TouchEvent::TOUCH_UP, CLOSURE(this, &Actor::_onMouseEvent));
 			//printf("added\n");
 		}
 		else
-			RootActor::instance->removeEventListener( TouchEvent::TOUCH_UP, CLOSURE(this, &Actor::_onMouseEvent));
+			getRoot()->removeEventListener( TouchEvent::TOUCH_UP, CLOSURE(this, &Actor::_onMouseEvent));
 
 		if (!old)
 			updateState();
@@ -231,11 +231,11 @@ namespace oxygine
 			e.index = v;
 			dispatchEvent(&e);
 
-			RootActor::instance->addEventListener( TouchEvent::MOVE, CLOSURE(this, &Actor::_onMouseEvent));
+			getRoot()->addEventListener( TouchEvent::MOVE, CLOSURE(this, &Actor::_onMouseEvent));
 		}
 		else
 		{
-			RootActor::instance->removeEventListener( TouchEvent::MOVE, CLOSURE(this, &Actor::_onMouseEvent));
+			getRoot()->removeEventListener( TouchEvent::MOVE, CLOSURE(this, &Actor::_onMouseEvent));
 			//if (!_overed)
 			{
 				TouchEvent e(TouchEvent::OUT);
@@ -259,7 +259,7 @@ namespace oxygine
 			if (isDescendant(act))
 			{
 				if (event->phase == Event::phase_target)
-					RootActor::instance->addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Actor::_onMouseEvent));					
+					getRoot()->addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Actor::_onMouseEvent));					
 				setPressed(me->index);
 				//_pressed = me->id;
 				//setPressed(true);
@@ -297,7 +297,7 @@ namespace oxygine
 						setOvered(me->index);
 
 						if (event->phase == Event::phase_target)
-							RootActor::instance->addEventListener(TouchEvent::MOVE, CLOSURE(this, &Actor::_onMouseEvent));
+							getRoot()->addEventListener(TouchEvent::MOVE, CLOSURE(this, &Actor::_onMouseEvent));
 					}
 				}
 				else

+ 2 - 2
oxygine/src/Button.cpp

@@ -95,7 +95,7 @@ namespace oxygine
 					{
 						_btnPressed = me->index;
 						setState(statePressed);
-						RootActor::instance->addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Button::_mouseEvent));
+						getRoot()->addEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Button::_mouseEvent));
 					}					
 				}				
 			}
@@ -105,7 +105,7 @@ namespace oxygine
 				if (_btnPressed == me->index)
 				{				
 					setState(stateNormal);
-					RootActor::instance->removeEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Button::_mouseEvent));
+					getRoot()->removeEventListener(TouchEvent::TOUCH_UP, CLOSURE(this, &Button::_mouseEvent));
 					_btnPressed = 0;
 				}
 

+ 12 - 12
oxygine/src/DebugActor.cpp

@@ -89,8 +89,8 @@ namespace oxygine
 		setPriority(1000);
 
 		float scale = 1.0f;
-		if (RootActor::instance)
-			scale = 1.0f/RootActor::instance->getScaleX();
+		if (getRoot())
+			scale = 1.0f/getRoot()->getScaleX();
 
 		setScale(scale);
 
@@ -173,17 +173,17 @@ namespace oxygine
 			return;
 		}
 
-		spActor inspector = RootActor::instance->getChild(DeveloperMenu::getDefaultName(), ep_ignore_error);
+		spActor inspector = getRoot()->getChild(DeveloperMenu::getDefaultName(), ep_ignore_error);
 		if (inspector)
 			inspector->detach();
 		else
 		{		
 			spDeveloperMenu dm = new DeveloperMenu();
-			dm->setPriority(getPriority() - 1);
-			float scale = RootActor::instance->getScaleX();
-			Vector2 size = RootActor::instance->getSize();
+			dm->setPriority(getPriority() - 1); 
+			float scale = getRoot()->getScaleX();
+			Vector2 size = core::getDisplaySize();
 
-			Vector2 s = size * scale;
+			Vector2 s = size;// * scale;
 			
 			if (name == "tree")
 			{
@@ -245,10 +245,10 @@ namespace oxygine
 		s << "objects=" << (int)__objects.size() << endl;
 #endif
 		s << "batches="<< batches << " triangles=" << triangles << endl;
-		s << "update=" << RootActor::instance->_statUpdate << "ms ";
-		s << "render=" << RootActor::instance->_statRender << "ms ";
+		s << "update=" << getRoot()->_statUpdate << "ms ";
+		s << "render=" << getRoot()->_statRender << "ms ";
 		s << "textures=" << NativeTexture::created << " ";
-		s << "\nlisteners=" << RootActor::instance->getListenersCount() << "";
+		s << "\nlisteners=" << getRoot()->getListenersCount() << "";
 
 		s << "\n";
 		s << _debugText;
@@ -307,10 +307,10 @@ namespace oxygine
 	
 	void DebugActor::showTouchedActor(bool show)
 	{
-		RootActor::instance->removeEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this, &DebugActor::onEvent));
+		getRoot()->removeEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this, &DebugActor::onEvent));
 		_showTouchedActor = show;
 		if (show)
-			RootActor::instance->addEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this, &DebugActor::onEvent));
+			getRoot()->addEventListener(TouchEvent::TOUCH_DOWN, CLOSURE(this, &DebugActor::onEvent));
 
 		spActor btn = getChild("finger");
 		btn->removeTweens(true);

+ 3 - 3
oxygine/src/Draggable.cpp

@@ -73,8 +73,8 @@ namespace oxygine
 	{
 		if (_actor && !_singleDrag)
 		{
-			if (RootActor::instance)
-				RootActor::instance->removeEventListeners(this);
+			if (getRoot())
+				getRoot()->removeEventListeners(this);
 			_actor->removeEventListeners(this);
 			_actor = 0;
 		}
@@ -161,7 +161,7 @@ namespace oxygine
 		case TouchEvent::TOUCH_UP:
 			{
 				_pressed = false;
-				RootActor::instance->removeEventListeners(this);
+				getRoot()->removeEventListeners(this);
 			}
 			break;
 

+ 3 - 3
oxygine/src/Input.cpp

@@ -29,7 +29,7 @@ namespace oxygine
 
 		ps->_position = p;
 
-		RootActor::instance->handleEvent(&me);
+		getRoot()->handleEvent(&me);
 	}
 
 	void Input::sendPointerMotionEvent(float x, float y, float pressure, PointerState *ps)
@@ -39,7 +39,7 @@ namespace oxygine
 		me.pressure = pressure;
 		ps->_position = Vector2(x, y);
 
-		RootActor::instance->handleEvent(&me);
+		getRoot()->handleEvent(&me);
 	}
 
 	void Input::sendPointerWheelEvent(int scroll, PointerState *ps)
@@ -49,7 +49,7 @@ namespace oxygine
 
 		ps->_position = Vector2(0, 0);
 
-		RootActor::instance->handleEvent(&me);
+		getRoot()->handleEvent(&me);
 	}
 
 

+ 1 - 1
oxygine/src/RootActor.h

@@ -57,5 +57,5 @@ namespace oxygine
 		friend class DebugActor;
 	};
 
-	inline spRootActor getRoot(){return RootActor::instance;}
+	inline const spRootActor& getRoot() {return RootActor::instance;}
 }

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

@@ -176,7 +176,9 @@ namespace oxygine
 		/**Cleans existing accumulated batch.*/
 		void cleanup();
 
-		int getMaxVertices() const {return _maxVertices;}		
+		int				getMaxVertices() const {return _maxVertices;}		
+		const Matrix&	getView() const {return _view;}
+		const Matrix&	getProjection() const {return _proj;}
 
 		IVideoDriver *getDriver();
 		void setDriver(IVideoDriver *);

+ 8 - 0
oxygine/src/core/VideoDriver.h

@@ -20,6 +20,14 @@ namespace oxygine
 		Vector2 &getUV() {return *((Vector2*)&u);}
 	};
 
+	struct vertexP2C
+	{
+		float x, y;		
+		unsigned int color;
+
+		Vector2 &getPos() {return *((Vector2*)&x);}
+	};
+
 	struct vertexPCT2
 	{
 		float x, y, z;

+ 61 - 56
oxygine/src/core/gl/VideoDriverGLES20.cpp

@@ -31,6 +31,8 @@ namespace oxygine
 			glDeleteProgram(_program);
 	}
 
+
+
 	void printShaderInfoLog(GLuint shader)
 	{
 		GLint length = 0;
@@ -54,6 +56,61 @@ namespace oxygine
 	}
 
 
+	unsigned int ShaderProgramGL::createShader(unsigned int type, const char* data, const char *prepend, const char *append)
+	{
+		GLuint shader = glCreateShader(type);
+
+		const char *sources[16];
+		const char **ptr = &sources[0];
+
+		char nonGLES[] = 
+			"#define lowp\n"
+			"#define mediump\n"
+			"#define highp\n";
+
+#if SDL_VIDEO_OPENGL
+		*ptr = nonGLES;
+		ptr++;
+#endif
+
+		if (prepend)
+		{
+			*ptr = prepend;
+			ptr++;
+		}
+
+		*ptr = data;
+		ptr++;
+
+		if (append)
+		{
+			*ptr = append;
+			ptr++;
+		}
+
+		int num = ptr - sources;
+		glShaderSource(shader, num, sources, 0);
+		glCompileShader(shader);
+		printShaderInfoLog(shader);
+
+		return shader;
+	}
+
+
+	unsigned int ShaderProgramGL::createProgram(int vs, int fs, const VertexDeclarationGL *decl)
+	{
+		int p = glCreateProgram();
+		glAttachShader(p, vs);
+		glAttachShader(p, fs);
+
+		for (int i = 0; i < decl->numElements; ++i)		
+			glBindAttribLocation(p, decl->elements[i].index, decl->elements[i].name);
+
+		glLinkProgram(p);
+
+		return p;
+	}
+
 	UberShaderProgram::UberShaderProgram()
 	{
 
@@ -138,76 +195,24 @@ namespace oxygine
 			strcat(prepend, "#define program_main_ps main\n");
 			strcat(prepend, "#define PS\n");
 
-			int fs = createShader(GL_FRAGMENT_SHADER, data, prepend, append);
+			int fs = ShaderProgramGL::createShader(GL_FRAGMENT_SHADER, data, prepend, append);
 
 			*end = 0;
 			strcat(prepend, "#define program_main_vs main\n");
 			strcat(prepend, "#define VS\n");
 
-			int vs = createShader(GL_VERTEX_SHADER, data, prepend, append);
+			int vs = ShaderProgramGL::createShader(GL_VERTEX_SHADER, data, prepend, append);
 					
 			const VertexDeclarationGL *decl = ((VideoDriverGLES20*)IVideoDriver::instance)->getVertexDeclaration(bformat);
 			ShaderProgramGL *pgl = new ShaderProgramGL;
-			pgl->init(createProgram(vs, fs, decl));
+			pgl->init(ShaderProgramGL::createProgram(vs, fs, decl));
 			s.program = pgl;
 		}
 
 		return &s;
 	}
 
-	unsigned int UberShaderProgram::createShader(unsigned int type, const char* data, const char *prepend, const char *append)
-	{
-		GLuint shader = glCreateShader(type);
-
-		const char *sources[16];
-		const char **ptr = &sources[0];
-
-		char nonGLES[] = 
-			"#define lowp\n"
-			"#define mediump\n";
-
-#if SDL_VIDEO_OPENGL
-		*ptr = nonGLES;
-		ptr++;
-#endif
-
-		if (prepend)
-		{
-			*ptr = prepend;
-			ptr++;
-		}
-
-		*ptr = data;
-		ptr++;
-
-		if (append)
-		{
-			*ptr = append;
-			ptr++;
-		}
-
-		int num = ptr - sources;
-		glShaderSource(shader, num, sources, 0);
-		glCompileShader(shader);
-		printShaderInfoLog(shader);
-
-		return shader;
-	}
-
-
-	unsigned int UberShaderProgram::createProgram(int vs, int fs, const VertexDeclarationGL *decl)
-	{
-		int p = glCreateProgram();
-		glAttachShader(p, vs);
-		glAttachShader(p, fs);
-
-		for (int i = 0; i < decl->numElements; ++i)		
-			glBindAttribLocation(p, decl->elements[i].index, decl->elements[i].name);
-
-		glLinkProgram(p);
-
-		return p;
-	}
+	
 
 	VideoDriverGLES20::VideoDriverGLES20():_blend(blend_default), 
 		_currentProgram(0)

+ 4 - 3
oxygine/src/core/gl/VideoDriverGLES20.h

@@ -47,6 +47,9 @@ namespace oxygine
 			glUniform1f(p, val);
 		}
 
+		static unsigned int createShader(unsigned int type, const char* data, const char *prepend, const char *append);
+		static unsigned int createProgram(int vs, int fs, const VertexDeclarationGL *decl);
+
 	private:
 		GLuint _program;
 	};
@@ -82,6 +85,7 @@ namespace oxygine
 		ShaderUniformsCallback	getShaderUniformsCallback() const {return _cb;}
 		shader*					getShaderProgram(int flags);
 
+
 	protected:
 		void *_getRestorableObject() {return this;}
 		void _restore(Restorable *, void*);
@@ -91,9 +95,6 @@ namespace oxygine
 		ShaderUniformsCallback _cb;		
 
 		void releaseShaders();
-
-		unsigned int createShader(unsigned int type, const char* data, const char *prepend, const char *append);
-		unsigned int createProgram(int vs, int fs, const VertexDeclarationGL *decl);
 	};
 
 

+ 11 - 11
tools/main.wpu

@@ -203,10 +203,10 @@ guimgr.overall-gui-state = {'windowing-policy': 'combined-window',
                       {'attrib-starts': [],
                        'first-line': 0,
                        'folded-linenos': [],
-                       'sel-line': 2,
-                       'sel-line-start': 44,
-                       'selection_end': 44,
-                       'selection_start': 44}),
+                       'sel-line': 0,
+                       'sel-line-start': 0,
+                       'selection_end': 0,
+                       'selection_start': 0}),
                      ('debug-probe',
                       'wide',
                       2,
@@ -658,14 +658,14 @@ guimgr.overall-gui-state = {'windowing-policy': 'combined-window',
         'sel-line-start': 5028,
         'selection_end': 5028,
         'selection_start': 5028}},
-        'has-focus': False,
+        'has-focus': True,
         'locked': False},
                                'open_files': [u'C:/Program Files (x86)/Wing IDE 4.1/resources/doc/en/TOC.idx',
-        u'src2/oxygine_helper.py',
-        u'src2/atlas.py',
-        u'src2/xml_processor.py',
         u'process_xml2.py',
+        u'src2/atlas.py',
+        u'src2/oxygine_helper.py',
         u'src2/process_atlas.py',
+        u'src2/xml_processor.py',
         u'others/convert_font2sd.py']},
         'saved_notebook_display': None,
         'split_percents': {0: 0.45911949685534592},
@@ -679,12 +679,12 @@ guimgr.overall-gui-state = {'windowing-policy': 'combined-window',
                  'user_data': {}},
         'window-alloc': (124,
                          46,
-                         1502,
-                         1218)}]}
+                         1242,
+                         722)}]}
 guimgr.recent-documents = [loc('others/convert_font2sd.py'),
+                           loc('src2/xml_processor.py'),
                            loc('src2/process_atlas.py'),
                            loc('process_xml2.py'),
-                           loc('src2/xml_processor.py'),
                            loc('src2/atlas.py'),
                            loc('src2/oxygine_helper.py')]
 guimgr.visual-state = {loc('file:C:/Program Files (x86)/Wing IDE 4.1/resources/builtin-pi-files/2.7/__builtin__.pi'): {''\