Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
InstancingModelRenderer.h
Go to the documentation of this file.
1/* Copyright (C) 2022 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Special ModelVertexRender that only works for non-animated models,
20 * but is very fast for instanced models.
21 */
22
23#ifndef INCLUDED_INSTANCINGMODELRENDERER
24#define INCLUDED_INSTANCINGMODELRENDERER
25
27
29
30/**
31 * Render non-animated (but potentially moving) models using a ShaderRenderModifier.
32 * This computes and binds per-vertex data; the modifier is responsible
33 * for setting any shader uniforms etc (including the instancing transform).
34 */
36{
37public:
38 InstancingModelRenderer(bool gpuSkinning, bool calculateTangents);
40
41 // Implementations
42 CModelRData* CreateModelData(const void* key, CModel* model) override;
43 void UpdateModelData(CModel* model, CModelRData* data, int updateflags) override;
44
45 void UploadModelData(
46 Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
47 CModel* model, CModelRData* data) override;
48 void PrepareModelDef(
49 Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
50 const CModelDef& def) override;
52 Renderer::Backend::IShaderProgram* shader, CModel* model, CModelRData* data) override;
53
54protected:
56};
57
58#endif // INCLUDED_INSTANCINGMODELRENDERER
Definition: ModelDef.h:141
Class CModelRData: Render data that is maintained per CModel.
Definition: ModelRenderer.h:63
Definition: Model.h:39
Render non-animated (but potentially moving) models using a ShaderRenderModifier.
Definition: InstancingModelRenderer.h:36
InstancingModelRendererInternals * m
Definition: InstancingModelRenderer.h:55
~InstancingModelRenderer()
Definition: InstancingModelRenderer.cpp:311
InstancingModelRenderer(bool gpuSkinning, bool calculateTangents)
Definition: InstancingModelRenderer.cpp:303
void PrepareModelDef(Renderer::Backend::IDeviceCommandContext *deviceCommandContext, const CModelDef &def) override
PrepareModelDef: Setup backend state for rendering of models that use the given CModelDef object as b...
Definition: InstancingModelRenderer.cpp:351
CModelRData * CreateModelData(const void *key, CModel *model) override
CreateModelData: Create internal data for one model.
Definition: InstancingModelRenderer.cpp:318
void RenderModel(Renderer::Backend::IDeviceCommandContext *deviceCommandContext, Renderer::Backend::IShaderProgram *shader, CModel *model, CModelRData *data) override
RenderModel: Invoke the rendering commands for the given model.
Definition: InstancingModelRenderer.cpp:371
void UpdateModelData(CModel *model, CModelRData *data, int updateflags) override
UpdateModelData: Calculate per-model data for each frame.
Definition: InstancingModelRenderer.cpp:338
void UploadModelData(Renderer::Backend::IDeviceCommandContext *deviceCommandContext, CModel *model, CModelRData *data) override
Upload per-model data to backend.
Definition: InstancingModelRenderer.cpp:343
Class ModelVertexRenderer: Normal ModelRenderer implementations delegate vertex array management and ...
Definition: ModelVertexRenderer.h:44
Definition: IDeviceCommandContext.h:42
IShaderProgram is a container for multiple shaders of different types.
Definition: IShaderProgram.h:81
Definition: InstancingModelRenderer.cpp:289
pthread_key_t key
Definition: wpthread.cpp:140