Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::RenderSystem Class Reference

The render system for a single ECSWorld, which joins together various RenderStages into a render pipeline for objects present in that world. More...

#include <render_system.hpp>

Inheritance diagram for ToyMaker::RenderSystem:
ToyMaker::System< RenderSystem, std::tuple<>, std::tuple< CameraProperties > >

Classes

class  LightQueue
 A subsystem of the RenderSystem; tracks light objects in this ECSWorld scheduled for rendering at the next render step. More...
 
class  OpaqueQueue
 A subsystem of the RenderSystem; tracks opaque and alpha-tested models present in this ECSWorld to be rendered at the next render step. More...
 

Public Member Functions

 RenderSystem (std::weak_ptr< ECSWorld > world)
 Constructs a new RenderSystem belonging to a single ECSWorld.
 
void execute (float simulationProgress)
 Runs through all the render stages in the render pipeline for this frame.
 
void updateCameraMatrices (float simulationProgress)
 Uploads camera matrices to the GPU per the camera's current stage.
 
void renderToScreen ()
 Renders the currently active screen texture (RenderSet::mCurrentScreenTexture) to the (global) screen or window texture.
 
void setSkybox (std::shared_ptr< Texture > skyboxTexture)
 Sets (or nulls) the skybox texture currently being used as the background to this scene's geometry.
 
std::shared_ptr< TexturegetSkybox () const
 Gets a handle to the skybox texture used in this RenderSystem's ECSWorld.
 
RenderSetID createRenderSet (glm::u16vec2 renderDimensions, glm::u16vec2 targetDimensions, const SDL_Rect &viewportDimensions, RenderSet::RenderType renderType=RenderSet::RenderType::BASIC_3D)
 Creates a RenderSet based on parameters provided by its caller.
 
void addOrAssignRenderSource (const std::string &name, std::shared_ptr< Texture > renderSource)
 Adds a "render source" to the currently bound RenderSet.
 
void removeRenderSource (const std::string &name)
 Removes a render source from this render set.
 
void useRenderSet (RenderSetID renderSet)
 Marks a particular RenderSet as active, i.e., its resources (cameras, textures) are used to render something.
 
void setRenderProperties (glm::u16vec2 renderDimensions, glm::u16vec2 targetDimensions, const SDL_Rect &viewportDimensions, RenderSet::RenderType renderType)
 Sets the render properties of the currently active RenderSet.
 
void deleteRenderSet (RenderSetID renderSet)
 Deletes, removes resources of a render set created in this ECSWorld.
 
void renderNextTexture ()
 (Used in debug) Sets the next texture in the currently active RenderSet's screen texture list as that set's target texture.
 
void setCamera (EntityID cameraEntity)
 Sets a camera with a particular ID as the active camera for the currently active RenderSet.
 
void setGamma (float gamma)
 Sets the gamma value for the active RenderSet.
 
float getGamma ()
 Gets the gamma value associated with the current render set.
 
void setExposure (float exposure)
 Sets the exposure value for the currently active render set.
 
float getExposure ()
 Gets the exposure value for the currently active render set.
 
std::shared_ptr< TexturegetCurrentScreenTexture ()
 Gets a handle to the currently active RenderSet's active screen texture.
 

Static Public Member Functions

static std::string getSystemTypeName ()
 Gets the system type string associated with the RenderSystem.
 

Private Member Functions

void onInitialize () override
 Initializes this render system.
 
void copyAndResize ()
 Command which invokes the ResizeRenderStage of the currently active RenderSet's current screen texture if necessary.
 

Private Attributes

std::shared_ptr< TexturemSkyboxTexture { nullptr }
 Returns a handle to the background texture for the geometry in this scene.
 
std::map< RenderSetID, RenderSetmRenderSets {}
 A list of render sets that were created for this render system.
 
RenderSetID mActiveRenderSetID
 The ID of the presently active RenderSet.
 
std::set< RenderSetID > mDeletedRenderSetIDs {}
 IDs of render sets which existed before, which may be used again to name new RenderSets.
 
RenderSetID mNextRenderSetID { 0 }
 The highest number of RenderSets which were active at once during the running of this program.
 
GLuint mMatrixUniformBufferIndex { 0 }
 The ID for this system's uniform buffer object storing camera related matrices.
 
GLuint mMatrixUniformBufferBinding { 0 }
 The ID for this system's uniform buffer binding point, where shader programs expect to find camera matrices.
 

Detailed Description

The render system for a single ECSWorld, which joins together various RenderStages into a render pipeline for objects present in that world.

Constructor & Destructor Documentation

◆ RenderSystem()

ToyMaker::RenderSystem::RenderSystem ( std::weak_ptr< ECSWorld > world)
inlineexplicit

Constructs a new RenderSystem belonging to a single ECSWorld.

Parameters
worldThe world this System belongs to.

Member Function Documentation

◆ addOrAssignRenderSource()

void RenderSystem::addOrAssignRenderSource ( const std::string & name,
std::shared_ptr< Texture > renderSource )

