SlideShare a Scribd company logo
1 of 31
Download to read offline
Consistent Game Development

across all Platforms
The Road to 

Starling 2.0
or:
How to turn a framework inside out

(while staying sane)
Daniel Sperl
Starling 1.x
• (quite) backwards-compatible since 2012
• Rock solid, but lots of small quirks
• Difficult to add new features 

without major API changes
• Underlying render architecture at its limit
Starling 2.0
• A major rework is required!
• Rethink complete architecture
• Clean up inconsistencies
• But: keep all basic concepts intact

(it’s still Starling, after all)
Meticulous Planning
Custom Batching
Clean Up APIs
Dynamic Lighting
Flexible Meshes
Release: Q1 2016
Simplify!
Easier to extend
State Stack
Scale9-Textures
FilterChain
Pro

cra

sti

nate!
Re

lea

se!
Rough
Kick-off
• Started development on July 24th, 2015
• All work done on a new branch (private)!
• That way, I could still fix bugs in Starling 1.7
Start small
• It’s tempting to start with the big components.
• That way, you’ll end up with 

too many changes at once
• One class leads to the next!
• Can you even compile?!
• Hard to pinpoint problems
Pro Tip:
Start small
• Instead, work bottom-up:

small components first, 

big components later
• Underlying building blocks

become ready for your 

rough plan
• Work in baby steps: Each 

commit must leave Starling 

running!
Pro Tip:
VertexData
• Stores information about each vertex:

position, texture coordinates, color
• Old class was very rigid





• Wanted: arbitrary per-vertex data
• Important: fast (!) and easy to use
Building Block #1:
vertexData = new VertexData();
vertexData.setPosition(0, 50, 20);
vertexData.setTexCoords(0, 1.0, 0.5);
vertexData.setColor(0, 0xff00ff);
VertexData
// format string defines per-vertex contents
vertexData = new VertexData("position:float2, color:bytes4");
vertexData.setPoint(0, "position", 320, 480);
vertexData.setColor(0, "color", 0xff00ff);
// default format contains position, texCoords and color
vertexData = new VertexData();
vertexData.setPoint(0, "position", 320, 480);
vertexData.setPoint(0, "texCoords", 1.0, 0.5);
vertexData.setColor(0, "color", 0xff00ff);
Building Block #1:
Painter
• RenderSupport → Painter
• Wraps many Context3D methods
• Passed to all “render” methods
• Universally accessible (Starling.painter)
• Keeps a stack of state changes
Building Block #2:
Painter
override public function render(painter:Painter):void
{
}
Building Block #2:
painter.pushState(); // save a current state on the stack
painter.popState(); // restore previous state
}
painter.state.renderTarget = renderTexture;
painter.state.alpha = 0.5;
painter.state.transformModelviewMatrix(matrix);
painter.prepareToDraw(); // apply all settings at context
drawSomething(); // insert Stage3D rendering code here
Effect
• Each Stage3D draw call requires a lot of set-up:
• shaders and buffers
• program constants
• context loss restoration
• The “Effect” class encapsulates all of this
• Plus, it supports inheritance!
Building Block #3:
Effect
// create effect
var effect:MeshEffect = new MeshEffect();
Building Block #3:
// configure effect
effect.mvpMatrix3D = painter.state.mvpMatrix3D;
effect.texture = getHeroTexture();
effect.color = 0xf0f0f0;
// upload vertex data
effect.uploadIndexData(indexData);
effect.uploadVertexData(vertexData);
// draw!
effect.render(0, numTriangles);
Effect
Effect position:float2
FilterEffect position:float2, texCoords:float2
MeshEffect position:float2, texCoords:float2, color:bytes4
LightEffect
position:float2, texCoords:float2, color:bytes4,
normalTexCoords:float2
Building Block #3:
Mesh & MeshBatch
• Basic “tangible” object in Starling 1: Quad
• Arguably the most important 2D object …
• … but shouldn’t be the only one.
• New: Mesh allows arbitrary shapes
• New: MeshBatch to batch meshes together
Building Block #4:
Mesh
Quad
Image
MeshBatch
// create geometry
var vertexData:VertexData = new VertexData();
vertexData.setPoint(0, "position", 0, 0);
vertexData.setPoint(1, "position", 10, 0);
vertexData.setPoint(2, "position", 0, 10);
var indexData:IndexData = new IndexData();
indexData.addTriangle(0, 1, 2);
// create Mesh
var mesh:Mesh = new Mesh(vertexData, indexData);
addChild(mesh);
Mesh & MeshBatch
Building Block #4:
Run into Dead Ends
• Original idea: IMeshBatch interface
• Custom Rendering: write “batchers”
implementing this interface
• Turned out to be too rigid: 

