context3D.drawToBitmapData(buffer) won't work on neko or html5

Hey peeps!
Today I stumbled upon a very specific problem(?).

I’m trying to draw pixelated shapes using Context3D with drawToBitmapData(buffer). I did find a way (not very efficient thought) to achieve this in Flash (as you can see in the image below).
image

It calls drawToBitmapData(myBitmapData) where myBitmapData is just a general purpose buffer.

Quite OK but only works in Flash… and achieving the same in HTML5 and maybe neko would be terrific! (which by the way I still couldn’t crack…)

You guys surely know a better way to do this and I’d love to hear it!

And by the way, the “Stage3D” in OpenFL is a very nice way to abstract many of the complexities of going full OpenGL when doing basic things (for a beginner in 3D like me it’s really nice to be able to grasp the basics of 3D graphics programming without the hassles of OpenGL).

Thanks in advance :slight_smile:
~asdfgl

I believe this is implemented currently, but with a few catches.

It performs an OpenGL readPixels call, which forces synchronization of the CPU and GPU, and is expensive. We currently render Stage3D in the same buffer as our standard renderer, so instead of drawing only the Stage3D content, this call currently will draw all OpenGL rendering.

There may also be a timing issue, where calling this after a clear, or before you are done with all of your draw calls, may impact the final result, perhaps in a slightly different way than Flash.

1 Like

Thanks for the quick response @singmajesty.

Well, my current ‘pipeline’ is this:
(pseudo code)
//init()
buffer = BitmapData(width, height, true, 0xff000000)
scene.addChild(Bitmap(buffer))

//onEnterFrame
context3D.clear(0, 0, 0)
context3D.drawTriangles(indexBuffer)
context3D.drawToBitmapData(buffer)
context3D.present()

Extra info: I’m passing a matrix to vc0 between clear and drawTriangles. For a rotation animation

//agal vertex shader
m44 op, va0, vc0