CathodeRetro::IGraphicsDevice

This is one of the interfaces that the user code needs to implement in order to use the CathodeRetro class. See Implementing the Required Interfaces for details.

This interface represents a texture that can be used as an input to IGraphicsDevice::RenderQuad.

Index

Interface Method

CreateRenderTarget
                std::unique_ptr<IRenderTarget> CreateRenderTarget(
                  uint32_t width,
                  uint32_t height,
                  uint32_t mipCount,
                  TextureFormat format)              
              
Description

Create a render target with the given dimensions, mip count, and format.

This will only be called during certain Cathode Retro state changes (including class initialization), and will never be called between calls to BeginRendering and EndRendering.

Parameters
width

Type: uint32_t

The width of the render target to create, in texels.

height

Type: uint32_t

The height of the render target to create, in texels.

mipCount

Type: uint32_t

The number of mipmap levels to create.

If this value is 0, then the render target should have the maximum number of mipmap levels for its size.

format

Type: TextureFormat

The format that this render target needs.

Return Value
Type: std::unique_ptr<IRenderTarget>

A unique_ptr to a created IRenderTarget, which can be used as a parameter to RenderQuad, as either a texture input or an output.

CreateConstantBuffer
                std::unique_ptr<IConstantBuffer> CreateConstantBuffer(
                  size_t byteCount)
              
Description

Create a constant buffer that can hold at least the given amount of bytes.

This will only be called during certain Cathode Retro state changes (including class initialization), and will never be called between calls to BeginRendering and EndRendering.

Parameters
byteCount

Type: size_t

The minimum number of bytes that this buffer object needs to be able to hold.

Return Value
Type: std::unique_ptr<IConstantBuffer>

A unique_ptr to a created IConstantBuffer which can be used as a parameter to RenderQuad.

BeginRendering
                void BeginRendering()
              
Description

Perform the setup necessary for Cathode Retro to render a frame.

This is called when Cathode Retro is beginning its rendering, and is a great place to set up any render state that is going to be consistent across the whole pipeline (the vertex shader, blending mode, etc).

  • 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.

This will be called once per frame.

RenderQuad
                void RenderQuad(
                  ShaderID shaderID,
                  RenderTargetView output,
                  std::initializer_list<ShaderResourceView> inputs,
                  IConstantBuffer *constantBuffer = nullptr)              
              
Description

Render to the given output render target (as a quad that is the full size of the output target) using the supplied shader, input textures, and constant buffer.

This is called multiple times during rendering, and will only be called between calls to BeginRendering and EndRendering.

Parameters
shaderID

Type: ShaderID

The ID of the shader to use.

output

Type: RenderTargetView

The output render target to use.

The render target view contains both a pointer to a render target and a desired target mipmap level to render to.

inputs

Type: std::initializer_list<ShaderResourceView>

A list of input textures to use.

Each input is a shader resource view that contains a pointer to a texture, an optional mip level to use as the input, and a sampler type to use for sampling the given texture.

constantBuffer

Type: IConstantBuffer *

The constant buffer to used to hand data bytes to the shader.

EndRendering
                void EndRendering()
              
Description

Perform the steps necessary to return the renderer into the state it needs to be in to render whatever else is being rendered, now that Cathode Retro is done rendering.

This is called when Cathode Retro is done rendering, and is a good spot for render state to be restored back to whatever the enclosing app expects (i.e. if it's a game, the game probably has its own standard state setup).

This will be called once per frame.