Friday, August 14, 2015

Abiathar Render Plane Management

I may have to clone Abiathar's rendering model into Abiathar Online to give it a speed boost, so I figured I'd document that model here for my own reference and for anybody wanting to develop Abiathar extensions.

The "view state" of each level and tileset consists of a bunch of planes, which are anything that implements ILevelRenderPlane or ITilesetRenderPlane as appropriate. Each has a name by which it can be accessed, preferably prefixed with the extension name and a colon. For instance, the normal background plane is called Abiathar:Background. There are two types of planes: those that hold an image to render on top of others below it, or those that store no image and instead render directly onto a Graphics object (called "ephemeral").

Both standard and ephemeral planes get queried on each rendering as to whether they are visible, that is, whether they should be rendered now. Standard planes are also queried for freshness (NeedsUpdate) and receive a Render call if they require a repaint. Their image is then accessed through the Image property, which can be null, in which case nothing will be rendered. Ephemeral planes simply receive a RenderEphemeral call with a Graphics object and several other parameters concerning the view settings.

Upon creation, each plane receives a SetRenderLevel (or the appropriate tileset-related method) and SetStateAccessor call, which set up necessary infrastructure for them to access level/tileset data. Level render planes can publish the ID of the technical plane that they represent, like 1 for foreground, in which case Abiathar will notify them (by calling UpdateTile) when tiles change in that plane. That way, the whole level doesn't have to be rerendered each time. The return value from that function indicates whether changes were made to the displayed image, but that value is currently never used.

No comments:

Post a Comment