Adds a "render source" to the currently bound RenderSet.

A render source can be any miscellaneous texture used as input to one of the render pipeline's render stages.

Parameters
nameThe name of the render source (presumably indicating its purpose).
renderSourceThe handle to the render source.

◆ createRenderSet()

RenderSetID RenderSystem::createRenderSet ( glm::u16vec2 renderDimensions,
glm::u16vec2 targetDimensions,
const SDL_Rect & viewportDimensions,
RenderSet::RenderType renderType = RenderSet::RenderType::BASIC_3D )

Creates a RenderSet based on parameters provided by its caller.

Parameters
renderDimensionsThe dimensions, in pixels, of the world rendered.
targetDimensionsThe dimensions, in pixels, for the target texture, which may be different from the render dimensions.
viewportDimensionsThe sub-region of the target texture that the render texture will be mapped to.
renderTypeThe type of pipeline used for this render set.
Returns
RenderSetID The ID representing the RenderSet created by this method.

◆ deleteRenderSet()

void RenderSystem::deleteRenderSet ( RenderSetID renderSet)

Deletes, removes resources of a render set created in this ECSWorld.

Parameters
renderSetThe render set being deleted.

◆ execute()

void RenderSystem::execute ( float simulationProgress)

Runs through all the render stages in the render pipeline for this frame.

Parameters
simulationProgressThe progress towards the next simulation step since the last simulation step, as a number between 0 and 1.

Implement a proper bloom some time in the future

◆ getCurrentScreenTexture()

std::shared_ptr< Texture > RenderSystem::getCurrentScreenTexture ( )

Gets a handle to the currently active RenderSet's active screen texture.

Returns
std::shared_ptr<Texture> A handle to this RenderSet's active screen texture.
See also
RenderSet::mCurrentScreenTexture

◆ getExposure()

float RenderSystem::getExposure ( )

Gets the exposure value for the currently active render set.

Returns
float The active RenderSet's current exposure value.

◆ getGamma()

float RenderSystem::getGamma ( )

Gets the gamma value associated with the current render set.

Returns
float This RenderSet's current gamma value.

◆ getSkybox()

std::shared_ptr< Texture > ToyMaker::RenderSystem::getSkybox ( ) const
inline

Gets a handle to the skybox texture used in this RenderSystem's ECSWorld.

Returns
std::shared_ptr<Texture> A handle to this ECSWorld's skybox texture.

◆ getSystemTypeName()

static std::string ToyMaker::RenderSystem::getSystemTypeName ( )
inlinestatic

Gets the system type string associated with the RenderSystem.

Returns
std::string The render system's system type string.

◆ removeRenderSource()

void RenderSystem::removeRenderSource ( const std::string & name)

Removes a render source from this render set.

Parameters
nameThe name of the render source being removed.

◆ setCamera()

void RenderSystem::setCamera ( EntityID cameraEntity)

Sets a camera with a particular ID as the active camera for the currently active RenderSet.

Parameters
cameraEntityThe ID of the active camera for the currently active render set.

◆ setExposure()

void RenderSystem::setExposure ( float exposure)

Sets the exposure value for the currently active render set.

Parameters
exposureThe active RenderSet's new exposure value.

◆ setGamma()

void RenderSystem::setGamma ( float gamma)

Sets the gamma value for the active RenderSet.

Parameters
gammaThe new gamma value to use.

◆ setRenderProperties()

void RenderSystem::setRenderProperties ( glm::u16vec2 renderDimensions,
glm::u16vec2 targetDimensions,
const SDL_Rect & viewportDimensions,
RenderSet::RenderType renderType )

Sets the render properties of the currently active RenderSet.

Parameters
renderDimensionsThe dimensions of the render texture.
targetDimensionsThe dimensions of the final texture, may be different from render dimensions.
viewportDimensionsThe sub-region of the target texture the render texture will be mapped to.
renderTypeThe type of render pipeline to use in this render set.

◆ setSkybox()

void RenderSystem::setSkybox ( std::shared_ptr< Texture > skyboxTexture)

Sets (or nulls) the skybox texture currently being used as the background to this scene's geometry.

Parameters
skyboxTextureA texture in a supported cubemap format, or nullptr.

◆ updateCameraMatrices()

void RenderSystem::updateCameraMatrices ( float simulationProgress)

Uploads camera matrices to the GPU per the camera's current stage.

Parameters
simulationProgressThe progress towards the next simulation step since the last simulation step, as a number between 0 and 1.

◆ useRenderSet()

void RenderSystem::useRenderSet ( RenderSetID renderSet)

Marks a particular RenderSet as active, i.e., its resources (cameras, textures) are used to render something.

Parameters
renderSetThe ID of the render set being made active.

Member Data Documentation

◆ mNextRenderSetID

RenderSetID ToyMaker::RenderSystem::mNextRenderSetID { 0 }
private

The highest number of RenderSets which were active at once during the running of this program.

The next useable ID for a render set if that number is exceeded.


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