uses inheritance → can’t apply to existing classes
• Turned out to be too slow: 

performance issue with AOT (fixed with AIR 21)
• You’ll find more dead ends when browsing
through the GitHub history ;-)
Pro Tip:
MeshStyles
• The more flexible solution after the 

IMeshBatch dead-end
• Can be attached to any mesh

(composition instead of inheritance)
• Allows customization of both 

rendering and batching
Building Block #5:
// example: ColorOffsetStyle (tutorial)
var image:Image = new Image(texture);
var style:ColorOffsetStyle = new ColorOffsetStyle();
style.redOffset = 0.5;
image.style = style;
MeshStyles
Building Block #5:
// example: LightStyle (extension)
var normalMap:Texture = Texture.fromBitmap(…);
var image:Image = new Image(texture);
var style:LightStyle = new LightStyle(normalMap);
style.light = new Light();
image.style = style;
Follow ideas along the road
• “Sprite.flatten()” needed to be re-implemented
• When starting to work on that, I realized that an
automatic render-cache would be feasible
• I gave it a try, and it worked out great!
Pro Tip:
Render Cache
• Starling keeps track of changes in the display tree
• Unmodified meshes can be drawn from cache
• Fewer matrix operations, method calls, loops
• Only ByteArray.copy → upload → draw
• Great for menus, business apps, etc. 

(anything with often static content)
Render Cache
Hide complexities
• no more “clipRect” 

→ instead, optimized masking with Quads
• TextField

→ supporting different font types through

ITextCompositor
• Texture class 

→ many internal classes inheriting “Texture”
Pro Tip:
Fix things 

you always hated
• Changed prefix of all member variables

mVariable → _variable
• … with the help of a small Ruby script:

http://tinyurl.com/convert-members
• Done very late in development 

→ easy “cherry-picking” between branches
Pro Tip:
Fix things 

you always hated
• Now enforcing “premultipliedAlpha”
• via Fragment Shader
• Simplified a lot of areas
• Fixed inconsistencies when switching 

between ATF and PNG textures
Pro Tip:
Fix things 

even if you’re hated for it ;)
• old TextField class had format settings 

directly on instance
• Hard to re-use format or pass around
• new: TextFormat class, just like in Flash
• … but sucks less!
• Everybody upgrading to Starling 2 will have to
change a LOT of code because of this.
Pro Tip:
Admit when 

you’ve been stupid
• PixelSnapping 

prevents blurriness when object is not pixel-aligned
• I never came up with a good solution!
• Now that it finally happened, and it’s just a few

lines of code (see: MatrixUtil.snapToPixels)
Pro Tip:
Write extensive 

commit messages
• When refactoring code, you often run into things
you know were important, but not: why?!
• Via “git blame”, you find the responsible commit
• Clutters up the code less than inline comments
Pro Tip:
• e.g. “February 2016”
• and keep it!
• Special hint: 

exploit Leap Years!
Promise a release date
Pro Tip:
One more thing …
• New (experimental) extension:

Cross-Texture-Batching
• Batches up to 4 textures in one draw call
• Available here:

http://wiki.starling-framework.org/extensions/cross-texture-batching
// usage:
Mesh.defaultStyle = MultiTextureStyle;
That's it, folks!
Thanks for
watching!
Mail: daniel@gamua.com
Twitter: @PrimaryFeather

More Related Content

What's hot

【Unite 2017 Tokyo】Unity UI最適化ガイド 〜ベストプラクティスと新機能
【Unite 2017 Tokyo】Unity UI最適化ガイド 〜ベストプラクティスと新機能【Unite 2017 Tokyo】Unity UI最適化ガイド 〜ベストプラクティスと新機能
【Unite 2017 Tokyo】Unity UI最適化ガイド 〜ベストプラクティスと新機能Unity Technologies Japan K.K.
 
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)Unity Technologies Japan K.K.
 
