scg3  0.6
scg::RenderState Class Reference

The central render state that collects information about the current shader, transformations, matrix stacks, light and color properties. More...

#include "RenderState.h"

Collaboration diagram for scg::RenderState:
[legend]

Public Member Functions

 RenderState ()
 
virtual ~RenderState ()
 
void init ()
 
int getNLights () const
 
GLuint getLightUBO () const
 
ColorCoregetColor ()
 
void setColor (ColorCore *core)
 
ShaderCoregetShader ()
 
void setShader (ShaderCore *core)
 
const glm::mat4 & getViewTransform () const
 
void setViewTransform (const glm::mat4 &viewTransform)
 
const glm::mat4 & getProjection () const
 
void setProjection (const glm::mat4 &projection)
 
const glm::mat4 & getMVPMatrix () const
 
const glm::mat4 & getModelMatrix () const
 
void setLighting (bool isLightingEnabled)
 
bool isLightingEnabled () const
 
void addLight ()
 
void removeLight ()
 
void setGlobalAmbientLight (const glm::vec4 &globalAmbientLight)
 
void applyProjectionViewTransform ()
 
void passToShader ()
 

Public Attributes

MatrixStack modelViewStack
 
MatrixStack projectionStack
 
MatrixStack textureStack
 
MatrixStack colorStack
 

Protected Attributes

ColorCorecolorCore_
 
ShaderCoreshaderCore_
 
glm::mat4 projection_
 
glm::mat4 viewTransform_
 
glm::mat4 tempMatrix_
 
bool isLightingEnabled_
 
GLint nLights_
 
GLuint lightUBO_
 
glm::vec4 globalAmbientLight_
 

Detailed Description

The central render state that collects information about the current shader, transformations, matrix stacks, light and color properties.

The light properties are stored in a uniform buffer object (UBO). A few member functions are defined in the header file to allow inlining. The matrix stacks are public member variables that are accessed as, e.g.,

RenderState* renderState; renderState->modelViewStack.pushMatrix();

Definition at line 107 of file RenderState.h.

Constructor & Destructor Documentation

◆ RenderState()

scg::RenderState::RenderState ( )

Constructor.

◆ ~RenderState()

virtual scg::RenderState::~RenderState ( )
virtual

Destructor.

Member Function Documentation

◆ addLight()

void scg::RenderState::addLight ( )

Add light, i.e., increase the number of lights.

◆ applyProjectionViewTransform()

void scg::RenderState::applyProjectionViewTransform ( )

Apply projection and view transformation before rendering the scene, to be called by Renderer.

◆ getColor()

ColorCore* scg::RenderState::getColor ( )

Get color core.

◆ getLightUBO()

GLuint scg::RenderState::getLightUBO ( ) const

Get light uniforma buffer object (UBO).

◆ getModelMatrix()

const glm::mat4& scg::RenderState::getModelMatrix ( ) const
inline

Get current model matrix.

Definition at line 194 of file RenderState.h.

◆ getMVPMatrix()

const glm::mat4& scg::RenderState::getMVPMatrix ( ) const
inline

Get current model-view-projection matrix.

Definition at line 187 of file RenderState.h.

◆ getNLights()

int scg::RenderState::getNLights ( ) const

Get number of active lights.

◆ getProjection()

const glm::mat4& scg::RenderState::getProjection ( ) const
inline

Get camera projection that is applied before rendering the scene.

Definition at line 173 of file RenderState.h.

◆ getShader()

ShaderCore* scg::RenderState::getShader ( )

Get shader core.

◆ getViewTransform()

const glm::mat4& scg::RenderState::getViewTransform ( ) const
inline

Get view transformation that is applied before rendering the scene.

Definition at line 159 of file RenderState.h.

◆ init()

void scg::RenderState::init ( )

Inittailize state, create light uniform buffer object (UBO).

◆ isLightingEnabled()

bool scg::RenderState::isLightingEnabled ( ) const

Check if lighting is enabled.

◆ passToShader()

void scg::RenderState::passToShader ( )

Pass current modelview, projection, normal, texture, color matrices to shader, to be called before rendering any geometry.

◆ removeLight()

void scg::RenderState::removeLight ( )

Remove light, i.e., decrease the number of lights.

◆ setColor()

void scg::RenderState::setColor ( ColorCore core)

Set color core.

◆ setGlobalAmbientLight()

void scg::RenderState::setGlobalAmbientLight ( const glm::vec4 &  globalAmbientLight)

Set global ambient light intensity to be applied independent of light sources.

◆ setLighting()

void scg::RenderState::setLighting ( bool  isLightingEnabled)

Enable or disable lighting (light sources and global ambient light).

Default: enabled

◆ setProjection()

void scg::RenderState::setProjection ( const glm::mat4 &  projection)
inline

Set camera projection that is applied before rendering the scene.

Definition at line 180 of file RenderState.h.

◆ setShader()

void scg::RenderState::setShader ( ShaderCore core)

Set shader core.

◆ setViewTransform()

void scg::RenderState::setViewTransform ( const glm::mat4 &  viewTransform)
inline

Get view transformation that is applied before rendering the scene.

Definition at line 166 of file RenderState.h.

Member Data Documentation

◆ colorCore_

ColorCore* scg::RenderState::colorCore_
protected

Definition at line 250 of file RenderState.h.

◆ colorStack

MatrixStack scg::RenderState::colorStack

Definition at line 246 of file RenderState.h.

◆ globalAmbientLight_

glm::vec4 scg::RenderState::globalAmbientLight_
protected

Definition at line 258 of file RenderState.h.

◆ isLightingEnabled_

bool scg::RenderState::isLightingEnabled_
protected

Definition at line 255 of file RenderState.h.

◆ lightUBO_

GLuint scg::RenderState::lightUBO_
protected

Definition at line 257 of file RenderState.h.

◆ modelViewStack

MatrixStack scg::RenderState::modelViewStack

Definition at line 243 of file RenderState.h.

◆ nLights_

GLint scg::RenderState::nLights_
protected

Definition at line 256 of file RenderState.h.

◆ projection_

glm::mat4 scg::RenderState::projection_
protected

Definition at line 252 of file RenderState.h.

◆ projectionStack

MatrixStack scg::RenderState::projectionStack

Definition at line 244 of file RenderState.h.

◆ shaderCore_

ShaderCore* scg::RenderState::shaderCore_
protected

Definition at line 251 of file RenderState.h.

◆ tempMatrix_

glm::mat4 scg::RenderState::tempMatrix_
mutableprotected

Definition at line 254 of file RenderState.h.

◆ textureStack

MatrixStack scg::RenderState::textureStack

Definition at line 245 of file RenderState.h.

◆ viewTransform_

glm::mat4 scg::RenderState::viewTransform_
protected

Definition at line 253 of file RenderState.h.


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