Hymn to Beauty
C++ 3D Engine
Video::LowLevelRenderer Class Referenceabstract

Low level renderer abstracting the underlaying graphics API (OpenGL or Vulkan). More...

#include <LowLevelRenderer.hpp>

Inheritance diagram for Video::LowLevelRenderer:
Video::OpenGLRenderer Video::VulkanRenderer Video::WebGPURenderer

Classes

struct  OptionalFeatures
 Optional features. More...
 

Public Member Functions

 LowLevelRenderer ()
 Create a new low-level renderer. More...
 
virtual ~LowLevelRenderer ()
 Destructor. More...
 
virtual CommandBufferCreateCommandBuffer ()=0
 Create a command buffer. More...
 
virtual void BeginFrame ()=0
 Begin a new frame. More...
 
virtual void Submit (CommandBuffer *commandBuffer)=0
 Submit a command buffer for execution. More...
 
virtual void Present ()=0
 Present the rendered image to the swap chain. More...
 
virtual BufferCreateBuffer (Buffer::BufferUsage bufferUsage, unsigned int size, const void *data=nullptr)=0
 Create a GPU buffer. More...
 
virtual BufferCreateTemporaryBuffer (Buffer::BufferUsage bufferUsage, unsigned int size, const void *data=nullptr)=0
 Create a temporary GPU buffer. More...
 
virtual VertexDescriptionCreateVertexDescription (unsigned int attributeCount, const VertexDescription::Attribute *attributes, bool indexBuffer=false)=0
 Create a vertex description. More...
 
virtual GeometryBindingCreateGeometryBinding (const VertexDescription *vertexDescription, Buffer *vertexBuffer, GeometryBinding::IndexType indexType=GeometryBinding::IndexType::NONE, const Buffer *indexBuffer=nullptr)=0
 Create a geometry binding. More...
 
virtual ShaderCreateShader (const ShaderSource &shaderSource, Shader::Type type)=0
 Create a shader. More...
 
virtual ShaderProgramCreateShaderProgram (std::initializer_list< const Shader * > shaders)=0
 Create a shader program. More...
 
virtual TextureCreateTexture (const glm::uvec2 size, Texture::Format format, int components, unsigned char *data)=0
 Create a texture. More...
 
virtual const SamplerGetSampler (Sampler::Filter filter, Sampler::Clamping clamping) const =0
 Get a sampler. More...
 
virtual TextureCreateRenderTarget (const glm::uvec2 &size, Texture::Format format)=0
 Create a render target. More...
 
virtual void FreeRenderTarget (Texture *renderTarget)=0
 Free a render target. More...
 
virtual GraphicsPipelineCreateGraphicsPipeline (const ShaderProgram *shaderProgram, const GraphicsPipeline::Configuration &configuration, const VertexDescription *vertexDescription=nullptr)=0
 Create a graphics pipeline. More...
 
virtual ComputePipelineCreateComputePipeline (const ShaderProgram *shaderProgram)=0
 Create a compute pipeline. More...
 
virtual void Wait ()=0
 Wait for all rendering to finish. More...
 
virtual unsigned char * ReadImage (Texture *texture)=0
 Read a render texture color image. More...
 
void SetProfiling (bool profiling)
 Set whether to profile. More...
 
bool IsProfiling () const
 Get whether profiling is active. More...
 
virtual const std::vector< Profiling::Event > & GetTimeline () const =0
 Get profiling timeline. More...
 
virtual const OptionalFeaturesGetOptionalFeatures () const =0
 Get which optional features are supported. More...
 

Detailed Description

Low level renderer abstracting the underlaying graphics API (OpenGL or Vulkan).

Constructor & Destructor Documentation

◆ LowLevelRenderer()

Video::LowLevelRenderer::LowLevelRenderer ( )
inline

Create a new low-level renderer.

◆ ~LowLevelRenderer()

virtual Video::LowLevelRenderer::~LowLevelRenderer ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ BeginFrame()

virtual void Video::LowLevelRenderer::BeginFrame ( )
pure virtual

Begin a new frame.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ CreateBuffer()

virtual Buffer * Video::LowLevelRenderer::CreateBuffer ( Buffer::BufferUsage  bufferUsage,
unsigned int  size,
const void *  data = nullptr 
)
pure virtual

Create a GPU buffer.

Parameters
bufferUsageHow the buffer will be used.
sizeThe size of the buffer in bytes.
dataData to upload to the buffer. Can be nullptr if no data should be uploaded.
Returns
The created buffer.

◆ CreateCommandBuffer()

virtual CommandBuffer * Video::LowLevelRenderer::CreateCommandBuffer ( )
pure virtual

Create a command buffer.

Returns
The created command buffer.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ CreateComputePipeline()

virtual ComputePipeline * Video::LowLevelRenderer::CreateComputePipeline ( const ShaderProgram shaderProgram)
pure virtual

Create a compute pipeline.

Parameters
shaderProgramThe shader program to use.
Returns
The created compute pipeline.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ CreateGeometryBinding()

virtual GeometryBinding * Video::LowLevelRenderer::CreateGeometryBinding ( const VertexDescription vertexDescription,
Buffer vertexBuffer,
GeometryBinding::IndexType  indexType = GeometryBinding::IndexType::NONE,
const Buffer indexBuffer = nullptr 
)
pure virtual

Create a geometry binding.

Parameters
vertexDescriptionDescription of the attributes in the vertex buffer.
vertexBufferBuffer containing the vertex data.
indexTypeThe type of values in the index buffer.
indexBufferIndex buffer.
Returns
The created geometry binding.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ CreateGraphicsPipeline()