Sergey Shamruk - Building Project From Scratch
Sergey Shamruk - Building Project From ScratchSergey Shamruk - Building Project From Scratch
Sergey Shamruk - Building Project From ScratchFlash Conference
 
【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~
【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~
【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~Unity Technologies Japan K.K.
 
Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014Alvinsight
 
Making HTML5 Games with Phaser
Making HTML5 Games with PhaserMaking HTML5 Games with Phaser
Making HTML5 Games with PhaserIndieOutpost
 
Going Mobile with AIR+Starling
Going Mobile with AIR+StarlingGoing Mobile with AIR+Starling
Going Mobile with AIR+StarlingAmos Laber
 
Mobile Performance Tuning: Poor Man's Tips And Tricks
Mobile Performance Tuning: Poor Man's Tips And TricksMobile Performance Tuning: Poor Man's Tips And Tricks
Mobile Performance Tuning: Poor Man's Tips And TricksValentin Simonov
 
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)David Salz
 
Gdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glGdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glchangehee lee
 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicschangehee lee
 
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
How we optimized our Game - Jake & Tess' Finding Monsters AdventureHow we optimized our Game - Jake & Tess' Finding Monsters Adventure
How we optimized our Game - Jake & Tess' Finding Monsters AdventureFelipe Lira
 
Game Engine Architecture
Game Engine ArchitectureGame Engine Architecture
Game Engine ArchitectureAttila Jenei
 
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来Unite2017Tokyo
 
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザインUnite2017Tokyo
 
Creating a third-person zombie horde shooter using DOTS – Unite Copenhagen
Creating a third-person zombie horde shooter using DOTS – Unite CopenhagenCreating a third-person zombie horde shooter using DOTS – Unite Copenhagen
Creating a third-person zombie horde shooter using DOTS – Unite CopenhagenUnity Technologies
 
Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engineDaosheng Mu
 
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...Pablo Farías Navarro
 

What's hot (19)

【Unite 2017 Tokyo】Unity UI最適化ガイド 〜ベストプラクティスと新機能
【Unite 2017 Tokyo】Unity UI最適化ガイド 〜ベストプラクティスと新機能【Unite 2017 Tokyo】Unity UI最適化ガイド 〜ベストプラクティスと新機能
【Unite 2017 Tokyo】Unity UI最適化ガイド 〜ベストプラクティスと新機能
 
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック(note付き)
 
Sergey Shamruk - Building Project From Scratch
Sergey Shamruk - Building Project From ScratchSergey Shamruk - Building Project From Scratch
Sergey Shamruk - Building Project From Scratch
 
【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~
【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~
【Unite 2017 Tokyo】Unity最適化講座 ~スペシャリストが教えるメモリとCPU使用率の負担最小化テクニック~
 
Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014Phaser Workshop Internet World 2014
Phaser Workshop Internet World 2014
 
Making HTML5 Games with Phaser
Making HTML5 Games with PhaserMaking HTML5 Games with Phaser
Making HTML5 Games with Phaser
 
Going Mobile with AIR+Starling
Going Mobile with AIR+StarlingGoing Mobile with AIR+Starling
Going Mobile with AIR+Starling
 
Mobile Performance Tuning: Poor Man's Tips And Tricks
Mobile Performance Tuning: Poor Man's Tips And TricksMobile Performance Tuning: Poor Man's Tips And Tricks
Mobile Performance Tuning: Poor Man's Tips And Tricks
 
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
 
Gdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_glGdc 14 bringing unreal engine 4 to open_gl
Gdc 14 bringing unreal engine 4 to open_gl
 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphics
 
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
How we optimized our Game - Jake & Tess' Finding Monsters AdventureHow we optimized our Game - Jake & Tess' Finding Monsters Adventure
How we optimized our Game - Jake & Tess' Finding Monsters Adventure
 
Game Engine Architecture
Game Engine ArchitectureGame Engine Architecture
Game Engine Architecture
 
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
【Unite 2017 Tokyo】Anima2Dについて語るで!2Dアニメーションの未来
 
Minh le
Minh leMinh le
Minh le
 
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン
【Unite 2017 Tokyo】EditorVRの設計から学んだこと:使えるVRエディターのためのデザイン
 
