{"id":455,"date":"2011-10-08T15:10:57","date_gmt":"2011-10-08T14:10:57","guid":{"rendered":"http:\/\/www.aymericlamboley.fr\/blog\/?p=455"},"modified":"2011-10-21T19:05:15","modified_gmt":"2011-10-21T18:05:15","slug":"starling-performance-test","status":"publish","type":"post","link":"http:\/\/www.aymericlamboley.fr\/blog\/starling-performance-test\/","title":{"rendered":"Starling performance test"},"content":{"rendered":"<p>Thanks to the Flash Player 11 we have now a stage 3D accelerated graphics rendering. <em>Stage 3D (formerly called &#8220;Molehill&#8221;) is a new architecture for hardware-accelerated graphics rendering developed by Adobe. Stage 3D provides a set of low-level APIs that enable advanced 2D\/3D rendering capabilities across screens and devices (desktop, mobile, and TV). It gives 2D and 3D app and framework developers access to high-performance GPU hardware acceleration, enabling the creation of new classes of rich, interactive experiences.<\/em><\/p>\n<p>Many 3D frameworks are already set up for FP 11 : <a href=\"http:\/\/away3d.com\" target=\"_blank\">away3d<\/a>, <a href=\"http:\/\/blog.aerys.in\/2011\/10\/07\/minko-released-as-open-source\/\" target=\"_blank\">minko<\/a>, <a href=\"http:\/\/alternativaplatform.com\" target=\"_blank\">alternativa<\/a>, <a href=\"http:\/\/www.flare3d.com\/\" target=\"_blank\">flare3D<\/a>, and <a href=\"http:\/\/labs.adobe.com\/technologies\/proscenium\/\" target=\"_blank\">adobe proscenium<\/a>.<br \/>\nThere are also 2D framewoks : <a href=\"https:\/\/github.com\/nulldesign\/nd2d\/\" target=\"_blank\">ND2D<\/a> and <a href=\"http:\/\/www.starling-framework.org\/\" target=\"_blank\">Starling<\/a>.<br \/>\nThat&#8217;s lots of things to test, certainly too much \ud83d\ude00<\/p>\n<p>Today, I have given a try to Starling, it is easy to use ! To get start go on this <a href=\"http:\/\/www.bytearray.org\/?p=3371\" target=\"_blank\">Thibault Imbert page&#8217;s blog<\/a>, there are some examples and a book!<br \/>\nDon&#8217;t forget to upgrade to the last version of the <a href=\"http:\/\/get.adobe.com\/fr\/flashplayer\/\" target=\"_blank\">Flash Player<\/a>.<\/p>\n<p><a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/10\/Starling\/index.html\" target=\"_blank\"><strong>Click here to find my Starling performance stress test.<\/strong><\/a><\/p>\n<p>There are 600 characters on the screen with animation, alpha and rotation! My FPS is 55\/60 with the standard FP, and 40\/60 with the Debugger FP. That&#8217;s a big difference. Also I have a 8600 Geforce with 256 MB ram on my macbook pro (2008). Starling uses the graphic card so this result may change a lot if you have a recent pc or not. However 55 FPS for a 3 years old computer, is really good. I&#8217;m impressed by Starling performance.<\/p>\n<p>I used the <a href=\"http:\/\/forum.starling-framework.org\/topic\/starling-port-of-mrdoobs-stats-class\" target=\"_blank\">Stats<\/a> class of Nicolas Gans originally created by Mr. Doob.<br \/>\nNow take a look in my code. The Main class which set up Starling :<\/p>\n<pre lang=\"actionscript3\" line=\"1\">package {\r\n\r\n\timport starling.core.Starling;\r\n\r\n\timport flash.display.Sprite;\r\n\timport flash.display.StageAlign;\r\n\timport flash.display.StageScaleMode;\r\n\t\r\n\t[SWF(backgroundColor=\"#999999\", frameRate=\"60\", width=\"640\", height=\"480\")]\r\n\r\n\t\/**\r\n\t * @author Aymeric\r\n\t *\/\r\n\tpublic class Main extends Sprite {\r\n\t\t\r\n\t\tprivate var _starling:Starling;\r\n\r\n\t\tpublic function Main() {\r\n\t\t\t\r\n\t\t\tstage.align = StageAlign.TOP_LEFT;\r\n\t\t\tstage.scaleMode = StageScaleMode.NO_SCALE;\r\n\t\t\t\r\n\t\t\t_starling = new Starling(StarlingTest, stage);\r\n\t\t\t\r\n\t\t\t_starling.antiAliasing = 1;\r\n\t\t\t_starling.start();\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<pre lang=\"actionscript3\" line=\"1\">package {\r\n\r\n\timport fr.kouma.starling.utils.Stats;\r\n\r\n\timport starling.core.Starling;\r\n\timport starling.display.MovieClip;\r\n\timport starling.display.Sprite;\r\n\timport starling.events.Event;\r\n\timport starling.textures.Texture;\r\n\timport starling.textures.TextureAtlas;\r\n\timport starling.utils.rad2deg;\r\n\r\n\timport flash.display.Bitmap;\r\n\r\n\t\/**\r\n\t * @author Aymeric\r\n\t *\/\r\n\tpublic class StarlingTest extends Sprite {\r\n\r\n\t\tprivate var _patches:Vector.<MovieClip>;\r\n\t\tprivate var _mc:MovieClip;\r\n\r\n\t\t[Embed(source=\"..\/assets\/patch.xml\", mimeType=\"application\/octet-stream\")]\r\n\t\tpublic static const SPRITESHEETXML:Class;\r\n\r\n\t\t[Embed(source=\"..\/assets\/patch.png\")]\r\n\t\tprivate static const _SPRITESHEET:Class;\r\n\r\n\t\tpublic function StarlingTest() {\r\n\r\n\t\t\taddEventListener(Event.ADDED_TO_STAGE, _init);\r\n\t\t}\r\n\r\n\t\tprivate function _init(evt:Event):void {\r\n\r\n\t\t\tremoveEventListener(Event.ADDED_TO_STAGE, _init);\r\n\r\n\t\t\taddChild(new Stats());\r\n\r\n\t\t\tvar bitmap:Bitmap = new _SPRITESHEET();\r\n\t\t\tvar texture:Texture = Texture.fromBitmap(bitmap);\r\n\t\t\tvar xml:XML = XML(new SPRITESHEETXML());\r\n\t\t\tvar sTextureAtlas:TextureAtlas = new TextureAtlas(texture, xml);\r\n\t\t\tvar frames:Vector.<Texture> = sTextureAtlas.getTextures(\"patch_\");\r\n\r\n\t\t\t_patches = new Vector.<MovieClip>();\r\n\r\n\t\t\tfor (var i:uint = 0; i < 600; ++i) {\r\n\t\t\t\t_mc = new MovieClip(frames, 60);\r\n\t\t\t\taddChild(_mc);\r\n\r\n\t\t\t\tif (Math.random() > 0.5)\r\n\t\t\t\t\t_mc.scaleX = -1;\r\n\r\n\t\t\t\t_mc.x = stage.stageWidth * Math.random();\r\n\t\t\t\t_mc.y = stage.stageHeight * Math.random();\r\n\r\n\t\t\t\t\/\/ Keep the Stats visible\r\n\t\t\t\tif (_mc.x < 150 &#038;&#038; _mc.y < 150) {\r\n\t\t\t\t\t_mc.x += 150;\r\n\t\t\t\t\t_mc.y += 150;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t_patches.push(_mc);\r\n\t\t\t\tStarling.juggler.add(_mc);\r\n\t\t\t}\r\n\r\n\t\t\taddEventListener(Event.ENTER_FRAME, _ef);\r\n\t\t}\r\n\r\n\t\tprivate function _ef(evt:Event):void {\r\n\r\n\t\t\tfor each (var patch:MovieClip in _patches) {\r\n\t\t\t\tpatch.rotation += rad2deg(Math.random());\r\n\t\t\t\tpatch.alpha = Math.random();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<p>To compile for FP 11, download this <a href=\"http:\/\/www.adobe.com\/support\/flashplayer\/downloads.html\" target=\"_blank\">playerglobal.swc 11<\/a>. To create the png file of the patch's character, I used <a href=\"http:\/\/www.texturepacker.com\" target=\"_blank\">TexturePacker<\/a> software.<\/p>\n<p>You can download my <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2011\/10\/Starling\/StarlingTest.zip\"><strong>zip<\/strong><\/a>.<\/p>\n<p>Starling is really an exciting framework, it is easy to learn (really close to the existing AS3 API sometimes too much), which enable to create rich graphics game. Stage3D should be able to target mobile device at the start of the new year!<\/p>\n<p>I'm thinking to integrate Starling support to the CitrusEngine! That's one of my project on a todo list which become bigger and bigger... all interesting stuff... so, stay tuned !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Thanks to the Flash Player 11 we have now a stage 3D accelerated graphics rendering. Stage 3D (formerly called &#8220;Molehill&#8221;) is a new architecture for hardware-accelerated graphics rendering developed by Adobe. Stage 3D provides a set of low-level APIs that enable advanced 2D\/3D rendering capabilities across screens and devices (desktop, mobile, and TV). It gives &hellip; <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/starling-performance-test\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Starling performance test<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[4,33,90],"tags":[15,34,91],"_links":{"self":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/455"}],"collection":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/comments?post=455"}],"version-history":[{"count":4,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/455\/revisions"}],"predecessor-version":[{"id":463,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/455\/revisions\/463"}],"wp:attachment":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/media?parent=455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/categories?post=455"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/tags?post=455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}