The patch covers very high level of External Render Engine OpenGL capabilities.
Since Draw Engine (OpenGL) will be used in Blender 2.8 Python API only with external engines it is convenient to expose its methods as methods of custom Render Engine instead of new Python type creating.
Main reference is DrawManager design document https://wiki.blender.org/index.php/Dev:2.8/Source/Viewport/DrawManager
The following callbacks are exposed:
- drw_init
- Ask the draw manager for custom framebuffers.
- Make sure engines shaders are compiled.
- Run any engine specific pre-rendering code.
- drw_cache_init
- The main task here is to setup the cache components : Passes & Shading Groups. When this function is called, you can assume that all passes from earlier cache have been free.
- drw_cache_populate
- This function is called once per object inside the active layer. In this step you fill the previously created shading groups saved in cache.
- drw_cache_finish
- The common use case for this callback is to update the UBO with the data gathered during the cache generation. You can also run some optimisation code here.
- drw_draw_background
- This function is only called for one engine (usually the render engine). It's in charge of clearing the default framebuffer. You can pretty much do whatever you can do in ENGINE_draw_scene here too (see Draw Scene for more details). If no enabled engines has a background function, then the default one is used instead. The real reason this function exists is to allow callbacks before rendering scene object.
- drw_draw_scene
- The goal of this function is to draw something to the default framebuffer. The default framebuffer is a simple offscreen buffer composed of a RGB8 color texture and a depth texture the size of the viewport.
engine_free - function was not exposed because we should design API which will be native for Python, and in this case Python GC should do work.
To make good Python API we should avoid low level structures like ViewportEngineData as far as possible. So all callbacks has simplest arguments.
The patch contanins temporary render engine for testing purposes which will be removed in the future.