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 |
|
---|
21 | #include "renderer/backend/IDeviceCommandContext.h"
|
---|
22 | #include "renderer/Scene.h"
|
---|
23 | #include "simulation2/system/Entity.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 | {
|
---|
38 | NONCOPYABLE(CGameView);
|
---|
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 |
|
---|
61 | InReaction HandleEvent(const SDL_Event_* ev);
|
---|
62 |
|
---|
63 | CVector3D GetCameraPivot() const;
|
---|
64 | CVector3D GetCameraPosition() const;
|
---|
65 | CVector3D GetCameraRotation() 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);
|
---|
72 | entity_id_t GetFollowedEntity();
|
---|
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();
|
---|
85 | CCinemaManager* GetCinema();
|
---|
86 | CObjectManager& GetObjectManager();
|
---|
87 |
|
---|
88 | // Implementations of Scene
|
---|
89 | void EnumerateObjects(const CFrustum& frustum, SceneCollector* c) override;
|
---|
90 | CLOSTexture& GetLOSTexture() override;
|
---|
91 | CTerritoryTexture& GetTerritoryTexture() override;
|
---|
92 | CMiniMapTexture& GetMiniMapTexture() override;
|
---|
93 |
|
---|
94 | private:
|
---|
95 | // Unloads all graphics resources loaded by RegisterInit.
|
---|
96 | void UnloadResources();
|
---|
97 |
|
---|
98 | CGameViewImpl* m;
|
---|
99 | };
|
---|
100 |
|
---|
101 | extern InReaction game_view_handler(const SDL_Event_* ev);
|
---|
102 |
|
---|
103 | #endif // INCLUDED_GAMEVIEW
|
---|