Fermat
The Renderer Interface

Top: Contents

Writing a renderer is now as simple as inheriting from this interface and implementing some of its methods:
// The abstract renderer / solver interface
//
{
// this method is responsible for returning the number of auxiliary framebuffer channels needed
// by the renderer
//
virtual uint32 auxiliary_channel_count() { return 0; }
// this method is responsible for registering the auxiliary framebuffer channels needed by the
// renderer, starting at the specified offset
//
virtual void register_auxiliary_channels(FBufferStorage& fbuffer, const uint32 channel_offset) {}
// this method is responsible for any command options parsing / initializations the renderer might
// need to perform
//
virtual void init(int argc, char** argv, RenderingContext& renderer) {}
// flag a scene geometry update
//
virtual void update_scene(RenderingContext& renderer) {}
// this method is responsible for rendering a given frame in a progressive rendering
//
// \param instance the frame instance
//
virtual void render(const uint32 instance, RenderingContext& renderer) {}
// this method is responsible for handling keyboard events
//
virtual void keyboard(unsigned char character, int x, int y, bool& invalidate) {}
// this method is responsible for handling mouse events
//
virtual void mouse(RenderingContext& renderer, int button, int state, int x, int y) {}
// this method is responsible for any additional UI/OpenGL drawing on screen
//
virtual void draw(RenderingContext& renderer) {}
// dump some speed stats
//
virtual void dump_speed_stats(FILE* stats) {}
// this method is responsible for destroying the object itself
//
virtual void destroy() {}
};
In practice, it's often not even necessary to implement anything except for the RendererInterface::init(), RendererInterface::destroy() and the RendererInterface::render() methods. All the others are optional methods to handle events (e.g. mouse, keyboard), inform the context that the renderer might output some custom framebuffer channels, or getting informed that the geometry of the scene has been updated, in case we need to know.

Next: Plugins