Access texture of BitmapData directly? (cpp)

I’m working on some projects for cpp where it would be really great to be able to access the texture and texture id in a bitmapdata directly (draw directly to the texture target). Anyone know what would be the best way to do this?

You can try bitmapData.getTexture (GL.context); in the current development builds, but I cannot promise it won’t change in the future.

We have work ongoing now for framebuffer support through bitmapData.draw

I’m not getting the dev builds to work yet… for now i solved it like its done in the dispose function:

var renderer = @:privateAccess Lib.current.stage.__renderer;
var renderSession = @:privateAccess renderer.renderSession;
var gl =;

So that gives me what i need:

var tex = bitmapData.getTexture(gl);
var texID =;
GL.bindTexture (GL.TEXTURE_2D, tex);

and i pass it inn to a native cpp function thats using glCopyTexSubImage2D to copy from an internal fbo.

All runs well and i get no errors, but neither anything updated in the bitmapdata…
Is it possible to copy the data directly to bitmapdatas texture this way?
Am i missing something?

So i got this working actually now. :grinning:

I’m using a 3rd party c++ lib thats draws the texure directly into the bitmapdata’s texture. It took quite a bit of time to find a working approach. But it still it feels like a bit of a hack, anyway to do this cleaner?

var glTex:GLTexture = @:privateAccess bitmapData.__texture;
if (glTex != null)
   myCppLib.receiveTexture(cast; // cast to GLUint, TextureID

And the following line does not seem to work at all … (OpenFl 4.5.0 and hxcpp 3.4.2)

bitmapData.getTexture (GL.context);