-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.h
178 lines (140 loc) · 3.79 KB
/
client.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include <cstdint>
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
typedef int64_t i64;
typedef int32_t i32;
typedef int16_t i16;
typedef int8_t i8;
struct VertexLayout;
struct kernel_services
{
typedef u32 TexID;
TexID create_texture(u32, u32, u32);
void update_texture(TexID, const u8*);
void delete_texture(TexID);
const VertexLayout *ui_vertex_layout;
const VertexLayout *stroke_vertex_layout;
static const TexID default_texid = 0;
typedef u32 MeshID;
MeshID create_mesh(const VertexLayout&, u32, u32);
MeshID create_quad_mesh(const VertexLayout&, u32);
void update_mesh(MeshID, const void*, u32, const u16*, u32);
void update_mesh_vb(MeshID, const void*, u32);
void delete_mesh(MeshID);
bool check_file(const char* path);
const u8 *get_capture_data(u32&, u32&);
};
struct input_data
{
double *pTimeIntervals;
u32 nTimeIntervals;
u32 nFrames;
float rawMouseXPt, rawMouseYPt;
float vpMouseXPt, vpMouseYPt;
bool mouseleft;
bool shiftkey;
bool scrolling;
float scrollY;
i32 windowWidthPx, windowHeightPx;
i32 windowWidthPt, windowHeightPt;
i32 windowPosXPt, windowPosYPt;
i32 vpWidthPx, vpHeightPx;
i32 vpWidthPt, vpHeightPt;
float vpWidthIn, vpHeightIn;
float rtWidthIn, rtHeightIn;
i32 swWidthPx, swHeightPx;
bool forceUpdate;
std::string debugstr;
};
#include "math.h"
struct GuiDrawcall
{
kernel_services::TexID texture;
kernel_services::MeshID mesh;
u32 offset;
u32 count;
};
struct StrokesDrawcall
{
kernel_services::MeshID mesh;
u32 offset;
u32 count;
};
struct ImageDrawcall
{
kernel_services::TexID texture;
basis2r basis;
};
struct LayerRecipe
{
struct ItemSpec
{
enum { STROKEBATCH, IMAGE } type;
u32 index;
};
std::vector<ItemSpec> items;
};
// we don't talk layer ids here, just above cur below and distinguish above layers to bake separately within that range
struct RenderRecipe
{
std::vector<StrokesDrawcall> strokeDCs;
std::vector<ImageDrawcall> imageDCs;
std::vector<LayerRecipe> belowBakery; // this should always contain actual info needed to reconstruct below layers.
std::vector<LayerRecipe> aboveBakery;
LayerRecipe currentBakery;
bool bakeBelow; // need this, because emptinness of bakery is also an update
bool bakeAbove;
bool bakeCurrent;
StrokesDrawcall currentStroke;
bool capture;
bool drawGrid;
bool blitBelow;
bool blitCurrent;
bool blitAbove;
bool fitImage;
ImageDrawcall fitDC;
std::vector<GuiDrawcall> guiDCs;
void clear()
{
strokeDCs.clear();
imageDCs.clear();
belowBakery.clear();
aboveBakery.clear();
currentBakery.items.clear();
bakeBelow = bakeAbove = bakeCurrent = false;
capture = drawGrid = blitBelow = blitCurrent = blitAbove = fitImage = false;
guiDCs.clear();
}
};
// moving towards `statelessness`
// this object's contents should be enough for building a frame, no matter if baked RT contain or not
// e.g.
// TODO: test case: all layers are turned off, drawing, what should happen?
struct output_data
{
// TODO: should be somehow generated from layout
struct Vertex
{
float x, y, z;
float u, v, e;
float r, g, b, a;
};
bool quit_flag;
// baked texture quad manipulations
float2 preTranslate;
float2 postTranslate;
float scale;
float rotate;
color3f bg_color;
color3f grid_bg_color;
color3f grid_fg_color;
float zbandwidth;
float capture_width;
float capture_height;
const RenderRecipe *recipe;
};
void update_and_render(input_data *input, output_data *output);
void setup(kernel_services *services);
void cleanup();