Pyrogenesis  trunk
Public Member Functions | Private Attributes | Friends | List of all members
ShaderModelRenderer Class Reference

Implementation of ModelRenderer that loads the appropriate shaders for rendering each model, and that batches by shader (and by mesh and texture). More...

#include <ModelRenderer.h>

Inheritance diagram for ShaderModelRenderer:
Inheritance graph
[legend]
Collaboration diagram for ShaderModelRenderer:
Collaboration graph
[legend]

Public Member Functions

 ShaderModelRenderer (ModelVertexRendererPtr vertexrender)
 
virtual ~ShaderModelRenderer ()
 
virtual void Submit (int cullGroup, CModel *model)
 Submit: Submit a model for rendering this frame. More...
 
virtual void PrepareModels ()
 PrepareModels: Calculate renderer data for all previously submitted models. More...
 
virtual void EndFrame ()
 EndFrame: Remove all models from the list of submitted models. More...
 
virtual void Render (const RenderModifierPtr &modifier, const CShaderDefines &context, int cullGroup, int flags)
 Render: Render submitted models, using the given RenderModifier to setup the fragment stage. More...
 
- Public Member Functions inherited from ModelRenderer
 ModelRenderer ()
 
virtual ~ModelRenderer ()
 

Private Attributes

ShaderModelRendererInternalsm
 

Friends

struct ShaderModelRendererInternals
 

Additional Inherited Members

- Static Public Member Functions inherited from ModelRenderer
static void Init ()
 Initialise global settings. More...
 
static void CopyPositionAndNormals (const CModelDefPtr &mdef, const VertexArrayIterator< CVector3D > &Position, const VertexArrayIterator< CVector3D > &Normal)
 CopyPositionAndNormals: Copy unanimated object-space vertices and normals into the given vertex array. More...
 
static void BuildPositionAndNormals (CModel *model, const VertexArrayIterator< CVector3D > &Position, const VertexArrayIterator< CVector3D > &Normal)
 BuildPositionAndNormals: Build animated vertices and normals, transformed into world space. More...
 
static void BuildColor4ub (CModel *model, const VertexArrayIterator< CVector3D > &Normal, const VertexArrayIterator< SColor4ub > &Color)
 BuildColor4ub: Build lighting colors for the given model, based on previously calculated world space normals. More...
 
static void BuildUV (const CModelDefPtr &mdef, const VertexArrayIterator< float[2]> &UV, int UVset)
 BuildUV: Copy UV coordinates into the given vertex array. More...
 
static void BuildIndices (const CModelDefPtr &mdef, const VertexArrayIterator< u16 > &Indices)
 BuildIndices: Create the indices array for the given CModelDef. More...
 
static void GenTangents (const CModelDefPtr &mdef, std::vector< float > &newVertices, bool gpuSkinning)
 GenTangents: Generate tangents for the given CModelDef. More...
 

Detailed Description

Implementation of ModelRenderer that loads the appropriate shaders for rendering each model, and that batches by shader (and by mesh and texture).

Note that the term "Shader" is somewhat misleading, as this handled fixed-function rendering using the same API as real GLSL/ARB shaders.

Constructor & Destructor Documentation

ShaderModelRenderer::ShaderModelRenderer ( ModelVertexRendererPtr  vertexrender)
ShaderModelRenderer::~ShaderModelRenderer ( )
virtual

Member Function Documentation

void ShaderModelRenderer::EndFrame ( )
virtual

EndFrame: Remove all models from the list of submitted models.

Implements ModelRenderer.

void ShaderModelRenderer::PrepareModels ( )
virtual

PrepareModels: Calculate renderer data for all previously submitted models.

Must be called before any rendering calls and after all models for this frame have been submitted.

Implements ModelRenderer.

void ShaderModelRenderer::Render ( const RenderModifierPtr modifier,
const CShaderDefines context,
int  cullGroup,
int  flags 
)
virtual

Render: Render submitted models, using the given RenderModifier to setup the fragment stage.

Note
It is suggested that derived model renderers implement and use this Render functions. However, a highly specialized model renderer may need to "disable" this function and provide its own Render function with a different prototype.

preconditions : PrepareModels must be called after all models have been submitted and before calling Render.

Parameters
modifierThe RenderModifier that specifies the fragment stage.
flagsIf flags is 0, all submitted models are rendered. If flags is non-zero, only models that contain flags in their CModel::GetFlags() are rendered.

Implements ModelRenderer.

void ShaderModelRenderer::Submit ( int  cullGroup,
CModel model 
)
virtual

Submit: Submit a model for rendering this frame.

preconditions : The model must not have been submitted to any ModelRenderer in this frame. Submit may only be called after EndFrame and before PrepareModels.

Parameters
modelThe model that will be added to the list of models submitted this frame.

Implements ModelRenderer.

Friends And Related Function Documentation

friend struct ShaderModelRendererInternals
friend

Member Data Documentation

ShaderModelRendererInternals* ShaderModelRenderer::m
private

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