Implementing the Required Interfaces
Once you have your project set up to include the Cathode Retro headers, it's time to start implementing the interfaces that will allow Cathode Retro to interface with your renderer.
For this, you'll need to #include "CathodeRetro/
.
Sample Implementations
There is a sample Direct3D 11 implementation of these interfaces in Samples/
.
There is a sample OpenGL 3.3 Core implementation of these interfaces in Samples/
.
The IGraphicsDevice Interface
The core interface you'll need to implement is CathodeRetro::
,
which is the interface that is passed to the main CathodeRetro::
class.
This interface can create objects (render targets and constant buffers) and render.
You'll need to implement the following methods:
Creation Methods
CreateRenderTarget
-
Create a
CathodeRetro::
-derived object representing a render target (or frame buffer object) with the given properties.IRenderTarget CreateConstantBuffer
-
Create a
CathodeRetro::
-derived object representing a block of bytes that is used to pass data to the shaders.IConstantBuffer
Render Methods
BeginRendering
-
This is called by the
CathodeRetro::
class when it is beginning its rendering, and is where you should set up any render state that is going to be consistent across the whole pipeline (the vertex shader, blending mode, etc).CathodeRetro - Cathode Retro specifically wants no alpha blending or testing enabled.
- Additionally, it expects floating-point textures to be able to use the full range of values, so if the API allows for truncating floating-point values to the 0..1 range on either shader output or sampling input, that should be disabled.
RenderQuad
-
This is called by the
CathodeRetro::
class during rendering to render a full-render-target quad using the shader with the givenCathodeRetro ShaderID
, to the givenIRenderTarget
, using a set of inputShaderResourceView
s and anIConstantBuffer
. EndRendering
-
This is called when the
CathodeRetro::
class is done rendering, and is where you should restore any render states necessary for the rest of your renderer to continue as normal.CathodeRetro
The IConstantBuffer Interface
CathodeRetro::
is a "constant buffer" (GL/Vulkan refer to these as "uniform buffers") - basically a
data buffer to be handed to a shader. These will be fully updated every frame
so it is valid for this to allocate GPU bytes out of a pool and update for
graphics APIs that prefer that style of CPU -> GPU buffering. These may be
updated by the CathodeRetro::
class more than once per frame.
This interface only has a single method that needs to be implemented:
Update
-
Copy the given data bytes into the constant buffer so that it is ready for rendering via a call to
IGraphicsDevice::
.RenderQuad
The ITexture and IRenderTarget Interfaces
CathodeRetro::
and CathodeRetro::
are two interfaces that share the same methods (IRenderTarget
inherits from ITexture
).
While the CathodeRetro::
interface can only directly create IRenderTarget
objects, you will potentially need to implement an
ITexture
-derived class as well, to represent the texture that is the input into
CathodeRetro::
.
These interfaces both have the following methods:
What's Next?
CathodeRetro
class.