i saw this video 11000 textured quad (rectangle shape/sprite ? ) were update at frame-rate ~30. So i wonder if we can make same thing with Gideros. If yes, maybe we will have a simple batch?
WhiteTree Games - Home, home on the web, where the bits and bytes they do play! #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
That surprises me - I would have thought a single mesh to be more efficient than rendering lot's of separate bitmaps, fancy sharing your code so we can see if we can identify the bottlenecks?
WhiteTree Games - Home, home on the web, where the bits and bytes they do play! #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
i made a simple example in bitmaptest, i add 11000 bitmap (8x8px), each frame i change their position to a random point. I got fps 59 on Desktop player in meshtest, i set vertex to create 11000 rect, each frame i setVertex to new position. I got fps 40 on Desktop player.
@hnim I think your bottleneck is Lua and not the drawing.
I've done a simple test. Here is my code:
localfunction add(t, ...)local n = select("#", ...)for i=1,n do
t[#t+1]= select(i, ...)endend
application:setBackgroundColor(0x306090)local vertices ={}local indices ={}local velocities ={}local nrect =0for i = -400, 400, 5dofor j = -400, 400, 5dolocal x = i /275local y = -j /275-- implicit heart function is from <a href="http://mathworld.wolfram.com/HeartCurve.html" rel="nofollow">http://mathworld.wolfram.com/HeartCurve.html</a>local a = x * x + y * y - 1local f = a * a * a - x * x * y * y * y
if f <0thenlocal n = #vertices/2-- add 4 corners
add(vertices, i, j)
add(vertices, i + 4, j)
add(vertices, i + 4, j + 4)
add(vertices, i, j + 4)-- add 2 triangles to indices
add(indices, n + 1, n + 2, n + 3)
add(indices, n + 1, n + 3, n + 4)-- and velocities
add(velocities, x + math.random(-100,100)/200, -y + math.random(-100,100)/200)
nrect = nrect + 1endendendprint("# of rects = "..nrect)local mesh = Mesh.new()
mesh:setVertexArray(vertices)
mesh:setIndexArray(indices)
mesh:setPosition(768/2, 1024/2)
stage:addChild(mesh)localfunction onEnterFrame()for i =1,#vertices,8dolocal ind =(i - 1)/4 + 1local vx = velocities[ind]local vy = velocities[ind+1]
vertices[i+0]= vertices[i+0] + vx
vertices[i+1]= vertices[i+1] + vy
vertices[i+2]= vertices[i+2] + vx
vertices[i+3]= vertices[i+3] + vy
vertices[i+4]= vertices[i+4] + vx
vertices[i+5]= vertices[i+5] + vy
vertices[i+6]= vertices[i+6] + vx
vertices[i+7]= vertices[i+7] + vy
end
mesh:setVertexArray(vertices)end
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)
This code creates and explodes 11073 rects and runs at ~15 fps on iPad 3.
* If I comment out the explosion calculation code, it runs at 60fps. * If I explode 1000 random rects at each frame, it runs at 60fps. * Without explosion calculation code, it's possible to display 5 * 11073 = 55365 rects at 60 fps.
Conclusion: if you try to move >10000 rects, Lua can be really a bottleneck. Guess: If the explosion calculation code is developed in C/C++ as a plugin, it may be possible to explode ~50000 rects at 60fps.
Comments
Likes: vitalitymobile
http://www.nightspade.com
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
in bitmaptest, i add 11000 bitmap (8x8px), each frame i change their position to a random point. I got fps 59 on Desktop player
in meshtest, i set vertex to create 11000 rect, each frame i setVertex to new position. I got fps 40 on Desktop player.
I've done a simple test. Here is my code:
* If I comment out the explosion calculation code, it runs at 60fps.
* If I explode 1000 random rects at each frame, it runs at 60fps.
* Without explosion calculation code, it's possible to display 5 * 11073 = 55365 rects at 60 fps.
Conclusion: if you try to move >10000 rects, Lua can be really a bottleneck.
Guess: If the explosion calculation code is developed in C/C++ as a plugin, it may be possible to explode ~50000 rects at 60fps.
i attached my test project here if someone can take a look.