-
Notifications
You must be signed in to change notification settings - Fork 0
/
easel.h
103 lines (78 loc) · 2.06 KB
/
easel.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
94
95
96
97
98
99
100
101
102
#pragma once
#include <vector>
#include <stdint.h>
#include "settings.hpp"
template <int V, typename T>
static inline void
fillV(T &container) {
std::fill(container.begin(), container.end(),
static_cast<typename T::value_type>(V));
}
template <typename T>
static inline void
fill0(T &container) {
fillV<0, T>(container);
}
template <int V, typename T>
static inline void
fillV(T container, size_t N) {
std::fill_n(container, N,
static_cast<typename std::remove_pointer_t<T>>(V));
}
template <typename T>
static inline void
fill0(T &container, size_t N) {
fillV<0, T>(container, N);
}
class Easel {
public:
Easel() = default;
virtual ~Easel() = default;
// every drawdot call is vertual now :(
virtual void drawdot(int32_t x, int32_t y, uint32_t c) = 0;
virtual void begin() {};
virtual void render() = 0;
virtual void clear() {};
virtual void gui() {};
virtual void reset() {};
// TODO: ugly pieces from vertex easel, move to a better place
unsigned frame_vertex_target_k = 128;
unsigned frame_vertex_target() const {
return frame_vertex_target_k * 1024;
}
unsigned vertex_buffer_maximum_k = 1024*16;
unsigned vertex_buffer_maximum() const {
return vertex_buffer_maximum_k * 1024;
}
// TODO: ugly pieces from plane easel, move to a better place
void set_window_size(int _w, int _h) {
ww = _w; wh = _h;
//w = _w; h = _h; // TODO: or do set_texture_size() in Art::default_resize?
//reset();
}
void set_texture_size(int _w, int _h) {
w = _w; h = _h;
reset();
}
int w, h;
int ww, wh;
PaletteSetting pal;
};
class EaselPlane;
class EaselVertex;
// deprecated
/*
class EaselPixel : public Easel {
public:
EaselPixel(unsigned max_vertices);
~EaselPixel();
void append(Pixel && p);
virtual void render() override;
virtual void clear() override;
virtual void gui() override;
private:
unsigned pixels_drawn = 0;
unsigned pixels_discarded = 0;
std::deque<Pixel> buffer;
};
*/