Creating a third-person zombie horde shooter using DOTS – Unite Copenhagen
Creating a third-person zombie horde shooter using DOTS – Unite CopenhagenCreating a third-person zombie horde shooter using DOTS – Unite Copenhagen
Creating a third-person zombie horde shooter using DOTS – Unite Copenhagen
 
Design your 3d game engine
Design your 3d game engineDesign your 3d game engine
Design your 3d game engine
 
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
 

Similar to Consistent Game Development across all Platforms with Starling 2.0

Dry-ing Magritte
Dry-ing MagritteDry-ing Magritte
Dry-ing MagritteESUG
 
DSL's with Groovy
DSL's with GroovyDSL's with Groovy
DSL's with Groovypaulbowler
 
Pharo 11: A stabilization release
Pharo 11: A stabilization releasePharo 11: A stabilization release
Pharo 11: A stabilization releaseESUG
 
Drupal Presentation for CapitalCamp 2011: Features Driven Development
Drupal Presentation for CapitalCamp 2011: Features Driven DevelopmentDrupal Presentation for CapitalCamp 2011: Features Driven Development
Drupal Presentation for CapitalCamp 2011: Features Driven DevelopmentMediacurrent
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDavid Lanier
 
Mel for beginners
Mel for beginnersMel for beginners
Mel for beginnerskedar nath
 
collapsible-panels-tutorial
collapsible-panels-tutorialcollapsible-panels-tutorial
collapsible-panels-tutorialtutorialsruby
 
collapsible-panels-tutorial
collapsible-panels-tutorialcollapsible-panels-tutorial
collapsible-panels-tutorialtutorialsruby
 
collapsible-panels-tutorial
collapsible-panels-tutorialcollapsible-panels-tutorial
collapsible-panels-tutorialtutorialsruby
 
collapsible-panels-tutorial
collapsible-panels-tutorialcollapsible-panels-tutorial
collapsible-panels-tutorialtutorialsruby
 
Flex Mobile Skinning Workshop
Flex Mobile Skinning WorkshopFlex Mobile Skinning Workshop
Flex Mobile Skinning WorkshopTerry Ryan
 
Objective-C Is Not Java
Objective-C Is Not JavaObjective-C Is Not Java
Objective-C Is Not JavaChris Adamson
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Eugene Yokota
 
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPDoctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPGuilherme Blanco
 
Java - A broad introduction
Java - A broad introductionJava - A broad introduction
Java - A broad introductionBirol Efe
 

Similar to Consistent Game Development across all Platforms with Starling 2.0 (20)

Dry-ing Magritte
Dry-ing MagritteDry-ing Magritte
Dry-ing Magritte
 
Rails data migrations
Rails data migrationsRails data migrations
Rails data migrations
 
DSL's with Groovy
DSL's with GroovyDSL's with Groovy
DSL's with Groovy
 
CSS 201
CSS 201CSS 201
CSS 201
 
Pharo 11: A stabilization release
Pharo 11: A stabilization releasePharo 11: A stabilization release
Pharo 11: A stabilization release
 
Drupal Presentation for CapitalCamp 2011: Features Driven Development
Drupal Presentation for CapitalCamp 2011: Features Driven DevelopmentDrupal Presentation for CapitalCamp 2011: Features Driven Development
Drupal Presentation for CapitalCamp 2011: Features Driven Development
 
Mini .net conf 2020
Mini .net conf 2020Mini .net conf 2020
Mini .net conf 2020
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 version
 
Mel for beginners
Mel for beginnersMel for beginners
Mel for beginners
 
collapsible-panels-tutorial
collapsible-panels-tutorialcollapsible-panels-tutorial
collapsible-panels-tutorial
 
collapsible-panels-tutorial
collapsible-panels-tutorialcollapsible-panels-tutorial
collapsible-panels-tutorial
 
collapsible-panels-tutorial
collapsible-panels-tutorialcollapsible-panels-tutorial
collapsible-panels-tutorial
 
collapsible-panels-tutorial
collapsible-panels-tutorialcollapsible-panels-tutorial
collapsible-panels-tutorial
 
Flex Mobile Skinning Workshop
Flex Mobile Skinning WorkshopFlex Mobile Skinning Workshop
Flex Mobile Skinning Workshop
 
