-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathRenderLoop.h
93 lines (69 loc) · 2.53 KB
/
RenderLoop.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
#include "AudioCapture.h"
#include "ProjectMWrapper.h"
#include "SDLRenderingWindow.h"
#include "notifications/QuitNotification.h"
#include <Poco/Logger.h>
#include <Poco/NObserver.h>
#include <Poco/Notification.h>
class ProjectMGUI;
class RenderLoop
{
public:
RenderLoop();
void Run();
protected:
struct ModifierKeyStates {
bool _shiftPressed{false}; //!< L/R shift keys
bool _ctrlPressed{false}; //!< L/R control keys
bool _altPressed{false}; //!< L/R alt keys
bool _metaPressed{false}; //!< Logo/meta/command key
};
/**
* @brief Polls all SDL events in the queue and takes action if required.
*/
void PollEvents();
/**
* @brief Checks if the GL viewport size has changed and if so, reconfigured projectM accordingly.
*/
void CheckViewportSize();
/**
* @brief Handles SDL key press events.
* @param event The key event.
*/
void KeyEvent(const SDL_KeyboardEvent& event, bool down);
/**
* @brief Handles SDL mouse wheel events.
* @param event The mouse wheel event
*/
void ScrollEvent(const SDL_MouseWheelEvent& event);
/**
* @brief Handles SDL mouse button down events.
* @param event The mouse button event
*/
void MouseDownEvent(const SDL_MouseButtonEvent& event);
/**
* @brief Handles SDL mouse button up events.
* @param event The mouse button event
*/
void MouseUpEvent(const SDL_MouseButtonEvent& event);
/**
* @brief Handler for quit notifications.
* @param notification The received notification.
*/
void QuitNotificationHandler(const Poco::AutoPtr<QuitNotification>& notification);
AudioCapture& _audioCapture;
ProjectMWrapper& _projectMWrapper;
SDLRenderingWindow& _sdlRenderingWindow;
projectm_handle _projectMHandle{nullptr};
projectm_playlist_handle _playlistHandle{nullptr};
ProjectMGUI& _projectMGui;
Poco::NObserver<RenderLoop, QuitNotification> _quitNotificationObserver{*this, &RenderLoop::QuitNotificationHandler}; //!< The observer for quit notifications.
bool _wantsToQuit{false};
bool _mouseDown{false}; //!< Left mouse button is pressed
int _renderWidth{0};
int _renderHeight{0};
ModifierKeyStates _keyStates; //!< Current "pressed" states of modifier keys
Poco::AutoPtr<Poco::Util::AbstractConfiguration> _userConfig; //!< View of the "projectM" configuration subkey in the "user" configuration.
Poco::Logger& _logger{Poco::Logger::get("RenderLoop")}; //!< The class logger.
};