/
modelrenderer.h
118 lines (99 loc) · 3.47 KB
/
modelrenderer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/** @file modelrenderer.h Model renderer.
*
* @authors Copyright (c) 2014 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/
#ifndef DENG_CLIENT_MODELRENDERER_H
#define DENG_CLIENT_MODELRENDERER_H
#include <de/Function>
#include <de/ModelDrawable>
#include <de/ModelBank>
#include <de/GLState>
#include <de/Scheduler>
#include <de/MultiAtlas>
#include <QList>
#include <QMap>
#include <QBitArray>
#include <functional>
#include "model.h"
struct vissprite_t;
struct vispsprite_t;
/**
* The model renderer: draws 3D models representing map objects and psprites.
*
* ModelRenderer also does the following:
* - prepares available model assets for drawing (using ModelDrawable), and keeps the
* set of needed ModelDrawable instances in memory
* - owns the shaders for rendering models
* - maintains the set of GL uniforms for rendering models, including transformation
* and lighting data
* - orchestrates the rendering of individual models when it comes to rendering passes
* and GL state changes
*
* ModelRenderer does not perform the low-level OpenGL drawing calls -- those are done by
* ModelDrawable.
*
* @ingroup render
*/
class ModelRenderer
{
public:
DENG2_ERROR(DefinitionError);
DENG2_ERROR(TextureMappingError);
public:
ModelRenderer();
void glInit();
void glDeinit();
/**
* Provides access to the bank containing available drawable models.
*/
de::ModelBank &bank();
render::Model::StateAnims const *animations(de::DotPath const &modelId) const;
/**
* Render a GL2 model.
*
* @param spr Parameters for the draw operation (as a vissprite).
*/
void render(vissprite_t const &spr);
/**
* Render a GL2 model representing a psprite.
*
* @param pspr Parameters for the draw operation (as a vispsprite).
*/
void render(vispsprite_t const &pspr);
/**
* Looks up the name of a shader based on a GLProgram instance.
*
* @param program Shader program. Must be a shader program
* created and owned by ModelRenderer.
* @return Name of the shader (in the shader bank).
*/
de::String shaderName(de::GLProgram const &program) const;
/**
* Looks up the definition of a shader based on a GLProgram instance.
*
* @param program Shader program. Must be a shader program
* created and owned by ModelRenderer.
* @return Shader definition record.
*/
de::Record const &shaderDefinition(de::GLProgram const &program) const;
public:
static void initBindings(de::Binder &binder, de::Record &module);
static int identifierFromText(de::String const &text,
std::function<int (de::String const &)> resolver);
private:
DENG2_PRIVATE(d)
};
#endif // DENG_CLIENT_MODELRENDERER_H