Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
GameView.h
Go to the documentation of this file.
1/* Copyright (C) 2026 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_GAMEVIEW
19#define INCLUDED_GAMEVIEW
20
21#include "lib/code_annotation.h"
22#include "renderer/Scene.h"
24
25class CCamera;
26class CCinemaManager;
27class CGame;
28class CGameViewImpl;
29class CObjectManager;
30class CVector3D;
31namespace Renderer::Backend { class IDevice; }
32namespace Renderer::Backend { class IDeviceCommandContext; }
33struct SViewPort;
34union SDL_Event;
35
36class CGameView : private Scene
37{
39public:
41 ~CGameView() override;
42
43 void SetViewport(const SViewPort& vp);
44
45 void RegisterInit();
46
47 /**
48 * Updates all the view information (i.e. rotate camera, scroll, whatever). This will *not* change any
49 * World information - only the *presentation*.
50 *
51 * @param deltaRealTime Elapsed real time since the last frame.
52 */
53 void Update(const float deltaRealTime);
54
56
60 float GetCameraZoom() const;
61
62 void SetCamera(const CVector3D& pos, float rotX, float rotY, float zoom);
63 void MoveCameraTarget(const CVector3D& target);
64 void LoadCameraConfig();
65 void ResetCameraTarget(const CVector3D& target);
66 void FollowEntity(entity_id_t entity, bool firstPerson);
68
69 #define DECLARE_BOOLEAN_SETTING(NAME) \
70 bool Get##NAME##Enabled() const; \
71 void Set##NAME##Enabled(bool Enabled);
72
74 DECLARE_BOOLEAN_SETTING(LockCullCamera);
75 DECLARE_BOOLEAN_SETTING(ConstrainCamera);
76
77 #undef DECLARE_BOOLEAN_SETTING
78
79 const CCamera& GetCamera() const;
80 void SetCamera(const CCamera& camera);
81
82 const CCamera& GetCullCamera() const;
83
86
87 // Implementations of Scene
88 void EnumerateObjects(const CFrustum& frustum, SceneCollector* c) override;
89 CLOSTexture& GetLOSTexture() override;
92
93private:
94 // Unloads all graphics resources loaded by RegisterInit.
95 void UnloadResources();
96 void UpdateCamera(const float deltaRealTime);
97 void UpdateCullCamera();
98
100};
101
102#endif // INCLUDED_GAMEVIEW
Definition: Camera.h:46
Class for in game playing of cinematics.
Definition: CinemaManager.h:32
Definition: Frustum.h:40
Definition: GameView.cpp:68
Definition: GameView.h:37
CMiniMapTexture & GetMiniMapTexture() override
Return the minimap texture to be used for rendering this scene.
Definition: GameView.cpp:226
float GetCameraZoom() const
Definition: GameView.cpp:335
void UnloadResources()
Definition: GameView.cpp:284
CVector3D GetCameraPosition() const
Definition: GameView.cpp:325
void UpdateCullCamera()
Definition: GameView.cpp:314
void EnumerateObjects(const CFrustum &frustum, SceneCollector *c) override
Send all objects that can be seen when rendering the given frustum to the scene collector.
Definition: GameView.cpp:254
entity_id_t GetFollowedEntity()
Definition: GameView.cpp:367
void UpdateCamera(const float deltaRealTime)
Definition: GameView.cpp:298
NONCOPYABLE(CGameView)
void EnumerateSceneObjects()
Definition: GameView.cpp:246
CGameViewImpl * m
Definition: GameView.h:99
CTerritoryTexture & GetTerritoryTexture() override
Return the territory texture to be used for rendering this scene.
Definition: GameView.cpp:221
void Update(const float deltaRealTime)
Updates all the view information (i.e.
Definition: GameView.cpp:290
void FollowEntity(entity_id_t entity, bool firstPerson)
Definition: GameView.cpp:362
CLOSTexture & GetLOSTexture() override
Return the LOS texture to be used for rendering this scene.
Definition: GameView.cpp:216
void LoadCameraConfig()
Definition: GameView.cpp:352
DECLARE_BOOLEAN_SETTING(Culling)
void ResetCameraTarget(const CVector3D &target)
Definition: GameView.cpp:357
CVector3D GetCameraPivot() const
Definition: GameView.cpp:320
void MoveCameraTarget(const CVector3D &target)
Definition: GameView.cpp:347
const CCamera & GetCullCamera() const
Definition: GameView.cpp:199
CCinemaManager * GetCinema()
Definition: GameView.cpp:211
void SetCamera(const CVector3D &pos, float rotX, float rotY, float zoom)
Definition: GameView.cpp:340
DECLARE_BOOLEAN_SETTING(ConstrainCamera)
void SetViewport(const SViewPort &vp)
Definition: GameView.cpp:184
void RegisterInit()
Definition: GameView.cpp:231
DECLARE_BOOLEAN_SETTING(LockCullCamera)
CVector3D GetCameraRotation() const
Definition: GameView.cpp:330
CObjectManager & GetObjectManager()
Definition: GameView.cpp:189
CGameView(Renderer::Backend::IDevice *device, CGame *pGame)
Definition: GameView.cpp:170
~CGameView() override
Definition: GameView.cpp:177
const CCamera & GetCamera() const
Definition: GameView.cpp:194
The container that holds the rules, resources and attributes of the game.
Definition: Game.h:49
Maintains the LOS (fog-of-war / shroud-of-darkness) texture, used for rendering and for the minimap.
Definition: LOSTexture.h:41
Definition: MiniMapTexture.h:46
Definition: ObjectManager.h:46
Maintains the territory boundary texture, used for rendering and for the minimap.
Definition: TerritoryTexture.h:35
Definition: Vector3D.h:32
Definition: IDevice.h:64
This interface accepts renderable objects.
Definition: Scene.h:90
This interface describes a scene to the renderer.
Definition: Scene.h:54
Definition: Canvas2D.h:30
std::uint32_t entity_id_t
Entity ID type.
Definition: Entity.h:29
Definition: Camera.h:38