2. Stage3D API
• Since 2011 (Flash Player 11)
• Unified API for managing texture memory, vertex
shading, pixel shading, and mesh rendering
• Transparently executed using OpenGL and DirectX
3. Each frame
— clear backbuffer by calling Context3D.clear
— set gpu state through Context3D API
— call drawTriangles()
— repeat until the scene is entirely rendered
— call the present() method to display the rendered scene on the
stage. It copies the backbuffer to a framebuffer
8. How does QuadBatch work?
• Collects quads with the same state(same texture,
blendMode, shader)
• Transforms all vertices to one space and upload
to VertexBuffer
• Render
11. Constants approach
• Create one common vertexBuffer during application
init, upload data once
• Batch quads and images by the same state and set
program constants
array(x,y,width,height,uv,tintcolor,rotation)
• Render
25. PixelPerfect Touch GPU!
• Use simple shader which renders images with
single color
• Optimization: collect candidates by bounds
• Render targets to 1x1 texture on desktop or 4x4
texture on mobile
• Read back & sample color from texture