CG-Project2
Loading...
Searching...
No Matches
systems::render Namespace Reference

All utilities for rendering entities. More...

Functions

void initStencilShader ()
 Initialize the stencil shader.
void prepareInstancedMesh (const std::vector< glm::mat4 > &models, const std::vector< glm::vec4 > &colors)
 This methods calls the renderer and prepares the buffers with the model matrixes and colors.
void getOtherLightData (LightShaderBlock &block, const Shared< LightComponent > &light)
 Retrieves all the light data and stores them in a shader block.
std::array< LightShaderBlock, SHADER_MAX_LIGHTS > prepareLightData ()
 Prepares data of all lights in the scene and put them in an array with defined size.
void sendOtherLightData (const Shared< ogl::ShaderProgram > &shader, LightShaderBlock &data, size_t &index)
 This method sends to the used shader program the specific data for that light caster.
void sendLightDataShader (const Shared< ogl::ShaderProgram > &shader, std::array< LightShaderBlock, SHADER_MAX_LIGHTS > data)
 This method sends to the used shader program the common lights data.
void renderSkybox (const unsigned int &id, const Shared< ogl::ShaderProgram > &shader)
 This method draws the Skybox of the scene.
void renderAllMeshes ()
 Renders all the entities in the scene.
void renderInstancedMeshes ()
 Renders all entities with instanced rendering available.
std::vector< glm::vec3 > getBoxLines (glm::vec3 &botLeft, glm::vec3 &topRight)
 This method calculates the lines to be drawn from two corners of a ColliderComponent.
void renderBoundingBox ()
 Renders all bounding box of the entities with a ColliderComponent.

Detailed Description

All utilities for rendering entities.

Function Documentation

◆ getBoxLines()

std::vector< glm::vec3 > systems::render::getBoxLines ( glm::vec3 & botLeft,
glm::vec3 & topRight )

This method calculates the lines to be drawn from two corners of a ColliderComponent.

Parameters
botLeftthe bot left corner position
topRightthe top right corner position

◆ getOtherLightData()

void systems::render::getOtherLightData ( LightShaderBlock & block,
const Shared< LightComponent > & light )

Retrieves all the light data and stores them in a shader block.

It prepares a single light data for sending to the shader program.

Parameters
[out]blockthe shader light block
[in]lightthe light in the scene

◆ prepareInstancedMesh()

void systems::render::prepareInstancedMesh ( const std::vector< glm::mat4 > & models,
const std::vector< glm::vec4 > & colors )

This methods calls the renderer and prepares the buffers with the model matrixes and colors.

Parameters
modelsa list of model matrixes
colorsa list of colors

TODO implement proper instancing rendering for every mesh

Warning
This currently works only for instanced rendering with spheres.

◆ prepareLightData()

std::array< LightShaderBlock, SHADER_MAX_LIGHTS > systems::render::prepareLightData ( )

Prepares data of all lights in the scene and put them in an array with defined size.

Returns
an array containing all the lights data prepared to be sent to shader programs.

◆ renderAllMeshes()

void systems::render::renderAllMeshes ( )

Renders all the entities in the scene.

It renderes all the entities with RenderComponent.

◆ renderSkybox()

void systems::render::renderSkybox ( const unsigned int & id,
const Shared< ogl::ShaderProgram > & shader )

This method draws the Skybox of the scene.

Parameters
idthe entity id
shaderthe skybox shader program

◆ sendLightDataShader()

void systems::render::sendLightDataShader ( const Shared< ogl::ShaderProgram > & shader,
std::array< LightShaderBlock, SHADER_MAX_LIGHTS > data )

This method sends to the used shader program the common lights data.

Warning
It doesn't send data for specific casters. The method systems::render::sendOtherLightData() should be called anyway.
Parameters
shaderthe shader program shared pointer
datathe array processed with systems::render::preparedLightData()
See also
systems::render::preparedLightData()

◆ sendOtherLightData()

void systems::render::sendOtherLightData ( const Shared< ogl::ShaderProgram > & shader,
LightShaderBlock & data,
size_t & index )

This method sends to the used shader program the specific data for that light caster.

Warning
It doesn't send common light data. The method systems::render::sendOtherLightData() should be called anyway.
Parameters
shaderthe shader program shared pointer
datathe array processed with systems::render::prepareLightData()
indexthe current light index in the array from systems::render::prepareLightData()
See also
systems::render::preparedLightData()