libdonut  2.3.2
Application framework for cross-platform game development in C++20
Public Member Functions | List of all members
donut::graphics::Renderer Class Reference

Persistent system for rendering the batched draw commands of a RenderPass onto a Framebuffer, such as the user's screen. More...

#include <donut/graphics/Renderer.hpp>

Public Member Functions

 Renderer (const RendererOptions &options={})
 Construct a renderer. More...
 
 ~Renderer ()
 Destructor. More...
 
 Renderer (const Renderer &)=delete
 Copying a renderer is not allowed, since it manages global state. More...
 
 Renderer (Renderer &&)=delete
 Moving a renderer is not allowed, since it manages global state. More...
 
Rendereroperator= (const Renderer &)=delete
 Copying a renderer is not allowed, since it manages global state. More...
 
Renderer operator= (Renderer &&)=delete
 Moving a renderer is not allowed, since it manages global state. More...
 
void clearFramebufferDepth (Framebuffer &framebuffer)
 Clear the depth buffer contents of a Framebuffer. More...
 
void clearFramebufferColor (Framebuffer &framebuffer, Color color)
 Clear the color contents of a Framebuffer. More...
 
void clearFramebufferColorAndDepth (Framebuffer &framebuffer, Color color)
 Clear the color and depth buffer contents of a Framebuffer. More...
 
void render (Framebuffer &framebuffer, const RenderPass &renderPass, const Viewport &viewport, const Camera &camera, std::optional< Rectangle< int >> scissor={})
 Render the contents of a RenderPass to a Framebuffer. More...
 

Detailed Description

Persistent system for rendering the batched draw commands of a RenderPass onto a Framebuffer, such as the user's screen.

An instance of this class should be kept throughout the lifetime of the application in order to continuously render the visual state of the latest frame produced through the application::Application::display() callback. It can also be used for smaller render jobs in the middle of a frame, such as copying a GPU Texture.

See also
RenderPass
Examples
example_game.cpp, and example_rectangle.cpp.

Constructor & Destructor Documentation

◆ Renderer() [1/3]

donut::graphics::Renderer::Renderer ( const RendererOptions options = {})
explicit

Construct a renderer.

Parameters
optionsinitial configuration of the renderer, see RendererOptions.
Exceptions
File::Erroron failure to open a required resource file.
graphics::Erroron failure to create or initialize a required GPU resource.
std::bad_allocon allocation failure.

◆ ~Renderer()

donut::graphics::Renderer::~Renderer ( )

Destructor.

◆ Renderer() [2/3]

donut::graphics::Renderer::Renderer ( const Renderer )
delete

Copying a renderer is not allowed, since it manages global state.

◆ Renderer() [3/3]

donut::graphics::Renderer::Renderer ( Renderer &&  )
delete

Moving a renderer is not allowed, since it manages global state.

Member Function Documentation

◆ operator=() [1/2]

Renderer& donut::graphics::Renderer::operator= ( const Renderer )
delete

Copying a renderer is not allowed, since it manages global state.

◆ operator=() [2/2]

Renderer donut::graphics::Renderer::operator= ( Renderer &&  )
delete

Moving a renderer is not allowed, since it manages global state.

◆ clearFramebufferDepth()

void donut::graphics::Renderer::clearFramebufferDepth ( Framebuffer framebuffer)

Clear the depth buffer contents of a Framebuffer.

Parameters
framebufferframebuffer to clear the depth of.
See also
clearFramebufferColor()
clearFramebufferColorAndDepth()

◆ clearFramebufferColor()

void donut::graphics::Renderer::clearFramebufferColor ( Framebuffer framebuffer,
Color  color 
)

Clear the color contents of a Framebuffer.

Parameters
framebufferframebuffer to clear the color of.
colorcolor to clear the framebuffer to.
See also
clearFramebufferDepth()
clearFramebufferColorAndDepth()

◆ clearFramebufferColorAndDepth()

void donut::graphics::Renderer::clearFramebufferColorAndDepth ( Framebuffer framebuffer,
Color  color 
)

Clear the color and depth buffer contents of a Framebuffer.

Parameters
framebufferframebuffer to clear the color and depth of.
colorcolor to clear the framebuffer to.
See also
clearFramebufferDepth()
clearFramebufferColor()

◆ render()

void donut::graphics::Renderer::render ( Framebuffer framebuffer,
const RenderPass renderPass,
const Viewport viewport,
const Camera camera,
std::optional< Rectangle< int >>  scissor = {} 
)

Render the contents of a RenderPass to a Framebuffer.

Parameters
framebufferframebuffer to render to.
renderPassrender pass to render from.
viewportrectangular region of the framebuffer to render inside of.
cameracamera to render from.
scissorif set, specifies a rectangular region of the framebuffer outside of which any attempts to render a pixel will be discarded.
Note
This function should typically be called at least once every frame during the application::Application::display() callback.

The documentation for this class was generated from the following file: