Renderer

From FIFE development wiki
Jump to: navigation, search


Introduction

FIFE has a bunch of different renderers for different cases. In the following I will try to explain what functions each renderer has and when to use them.

But first a few basic things about FIFE. The coordinates for rendering must be counter clockwise and orientated on the top left corner.

So for a quad the order would be something like this:

Point(0,100) bottom left
Point(100,100) bottom right
Point(100,0) top right
Point(0,0) top left

Most renderers need a camera so a loaded map is needed. The exceptions to this rule are the OffRenderer and the TargetRenderer. These are also the only ones who can handle direct coordinates while the others either need Instances or RendererNodes. Except for these two all other share the following API.

-returns a pointer to renderer
getInstance(Camera* camera)

-get current pipeline position
renderer.getPipelinePosition()

-change pipeline positon means that you can change the order of  which the renderers draw
renderer.setPipelinePosition(int32 position)

-enables(true) or disables(false) the renderer
renderer.setEnabled(bool enabled)

-returns a bool that indicates if the renderer is enabled(true) or disabled(false)
renderer.isEnabled()

-adds active layer to renderer, only active layers are rendered!!!
renderer.addActiveLayer(Layer* layer)

-removes active layer from renderer
renderer.removeActiveLayer(Layer* layer)

-removes all active layers from renderer
renderer.clearActiveLayers()

-activates all layers from given map
renderer.activateAllLayers(Map* map)

returns a list that contain pointer to all active layers
renderer.getActiveLayers()


Renderer Usage

InstanceRenderer

The most important and mostly used renderer is the InstanceRenderer. The renderer is enabled by default, all loaded/created instances that have a visual are rendered with it. In addition you can use it to generate outlines or colorings for your instances.

More details: InstanceRenderer

BlockingInfoRenderer

This can be used to show you which instances on the map have their blocking property set to True. While this may not be an application for a game, it is useful for debugging or an editor tool like FIFedit.

More details: BlockingInfoRenderer

CellSelectionRenderer

This one is quite similar to the BlockingInfoRenderer. But you can select by your own, which cells to be framed.

More details: CellSelectionRenderer

CoordinateRenderer

This renderer is able to display LayerCoordinates on the map. You have to set a font which is then used to render the coordinates.

More details: CoordinateRenderer

FloatingTextRenderer

As the name suggest the renderer is used to draw floating textes. So if you call instance.say() the text is rendered with it. You can set the font and define the background.

More details: FloatingTextRenderer

GenericRenderer

The GenericRenderer is able to draw all sorts of primitives, images and animations. It uses RendererNodes for positioning of elements. You can use it to render some special fx or other things. But note that the z ordering is not in harmony with the InstanceRenderer. If the same layer is used and the pipeline position is unchanged then the GenericRenderer draws on top of the InstanceRenderer.

More details: GenericRenderer

GridRenderer

This renderer is used in FIFedit to display the geometry of the active layer/grid. Works not for an empty layer(without instances) because the layers need a size. So the minimum is to place edge instances. You can change the used color.

More details: GridRenderer

LightRenderer

As you may have guessed already this renderer is used to draw lights. It uses the same RendererNodes as GenericRenderer to position them. You can use images, animations or simple lights (consisting of triangles to generate a shape effect).

More details: LightRenderer

OffRenderer

This renderer should be used if no map is loaded. It can draw directly on the screen and thus can e.g. be used to generate some sort of a intro. The API is pretty much the same as for the GenericRenderer but it will only accept screen coordinates instead of RendererNodes.

More details: OffRenderer

TargetRenderer

With this renderer you can directly manipulate an image. It uses elements of the OffRenderer so the API is the same. It can be used for a variety of applications, such as a mini-map or statistics.

More details: TargetRenderer