[Gameplay] Reduce loom cost
[0ad.git] / source / graphics / GameView.h
blobdfcfb04a81373067ee301c658f40ed9a12092a1a
1 /* Copyright (C) 2023 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/>.
18 #ifndef INCLUDED_GAMEVIEW
19 #define INCLUDED_GAMEVIEW
21 #include "renderer/backend/IDeviceCommandContext.h"
22 #include "renderer/Scene.h"
23 #include "simulation2/system/Entity.h"
25 #include "lib/input.h" // InReaction - can't forward-declare enum
27 class CCamera;
28 class CCinemaManager;
29 class CGame;
30 class CObjectManager;
31 class CVector3D;
32 struct SViewPort;
34 class CGameViewImpl;
36 class CGameView : private Scene
38 NONCOPYABLE(CGameView);
39 public:
40 CGameView(Renderer::Backend::IDevice* device, CGame *pGame);
41 ~CGameView() override;
43 void SetViewport(const SViewPort& vp);
45 void RegisterInit();
47 /**
48 * Updates all the view information (i.e. rotate camera, scroll, whatever). This will *not* change any
49 * World information - only the *presentation*.
51 * @param deltaRealTime Elapsed real time since the last frame.
53 void Update(const float deltaRealTime);
55 void BeginFrame();
56 void Prepare(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
57 void Render(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
58 void RenderOverlays(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
60 InReaction HandleEvent(const SDL_Event_* ev);
62 CVector3D GetCameraPivot() const;
63 CVector3D GetCameraPosition() const;
64 CVector3D GetCameraRotation() const;
65 float GetCameraZoom() const;
67 void SetCamera(const CVector3D& pos, float rotX, float rotY, float zoom);
68 void MoveCameraTarget(const CVector3D& target);
69 void ResetCameraTarget(const CVector3D& target);
70 void FollowEntity(entity_id_t entity, bool firstPerson);
71 entity_id_t GetFollowedEntity();
73 #define DECLARE_BOOLEAN_SETTING(NAME) \
74 bool Get##NAME##Enabled() const; \
75 void Set##NAME##Enabled(bool Enabled);
77 DECLARE_BOOLEAN_SETTING(Culling);
78 DECLARE_BOOLEAN_SETTING(LockCullCamera);
79 DECLARE_BOOLEAN_SETTING(ConstrainCamera);
81 #undef DECLARE_BOOLEAN_SETTING
83 CCamera* GetCamera();
84 CCinemaManager* GetCinema();
85 CObjectManager& GetObjectManager();
87 // Implementations of Scene
88 void EnumerateObjects(const CFrustum& frustum, SceneCollector* c) override;
89 CLOSTexture& GetLOSTexture() override;
90 CTerritoryTexture& GetTerritoryTexture() override;
91 CMiniMapTexture& GetMiniMapTexture() override;
93 private:
94 // Unloads all graphics resources loaded by RegisterInit.
95 void UnloadResources();
97 CGameViewImpl* m;
100 extern InReaction game_view_handler(const SDL_Event_* ev);
102 #endif // INCLUDED_GAMEVIEW