virtual GraphicsPipeline * Video::LowLevelRenderer::CreateGraphicsPipeline ( const ShaderProgram shaderProgram,
const GraphicsPipeline::Configuration configuration,
const VertexDescription vertexDescription = nullptr 
)
pure virtual

Create a graphics pipeline.

Parameters
shaderProgramThe shader program to use.
configurationThe configuration of the pipeline.
vertexDescriptionThe description of the vertex input to the pipeline.
Returns
The created graphics pipeline.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ CreateRenderTarget()

virtual Texture * Video::LowLevelRenderer::CreateRenderTarget ( const glm::uvec2 &  size,
Texture::Format  format 
)
pure virtual

Create a render target.

Parameters
sizeThe size of the texture, in pixels.
formatThe format of the texture.
Returns
The created texture.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ CreateShader()

virtual Shader * Video::LowLevelRenderer::CreateShader ( const ShaderSource &  shaderSource,
Shader::Type  type 
)
pure virtual

Create a shader.

Parameters
shaderSourceThe source of the shader, generated by the shader processor.
typeThe type of shader to create.
Returns
The created shader.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ CreateShaderProgram()

virtual ShaderProgram * Video::LowLevelRenderer::CreateShaderProgram ( std::initializer_list< const Shader * >  shaders)
pure virtual

Create a shader program.

Link together shaders into a shader program that can be run on the GPU.

Sample:

Shader* vertexShader = lowLevelRenderer->CreateShader(vertexSource, Shader::Type::VERTEX_SHADER);
Shader* fragmentShader = lowLevelRenderer->CreateShader(fragmentSource, Shader::Type::FRAGMENT_SHADER);
ShaderProgram* shaderProgram = lowLevelRenderer->CreateShaderProgram({ vertexShader, fragmentShader });
@ VERTEX_SHADER
Vertex shader.
@ FRAGMENT_SHADER
Fragment shader.
Parameters
shadersList of shaders to link together.
Returns
The created shader program.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ CreateTemporaryBuffer()

virtual Buffer * Video::LowLevelRenderer::CreateTemporaryBuffer ( Buffer::BufferUsage  bufferUsage,
unsigned int  size,
const void *  data = nullptr 
)
pure virtual

Create a temporary GPU buffer.

The returned buffer's lifetime is controlled by the rendered and should not be deleted.

Parameters
bufferUsageHow the buffer will be used.
sizeThe size of the buffer in bytes.
dataData to upload to the buffer. Can be nullptr if no data should be uploaded.
Returns
The created buffer.

◆ CreateTexture()

virtual Texture * Video::LowLevelRenderer::CreateTexture ( const glm::uvec2  size,
Texture::Format  format,
int  components,
unsigned char *  data 
)
pure virtual

Create a texture.

Parameters
sizeThe size of the texture, in pixels.
formatThe format of the texture.
componentsThe number of components in the texture, 0 if no texture data is supplied.
dataThe texture data to upload, or nullptr.
Returns
The created texture.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ CreateVertexDescription()

virtual VertexDescription * Video::LowLevelRenderer::CreateVertexDescription ( unsigned int  attributeCount,
const VertexDescription::Attribute attributes,
bool  indexBuffer = false 
)
pure virtual

Create a vertex description.

Parameters
attributeCountThe number of vertex attributes.
attributesThe array of attributes.
indexBufferWhether to use an index buffer.
Returns
The created vertex description.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ FreeRenderTarget()

virtual void Video::LowLevelRenderer::FreeRenderTarget ( Texture renderTarget)
pure virtual

Free a render target.

Parameters
renderTargetThe render target to free.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ GetOptionalFeatures()

virtual const OptionalFeatures & Video::LowLevelRenderer::GetOptionalFeatures ( ) const
pure virtual

Get which optional features are supported.

Returns
Which optional features are supported.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ GetSampler()

virtual const Sampler * Video::LowLevelRenderer::GetSampler ( Sampler::Filter  filter,
Sampler::Clamping  clamping 
) const
pure virtual

Get a sampler.

Parameters
filterThe interpolation to apply.
clampingHow to handle sampling outside the texture dimensions.
Returns
The requested sampler.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ GetTimeline()

virtual const std::vector< Profiling::Event > & Video::LowLevelRenderer::GetTimeline ( ) const
pure virtual

Get profiling timeline.

Returns
A list of events that have occurred since the last time fetching the timeline.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ IsProfiling()

bool Video::LowLevelRenderer::IsProfiling ( ) const
inline

Get whether profiling is active.

Returns
Whether profiling is active.

◆ Present()

virtual void Video::LowLevelRenderer::Present ( )
pure virtual

Present the rendered image to the swap chain.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ ReadImage()

virtual unsigned char * Video::LowLevelRenderer::ReadImage ( Texture texture)
pure virtual

Read a render texture color image.

Parameters
textureThe texture to read.
Returns
The color image as a char-array.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ SetProfiling()

void Video::LowLevelRenderer::SetProfiling ( bool  profiling)
inline

Set whether to profile.

Parameters
profilingWhether to profile.

◆ Submit()

virtual void Video::LowLevelRenderer::Submit ( CommandBuffer commandBuffer)
pure virtual

Submit a command buffer for execution.

Parameters
commandBufferThe command buffer to submit.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.

◆ Wait()

virtual void Video::LowLevelRenderer::Wait ( )
pure virtual

Wait for all rendering to finish.

Implemented in Video::OpenGLRenderer, Video::VulkanRenderer, and Video::WebGPURenderer.


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