sincerely Singaporean

If you have not done so, read this full tutorial on how to use SGEXTN to build an application.

SGRBaseRenderer

see header file

see source file

class SGRBaseRenderer;

part of SGEXTN module SG_RI

base class of custom renderers

detailed description

list of all including inherited members

implementation details

preprocessor file inclusion directive: #include ‹SGRBaseRenderer.h›

CMake target for BuildLah: SGEXTN::SG_RI

see this link for more information about BuildLah

parent class: (none)

children classes: (none)

pure virtual functions

virtual void cleanResourcesOnDestruction() = 0;

virtual SGRRenderingProgramme* createRenderingProgramme() = 0;

virtual void initialise() = 0;

virtual void requestRenderCommands(SGRCommandRequest* commandRequest) = 0;

virtual void uploadShaderData() = 0;

instance member functions

SGRBaseRenderer();

[[nodiscard]] SGRRenderingProgramme* renderingProgramme() const;

Detailed Description

SGRBaseRenderer provides a base class to build SG - RI ⁽㈳㈴㈳㈮㈱㈨㈠㈫ ㈧㈤㈱㈤⁾ renderers on top of. All renderers must inherit this class and implement all pure virtual functions provided in this class. Creating SG - RI ⁽㈳㈴㈳㈮㈱㈨㈠㈫ ㈧㈤㈱㈤⁾ renderers is the only way in SGEXTN to use custom shaders.

Implementation Details

SG - RI ⁽㈳㈴㈳㈮㈱㈨㈠㈫ ㈧㈤㈱㈤⁾ internally uses QRhi.

virtual void cleanResourcesOnDestruction() = 0;

This is called when a renderer is deleted. It must clean up everything that you allocated yourself, including vertex buffer objects, element buffer objects, and textures.

Forgetting to free all allocated memory in this function will lead to memory leaks.

To prevent data race, accessing any static variables or objects that do not belong to the renderer in this function is undefined behaviour.

virtual SGRRenderingProgramme* createRenderingProgramme() = 0;

Use this to create a SGRRenderingProgramme. The SGRRenderingProgramme enables the use of shaders, textures and uniform buffer objects. Every renderer must create a SGRRenderingProgramme.

Not returning a pointer to a valid SGRRenderingProgramme at the end of this function is undefined behaviour.

To prevent data race, accessing any static variables or objects that do not belong to the renderer in this function is undefined behaviour.

virtual void initialise() = 0;

This is run once before the render process begins. Use this to create resources that do not change, such as vertex buffer objects for the bounding box of your shader.

virtual void requestRenderCommands(SGRCommandRequest* commandRequest) = 0;

Use this to issue draw commands to the GPU. The SGRCommandRequest commandRequest is provided for this purpose. It is not allowed to upload shader data in this function, that should have been done in your implementation of SGRBaseRenderer::uploadShaderData.

Uploading shader data in this function is undefined behaviour.

To prevent data race, accessing any static variables or objects that do not belong to the renderer in this function is undefined behaviour.

virtual void uploadShaderData() = 0;

This is used to upload data to the GPU. Data can be uploaded using SGRRenderingProgramme::updateDataBuffer for vertex buffer objects and element buffer objects, SGRRenderingProgramme::updateShaderUniforms for uniform buffer objects, and SGRRenderingProgramme::updateTexture for textures. It is not allowed to issue draw commands in this function, which you cannot do anyways as you do not have a SGRCommandRequest.

To prevent data race, accessing any static variables or objects that do not belong to the renderer in this function is undefined behaviour.

SGRBaseRenderer();

Creates a SGRBaseRenderer. This should be used in the constructor of your renderer.

[[nodiscard]] SGRRenderingProgramme* renderingProgramme() const;

Returns a pointer to the SGRRenderingProgramme used by this renderer. This is owned by the renderer and is automatically cleaned up upon deletion. Access to this is needed to upload shader data.

Attempting to modify the SGRRenderingProgramme that this pointer points to is undefined behaviour.

©2025 05524F.sg (Singapore)

contact 05524F / report a bug / make a suggestion

about 05524F SINGAPORE values

list of 05524F projects