Removes unused forward declarations of class and struct.
[0ad.git] / source / renderer / TerrainRenderer.h
blob7ef1ddaa652f3dc782c8c7ca22351023058de601
1 /* Copyright (C) 2021 Wildfire Games.
2 * This file is part of 0 A.D.
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.
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.
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/>.
19 * Terrain rendering (everything related to patches and water) is
20 * encapsulated in TerrainRenderer
23 #ifndef INCLUDED_TERRAINRENDERER
24 #define INCLUDED_TERRAINRENDERER
26 #include "graphics/Color.h"
27 #include "maths/BoundingBoxAligned.h"
29 class CCamera;
30 class CMatrix3D;
31 class CModelDecal;
32 class CPatch;
33 class CShaderDefines;
34 class CSimulation2;
36 class ShadowMap;
38 struct TerrainRendererInternals;
40 /**
41 * Class TerrainRenderer: Render everything related to the terrain,
42 * especially patches and water.
44 class TerrainRenderer
46 friend class CPatchRData;
47 friend class CDecalRData;
49 public:
50 TerrainRenderer();
51 ~TerrainRenderer();
53 /**
54 * Set the simulation context for this frame.
55 * Call at start of frame, before any other Submits.
57 void SetSimulation(CSimulation2* simulation);
59 /**
60 * Submit: Add a patch for rendering in this frame.
62 * preconditions : PrepareForRendering must not have been called
63 * for this frame yet.
64 * The patch must not have been submitted in this frame yet (i.e. you
65 * can only submit a frame once).
67 * @param patch the patch
69 void Submit(int cullGroup, CPatch* patch);
71 /**
72 * Submit: Add a terrain decal for rendering in this frame.
74 void Submit(int cullGroup, CModelDecal* decal);
76 /**
77 * PrepareForRendering: Prepare internal data structures like vertex
78 * buffers for rendering.
80 * All patches must have been submitted before the call to
81 * PrepareForRendering.
82 * PrepareForRendering must be called before any rendering calls.
84 void PrepareForRendering();
86 /**
87 * EndFrame: Remove all patches from the list of submitted patches.
89 void EndFrame();
91 /**
92 * Render textured terrain (including blends between
93 * different terrain types).
95 * preconditions : PrepareForRendering must have been called this
96 * frame before calling RenderTerrain.
98 * @param shadow A prepared shadow map, in case rendering with shadows is enabled.
100 void RenderTerrainShader(const CShaderDefines& context, int cullGroup, ShadowMap* shadow);
103 * RenderPatches: Render all patches un-textured as polygons.
105 * preconditions : PrepareForRendering must have been called this
106 * frame before calling RenderPatches.
108 * @param filtered If true then only render objects that passed CullPatches.
109 * @param color Fill color of the patches.
111 void RenderPatches(int cullGroup, const CColor& color = CColor(0.0f, 0.0f, 0.0f, 1.0f));
114 * RenderOutlines: Render the outline of patches as lines.
116 * preconditions : PrepareForRendering must have been called this
117 * frame before calling RenderOutlines.
119 * @param filtered If true then only render objects that passed CullPatches.
121 void RenderOutlines(int cullGroup);
124 * RenderWater: Render water for all patches that have been submitted
125 * this frame.
127 * preconditions : PrepareForRendering must have been called this
128 * frame before calling RenderWater.
130 void RenderWater(const CShaderDefines& context, int cullGroup, ShadowMap* shadow);
133 * Calculate a scissor rectangle for the visible water patches.
135 CBoundingBoxAligned ScissorWater(int cullGroup, const CCamera& camera);
138 * Render priority text for all submitted patches, for debugging.
140 void RenderPriorities(int cullGroup);
143 * Render texture unit 0 over the terrain mesh, with UV coords calculated
144 * by the given texture matrix.
145 * Intended for use by TerrainTextureOverlay.
147 void RenderTerrainOverlayTexture(int cullGroup, CMatrix3D& textureMatrix, GLuint texture);
149 private:
150 TerrainRendererInternals* m;
153 * RenderFancyWater: internal rendering method for fancy water.
154 * Returns false if unable to render with fancy water.
156 bool RenderFancyWater(const CShaderDefines& context, int cullGroup, ShadowMap* shadow);
159 * RenderSimpleWater: internal rendering method for water
161 void RenderSimpleWater(int cullGroup);
163 static void PrepareShader(const CShaderProgramPtr& shader, ShadowMap* shadow);
166 #endif // INCLUDED_TERRAINRENDERER