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::BaseOffscreenRenderStage Class Reference

Base class for render stages which render to an offscreen buffer. More...

#include <render_stage.hpp>

Inheritance diagram for ToyMaker::BaseOffscreenRenderStage:
ToyMaker::BaseRenderStage ToyMaker::AdditionRenderStage ToyMaker::BlurRenderStage ToyMaker::GeometryRenderStage ToyMaker::LightingRenderStage ToyMaker::ResizeRenderStage ToyMaker::SkyboxRenderStage ToyMaker::TonemappingRenderStage

Public Member Functions

 BaseOffscreenRenderStage (const std::string &shaderFilepath, const nlohmann::json &templateFramebufferDescription)
 Constructs a new Base Offscreen Render Stage object.
 
void setTargetTexture (std::shared_ptr< Texture > texture, std::size_t targetID)
 I don't really know what my intention for this was.
 
std::size_t attachTextureAsTarget (std::shared_ptr< Texture > textureHandle)
 Adds a texture to this stage's list of target textures.
 
std::size_t attachTextureAsTarget (const std::string &targetName, std::shared_ptr< Texture > textureHandle)
 Adds a texture to this stage's list of named target textures.
 
void declareRenderTarget (const std::string &name, unsigned int index)
 Assigns a name to an attached target texture, intended to be used by the system connecting render stages together by input and output.
 
std::shared_ptr< TexturegetRenderTarget (const std::string &name)
 Gets a named render target texture from this stage.
 
void detachTargetTexture (std::size_t targetTextureID)
 (in theory) Removes a target texture from this stage's list of target textures.
 
void removeRenderTarget (const std::string &name)
 (in theory) Removes a target texture that was given a name from a list of named target textures.
 
bool hasAttachedRBO () const
 Tests whether an RBO was attached to this render stage.
 
bool hasOwnRBO () const
 Tests whether this stage has created and owns an RBO.
 
RBOgetOwnRBO ()
 Returns the RBO owned by this stage's Framebuffer, if it has one.
 
void attachRBO (RBO &rbo)
 Attaches an RBO to this stage's Framebuffer which may or may not be owned by it.
 
void detachRBO ()
 Detaches the RBO currently attached to this stage's Framebuffer.
 
- Public Member Functions inherited from ToyMaker::BaseRenderStage
 BaseRenderStage (const std::string &shaderFilepath)
 Constructs a new BaseRenderStage object.
 
 BaseRenderStage (const BaseRenderStage &other)=delete
 
 BaseRenderStage (BaseRenderStage &&other)=delete
 
BaseRenderStageoperator= (const BaseRenderStage &other)=delete
 
BaseRenderStageoperator= (BaseRenderStage &&other)=delete
 
virtual ~BaseRenderStage ()
 Destroys the Base Render Stage object.
 
virtual void setup (const glm::u16vec2 &targetDimensions)=0
 Sets up the program per its configuration.
 
virtual void validate ()=0
 Validates this stage by checking for availability of required resources, connections with adjacent render stages.
 
virtual void execute ()=0
 Executes this render stage, presumably after preceding render stages have been executed.
 
void attachTexture (const std::string &name, std::shared_ptr< Texture > textureHandle)
 Attaches a named texture to this rendering stage.
 
void attachMesh (const std::string &name, std::shared_ptr< StaticMesh > meshHandle)
 Attaches a named texture to this rendering stage.
 
void attachMaterial (const std::string &name, std::shared_ptr< Material > materialHandle)
 Attaches a named material to this rendering stage.
 
std::shared_ptr< TexturegetTexture (const std::string &name)
 Gets a reference to an attached texture by its name.
 
std::shared_ptr< StaticMeshgetMesh (const std::string &name)
 Gets a reference to an attached mesh by its name.
 
std::shared_ptr< MaterialgetMaterial (const std::string &name)
 Gets a reference to an attached material by its name.
 
void useViewport ()
 Should be called once this stage's shader is made active; applies the viewport config associated with this render stage.
 
void setTargetViewport (const SDL_Rect &targetViewport)
 Sets the rendering area for this stage, a rectangular sub-region of the target texture.
 
void submitToRenderQueue (OpaqueRenderUnit renderUnit)
 Adds an opaque render unit expected by this stage to its associated render queue.
 
void submitToRenderQueue (LightRenderUnit lightRenderUnit)
 Adds a light render unit expected by this stage to its associated render queue.
 

Protected Attributes

std::shared_ptr< FramebuffermFramebufferHandle
 The framebuffer owned by this stage, to which this stage renders its results.
 
nlohmann::json mTemplateFramebufferDescription
 A description of this stage's framebuffer, used as a template to create a framebuffer matching requested render dimensions.
 
std::map< std::string, unsigned int > mRenderTargets {}
 A list of named render target textures along with their indices in this stage's framebuffer's target color buffer list.
 
- Protected Attributes inherited from ToyMaker::BaseRenderStage
GLuint mVertexArrayObject {}
 The OpenGL vertex array object associated with this object.
 
