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

Render step responsible for translating mesh-material data into geometry buffers. More...

#include <render_stage.hpp>

Inheritance diagram for ToyMaker::GeometryRenderStage:
ToyMaker::BaseOffscreenRenderStage ToyMaker::BaseRenderStage

Public Member Functions

 GeometryRenderStage (const std::string &shaderFilepath)
 Constructs a new geometry render stage object with templates for its position, normal, and albedo-spec color buffers.
 
virtual void setup (const glm::u16vec2 &textureDimensions) override
 Sets up the program per its configuration.
 
virtual void validate () override
 Validates this stage by checking for availability of required resources, connections with adjacent render stages.
 
virtual void execute () override
 Executes this render stage, presumably after preceding render stages have been executed.
 
- Public Member Functions inherited from ToyMaker::BaseOffscreenRenderStage
 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.
 
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.
 

Additional Inherited Members

- Protected Attributes inherited from ToyMaker::BaseOffscreenRenderStage
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

Render step responsible for translating mesh-material data into geometry buffers.

This render stage produces a position buffer, normal buffer, an albedo-specular buffer, and a depth buffer.

The first three are available as this stage's "geometryPosition", "geometryNormal", and "geometryAlbedoSpecular" render targets, while the third is available on the RBO owned by this stage.

To queue an opaque or alpha-tested object to this buffer, call submitToRenderQueue() with an OpaqueRenderUnit object.

Constructor & Destructor Documentation

◆ GeometryRenderStage()

ToyMaker::GeometryRenderStage::GeometryRenderStage ( const std::string & shaderFilepath)
inline

Constructs a new geometry render stage object with templates for its position, normal, and albedo-spec color buffers.

Parameters
shaderFilepathThe path to the header JSON of this object's geometry shader object.

Member Function Documentation

◆ execute()

void GeometryRenderStage::execute ( )
overridevirtual

Executes this render stage, presumably after preceding render stages have been executed.

Mostly anything can happen here, where this stage's behaviour is assumed to be defined in the material properties of the things it renders.

Implements ToyMaker::BaseRenderStage.

◆ setup()

void GeometryRenderStage::setup ( const glm::u16vec2 & targetDimensions)
overridevirtual

Sets up the program per its configuration.

A part of this process includes creating and storing needed resources, and registering material properties used by this render stage.

Parameters
targetDimensionsThe dimensions of the texture to which this stage will render.
Todo
Much of this is finicky and poorly defined. Stricter requirements needed.

Implements ToyMaker::BaseRenderStage.

◆ validate()

void GeometryRenderStage::validate ( )
overridevirtual

Validates this stage by checking for availability of required resources, connections with adjacent render stages.

Todo
Much of this is finicky and poorly defined. Stricter requirements needed.

Implements ToyMaker::BaseRenderStage.


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