Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
After playing a little bit around with NME and various targets, I found out that we should definitely implement different rendering systems for the various platforms.
Here is a diagram of a benchmark I ran with the different drawing techniques on the targets Flash and Windows:
Finally I came up with 3 major rendering systems to allow maximum performance on all platforms:
After those systems are implemented, we can test further platforms and see what's running best on them.
Now I'd like to go a little bit more in detail about the rendering systems:
This is the current rendering system. It uses "blitting" to display objects on screen, which means Rygal creates one bitmap that has the size of the game and every texture/sprite gets drawn on that bitmap. This method is a little bit faster on Flash than the traditional display lists, it however has the disadvantage that it can't handle rotation.
This is the default rendering system of NME (And Flash). It basically consists of display objects that can be added to the stage, thus being drawn there. To implement this system in Rygal, one would have to rebuild the DisplayObject-hierarchy inside the GameObject-tree (Which is quite similar to the default display list model), so for instance a Sprite contains a hidden nme.display.Bitmap that will be added to the stage as soon as it gets added to the game. This is the fastest possible way of drawing in HTML 5 and has the advantage of being able to transform (Rotation, scale, etc.). It's however not able to use correct zooming (When tranforming), as rotations may result in "subpixels", so for instance in a game with 4x zoom (So one game's pixel consists of 4x4 visual pixels) where there is a sprite that is rotated, the pixels of the sprite may not always fill one whole "game-pixel", which looks quite bad in Pixelart-games.
NME introduces the class Tilesheet that may be used for drawing a spritesheet. However, it has one particular method that revolutionized performance in NME: drawTiles. This is a single method that is able to draw an arbitrary number of tiles from the spritesheet. It takes an array as a parameter where are all target positions, accompanied by optional transformation data. It is able to draw ridiculously fast on C++ targets like Windows, thus being the most useful performance enhancement.
Gonna implement the drawTiles method soon as it will hopefully reintroduce HTML5 support as well: