Pyrogenesis  trunk
GameView.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 #ifndef INCLUDED_GAMEVIEW
19 #define INCLUDED_GAMEVIEW
20 
22 #include "renderer/Scene.h"
24 
25 #include "lib/input.h" // InReaction - can't forward-declare enum
26 
27 class CCamera;
28 class CCinemaManager;
29 class CGame;
30 class CObjectManager;
31 class CVector3D;
32 struct SViewPort;
33 
34 class CGameViewImpl;
35 
36 class CGameView : private Scene
37 {
39 public:
40  CGameView(CGame *pGame);
41  ~CGameView() override;
42 
43  void SetViewport(const SViewPort& vp);
44 
45  void RegisterInit();
46  int Initialize();
47 
48  /**
49  * Updates all the view information (i.e. rotate camera, scroll, whatever). This will *not* change any
50  * World information - only the *presentation*.
51  *
52  * @param deltaRealTime Elapsed real time since the last frame.
53  */
54  void Update(const float deltaRealTime);
55 
56  void BeginFrame();
57  void Prepare(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
58  void Render(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
59  void RenderOverlays(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
60 
62 
63  CVector3D GetCameraPivot() const;
66  float GetCameraZoom() const;
67 
68  void SetCamera(const CVector3D& pos, float rotX, float rotY, float zoom);
69  void MoveCameraTarget(const CVector3D& target);
70  void ResetCameraTarget(const CVector3D& target);
71  void FollowEntity(entity_id_t entity, bool firstPerson);
73 
74  #define DECLARE_BOOLEAN_SETTING(NAME) \
75  bool Get##NAME##Enabled() const; \
76  void Set##NAME##Enabled(bool Enabled);
77 
78  DECLARE_BOOLEAN_SETTING(Culling);
79  DECLARE_BOOLEAN_SETTING(LockCullCamera);
80  DECLARE_BOOLEAN_SETTING(ConstrainCamera);
81 
82  #undef DECLARE_BOOLEAN_SETTING
83 
84  CCamera* GetCamera();
87 
88  // Implementations of Scene
89  void EnumerateObjects(const CFrustum& frustum, SceneCollector* c) override;
90  CLOSTexture& GetLOSTexture() override;
93 
94 private:
95  // Unloads all graphics resources loaded by RegisterInit.
96  void UnloadResources();
97 
99 };
100 
101 extern InReaction game_view_handler(const SDL_Event_* ev);
102 
103 #endif // INCLUDED_GAMEVIEW
void UnloadResources()
Definition: GameView.cpp:287
The container that holds the rules, resources and attributes of the game.
Definition: Game.h:42
void BeginFrame()
Definition: GameView.cpp:224
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:257
CVector3D GetCameraPivot() const
Definition: GameView.cpp:312
CCinemaManager * GetCinema()
Definition: GameView.cpp:190
CObjectManager & GetObjectManager()
Definition: GameView.cpp:180
Definition: Camera.h:33
Definition: MiniMapTexture.h:40
Definition: GameView.cpp:66
CMiniMapTexture & GetMiniMapTexture() override
Return the minimap texture to be used for rendering this scene.
Definition: GameView.cpp:205
CVector3D GetCameraRotation() const
Definition: GameView.cpp:322
Definition: ObjectManager.h:41
Definition: Vector3D.h:30
Definition: Frustum.h:36
void SetCamera(const CVector3D &pos, float rotX, float rotY, float zoom)
Definition: GameView.cpp:332
Definition: libsdl.h:52
CGameViewImpl * m
Definition: GameView.h:98
void SetViewport(const SViewPort &vp)
Definition: GameView.cpp:175
void Render(Renderer::Backend::IDeviceCommandContext *deviceCommandContext)
Definition: GameView.cpp:242
CVector3D GetCameraPosition() const
Definition: GameView.cpp:317
This interface accepts renderable objects.
Definition: Scene.h:89
void Update(const float deltaRealTime)
Updates all the view information (i.e.
Definition: GameView.cpp:293
InReaction
Definition: input.h:34
int Initialize()
Definition: GameView.cpp:210
Definition: Camera.h:41
~CGameView() override
Definition: GameView.cpp:168
CGameView(CGame *pGame)
Definition: GameView.cpp:161
Definition: GameView.h:36
CCamera * GetCamera()
Definition: GameView.cpp:185
void Prepare(Renderer::Backend::IDeviceCommandContext *deviceCommandContext)
Definition: GameView.cpp:236
void RenderOverlays(Renderer::Backend::IDeviceCommandContext *deviceCommandContext)
Definition: GameView.cpp:248
entity_id_t GetFollowedEntity()
Definition: GameView.cpp:352
void RegisterInit()
Definition: GameView.cpp:216
CTerritoryTexture & GetTerritoryTexture() override
Return the territory texture to be used for rendering this scene.
Definition: GameView.cpp:200
Class for in game playing of cinematics.
Definition: CinemaManager.h:28
CLOSTexture & GetLOSTexture() override
Return the LOS texture to be used for rendering this scene.
Definition: GameView.cpp:195
void FollowEntity(entity_id_t entity, bool firstPerson)
Definition: GameView.cpp:347
NONCOPYABLE(CGameView)
This interface describes a scene to the renderer.
Definition: Scene.h:53
DECLARE_BOOLEAN_SETTING(Culling)
Maintains the LOS (fog-of-war / shroud-of-darkness) texture, used for rendering and for the minimap...
Definition: LOSTexture.h:38
InReaction HandleEvent(const SDL_Event_ *ev)
Definition: GameView.cpp:368
InReaction game_view_handler(const SDL_Event_ *ev)
Definition: GameView.cpp:357
u32 entity_id_t
Entity ID type.
Definition: Entity.h:23
Definition: IDeviceCommandContext.h:40
void MoveCameraTarget(const CVector3D &target)
Definition: GameView.cpp:337
Maintains the territory boundary texture, used for rendering and for the minimap. ...
Definition: TerritoryTexture.h:30
void ResetCameraTarget(const CVector3D &target)
Definition: GameView.cpp:342
float GetCameraZoom() const
Definition: GameView.cpp:327