hadronized / spectra

Rust demoscene engine (currently on hold)
122 stars 6 forks source link

Graphics pipeline #54

Open hadronized opened 5 years ago

hadronized commented 5 years ago
hadronized commented 5 years ago

We want to be able to write several kinds of renderers:

The main challenge is to define what a renderer is so that people can create their own and what’s their public interface.

Renderers ?

A renderer is a pipeline that displays images. Renderers can output to either one or many images. Those images are called render targets. A render target cannot be inspected as-is and one must use a method to get access to what it contains, if ever needed. Also, a render target should always represent a stream of rasterized fragments, not the fragments themselves.

So, to sum up:

The render::output::OutputType trait is a good candidate to represent what fragments can have as properties. Render targets are just then an aggregation of of outputs.

Then, a renderer. Renderers must have their own trait. They are like functions that output into render targets:

trait Renderer {
  type Input;
  type Targets: RenderTargets;

  fn render(&self, input: Input) -> Self::Targets;
}

The render targets then must be able to be carried around to other renderers… or ultimately, to the screen.

Screen render

In order to render to the screen, a renderer must use a special render target: Backbuffer. Rendering to that target will perform a draw that will show up on the screen.