Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OverlayRenderer.h
Go to the documentation of this file.
1 /* Copyright (C) 2013 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 #ifndef INCLUDED_OVERLAYRENDERER
19 #define INCLUDED_OVERLAYRENDERER
20 
21 #include "graphics/ShaderManager.h"
22 
23 struct SOverlayLine;
25 struct SOverlaySprite;
26 struct SOverlayQuad;
27 class CCamera;
28 
30 
31 /**
32  * Class OverlayRenderer: Render various bits of data that overlay the
33  * game world (selection circles, health bars, etc).
34  */
36 {
38 
39 public:
42 
43  /**
44  * Performs one-time initialization. Called by CRenderer::Open after graphics
45  * capabilities and the shader path have been determined (notably VBO support).
46  */
47  void Initialize();
48 
49  /**
50  * Add a line overlay for rendering in this frame.
51  * @param overlay Must be non-null. The pointed-to object must remain valid at least
52  * until the end of the frame.
53  */
54  void Submit(SOverlayLine* overlay);
55 
56  /**
57  * Add a textured line overlay for rendering in this frame.
58  * @param overlay Must be non-null. The pointed-to object must remain valid at least
59  * until the end of the frame.
60  */
61  void Submit(SOverlayTexturedLine* overlay);
62 
63  /**
64  * Add a sprite overlay for rendering in this frame.
65  * @param overlay Must be non-null. The pointed-to object must remain valid at least
66  * until the end of the frame.
67  */
68  void Submit(SOverlaySprite* overlay);
69 
70  /**
71  * Add a textured quad overlay for rendering in this frame.
72  * @param overlay Must be non-null. The pointed-to object must remain valid at least
73  * until the end of the frame.
74  */
75  void Submit(SOverlayQuad* overlay);
76 
77  /**
78  * Prepare internal data structures for rendering.
79  * Must be called after all Submit calls for a frame, and before
80  * any rendering calls.
81  */
82  void PrepareForRendering();
83 
84  /**
85  * Reset the list of submitted overlays.
86  */
87  void EndFrame();
88 
89  /**
90  * Render all the submitted overlays that are embedded in the world
91  * (i.e. rendered behind other objects in the normal 3D way)
92  * and should be drawn before water (i.e. may be visible under the water)
93  */
95 
96  /**
97  * Render all the submitted overlays that are embedded in the world
98  * (i.e. rendered behind other objects in the normal 3D way)
99  * and should be drawn after water (i.e. may be visible on top of the water)
100  */
102 
103  /**
104  * Render all the submitted overlays that should appear on top of everything
105  * in the world.
106  * @param viewCamera camera to be used for billboard computations
107  */
108  void RenderForegroundOverlays(const CCamera& viewCamera);
109 
110  /// Small vertical offset of overlays from terrain to prevent visual glitches
111  static const float OVERLAY_VOFFSET;
112 
113 private:
114 
115  /**
116  * Helper method; renders all overlay lines currently registered in the internals. Batch-
117  * renders textured overlay lines batched according to their visibility status by delegating
118  * to RenderTexturedOverlayLines(CShaderProgramPtr, bool).
119  */
121 
122  /**
123  * Helper method; renders those overlay lines currently registered in the internals (i.e.
124  * in m->texlines) for which the 'always visible' flag equals @p alwaysVisible. Used for
125  * batch rendering the overlay lines according to their alwaysVisible status, as this
126  * requires a separate shader to be used.
127  */
128  void RenderTexturedOverlayLines(CShaderProgramPtr shader, bool alwaysVisible);
129 
130  /**
131  * Helper method; batch-renders all registered quad overlays, batched by their texture for effiency.
132  */
133  void RenderQuadOverlays();
134 
135 private:
137 };
138 
139 #endif // INCLUDED_OVERLAYRENDERER
Line-based overlay, with world-space coordinates, rendered in the world potentially behind other obje...
Definition: Overlay.h:36
NONCOPYABLE(OverlayRenderer)
Class OverlayRenderer: Render various bits of data that overlay the game world (selection circles...
void RenderQuadOverlays()
Helper method; batch-renders all registered quad overlays, batched by their texture for effiency...
Billboard sprite overlay, with world-space coordinates, rendered on top of all other objects...
Definition: Overlay.h:137
void Submit(SOverlayLine *overlay)
Add a line overlay for rendering in this frame.
void EndFrame()
Reset the list of submitted overlays.
Textured line overlay, with world-space coordinates, rendered in the world onto the terrain...
Definition: Overlay.h:62
void Initialize()
Performs one-time initialization.
Definition: Camera.h:39
void RenderForegroundOverlays(const CCamera &viewCamera)
Render all the submitted overlays that should appear on top of everything in the world.
Rectangular single-quad terrain overlay, in world space coordinates.
Definition: Overlay.h:149
void RenderOverlaysAfterWater()
Render all the submitted overlays that are embedded in the world (i.e.
OverlayRendererInternals * m
static const float OVERLAY_VOFFSET
Small vertical offset of overlays from terrain to prevent visual glitches.
void RenderOverlaysBeforeWater()
Render all the submitted overlays that are embedded in the world (i.e.
shared_ptr< CShaderProgram > CShaderProgramPtr
void PrepareForRendering()
Prepare internal data structures for rendering.
void RenderTexturedOverlayLines()
Helper method; renders all overlay lines currently registered in the internals.