Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
ShaderModelRenderer Class Reference

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

#include <ModelRenderer.h>

Inheritance diagram for ShaderModelRenderer:
Collaboration diagram for ShaderModelRenderer:

Classes

struct  ShaderModelRendererInternals
 Internal data of the ShaderModelRenderer. More...
 

Public Member Functions

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

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 technique (and by mesh and texture).

Constructor & Destructor Documentation

◆ ShaderModelRenderer()

ShaderModelRenderer::ShaderModelRenderer ( ModelVertexRendererPtr  vertexrender)

◆ ~ShaderModelRenderer()

ShaderModelRenderer::~ShaderModelRenderer ( )
override

Member Function Documentation

◆ EndFrame()

void ShaderModelRenderer::EndFrame ( )
overridevirtual

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

Implements ModelRenderer.

◆ PrepareModels()

void ShaderModelRenderer::PrepareModels ( )
overridevirtual

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.

◆ Render()

void ShaderModelRenderer::Render ( Renderer::Backend::IDeviceCommandContext deviceCommandContext,
const RenderModifierPtr modifier,
const CShaderDefines context,
int  cullGroup,
int  flags 
)
overridevirtual

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.

◆ Submit()

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

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.

◆ UploadModels()

void ShaderModelRenderer::UploadModels ( Renderer::Backend::IDeviceCommandContext deviceCommandContext)
overridevirtual

Upload renderer data for all previously submitted models to backend.

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

Implements ModelRenderer.

Friends And Related Function Documentation

◆ ShaderModelRendererInternals

friend struct ShaderModelRendererInternals
friend

Member Data Documentation

◆ m

ShaderModelRendererInternals* ShaderModelRenderer::m
private

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