Overriding Context3DRenderer properties

Hello!

I was using openfl 8.9.0 in our project and we used our custom rendering mechanic based on our own display object class (extended from InteractiveObject) with overriden __renderGL() function. Our __renderGL() was doing two jobs:

  1. Prepare/update some shader/transform data before rendering
  2. Pass renderer to custom class just like in Context3DDisplayObject.render. This is the place were we used to apply our changed transformation matrix/set custom shaders/bind our texture with applyBitmapData and set our custom vertex/index buffer, and finaly drawTriangles().

But in 8.9.2 I think, there was display objects refactor and renderer stuff was separated from display objects. So, with __renderGL() is gone and everything render-related is moved to single one-for-everyone Context3DRenderer we lost our ability to put custom changes in renderer for our specific objects.

My question is, maybe there is some intended ways to change shader/transform/verticle and all sort of other data in renderer for custom objects? Our way of doing that was feeling wrong and hectic, but with last changes in renderer I feel like we forced to break in openfl even deeper to do required stuff

Thanks!

Hello!

There are a number of items on our lists to have ready for OpenFL 9 which are necessitating architecture changes:

  • One some projects the performance bottleneck is the number of times we recurse to call functions when rendering. Literally this means that calling __renderGL instead of a single for loop is the fix :frowning:
  • Our goal is to batch render more of the display list automatically (as if everything is a Tilemap) so this also frowns upon our previous approach
  • We may be added a “display2d” API to combine Cairo/Canvas software rendering together and trying to simplify down to the Stage being rendered using either 2D/3D context and not exposing GL directly

There currently is a RENDER_OPENGL event which is beta in OpenFL 8 that I expect will change slightly for OpenFL 9 that is meant to help replace the custom display object class approach.

var sprite = new Sprite();
sprite.addEventListener(RenderEvent.RENDER_OPENGL, function(renderer)
{
    // time to render this sprite!
   renderer.applyBitmapData(...);
});

https://api.openfl.org/openfl/display/OpenGLRenderer.html

With the above in mind I wonder how much we can get away with only doing custom rendering through Context3D without any of the special renderer methods

var sprite = new Sprite();
sprite.addEventListener(RenderEvent.RENDER_OPENGL /* rename */, function(_)
{
    stage.context3D.setTextureAt(...);
    stage.context3D.drawTriangles(...);
});