0

Lately I have been using haxe and openfl to (attempt) to make games, I'm coming from previous knowledge with XNA, where, when drawing with a spritebatch, you can specify a depth to draw the image, independent of when you actually call the draw function. starting out with openfl, I noticed that drawing to a bitmapdata as a buffer provided me with a similar way to draw as a spritebatch, but it does not have a depth parameter.

My question is, does anyone know of a good way of handling draw calls to allow for specifying a draw depth?

Seth Battin
  • 2,811
  • 22
  • 36
Nico
  • 94
  • 9

2 Answers2

0

Depth buffer is not enabled in openfl so you have to fallback to another render path ( ie engine).

Otherwise you can patch openfl to fetch depth buffer and implement z-test but it requires lot of knowledge.

Nagendra Rao
  • 7,016
  • 5
  • 54
  • 92
blackmagic
  • 178
  • 3
  • I was using an array of "DrawCall" objects to sort by depth (I used a string identifier for the image, so as to save memory), and then looping through the array to draw in order to the screen, but if I drew more than 10 sprites, it locked up completly, which is not usable in any way – Nico Feb 15 '14 at 21:48
0

You can set the depth by creating new bitmap for each depth you need, then you can change the depth of each created bitmap.

This is handled in openfl, but you can also see how haxeflixel handles depth of created elements..

simo
  • 23,342
  • 38
  • 121
  • 218
  • isnt that only if you are using a displaylist? – Nico Feb 15 '14 at 21:25
  • Yes, in case you don't use displaylist you will have to clear buffer each time logical depth changes and draw all elements again.. – simo Feb 16 '14 at 02:54