Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
|
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>
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< Texture > | getSkybox () 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< Texture > | getCurrentScreenTexture () |
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< Texture > | mSkyboxTexture { nullptr } |
Returns a handle to the background texture for the geometry in this scene. | |
std::map< RenderSetID, RenderSet > | mRenderSets {} |
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. | |
The render system for a single ECSWorld, which joins together various RenderStages into a render pipeline for objects present in that world.
|
inlineexplicit |
Constructs a new RenderSystem belonging to a single ECSWorld.
world | The world this System belongs to. |
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.
name | The name of the render source (presumably indicating its purpose). |
renderSource | The handle to the render source. |
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.
renderDimensions | The dimensions, in pixels, of the world rendered. |
targetDimensions | The dimensions, in pixels, for the target texture, which may be different from the render dimensions. |
viewportDimensions | The sub-region of the target texture that the render texture will be mapped to. |
renderType | The type of pipeline used for this render set. |
void RenderSystem::deleteRenderSet | ( | RenderSetID | renderSet | ) |
Deletes, removes resources of a render set created in this ECSWorld.
renderSet | The render set being deleted. |
void RenderSystem::execute | ( | float | simulationProgress | ) |
Runs through all the render stages in the render pipeline for this frame.
simulationProgress | The 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
std::shared_ptr< Texture > RenderSystem::getCurrentScreenTexture | ( | ) |
Gets a handle to the currently active RenderSet's active screen texture.
float RenderSystem::getExposure | ( | ) |
Gets the exposure value for the currently active render set.
float RenderSystem::getGamma | ( | ) |
Gets the gamma value associated with the current render set.
|
inline |
Gets a handle to the skybox texture used in this RenderSystem's ECSWorld.
|
inlinestatic |
Gets the system type string associated with the RenderSystem.
void RenderSystem::removeRenderSource | ( | const std::string & | name | ) |
Removes a render source from this render set.
name | The name of the render source being removed. |
void RenderSystem::setCamera | ( | EntityID | cameraEntity | ) |
Sets a camera with a particular ID as the active camera for the currently active RenderSet.
cameraEntity | The ID of the active camera for the currently active render set. |
void RenderSystem::setExposure | ( | float | exposure | ) |
Sets the exposure value for the currently active render set.
exposure | The active RenderSet's new exposure value. |
void RenderSystem::setGamma | ( | float | gamma | ) |
Sets the gamma value for the active RenderSet.
gamma | The new gamma value to use. |
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.
renderDimensions | The dimensions of the render texture. |
targetDimensions | The dimensions of the final texture, may be different from render dimensions. |
viewportDimensions | The sub-region of the target texture the render texture will be mapped to. |
renderType | The type of render pipeline to use in this render set. |
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.
skyboxTexture | A texture in a supported cubemap format, or nullptr. |
void RenderSystem::updateCameraMatrices | ( | float | simulationProgress | ) |
Uploads camera matrices to the GPU per the camera's current stage.
simulationProgress | The progress towards the next simulation step since the last simulation step, as a number between 0 and 1. |
void RenderSystem::useRenderSet | ( | RenderSetID | renderSet | ) |
Marks a particular RenderSet as active, i.e., its resources (cameras, textures) are used to render something.
renderSet | The ID of the render set being made active. |
|
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.