Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
render_debug_viewer.hpp
Go to the documentation of this file.
1
10
11#ifndef ZOAPPRENDERDEBUGVIEWER_H
12#define ZOAPPRENDERDEBUGVIEWER_H
13
14#include "toymaker/sim_system.hpp"
15#include "toymaker/window_context_manager.hpp"
16
21class RenderDebugViewer: public ToyMaker::SimObjectAspect<RenderDebugViewer> {
22public:
23 inline static std::string getSimObjectAspectTypeName() { return "RenderDebugViewer"; }
24 std::shared_ptr<BaseSimObjectAspect> clone() const override;
25 static std::shared_ptr<BaseSimObjectAspect> create(const nlohmann::json& jsonAspectProperties);
26 ToyMaker::SignalObserver<> mObserveWindowResized { *this, "WindowResizedObserved", [this]() { std::cout << "RenderDebugViewer: Window was resized\n"; this->printWindowProps(); } };
27 ToyMaker::SignalObserver<> mObserveWindowMinimized { *this, "WindowMinimizedObserved", [this]() { std::cout << "RenderDebugViewer: Window was minimized\n"; this->printWindowProps(); } };
28 ToyMaker::SignalObserver<> mObserveWindowMaximized { *this, "WindowMaximizedObserved", [this]() { std::cout << "RenderDebugViewer: Window was maximized\n"; this->printWindowProps(); } };
29 ToyMaker::SignalObserver<> mObserveWindowMoved { *this, "WindowMovedObserved", [this]() { std::cout << "RenderDebugViewer: Window was moved\n"; this->printWindowProps(); } };
30 ToyMaker::SignalObserver<> mObserveWindowMouseEntered { *this, "WindowMouseEnteredObserved", [this]() { std::cout << "RenderDebugViewer: Mouse entered window\n"; this->printWindowProps(); } };
31 ToyMaker::SignalObserver<> mObserveWindowMouseExited { *this, "WindowMouseExitedObserved", [this]() { std::cout << "RenderDebugViewer: Mouse left window\n"; this->printWindowProps(); } };
32 ToyMaker::SignalObserver<> mObserveWindowCloseRequested { *this, "WindowCloseRequestedObserved", [this]() { std::cout << "RenderDebugViewer: Window close requested\n"; this->printWindowProps(); } };
33 ToyMaker::SignalObserver<> mObserveWindowSizeChanged { *this, "WindowSizeChangedObserved", [this]() { std::cout << "RenderDebugViewer: Window's size was changed\n"; this->printWindowProps(); } };
34 ToyMaker::SignalObserver<> mObserveWindowRestored { *this, "WindowRestoredObserved", [this]() { std::cout << "RenderDebugViewer: Window was restored\n"; this->printWindowProps(); } };
35 ToyMaker::SignalObserver<> mObserveWindowShown { *this, "WindowShownObserved", [this]() { std::cout << "RenderDebugViewer: Window was shown\n"; this->printWindowProps(); } };
36 ToyMaker::SignalObserver<> mObserveWindowExposed { *this, "WindowExposedObserved", [this]() { std::cout << "RenderDebugViewer: Window was exposed\n"; this->printWindowProps(); } };
37 ToyMaker::SignalObserver<> mObserveWindowKeyFocusGained { *this, "WindowKeyFocusGainedObserved", [this]() { std::cout << "RenderDebugViewer: Window gained key focus\n"; this->printWindowProps(); } };
38 ToyMaker::SignalObserver<> mObserveWindowKeyFocusLost { *this, "WindowKeyFocusLostObserved", [this]() { std::cout << "RenderDebugViewer: Window lost key focus\n"; this->printWindowProps(); } };
39 ToyMaker::SignalObserver<> mObserveWindowKeyFocusOffered { *this, "WindowKeyFocusOffered", [this]() { std::cout << "RenderDebugViewer: Window was offered key focus\n"; this->printWindowProps(); } };
40 void printWindowProps();
41
42protected:
43 bool onUpdateGamma(const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition);
44 bool onUpdateExposure(const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition);
45 bool onRenderNextTexture(const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition);
46
47 std::weak_ptr<ToyMaker::FixedActionBinding> handleUpdateGamma{ declareFixedActionBinding (
48 "Graphics", "UpdateGamma", [this](const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition) {
49 return this->onUpdateGamma(actionData, actionDefinition);
50 }
51 )};
52 std::weak_ptr<ToyMaker::FixedActionBinding> handleUpdateExposure { declareFixedActionBinding (
53 "Graphics", "UpdateExposure", [this](const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition) {
54 return this->onUpdateExposure(actionData, actionDefinition);
55 }
56 )};
57 std::weak_ptr<ToyMaker::FixedActionBinding> handleRenderNextTexture { declareFixedActionBinding(
58 "Graphics", "RenderNextTexture", [this](const ToyMaker::ActionData& actionData, const ToyMaker::ActionDefinition& actionDefinition) {
59 return this->onRenderNextTexture(actionData, actionDefinition);
60 }
61 )};
62
63private:
64
65 RenderDebugViewer() : SimObjectAspect<RenderDebugViewer>{0} {
67 mObserveWindowMoved.connectTo(windowContextManager.mSigWindowMoved);
68 mObserveWindowResized.connectTo(windowContextManager.mSigWindowResized);
69 mObserveWindowMinimized.connectTo(windowContextManager.mSigWindowMinimized);
70 mObserveWindowMaximized.connectTo(windowContextManager.mSigWindowMaximized);
71 mObserveWindowMouseEntered.connectTo(windowContextManager.mSigWindowMouseEntered);
72 mObserveWindowMouseExited.connectTo(windowContextManager.mSigWindowMouseExited);
73 mObserveWindowShown.connectTo(windowContextManager.mSigWindowShown);
74 mObserveWindowSizeChanged.connectTo(windowContextManager.mSigWindowSizeChanged);
75 mObserveWindowCloseRequested.connectTo(windowContextManager.mSigWindowCloseRequested);
76 mObserveWindowRestored.connectTo(windowContextManager.mSigWindowRestored);
77 mObserveWindowExposed.connectTo(windowContextManager.mSigWindowExposed);
78 mObserveWindowKeyFocusGained.connectTo(windowContextManager.mSigWindowKeyFocusGained);
79 mObserveWindowKeyFocusLost.connectTo(windowContextManager.mSigWindowKeyFocusLost);
80 mObserveWindowKeyFocusOffered.connectTo(windowContextManager.mSigWindowKeyFocusOffered);
81 }
82
83 float mGammaStep { .1f };
84 float mExposureStep { .1f };
85};
86
87#endif
std::shared_ptr< BaseSimObjectAspect > clone() const override
A method which must be overridden to specify how a new aspect should be constructed as a copy of this...
Definition render_debug_viewer.cpp:33
std::weak_ptr< FixedActionBinding > declareFixedActionBinding(const std::string &context, const std::string &action, std::function< bool(const ActionData &, const ActionDefinition &)>)
Binds some method (or any function) present on this object to an action generated by the InputManager...
Definition sim_system.cpp:219
A SignalObserver object, which can subscribe to Signals matching its data signature and receive signa...
Definition signals.hpp:412
An object containing closely related methods and data, and exposing object lifecycle and application ...
Definition sim_system.hpp:956
A class providing access to various window management methods and window event Signals.
Definition window_context_manager.hpp:36
static WindowContext & getInstance()
Gets this application's sole window instance.
Definition window_context_manager.cpp:168
The definition of a single action, including whether it represents state or change,...
Definition input_data.hpp:511
A union that may contain any one of SimpleActionData, OneAxisActionData, TwoAxisActionData,...
Definition input_data.hpp:721