Renderering

Renderer

Inheritance diagram of serge.render.Renderer
class serge.render.Renderer(width=640, height=480, title='Serge', backcolour=(0, 0, 0), icon=None, fullscreen=False)[source]

Bases: serge.common.Loggable, serge.serialize.Serializable, serge.common.EventAware

The main rendering component

addLayer(layer)[source]

Add a layer to the rendering

clearLayers()[source]

Clear all the layers

clearSurface()[source]

Clear the surface

getBackgroundLayer()[source]

Return the layer that is in the background

getCamera()[source]

Return our camera

getLayer(name)[source]

Return the named layer

getLayerBefore(layer)[source]

Return the layer before the specified one in terms of rendering order

getLayers()[source]

Return all the layers

getRenderingOrder(layer)[source]

Return the order that a layer will be rendered in (0 = first)

getRenderingOrderDictionary()[source]

Return a dictionary of the rendering orders of each layer by name ({name:0, name:1} etc)

The dictionary is actually a live copy that will be updated if you add layers to the renderer so it is safe for you to cache it and re-use it.

Changing the dictionary results in undefined behaviour.

getScreenSize()[source]

Returns the screen size

getSurface()[source]

Return the overall surface

init()[source]

Initialise from serialized state

orderActors(actors)[source]

Return the list of actors sorted by who should be processed first to correctly render

The actors are checked to see which layer they reside on and then this is used to order the returned list.

preRender()[source]

Prepare for new rendering

removeLayer(layer)[source]

Remove the layer from the rendering

removeLayerNamed(name)[source]

Remove the layer with the specific name

render()[source]

Render all the layers

resetSurfaces()[source]

Recreate the surfaces for our layers

When layers are added we sometimes need to reset the layers, for instance, virtual layers need to be shifted around so that they have the right order.

setCamera(camera)[source]

Set our camera

Layers

RenderingLayer

Inheritance diagram of serge.render.RenderingLayer
class serge.render.RenderingLayer(name, order)[source]

Bases: serge.common.Loggable, serge.serialize.Serializable, serge.common.EventAware

A layer on which to render things

This is the abstract version of the layer. Create subclasses of this to do useful things.

clearSurface()[source]

Clear our surface

getNiceName()[source]

Return the nice name for this layer

getSurface()[source]

Return the surface

init()[source]

Initialise from serialized state

initSurface(renderer)[source]

Create the surface that we need to draw on

postRender()[source]

Called after the layer has has had everything rendered on it

preRender()[source]

Called before the layer has anything rendered to

render(surface)[source]

Render to a surface

setStatic(static)[source]

Determine whether this layer is static with respect to camera movements or not

setSurface(surface)[source]

Set our surface

Layer

Inheritance diagram of serge.render.Layer
class serge.render.Layer(name, order)[source]

Bases: serge.render.RenderingLayer

A rendering layer with its own surface

This type of layer is useful for compositing because you can do things to this layer once it has been rendered (eg shadows, glows, blurs etc).

clearSurface()[source]

Clear our surface

initSurface(renderer)[source]

Create the surface that we need to draw on

We create a surface that is identical to the background for the main renderer.

render(surface)[source]

Render to a surface

VirtualLayer

Inheritance diagram of serge.render.VirtualLayer
class serge.render.VirtualLayer(name, order)[source]

Bases: serge.render.RenderingLayer

A rendering layer that doesn’t have its own surface

This layer will render to the layer immediately before it in the rendering cycle.

clearSurface()[source]

Clear our surface

Nothing to do here - handled by the real owner of the surface.

initSurface(renderer)[source]

Create the surface that we need to draw on

We do not want a surface ourself but we need the next surface in line as far as the renderer is concerned.

render(surface)[source]

Render to a surface

Nothing to do here - handled by the real owner of the surface.

Cameras

Camera

Inheritance diagram of serge.camera.Camera
class serge.camera.Camera[source]

Bases: serge.common.Loggable, serge.geometry.Rectangle

Represents a camera

canSee(actor)[source]

Return True if we can see the actor

canSeeActors(actors)[source]

Return the actors that we can see from a list of actors

getRelativeLocation(other)[source]

Return the relative location of one from another

getTarget()[source]

Return the camera’s target location

init()[source]

Initialise from serialized

setTarget(target)[source]

Set the target for the camera to head towards

setZoom(zoom, x, y)[source]

Set the new zoom centered on the given x and y

update(interval)[source]

Update the location of the camera

NullCamera

Inheritance diagram of serge.camera.NullCamera
class serge.camera.NullCamera[source]

Bases: serge.camera.Camera

A camera that can see everything

canSee(actor)[source]

Can we see it? Yes we can

init()[source]

Initialise