std::shared_ptr< ShaderProgrammShaderHandle
 A handle to the compiled and uploaded shader program associated with this render stage.
 
std::map< std::string, std::shared_ptr< Texture > > mTextureAttachments {}
 This stage's named texture attachments.
 
std::map< std::string, std::shared_ptr< StaticMesh > > mMeshAttachments {}
 This stage's named mesh attachments.
 
std::map< std::string, std::shared_ptr< Material > > mMaterialAttachments {}
 This stage's named material attachments.
 
std::priority_queue< OpaqueRenderUnitmOpaqueMeshQueue {}
 A queue containing all the opaque meshes to be rendered this frame by this stage.
 
std::priority_queue< LightRenderUnitmLightQueue {}
 A queue containing all the light units to be rendered this frame by this stage.
 
SDL_Rect mTargetViewport {0, 0, 800, 600}
 The rectangle defining the sub-region of its target texture to which this render stage renders.
 

Detailed Description

Base class for render stages which render to an offscreen buffer.

Constructor & Destructor Documentation

◆ BaseOffscreenRenderStage()

BaseOffscreenRenderStage::BaseOffscreenRenderStage ( const std::string & shaderFilepath,
const nlohmann::json & templateFramebufferDescription )

Constructs a new Base Offscreen Render Stage object.

Parameters
shaderFilepathThe path to the JSON shader program header used by this stage.
templateFramebufferDescriptionA JSON description of this stage's Framebuffer's initial state.

Member Function Documentation

◆ attachRBO()

void BaseOffscreenRenderStage::attachRBO ( RBO & rbo)

Attaches an RBO to this stage's Framebuffer which may or may not be owned by it.

Parameters
rboA reference to the RBO being attached to this stage.

◆ attachTextureAsTarget() [1/2]

std::size_t BaseOffscreenRenderStage::attachTextureAsTarget ( const std::string & targetName,
std::shared_ptr< Texture > textureHandle )

Adds a texture to this stage's list of named target textures.

Parameters
targetNameThe name of the texture as target, once attached.
textureHandleThe actual texture being attached as a target.
Returns
std::size_t The index associated with the newly added target texture.
See also
declareRenderTarget()

◆ attachTextureAsTarget() [2/2]

std::size_t BaseOffscreenRenderStage::attachTextureAsTarget ( std::shared_ptr< Texture > textureHandle)

Adds a texture to this stage's list of target textures.

Parameters
textureHandleThe texture being added to this stage's target texture list.
Returns
std::size_t The ID of the newly added target texture.

◆ declareRenderTarget()

void BaseOffscreenRenderStage::declareRenderTarget ( const std::string & name,
unsigned int index )

Assigns a name to an attached target texture, intended to be used by the system connecting render stages together by input and output.

Parameters
nameThe name of the render target.
indexThe target texture attachment ID.

◆ detachTargetTexture()

void ToyMaker::BaseOffscreenRenderStage::detachTargetTexture ( std::size_t targetTextureID)

(in theory) Removes a target texture from this stage's list of target textures.

Parameters
targetTextureIDThe index of the target texture to remove.
Todo
Figure out what my intentions were re: this method.

◆ getOwnRBO()

RBO & BaseOffscreenRenderStage::getOwnRBO ( )

Returns the RBO owned by this stage's Framebuffer, if it has one.

Returns
RBO& A reference to the RBO owned by this stage.

◆ getRenderTarget()

std::shared_ptr< Texture > BaseOffscreenRenderStage::getRenderTarget ( const std::string & name)

Gets a named render target texture from this stage.

Parameters
nameThe name of the render target.
Returns
std::shared_ptr<Texture> The handle to the target.
See also
declareRenderTarget()
attachTextureAsTarget()

◆ hasAttachedRBO()

bool BaseOffscreenRenderStage::hasAttachedRBO ( ) const

Tests whether an RBO was attached to this render stage.

Return values
trueThis stage has an RBO attached.
falseThis stage has no RBO attached.

◆ hasOwnRBO()

bool BaseOffscreenRenderStage::hasOwnRBO ( ) const

Tests whether this stage has created and owns an RBO.

Return values
trueThis stage has an RBO of its own.
falseThis stage has no RBO of its own.

◆ removeRenderTarget()

void ToyMaker::BaseOffscreenRenderStage::removeRenderTarget ( const std::string & name)

(in theory) Removes a target texture that was given a name from a list of named target textures.

Parameters
nameThe name of the target texture to be made nameless.
Todo
Figure out what my intentions were re: this method.

◆ setTargetTexture()

void ToyMaker::BaseOffscreenRenderStage::setTargetTexture ( std::shared_ptr< Texture > texture,
std::size_t targetID )

I don't really know what my intention for this was.

Parameters
textureThe texture being made a target, presumably.
targetIDThe color attachment ID the texture should be bound to in this stage's framebuffer, presumably.
Todo
Figure out whatever it was I might have wanted this for.

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