-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatostim.h
More file actions
240 lines (127 loc) · 6.1 KB
/
datostim.h
File metadata and controls
240 lines (127 loc) · 6.1 KB
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/*
* Copyright (c) 2025 Cyrille Rossant and contributors. All rights reserved.
* Licensed under the MIT license. See LICENSE file in the project root for details.
* SPDX-License-Identifier: MIT
*/
/*************************************************************************************************/
/* Datostim header file */
/*************************************************************************************************/
#ifndef DSTIM_HEADER
#define DSTIM_HEADER
/*************************************************************************************************/
/* Macros */
/*************************************************************************************************/
#ifdef __cplusplus
#define LANG_CPP
#define EXTERN_C_ON \
extern "C" \
{
#define EXTERN_C_OFF }
#else
#define LANG_C
#define EXTERN_C_ON
#define EXTERN_C_OFF
#endif
#ifndef DSTIM_EXPORT
#if CC_MSVC
#ifdef DSTIM_SHARED
#define DSTIM_EXPORT __declspec(dllexport)
#else
#define DSTIM_EXPORT __declspec(dllimport)
#endif
#define DSTIM_INLINE __forceinline
#else
#define DSTIM_EXPORT __attribute__((visibility("default")))
#define DSTIM_INLINE static inline __attribute((always_inline))
#endif
#endif
#ifndef ASSERT
#define ASSERT(x) assert(x)
#endif
#ifndef ANN
#define ANN(x) ASSERT((x) != NULL);
#endif
/*************************************************************************************************/
/* Typedefs */
/*************************************************************************************************/
// Forward declarations.
typedef struct DStim DStim;
typedef struct DStimVertex DStimVertex;
/*************************************************************************************************/
/* Enums */
/*************************************************************************************************/
typedef enum
{
DSTIM_INTERPOLATION_NEAREST = 0,
DSTIM_INTERPOLATION_LINEAR = 1,
} DStimInterpolation;
typedef enum
{
DSTIM_BLEND_NONE,
DSTIM_BLEND_DST,
DSTIM_BLEND_SRC,
DSTIM_BLEND_ONE_MINUS_SRC,
} DStimBlend;
/*
case {'none' ''}
glBlendFunc(GL.ONE, GL.ZERO);
case {'dst' 'destination'}
glBlendFunc(GL.DST_ALPHA, GL.ONE_MINUS_DST_ALPHA);
case {'src' 'source'}
glBlendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA);
case {'1-src' '1-source'}
glBlendFunc(GL.ONE_MINUS_SRC_ALPHA, GL.SRC_ALPHA);
*/
EXTERN_C_ON
/*************************************************************************************************/
/* Functions */
/*************************************************************************************************/
DSTIM_EXPORT DStim* dstim_init(uint32_t width, uint32_t height); // open a fixed window
DSTIM_EXPORT void
dstim_background(DStim* stim, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
DSTIM_EXPORT void dstim_vertices(
DStim* stim, uint32_t vertex_count,
DStimVertex* vertices); // by default, will automatically set the sphere vertices
DSTIM_EXPORT void dstim_indices(
DStim* stim, uint32_t index_count,
uint32_t* indices); // by default, will automatically set the sphere indices
DSTIM_EXPORT void dstim_square_pos(
DStim* stim, uint32_t x, uint32_t y, uint32_t w, uint32_t h); // position and size in pixels
DSTIM_EXPORT void
dstim_square_color(DStim* stim, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
DSTIM_EXPORT void dstim_model(DStim* stim, mat4 model); // global model matrix
DSTIM_EXPORT void
dstim_screen(DStim* stim, uint32_t screen_idx, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
DSTIM_EXPORT void dstim_projection(DStim* stim, uint32_t screen_idx, mat4 projection);
DSTIM_EXPORT void dstim_layer_texture(
DStim* stim, uint32_t layer_idx, DvzFormat format, uint32_t width, uint32_t height,
DvzSize tex_nbytes, uint8_t* rgba);
DSTIM_EXPORT void dstim_layer_interpolation(
DStim* stim, uint32_t layer_idx, DStimInterpolation interpolation); // 0=nearest, 1=linear
DSTIM_EXPORT void dstim_layer_periodic(DStim* stim, uint32_t layer_idx, bool is_periodic);
DSTIM_EXPORT void dstim_layer_blend(
DStim* stim, uint32_t layer_idx,
DStimBlend blend); // per-layer blend options (there will be a few predefined options)
DSTIM_EXPORT void
dstim_layer_mask(DStim* stim, uint32_t layer_idx, bool red, bool green, bool blue, bool alpha);
DSTIM_EXPORT void
dstim_layer_view(DStim* stim, uint32_t layer_idx, mat4 view); // per-layer view matrix
DSTIM_EXPORT void dstim_layer_angle(DStim* stim, uint32_t layer_idx, float tex_angle);
DSTIM_EXPORT void dstim_layer_offset(DStim* stim, uint32_t layer_idx, float tex_x, float tex_y);
DSTIM_EXPORT void
dstim_layer_size(DStim* stim, uint32_t layer_idx, float tex_size_x, float tex_size_y);
DSTIM_EXPORT void dstim_layer_min_color(
DStim* stim, uint32_t layer_idx, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
DSTIM_EXPORT void dstim_layer_max_color(
DStim* stim, uint32_t layer_idx, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
DSTIM_EXPORT void dstim_layer_show(DStim* stim, uint32_t layer_idx, bool is_visible); // show/hide
DSTIM_EXPORT void
dstim_update(DStim* stim); // send all updates since that last call to this function to the GPU,
// and returns the update timestamp when the update has finished
DSTIM_EXPORT void dstim_mouse(DStim* stim, double* x, double* y, DvzMouseButton* button);
DSTIM_EXPORT void dstim_keyboard(DStim* stim, DvzKeyCode* key);
DSTIM_EXPORT double dstim_time(DStim* stim);
DSTIM_EXPORT double dstim_frame_time(DStim* stim);
DSTIM_EXPORT void dstim_cleanup(DStim* stim); // close the window
EXTERN_C_OFF
#endif