Cogs.Core
|
#include <Renderer.h>
Public Member Functions | |
Renderer (Context *context) | |
void | initialize (IGraphicsDevice *device) override |
void | cleanup () override |
Cleanup the renderer, releasing all resources held. | |
void | setMode (RenderMode mode) override |
Set the rendering mode the renderer should use. | |
RenderMode | getMode () const override |
Get the Rendering mode used by the renderer. | |
void | setBackgroundColor (const glm::vec4 &backgroundColor) override |
Set the background color applied to the output surface before rendering. | |
glm::vec4 | getBackgroundColor () const override |
Get the reference to the background color. | |
glm::vec2 | getSize () const override |
Get the output surface size of the renderer. | |
IGraphicsDevice * | getDevice () override |
Get the graphics device used by the renderer. | |
const RenderSettings & | getSettings () const override |
Get the settings of the renderer. | |
void | beginFrame () override |
Signals the beginning of a new frame. | |
void | endFrame (uint32_t syncInterval=0, uint32_t presentFlags=PresentFlags::None) override |
Signals the end of the current frame. | |
void | render () override |
Kick off the actual rendering, allowing the renderer to produce its output. | |
glm::mat4 | getProjectionMatrix (const glm::mat4 projectionMatrix) override |
Get an adjusted projection matrix used to render. | |
glm::mat4 | getViewFromViewportMatrix (glm::mat4 inverseProjectionMatrix) override |
Get an adjusted inverse projection matrix mainly used in post processing. | |
float | getClearDepth () override |
Get adjusted clear depth used to render. | |
float | getNearDepth () override |
Get adjusted near plane depth. | |
IRenderResources * | getResources () override |
Get the render resources interface. | |
void | registerExtension (IRendererExtension *extension) override |
Registers the given extension with the renderer. Doesn not take ownership of pointer. | |
void | unregisterExtension (IRendererExtension *extension) override |
Unregister an extension with the renderer. | |
std::span< IRendererExtension * > | getExtensions () override |
Get the list of all extensions. | |
void | renderScreenshot (const ScreenshotSettings &settings, std::vector< uint8_t > &bytes, uint32_t *stride=nullptr) override |
Render screenshot. | |
EngineBuffers & | getEngineBuffers () override |
Get the reference to the EngineBuffers structure. | |
RenderStates & | getRenderStates () override |
Get the reference to the RenderStates structure. | |
EffectFlags::EEffectFlags | getEffectFlags () const override |
Get the EffectFlags. | |
EffectCache & | getEffectCache () override |
Get the reference to the EffectCache structure. | |
EffectBindings & | getEffectBindings () override |
Get the reference to the EffectBindings structure. | |
ActiveLights & | getActiveLights () override |
Get the reference to the ActiveLights structure. | |
unsigned | getMaxLights () const override |
Get the maximum number of lights. | |
void | updatePermutation (EnginePermutation *permutation) override |
Updates the EnginePermutation. | |
EnginePermutations & | getEnginePermutations () override |
Get the reference to the EnginePermutations structure. | |
COGSCORE_DLL_API class ImguiRenderer * | getGuiRenderer () override |
COGSCORE_DLL_API class InspectorGuiRenderer * | getInspectorGuiRenderer () override |
COGSCORE_DLL_API class InspectorGuiRenderer * | getEngineInspectorGuiRenderer () override |
class RenderResources & | getRenderResources () |
class RenderPipelineManager * | getPipelineManager () |
RenderTaskContext & | getRenderContext () |
![]() | |
virtual | ~IRenderer ()=default |
Provided for destruction via pointer to base. | |
virtual void | initialize (IGraphicsDevice *device)=0 |
virtual void | cleanup ()=0 |
Cleanup the renderer, releasing all resources held. | |
virtual glm::vec2 | getSize () const =0 |
Get the output surface size of the renderer. | |
virtual IGraphicsDevice * | getDevice ()=0 |
Get the graphics device used by the renderer. | |
virtual void | setMode (RenderMode mode)=0 |
Set the rendering mode the renderer should use. | |
virtual RenderMode | getMode () const =0 |
Get the Rendering mode used by the renderer. | |
virtual void | setBackgroundColor (const glm::vec4 &color)=0 |
Set the background color applied to the output surface before rendering. | |
virtual glm::vec4 | getBackgroundColor () const =0 |
Get the reference to the background color. | |
virtual void | beginFrame ()=0 |
Signals the beginning of a new frame. | |
virtual void | endFrame (uint32_t syncInterval=0, uint32_t presentFlags=Cogs::PresentFlags::None)=0 |
Signals the end of the current frame. | |
virtual void | render ()=0 |
Kick off the actual rendering, allowing the renderer to produce its output. | |
virtual glm::mat4 | getProjectionMatrix (const glm::mat4 projectionMatrix)=0 |
Get an adjusted projection matrix used to render. | |
virtual glm::mat4 | getViewFromViewportMatrix (const glm::mat4 inverseProjectionMatrix)=0 |
Get an adjusted inverse projection matrix mainly used in post processing. | |
virtual float | getClearDepth ()=0 |
Get adjusted clear depth used to render. | |
virtual float | getNearDepth ()=0 |
Get adjusted near plane depth. | |
virtual IRenderResources * | getResources ()=0 |
Get the render resources interface. | |
virtual const RenderSettings & | getSettings () const =0 |
Get the settings of the renderer. | |
virtual void | registerExtension (IRendererExtension *extension)=0 |
Register an extension with the renderer. | |
virtual void | unregisterExtension (IRendererExtension *extension)=0 |
Unregister an extension with the renderer. | |
virtual std::span< IRendererExtension * > | getExtensions ()=0 |
Get the list of all extensions. | |
virtual void | renderScreenshot (const ScreenshotSettings &settings, std::vector< uint8_t > &bytes, uint32_t *stride)=0 |
Render screenshot. | |
virtual unsigned | getMaxLights () const =0 |
Get the maximum number of lights. | |
virtual EngineBuffers & | getEngineBuffers ()=0 |
Get the reference to the EngineBuffers structure. | |
virtual RenderStates & | getRenderStates ()=0 |
Get the reference to the RenderStates structure. | |
virtual EffectCache & | getEffectCache ()=0 |
Get the reference to the EffectCache structure. | |
virtual EffectFlags::EEffectFlags | getEffectFlags () const =0 |
Get the EffectFlags. | |
virtual EffectBindings & | getEffectBindings ()=0 |
Get the reference to the EffectBindings structure. | |
virtual ActiveLights & | getActiveLights ()=0 |
Get the reference to the ActiveLights structure. | |
virtual void | updatePermutation (EnginePermutation *permutation)=0 |
Updates the EnginePermutation. | |
virtual EnginePermutations & | getEnginePermutations ()=0 |
Get the reference to the EnginePermutations structure. | |
virtual COGSCORE_DLL_API class ImguiRenderer * | getGuiRenderer ()=0 |
virtual COGSCORE_DLL_API class InspectorGuiRenderer * | getInspectorGuiRenderer ()=0 |
virtual COGSCORE_DLL_API class InspectorGuiRenderer * | getEngineInspectorGuiRenderer ()=0 |
Protected Member Functions | |
void | updateSettings () |
void | updateEffectFlags () |
void | emitEvent (uint32_t eventId, const DrawContext *renderingContext) |
Emits the given render event to all registered extensions. | |
Private Attributes | |
Context * | context = nullptr |
IGraphicsDevice * | device = nullptr |
RenderSettings | settings |
RenderMode | mode = RenderMode::Normal |
EngineBuffers | engineBuffers = {} |
RenderStates | renderStates |
struct RenderTarget * | defaultTarget = nullptr |
EffectCache | effectCache |
EffectFlags::EEffectFlags | effectFlags = EffectFlags::None |
RenderResources | resources |
EnginePermutations | enginePermutations |
EffectBindings | effectBindings |
std::unique_ptr< struct Renderers > | renderers |
std::unique_ptr< class RenderPipelineManager > | pipelineManager |
ActiveLights | activeLights |
unsigned | maxLights = static_cast<unsigned>(kMaxLights) |
glm::vec4 | backgroundColor |
std::vector< IRendererExtension * > | extensions |
RenderTaskContext | renderContext |
Friends | |
Cogs::Core::RenderTaskContext | getRenderTaskContext (Renderer *renderer) |
Core renderer system.
Implements the IRenderer interface and provides a basic renderer for Cogs.Core.
Definition at line 27 of file Renderer.h.
Cogs::Core::Renderer::Renderer | ( | Context * | context | ) |
Definition at line 146 of file Renderer.cpp.
Cogs::Core::Renderer::~Renderer | ( | ) |
Definition at line 157 of file Renderer.cpp.
|
overridevirtual |
Signals the beginning of a new frame.
Implements Cogs::Core::IRenderer.
Definition at line 607 of file Renderer.cpp.
References Cogs::IGraphicsDevice::beginFrame().
|
overridevirtual |
Cleanup the renderer, releasing all resources held.
Implements Cogs::Core::IRenderer.
Definition at line 210 of file Renderer.cpp.
References Cogs::Core::Context::variables.
|
protected |
Emits the given render event to all registered extensions.
Definition at line 750 of file Renderer.cpp.
|
overridevirtual |
Signals the end of the current frame.
Implements Cogs::Core::IRenderer.
Definition at line 614 of file Renderer.cpp.
References Cogs::IGraphicsDevice::endFrame().
|
inlineoverridevirtual |
Get the reference to the ActiveLights structure.
Implements Cogs::Core::IRenderer.
Definition at line 72 of file Renderer.h.
|
inlineoverridevirtual |
Get the reference to the background color.
Implements Cogs::Core::IRenderer.
Definition at line 42 of file Renderer.h.
|
overridevirtual |
Get adjusted clear depth used to render.
The depth value is accounting for device coordinate system differences.
Implements Cogs::Core::IRenderer.
Definition at line 582 of file Renderer.cpp.
References Cogs::GraphicsDeviceCapabilities::DepthNegativeOneToOne, Cogs::IGraphicsDevice::getCapabilities(), Cogs::ICapabilities::getDeviceCapabilities(), and Cogs::Core::Context::variables.
|
inlineoverridevirtual |
Get the graphics device used by the renderer.
Implements Cogs::Core::IRenderer.
Definition at line 45 of file Renderer.h.
|
inlineoverridevirtual |
Get the reference to the EffectBindings structure.
Implements Cogs::Core::IRenderer.
Definition at line 71 of file Renderer.h.
Referenced by Cogs::Core::RenderMaterial::getBinding().
|
inlineoverridevirtual |
Get the reference to the EffectCache structure.
Implements Cogs::Core::IRenderer.
Definition at line 70 of file Renderer.h.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Get the reference to the EngineBuffers structure.
Implements Cogs::Core::IRenderer.
Definition at line 67 of file Renderer.h.
|
overridevirtual |
Implements Cogs::Core::IRenderer.
Definition at line 838 of file Renderer.cpp.
|
inlineoverridevirtual |
Get the reference to the EnginePermutations structure.
Implements Cogs::Core::IRenderer.
Definition at line 76 of file Renderer.h.
|
inlineoverridevirtual |
Get the list of all extensions.
Implements Cogs::Core::IRenderer.
Definition at line 63 of file Renderer.h.
|
overridevirtual |
Implements Cogs::Core::IRenderer.
Definition at line 829 of file Renderer.cpp.
|
overridevirtual |
Implements Cogs::Core::IRenderer.
Definition at line 833 of file Renderer.cpp.
|
inlineoverridevirtual |
Get the maximum number of lights.
Implements Cogs::Core::IRenderer.
Definition at line 73 of file Renderer.h.
|
inlineoverridevirtual |
Get the Rendering mode used by the renderer.
Implements Cogs::Core::IRenderer.
Definition at line 39 of file Renderer.h.
|
overridevirtual |
Get adjusted near plane depth.
The depth value is accounting for device coordinate system differences.
Implements Cogs::Core::IRenderer.
Definition at line 594 of file Renderer.cpp.
References Cogs::GraphicsDeviceCapabilities::DepthNegativeOneToOne, Cogs::IGraphicsDevice::getCapabilities(), Cogs::ICapabilities::getDeviceCapabilities(), and Cogs::Core::Context::variables.
|
inline |
Definition at line 85 of file Renderer.h.
|
overridevirtual |
Get an adjusted projection matrix used to render.
The matrix is accounting for device coordinate system differences.
projectionMatrix | GL-convention projection matrix used as base for the conversion. |
Implements Cogs::Core::IRenderer.
Definition at line 453 of file Renderer.cpp.
References Cogs::GraphicsDeviceCapabilities::DepthNegativeOneToOne, Cogs::Direct3D11, Cogs::Direct3D12, Cogs::IGraphicsDevice::getCapabilities(), Cogs::ICapabilities::getDeviceCapabilities(), Cogs::IGraphicsDevice::getType(), Cogs::Null, Cogs::OpenGL20, Cogs::OpenGLES30, Cogs::Core::Context::variables, Cogs::Vulkan, and Cogs::WebGPU.
|
inline |
Definition at line 86 of file Renderer.h.
|
inline |
Definition at line 84 of file Renderer.h.
|
inlineoverridevirtual |
Get the reference to the RenderStates structure.
Implements Cogs::Core::IRenderer.
Definition at line 68 of file Renderer.h.
|
overridevirtual |
Get the render resources interface.
Implements Cogs::Core::IRenderer.
Definition at line 621 of file Renderer.cpp.
|
inlineoverridevirtual |
Get the settings of the renderer.
Implements Cogs::Core::IRenderer.
Definition at line 46 of file Renderer.h.
|
inlineoverridevirtual |
Get the output surface size of the renderer.
Implements Cogs::Core::IRenderer.
Definition at line 44 of file Renderer.h.
|
overridevirtual |
Get an adjusted inverse projection matrix mainly used in post processing.
The matrix is accounting for how depth values are converted from clip space to viewport coordinates.
inverseProjectionMatrix | inverse of the actual projection matrix used for rendering. |
Implements Cogs::Core::IRenderer.
Definition at line 527 of file Renderer.cpp.
References Cogs::GraphicsDeviceCapabilities::DepthNegativeOneToOne, Cogs::Direct3D11, Cogs::Direct3D12, Cogs::IGraphicsDevice::getCapabilities(), Cogs::ICapabilities::getDeviceCapabilities(), Cogs::IGraphicsDevice::getType(), Cogs::Null, Cogs::OpenGL20, Cogs::OpenGLES30, Cogs::Vulkan, and Cogs::WebGPU.
|
overridevirtual |
Implements Cogs::Core::IRenderer.
Definition at line 161 of file Renderer.cpp.
|
overridevirtual |
Registers the given extension with the renderer. Doesn not take ownership of pointer.
Implements Cogs::Core::IRenderer.
Definition at line 626 of file Renderer.cpp.
|
overridevirtual |
Kick off the actual rendering, allowing the renderer to produce its output.
Implements Cogs::Core::IRenderer.
Definition at line 231 of file Renderer.cpp.
References Cogs::SamplerState::addressModeS, Cogs::SamplerState::Border, Cogs::Core::Box, Cogs::SamplerState::ComparisonMinMagMipLinear, Cogs::Core::Default, Cogs::DepthStencilState::DefaultState(), Cogs::DepthStencilState::depthFunction, Cogs::IGraphicsDevice::getImmediateContext(), Cogs::IGraphicsDevice::getRenderTargets(), Cogs::IGraphicsDevice::getTextures(), Cogs::DepthStencilState::Greater, Cogs::Handle_t< RenderTargetTag >::NoHandle, Cogs::Handle_t< DepthStencilTag >::NoHandle, Cogs::GraphicsDeviceSettings::numSamples, Cogs::Core::RenderingEvent::PostRender, Cogs::Core::RenderingEvent::PreRender, Cogs::Core::RenderingEvent::RenderGui, Cogs::IContext::setRenderTarget(), and Cogs::Core::Context::variables.
|
overridevirtual |
Render screenshot.
Implements Cogs::Core::IRenderer.
Definition at line 645 of file Renderer.cpp.
References Cogs::Framebuffer::Front, Cogs::IGraphicsDevice::getBuffers(), Cogs::IGraphicsDevice::getImmediateContext(), Cogs::IGraphicsDevice::getRenderTargets(), Cogs::IGraphicsDevice::getTextures(), Cogs::BindFlags::None, Cogs::AccessMode::Read, Cogs::MapMode::Read, Cogs::TextureFlags::RenderTarget, and Cogs::Usage::Staging.
|
overridevirtual |
Set the background color applied to the output surface before rendering.
color | A four-component RGBA color to clear the surface to. |
Implements Cogs::Core::IRenderer.
Definition at line 330 of file Renderer.cpp.
|
inlineoverridevirtual |
Set the rendering mode the renderer should use.
mode | Rendering mode to use. |
Implements Cogs::Core::IRenderer.
Definition at line 38 of file Renderer.h.
|
overridevirtual |
Unregister an extension with the renderer.
extension | Pointer to a class implementing the IRendererExtension interface. |
Implements Cogs::Core::IRenderer.
Definition at line 635 of file Renderer.cpp.
|
protected |
Definition at line 337 of file Renderer.cpp.
|
overridevirtual |
Updates the EnginePermutation.
permutation | EnginePermutation to update. |
Implements Cogs::Core::IRenderer.
Definition at line 757 of file Renderer.cpp.
References Cogs::GraphicsDeviceCapabilities::DepthNegativeOneToOne, Cogs::IGraphicsDevice::getCapabilities(), Cogs::ICapabilities::getDeviceCapabilities(), and Cogs::Core::Context::variables.
|
protected |
Definition at line 349 of file Renderer.cpp.
|
friend |
Definition at line 112 of file Renderer.cpp.
|
private |
Definition at line 113 of file Renderer.h.
|
private |
Definition at line 116 of file Renderer.h.
|
private |
Definition at line 97 of file Renderer.h.
|
private |
Definition at line 103 of file Renderer.h.
|
private |
Definition at line 98 of file Renderer.h.
|
private |
Definition at line 109 of file Renderer.h.
|
private |
Definition at line 104 of file Renderer.h.
|
private |
Definition at line 105 of file Renderer.h.
|
private |
Definition at line 101 of file Renderer.h.
|
private |
Definition at line 108 of file Renderer.h.
|
private |
Definition at line 117 of file Renderer.h.
|
private |
Definition at line 115 of file Renderer.h.
|
private |
Definition at line 100 of file Renderer.h.
|
private |
Definition at line 111 of file Renderer.h.
|
private |
Definition at line 119 of file Renderer.h.
|
private |
Definition at line 110 of file Renderer.h.
|
private |
Definition at line 102 of file Renderer.h.
|
private |
Definition at line 107 of file Renderer.h.
|
private |
Definition at line 99 of file Renderer.h.