Skip to content

MatseFR/massive-starling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

196 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Massive

Massive is a high performance library for Starling, meant to render lots of quads (textured, animated) in a single DisplayObject very efficiently.

It's heavily inspired by the FFParticleSystem lib by Michael Trenkler, which I ported to haxe some years ago.

It's been tested on windows (haxelib version of hxcpp), html5 and air targets with the latest versions of OpenFL, Lime and Starling.

Demos

Benchmark - compare Massive performance with classic Starling Quad and MovieClip (README)

Hex Grid - display only a part of an hexagon map, move around with infinite scroll and interact with it (README)

Particle Editor - editor for Massive's ParticleSystem (WIP) (README)

Getting started

Massive is available on haxelib

haxelib install massive-starling

you can also use haxelib to install it directly from GitHub :

haxelib git massive-starling https://github.com/MatseFR/massive-starling

or download the Massive repo and then use haxelib to install it

haxelib dev massive-starling path/to/massive

To include Massive in an OpenFL project, add this line to your project.xml file:

<haxelib name="massive-starling" />

Quick setup

Massive is meant to be as easy as possible to work with, startup Starling like you would normally do

// first init Massive
// you only have to do this once, and currently you don't need it if you don't use multitexturing
// but later updates might rely on this for non-multitexturing stuff so it's safer to do it anyway
MassiveDisplay.init();

// create a Massive DisplayObject
var massive:MassiveDisplay = new MassiveDisplay();
// by default a MassiveDisplay instance will use the maximum buffer size, which is MassiveConstants.MAX_QUADS (16383)
// if you know you're gonna use less than that you can set the buffer size for better performance
massive.maxQuads = 5000; // display up to 5000 quads
massive.texture = assetManager.getTextureAtlas("my-atlas").texture;
addChild(massive);

// we need a layer in order to display something
var layer:ImageLayer = new ImageLayer();
massive.addLayer(layer);

// we need to create Frame instances to display Massive's equivalent of Image
var textures = assetManager.getTextures("my-atlas-animation");
var frames = Frame.fromTextureVectorWithAlign(textures, Align.CENTER, Align.CENTER); // the Frame class offers various helper functions
// we also need timings to associate with those frames
var timings = Animator.generateTimings(frames);

// we're ready to display our animated "image"
var img:ImageData = new ImageData();
img.setFrames(frames, timings);
img.x = 200;
img.y = 100;
layer.addImage(img);

// note that we don't use multitexturing here : MassiveDisplay only has one texture
// with multitexturing, unless we want our image to use the first texture we would
// have to set the image's textureIndex

You can also look at the samples source code for starters

Frequently Asked Questions

Why is Massive so fast ?

There are several reasons to this :

  • every object in a MassiveDisplay is batchable with the others, no need to check anything
  • Massive display objects are simple : they only have x y position, x y offset, x y scaling, rotation, red/green/blue/alpha and visible properties. Those are public and changing their values doesn't trigger any additionnal code like setting vertex data etc They also aren't touchable, can't have individual blend modes or filters
  • ByteArray is slow + on non-flash targets it needs to be copied before being sent to OpenGL. In Massive the ByteArray renderMode is only there to show that you shouldn't use ByteArray for that kind of stuff :)

About

High performance quad rendering and texture animation for Starling through custom DisplayObject

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages