Cogs.Core
ViewContext.h
1#pragma once
2
3#include "Foundation/Platform/PlatformContext.h"
4
5#include "EntityPtr.h"
6#include "Resources/Resources.h"
7
8namespace Cogs {
9 class IGraphicsDevice;
10 class ISwapChain;
11
12 namespace Platform {
13 class GamepadHandler;
14 }
15
16 namespace Core {
17 class CameraComponent;
18 class Context;
19 struct CameraData;
20
21 using ResizeCallback = void(class ViewContext* context, int x, int y);
22
23 class COGSCORE_DLL_API ViewContext : public PlatformContext {
24 public:
29 ViewContext(Context* ctx, WindowData* windowData);
30 ~ViewContext() override;
31
38 bool initialize(const Cogs::Core::EntityPtr& renderCamera);
39
41 void update();
42
44 void preRender();
45
51 void setCamera(const Cogs::Core::EntityPtr& renderCamera);
52
54 void setSize(int newWidth, int newHeight);
55 void setDPI(int newDPI, float scaleFactor);
56
57 constexpr Context* getContext() const { return context; }
58 constexpr ISwapChain* getSwapChain() const { return swapChain; }
59 glm::vec2 getSize() const;
60
62 Cogs::Core::EntityPtr getCamera() const;
63
65 CameraComponent* getCameraComponent() const;
66
67 void addResizeCallback(ResizeCallback* callback);
68 void removeResizeCallback(ResizeCallback* callback);
69
71 std::unique_ptr<class DPIService> dpiService;
72
74 std::unique_ptr<Platform::GamepadHandler> gamepadHandler;
75
78 std::unique_ptr<class InputManager> inputManager;
79
80 private:
82 std::vector<ResizeCallback*> resizeCallbacks;
83
86
88 Context* context = nullptr;
89
91 ISwapChain* swapChain = nullptr;
92
95 };
96 }
97}
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
Cogs::Core::WeakEntityPtr camera
The entity that's rendering this view. (Needs a CameraComponent at the bare minimum,...
Definition: ViewContext.h:85
TextureHandle texture
Cogs.Core texture that represents the swapchain's buffers.
Definition: ViewContext.h:94
std::unique_ptr< Platform::GamepadHandler > gamepadHandler
Gamepad input handler.
Definition: ViewContext.h:74
std::vector< ResizeCallback * > resizeCallbacks
List of callbacks to be called when this view is resized.
Definition: ViewContext.h:82
std::unique_ptr< class InputManager > inputManager
Definition: ViewContext.h:78
std::unique_ptr< class DPIService > dpiService
DPI service instance.
Definition: ViewContext.h:71
std::shared_ptr< ComponentModel::Entity > EntityPtr
Smart pointer for Entity access.
Definition: EntityPtr.h:12
std::weak_ptr< ComponentModel::Entity > WeakEntityPtr
Weak Smart pointer for Entity access.
Definition: EntityPtr.h:18
Contains all Cogs related functionality.
Definition: FieldSetter.h:23