-
Notifications
You must be signed in to change notification settings - Fork 4
/
debug.h
54 lines (47 loc) · 1.48 KB
/
debug.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
#pragma once
#include <iosfwd>
#include <ostream>
namespace Debug {
#ifdef _DEBUG
inline bool Draw = false;
inline bool FrameByFrame = false;
inline bool FastForward = false;
inline bool CameraFixed = false;
#else
static const bool Draw = false;
static const bool FrameByFrame = false;
static const bool FastForward = false;
static const bool CameraFixed = false;
#endif
extern std::ostream& _forwarded_out;
};
extern int lastTicks;
// Delegate from: https://stackoverflow.com/questions/49332013/adding-a-new-line-after-stdostream-output-without-explicitly-calling-it
struct DebugStreamDelegate
{
DebugStreamDelegate() = default;
~DebugStreamDelegate();
template <typename T>
DebugStreamDelegate& operator<<(T&& val) noexcept {
Debug::_forwarded_out << std::forward<T>(val);
return *this;
}
DebugStreamDelegate& operator=(const DebugStreamDelegate&) = delete;
DebugStreamDelegate(const DebugStreamDelegate&) = delete;
};
struct DebugStream {
template <typename T>
DebugStreamDelegate operator<<(T&& val) noexcept {
Debug::_forwarded_out << lastTicks << ": " << std::forward<T>(val);
return DebugStreamDelegate();
}
};
namespace Debug {
extern DebugStream out;
};
#define COLOR_UINT8_RGB_RED 255,0,0
#define COLOR_UINT8_RGB_GREEN 0,255,0
#define COLOR_UINT8_RGB_BLUE 0,0,255
#define COLOR_UINT8_RGB_CYAN 0,255,255
#define COLOR_UINT8_RGB_MAGENTA 255,0,255
#define COLOR_UINT8_RGB_YELLOW 255,255,0