Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
ShadowMap Class Reference

Class ShadowMap: Maintain the shadow map texture and perform necessary OpenGL setup, including matrix calculations. More...

#include <ShadowMap.h>

Public Member Functions

 ShadowMap ()
 
 ~ShadowMap ()
 
void RecreateTexture ()
 RecreateTexture: Destroy the current shadow texture and force creation of a new one. More...
 
int GetDepthTextureBits () const
 GetDepthTextureBits: Return the number of bits to use for depth textures when enabled. More...
 
void SetDepthTextureBits (int bits)
 SetDepthTextureBits: Sets the number of bits to use for depth textures when enabled. More...
 
int GetWidth () const
 GetWidth: Return the width of the depth texture. More...
 
int GetHeight () const
 GetHeight: Return the height of the depth texture. More...
 
void SetupFrame (const CCamera &camera, const CVector3D &lightdir)
 SetupFrame: Configure light space for the given camera and light direction, create the shadow texture if necessary, etc. More...
 
void AddShadowedBound (const CBoundingBoxAligned &bounds)
 AddShadowedBound: Add the bounding box of an object that has to be shadowed. More...
 
void BeginRender ()
 BeginRender: Set OpenGL state for rendering into the shadow map texture. More...
 
void EndRender ()
 EndRender: Finish rendering into the shadow map. More...
 
GLuint GetTexture () const
 GetTexture: Retrieve the OpenGL texture object name that contains the shadow map. More...
 
const CMatrix3DGetTextureMatrix () const
 GetTextureMatrix: Retrieve the world-space to shadow map texture coordinates transformation matrix. More...
 
void RenderDebugBounds ()
 Visualize shadow mapping calculations to help in debugging and optimal shadow map usage. More...
 
void RenderDebugTexture ()
 Visualize shadow map texture to help in debugging. More...
 

Private Attributes

ShadowMapInternalsm
 

Detailed Description

Class ShadowMap: Maintain the shadow map texture and perform necessary OpenGL setup, including matrix calculations.

The class will automatically generate a texture the first time the shadow map is rendered into. The texture will not be resized afterwards.

Definition at line 39 of file ShadowMap.h.

Constructor & Destructor Documentation

ShadowMap::ShadowMap ( )

Definition at line 98 of file ShadowMap.cpp.

ShadowMap::~ShadowMap ( )

Definition at line 120 of file ShadowMap.cpp.

Member Function Documentation

void ShadowMap::AddShadowedBound ( const CBoundingBoxAligned bounds)

AddShadowedBound: Add the bounding box of an object that has to be shadowed.

This is used to calculate the bounds for the shadow map.

Parameters
boundsworld space bounding box

Definition at line 213 of file ShadowMap.cpp.

void ShadowMap::BeginRender ( )

BeginRender: Set OpenGL state for rendering into the shadow map texture.

Todo:
this depends in non-obvious ways on the behaviour of the call-site

Definition at line 455 of file ShadowMap.cpp.

void ShadowMap::EndRender ( )

EndRender: Finish rendering into the shadow map.

Todo:
this depends in non-obvious ways on the behaviour of the call-site

Definition at line 505 of file ShadowMap.cpp.

int ShadowMap::GetDepthTextureBits ( ) const

GetDepthTextureBits: Return the number of bits to use for depth textures when enabled.

Returns
depth texture bit depth

Definition at line 537 of file ShadowMap.cpp.

int ShadowMap::GetHeight ( ) const

GetHeight: Return the height of the depth texture.

Returns
depth texture height

Definition at line 564 of file ShadowMap.cpp.

GLuint ShadowMap::GetTexture ( ) const

GetTexture: Retrieve the OpenGL texture object name that contains the shadow map.

Returns
the texture name of the shadow map texture

Definition at line 524 of file ShadowMap.cpp.

const CMatrix3D & ShadowMap::GetTextureMatrix ( ) const

GetTextureMatrix: Retrieve the world-space to shadow map texture coordinates transformation matrix.

Returns
the matrix that transforms world-space coordinates into homogenous shadow map texture coordinates

Definition at line 529 of file ShadowMap.cpp.

int ShadowMap::GetWidth ( ) const

GetWidth: Return the width of the depth texture.

Returns
depth texture width

Definition at line 559 of file ShadowMap.cpp.

void ShadowMap::RecreateTexture ( )

RecreateTexture: Destroy the current shadow texture and force creation of a new one.

Useful when the renderer's size has changed and the texture should be resized too.

Definition at line 135 of file ShadowMap.cpp.

void ShadowMap::RenderDebugBounds ( )

Visualize shadow mapping calculations to help in debugging and optimal shadow map usage.

Definition at line 571 of file ShadowMap.cpp.

void ShadowMap::RenderDebugTexture ( )

Visualize shadow map texture to help in debugging.

Definition at line 648 of file ShadowMap.cpp.

void ShadowMap::SetDepthTextureBits ( int  bits)

SetDepthTextureBits: Sets the number of bits to use for depth textures when enabled.

Possible values are 16, 24, 32 and 0 (= use default)

Parameters
bitsnumber of bits

Definition at line 542 of file ShadowMap.cpp.

void ShadowMap::SetupFrame ( const CCamera camera,
const CVector3D lightdir 
)

SetupFrame: Configure light space for the given camera and light direction, create the shadow texture if necessary, etc.

Parameters
camerathe camera that will be used for world rendering
lightdirthe direction of the (directional) sunlight

Definition at line 153 of file ShadowMap.cpp.

Member Data Documentation

ShadowMapInternals* ShadowMap::m
private

Definition at line 141 of file ShadowMap.h.


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