Objective-C Is Not Java
Objective-C Is Not JavaObjective-C Is Not Java
Objective-C Is Not Java
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)
 
rsyslog meets docker
rsyslog meets dockerrsyslog meets docker
rsyslog meets docker
 
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPDoctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
 
Java - A broad introduction
Java - A broad introductionJava - A broad introduction
Java - A broad introduction
 
OpenGL for 2015
OpenGL for 2015OpenGL for 2015
OpenGL for 2015
 

Recently uploaded

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 

Recently uploaded (20)

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 

Consistent Game Development across all Platforms with Starling 2.0

  • 1. Consistent Game Development
 across all Platforms The Road to 
 Starling 2.0 or: How to turn a framework inside out
 (while staying sane) Daniel Sperl
  • 2. Starling 1.x • (quite) backwards-compatible since 2012 • Rock solid, but lots of small quirks • Difficult to add new features 
 without major API changes • Underlying render architecture at its limit
  • 3. Starling 2.0 • A major rework is required! • Rethink complete architecture • Clean up inconsistencies • But: keep all basic concepts intact
 (it’s still Starling, after all)
  • 4. Meticulous Planning Custom Batching Clean Up APIs Dynamic Lighting Flexible Meshes Release: Q1 2016 Simplify! Easier to extend State Stack Scale9-Textures FilterChain Pro
 cra
 sti
 nate! Re
 lea
 se! Rough
  • 5. Kick-off • Started development on July 24th, 2015 • All work done on a new branch (private)! • That way, I could still fix bugs in Starling 1.7
  • 6. Start small • It’s tempting to start with the big components. • That way, you’ll end up with 
 too many changes at once • One class leads to the next! • Can you even compile?! • Hard to pinpoint problems Pro Tip:
  • 7. Start small • Instead, work bottom-up:
 small components first, 
 big components later • Underlying building blocks
 become ready for your 
 rough plan • Work in baby steps: Each 
 commit must leave Starling 
 running! Pro Tip:
  • 8. VertexData • Stores information about each vertex:
 position, texture coordinates, color • Old class was very rigid
 
 
 • Wanted: arbitrary per-vertex data • Important: fast (!) and easy to use Building Block #1: vertexData = new VertexData(); vertexData.setPosition(0, 50, 20); vertexData.setTexCoords(0, 1.0, 0.5); vertexData.setColor(0, 0xff00ff);
  • 9. VertexData // format string defines per-vertex contents vertexData = new VertexData("position:float2, color:bytes4"); vertexData.setPoint(0, "position", 320, 480); vertexData.setColor(0, "color", 0xff00ff); // default format contains position, texCoords and color vertexData = new VertexData(); vertexData.setPoint(0, "position", 320, 480); vertexData.setPoint(0, "texCoords", 1.0, 0.5); vertexData.setColor(0, "color", 0xff00ff); Building Block #1:
  • 10. Painter • RenderSupport → Painter • Wraps many Context3D methods • Passed to all “render” methods • Universally accessible (Starling.painter) • Keeps a stack of state changes Building Block #2:
  • 11. Painter override public function render(painter:Painter):void { } Building Block #2: painter.pushState(); // save a current state on the stack painter.popState(); // restore previous state } painter.state.renderTarget = renderTexture; painter.state.alpha = 0.5; painter.state.transformModelviewMatrix(matrix); painter.prepareToDraw(); // apply all settings at context drawSomething(); // insert Stage3D rendering code here
  • 12. Effect • Each Stage3D draw call requires a lot of set-up: • shaders and buffers • program constants • context loss restoration • The “Effect” class encapsulates all of this • Plus, it supports inheritance! Building Block #3:
  • 13. Effect // create effect var effect:MeshEffect = new MeshEffect(); Building Block #3: // configure effect effect.mvpMatrix3D = painter.state.mvpMatrix3D; effect.texture = getHeroTexture(); effect.color = 0xf0f0f0; // upload vertex data effect.uploadIndexData(indexData); effect.uploadVertexData(vertexData); // draw! effect.render(0, numTriangles);
  • 14. Effect Effect position:float2 FilterEffect position:float2, texCoords:float2 MeshEffect position:float2, texCoords:float2, color:bytes4 LightEffect position:float2, texCoords:float2, color:bytes4, normalTexCoords:float2 Building Block #3:
  • 15. Mesh & MeshBatch • Basic “tangible” object in Starling 1: Quad • Arguably the most important 2D object … • … but shouldn’t be the only one. • New: Mesh allows arbitrary shapes • New: MeshBatch to batch meshes together Building Block #4: Mesh Quad Image MeshBatch
  • 16. // create geometry var vertexData:VertexData = new VertexData(); vertexData.setPoint(0, "position", 0, 0); vertexData.setPoint(1, "position", 10, 0); vertexData.setPoint(2, "position", 0, 10); var indexData:IndexData = new IndexData(); indexData.addTriangle(0, 1, 2); // create Mesh var mesh:Mesh = new Mesh(vertexData, indexData); addChild(mesh); Mesh & MeshBatch Building Block #4:
  • 17. Run into Dead Ends • Original idea: IMeshBatch interface • Custom Rendering: write “batchers” implementing this interface • Turned out to be too rigid: 
 uses inheritance → can’t apply to existing classes • Turned out to be too slow: 
 performance issue with AOT (fixed with AIR 21) • You’ll find more dead ends when browsing through the GitHub history ;-) Pro Tip:
  • 18. MeshStyles • The more flexible solution after the 
 IMeshBatch dead-end • Can be attached to any mesh
 (composition instead of inheritance) • Allows customization of both 
 rendering and batching Building Block #5:
  • 19. // example: ColorOffsetStyle (tutorial) var image:Image = new Image(texture); var style:ColorOffsetStyle = new ColorOffsetStyle(); style.redOffset = 0.5; image.style = style; MeshStyles Building Block #5: // example: LightStyle (extension) var normalMap:Texture = Texture.fromBitmap(…); var image:Image = new Image(texture); var style:LightStyle = new LightStyle(normalMap); style.light = new Light(); image.style = style;
  • 20. Follow ideas along the road • “Sprite.flatten()” needed to be re-implemented • When starting to work on that, I realized that an automatic render-cache would be feasible • I gave it a try, and it worked out great! Pro Tip:
  • 21. Render Cache • Starling keeps track of changes in the display tree • Unmodified meshes can be drawn from cache • Fewer matrix operations, method calls, loops • Only ByteArray.copy → upload → draw • Great for menus, business apps, etc. 
 (anything with often static content)
  • 23. Hide complexities • no more “clipRect” 
 → instead, optimized masking with Quads • TextField
 → supporting different font types through
 ITextCompositor • Texture class 
 → many internal classes inheriting “Texture” Pro Tip:
  • 24. Fix things 
 you always hated • Changed prefix of all member variables
 mVariable → _variable • … with the help of a small Ruby script:
 http://tinyurl.com/convert-members • Done very late in development 
 → easy “cherry-picking” between branches Pro Tip:
  • 25. Fix things 
 you always hated • Now enforcing “premultipliedAlpha” • via Fragment Shader • Simplified a lot of areas • Fixed inconsistencies when switching 
 between ATF and PNG textures Pro Tip:
  • 26. Fix things 
 even if you’re hated for it ;) • old TextField class had format settings 
 directly on instance • Hard to re-use format or pass around • new: TextFormat class, just like in Flash • … but sucks less! • Everybody upgrading to Starling 2 will have to change a LOT of code because of this. Pro Tip:
  • 27. Admit when 
 you’ve been stupid • PixelSnapping 
 prevents blurriness when object is not pixel-aligned • I never came up with a good solution! • Now that it finally happened, and it’s just a few
 lines of code (see: MatrixUtil.snapToPixels) Pro Tip:
  • 28. Write extensive 
 commit messages • When refactoring code, you often run into things you know were important, but not: why?! • Via “git blame”, you find the responsible commit • Clutters up the code less than inline comments Pro Tip:
  • 29. • e.g. “February 2016” • and keep it! • Special hint: 
 exploit Leap Years! Promise a release date Pro Tip:
  • 30. One more thing … • New (experimental) extension:
 Cross-Texture-Batching • Batches up to 4 textures in one draw call • Available here:
 http://wiki.starling-framework.org/extensions/cross-texture-batching // usage: Mesh.defaultStyle = MultiTextureStyle;
  • 31. That's it, folks! Thanks for watching! Mail: daniel@gamua.com Twitter: @PrimaryFeather