@tty-pt/lamina 0.0.0-stage → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,372 @@
1
+ /**
2
+ * @file lam.h
3
+ * @brief Public header for the liblamina rendering and input system.
4
+ *
5
+ * liblamina is a lightweight, cross-platform 2D/3D graphics layer providing
6
+ * a unified API across OpenGL, framebuffer, WebGL2/WASM, and software backends.
7
+ *
8
+ * It manages window/framebuffer creation, texture and sprite
9
+ * drawing, color and tint management, 3D terrain/billboard streaming,
10
+ * and basic input event handling.
11
+ */
12
+
13
+ #ifndef LAM_H
14
+ #define LAM_H
15
+ #ifndef TTYPT_LAM_H
16
+ #define TTYPT_LAM_H
17
+
18
+ #include <stdint.h>
19
+ #include <stddef.h>
20
+ #include "./lam-key.h"
21
+
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
26
+ /*───────────────────────────────────────────────*
27
+ * CONSTANTS & TYPES *
28
+ *───────────────────────────────────────────────*/
29
+
30
+ /**
31
+ * @defgroup lam_types liblamina types and constants
32
+ * @brief Fundamental types and constants used by liblamina.
33
+ * @{
34
+ */
35
+
36
+ /** Pack 8-bit RGBA channels into 32-bit integer compatible with liblamina shaders. */
37
+ #define LAM_RGBA(r, g, b, a) \
38
+ ((((uint32_t)(a) & 0xFF) << 24) | \
39
+ (((uint32_t)(r) & 0xFF) << 16) | \
40
+ (((uint32_t)(g) & 0xFF) << 8) | \
41
+ ((uint32_t)(b) & 0xFF))
42
+
43
+ /** Pack 8-bit RGB channels with full opacity (alpha = 255). */
44
+ #define LAM_RGB(r, g, b) LAM_RGBA(r, g, b, 255)
45
+
46
+ /** Extract 8-bit Alpha channel from 32-bit color. */
47
+ #define LAM_COLOR_A(c) (((uint32_t)(c) >> 24) & 0xFF)
48
+ /** Extract 8-bit Red channel from 32-bit color. */
49
+ #define LAM_COLOR_R(c) (((uint32_t)(c) >> 16) & 0xFF)
50
+ /** Extract 8-bit Green channel from 32-bit color. */
51
+ #define LAM_COLOR_G(c) (((uint32_t)(c) >> 8) & 0xFF)
52
+ /** Extract 8-bit Blue channel from 32-bit color. */
53
+ #define LAM_COLOR_B(c) ((uint32_t)(c) & 0xFF)
54
+
55
+ /** Standard color palette constants */
56
+ #define LAM_COLOR_WHITE 0xFFFFFFFF
57
+ #define LAM_COLOR_BLACK 0xFF000000
58
+ #define LAM_COLOR_TRANSPARENT 0x00000000
59
+ #define LAM_COLOR_RED 0xFFFF0000
60
+ #define LAM_COLOR_GREEN 0xFF00FF00
61
+ #define LAM_COLOR_BLUE 0xFF0000FF
62
+ #define LAM_COLOR_YELLOW 0xFFFFFF00
63
+ #define LAM_COLOR_CYAN 0xFF00FFFF
64
+ #define LAM_COLOR_MAGENTA 0xFFFF00FF
65
+
66
+ /** @brief Input field flags used by keyboard handlers. */
67
+ enum lam_key_flags {
68
+ LAM_INPUT_MULTILINE = 1, /**< Allows multi-line input (ENTER adds newlines). */
69
+ LAM_INPUT_NUMERIC = 2, /**< Restricts input to numeric characters. */
70
+ };
71
+
72
+ /**
73
+ * @brief Software rendering callback.
74
+ *
75
+ * Called once per pixel for procedural or CPU-based rendering.
76
+ *
77
+ * @param[out] color Pointer to the pixel in BGRA format.
78
+ * @param[in] x X coordinate of the pixel.
79
+ * @param[in] y Y coordinate of the pixel.
80
+ * @param[in] ctx Optional user data pointer.
81
+ */
82
+ typedef void lam_lambda_t(uint8_t *color,
83
+ uint32_t x,
84
+ uint32_t y,
85
+ void *ctx);
86
+
87
+ /** Default white RGBA tint (no color modulation). */
88
+ static const uint32_t lam_default_tint = 0xFFFFFFFF;
89
+
90
+ /**
91
+ * @brief Keyboard event callback prototype.
92
+ *
93
+ * @param[in] code Platform key code.
94
+ * @param[in] type Event type (press, release, repeat).
95
+ * @param[in] value Event state (1 = pressed, 0 = released).
96
+ * @return Non-zero to consume the event, zero to propagate.
97
+ */
98
+ typedef int lam_key_cb_t(unsigned short code,
99
+ unsigned short type,
100
+ int value);
101
+
102
+ /** @} */
103
+
104
+ #ifdef __wasm__
105
+
106
+ __attribute__((import_module("lamina"), import_name("lam_fill")))
107
+ void lam_fill(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t color);
108
+
109
+ __attribute__((import_module("lamina"), import_name("lam_tile_draw")))
110
+ void lam_tile_draw(uint32_t ref, uint32_t idx, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t rx, uint32_t ry);
111
+
112
+ __attribute__((import_module("lamina"), import_name("lam_flush")))
113
+ void lam_flush(void);
114
+
115
+ __attribute__((import_module("lamina"), import_name("lam_canvas_flush")))
116
+ void lam_canvas_flush(const void *buf, uint32_t w, uint32_t h);
117
+
118
+ __attribute__((import_module("lamina"), import_name("lam_shader_register")))
119
+ uint32_t lam_shader_register(const char *name, const char *frag_glsl);
120
+
121
+ __attribute__((import_module("lamina"), import_name("lam_shader_bind")))
122
+ void lam_shader_bind(uint32_t shader_id);
123
+
124
+ __attribute__((import_module("lamina"), import_name("lam_shader_uniforms")))
125
+ void lam_shader_uniforms(uint32_t shader_id, const float *values, uint32_t count);
126
+
127
+ __attribute__((import_module("lamina"), import_name("lam_cam_set_3d")))
128
+ void lam_cam_set_3d(float target_x, float target_y, float target_z,
129
+ float distance, float pitch_deg, float yaw_deg, float fov_deg);
130
+
131
+ __attribute__((import_module("lamina"), import_name("lam_cam_set_2d")))
132
+ void lam_cam_set_2d(void);
133
+
134
+ __attribute__((import_module("lamina"), import_name("lam_terrain_mesh_flush")))
135
+ void lam_terrain_mesh_flush(const void *color_rgba, const int16_t *height_i16,
136
+ uint32_t chunk_w, uint32_t chunk_h,
137
+ uint32_t stage_w, uint32_t stage_h,
138
+ float sea_level, const float *cam_params,
139
+ const void *water_rgba);
140
+
141
+ __attribute__((import_module("lamina"), import_name("lam_billboard_batch_flush")))
142
+ void lam_billboard_batch_flush(const void *billboard_data, uint32_t count, const void *atlas_ptr);
143
+
144
+ __attribute__((import_module("lamina"), import_name("lam_image_request")))
145
+ uint32_t lam_image_request(const char *url);
146
+
147
+ __attribute__((import_module("lamina"), import_name("lam_image_read")))
148
+ uint32_t lam_image_read(uint32_t img_id, void *dst_rgba, uint32_t max_bytes,
149
+ uint32_t *out_w, uint32_t *out_h);
150
+
151
+ #else /* !__wasm__ */
152
+
153
+ /**
154
+ * @brief Obtain the current framebuffer dimensions.
155
+ *
156
+ * @param[out] width Framebuffer width in pixels.
157
+ * @param[out] height Framebuffer height in pixels.
158
+ */
159
+ void lam_size(uint32_t *width, uint32_t *height);
160
+
161
+ /**
162
+ * @brief Initialise the OpenGL context, window, and input system.
163
+ */
164
+ void lam_init(void);
165
+ void lam_deinit(void);
166
+
167
+ /*───────────────────────────────────────────────*
168
+ * RENDERING API *
169
+ *───────────────────────────────────────────────*/
170
+
171
+ /**
172
+ * @defgroup lam_render liblamina rendering
173
+ * @brief Immediate-mode drawing and frame presentation.
174
+ * @{
175
+ */
176
+
177
+ void lam_render(lam_lambda_t *lambda,
178
+ int32_t x, int32_t y,
179
+ uint32_t w, uint32_t h,
180
+ void *ctx);
181
+
182
+ void lam_fill(int32_t x, int32_t y,
183
+ uint32_t w, uint32_t h,
184
+ uint32_t color);
185
+
186
+ void lam_clear(uint32_t color);
187
+
188
+ void lam_rect(int32_t x, int32_t y,
189
+ uint32_t w, uint32_t h,
190
+ uint32_t border_color,
191
+ uint32_t border_width);
192
+
193
+ void lam_line(int32_t x0, int32_t y0,
194
+ int32_t x1, int32_t y1,
195
+ uint32_t color,
196
+ uint32_t thickness);
197
+
198
+ void lam_flush(void);
199
+
200
+ /** @} */
201
+
202
+ /*───────────────────────────────────────────────*
203
+ * TEXTURE / SPRITE API *
204
+ *───────────────────────────────────────────────*/
205
+
206
+ /**
207
+ * @defgroup lam_texture liblamina textures and sprites
208
+ * @brief Texture management and sprite drawing.
209
+ * @{
210
+ */
211
+
212
+ void lam_tex_draw_x(uint32_t ref,
213
+ int32_t x, int32_t y,
214
+ uint32_t cx, uint32_t cy,
215
+ uint32_t sw, uint32_t sh,
216
+ uint32_t dw, uint32_t dh,
217
+ uint32_t tint);
218
+
219
+ void lam_tex_draw(uint32_t ref,
220
+ int32_t x, int32_t y,
221
+ uint32_t dw, uint32_t dh);
222
+
223
+ unsigned lam_tex_load(const char *filename);
224
+ void lam_tex_save(unsigned ref);
225
+ void lam_tex_size(uint32_t *w, uint32_t *h, unsigned ref);
226
+ uint32_t lam_tex_pick(unsigned ref, uint32_t x, uint32_t y);
227
+ void lam_tex_paint(unsigned ref,
228
+ uint32_t x, uint32_t y,
229
+ uint32_t color);
230
+ void lam_tint(uint32_t tint);
231
+
232
+ /** @} */
233
+
234
+ /*───────────────────────────────────────────────*
235
+ * INPUT API *
236
+ *───────────────────────────────────────────────*/
237
+
238
+ /**
239
+ * @defgroup lam_input liblamina input handling
240
+ * @brief Keyboard polling and event dispatch.
241
+ * @{
242
+ */
243
+
244
+ void lam_poll(void);
245
+ void lam_key_reg(unsigned short key, lam_key_cb_t *cb);
246
+ void lam_key_default_reg(lam_key_cb_t *cb);
247
+ unsigned short lam_key_val(unsigned short code);
248
+ int lam_key_parse(char *target, size_t len,
249
+ unsigned short code, int flags);
250
+
251
+ /** @} */
252
+
253
+ /*───────────────────────────────────────────────*
254
+ * WEBGL / HYBRID SSR FALLBACKS *
255
+ *───────────────────────────────────────────────*/
256
+
257
+ static inline void lam_canvas_flush(const void *buf, uint32_t w, uint32_t h)
258
+ { (void)buf; (void)w; (void)h; }
259
+
260
+ static inline uint32_t lam_shader_register(const char *name, const char *frag_glsl)
261
+ { (void)name; (void)frag_glsl; return 0; }
262
+
263
+ static inline void lam_shader_bind(uint32_t shader_id)
264
+ { (void)shader_id; }
265
+
266
+ static inline void lam_shader_uniforms(uint32_t shader_id, const float *values, uint32_t count)
267
+ { (void)shader_id; (void)values; (void)count; }
268
+
269
+ static inline void lam_terrain_mesh_flush(const void *c, const int16_t *h,
270
+ uint32_t cw, uint32_t ch,
271
+ uint32_t sw, uint32_t sh,
272
+ float sl, const float *cp,
273
+ const void *water_rgba)
274
+ { (void)c; (void)h; (void)cw; (void)ch; (void)sw; (void)sh; (void)sl; (void)cp; (void)water_rgba; }
275
+
276
+ static inline void lam_billboard_batch_flush(const void *b, uint32_t count, const void *atlas)
277
+ { (void)b; (void)count; (void)atlas; }
278
+
279
+ static inline uint32_t lam_image_request(const char *url)
280
+ { (void)url; return 0; }
281
+
282
+ static inline uint32_t lam_image_read(uint32_t img_id, void *dst_rgba, uint32_t max_bytes,
283
+ uint32_t *out_w, uint32_t *out_h)
284
+ { (void)img_id; (void)dst_rgba; (void)max_bytes; (void)out_w; (void)out_h; return 0; }
285
+
286
+ static inline void lam_cam_set_3d_7_(float tx, float ty, float tz, float d, float p, float y, float f)
287
+ { (void)tx; (void)ty; (void)tz; (void)d; (void)p; (void)y; (void)f; }
288
+
289
+ static inline void lam_cam_set_2d_noop_(void) {}
290
+
291
+ #define _LAM_CAM_SET_3D_PICK(_1, _2, _3, _4, _5, _6, _7, NAME, ...) NAME
292
+ #define lam_cam_set_3d(...) _LAM_CAM_SET_3D_PICK(__VA_ARGS__, lam_cam_set_3d_7_, (lam_cam_set_3d))(__VA_ARGS__)
293
+
294
+ #ifndef LAM_CAM_H
295
+ #define lam_cam_set_2d() lam_cam_set_2d_noop_()
296
+ #endif
297
+
298
+ #endif /* !__wasm__ */
299
+
300
+ /*───────────────────────────────────────────────*
301
+ * 3D BALLISTIC & ADVECTED PARTICLE API *
302
+ *───────────────────────────────────────────────*/
303
+
304
+ /**
305
+ * @brief Optional surface/floor elevation callback: returns surface Z at (wx, wy).
306
+ */
307
+ typedef float (*lam_particle_surface_fn)(void *user_ctx, float wx, float wy);
308
+
309
+ typedef struct {
310
+ float x, y, z; /* 3D world position */
311
+ float vx, vy, vz; /* 3D velocity (units/sec) */
312
+ float size0, size1; /* Start and end particle quad size */
313
+ float age, max_age; /* Current age and lifetime (seconds) */
314
+ float drag; /* Linear fluid/air drag coefficient (1/sec) */
315
+ float gravity_scale; /* Multiplier on system gravity (positive = falls, negative = rises) */
316
+ float restitution; /* Surface bounce restitution (< 0 = kill on surface contact, 0 = slide/settle, > 0 = bounce) */
317
+ uint32_t rgba0, rgba1; /* Start and end RGBA tint (0xRRGGBBAA) */
318
+ uint8_t kind; /* Caller-defined material/behavior tag */
319
+ uint8_t flags; /* Bit 0: active */
320
+ uint16_t seed; /* Per-particle deterministic phase seed */
321
+ } lam_particle_t;
322
+
323
+ typedef struct {
324
+ float x, y, z; /* Emission origin */
325
+ float spread_x, spread_y, spread_z; /* Position jitter box half-extents */
326
+ float dir_x, dir_y, dir_z; /* Mean emission direction vector */
327
+ float speed_min, speed_max; /* Initial speed range */
328
+ float cone_spread; /* Angular velocity cone spread (0 = laser, 1 = hemisphere) */
329
+ float size0_min, size0_max; /* Start size range */
330
+ float size1_min, size1_max; /* End size range */
331
+ float life_min, life_max; /* Lifetime range in seconds */
332
+ float drag; /* Air/fluid drag coefficient */
333
+ float gravity_scale; /* Gravity multiplier */
334
+ float restitution; /* Surface contact behavior */
335
+ uint32_t rgba0, rgba1; /* Start and end RGBA colors (0xRRGGBBAA) */
336
+ uint32_t count; /* Number of particles to emit in this burst */
337
+ uint8_t kind; /* Material tag */
338
+ } lam_particle_emitter_t;
339
+
340
+ typedef struct {
341
+ float x, y, z; /* Interpolated 3D world position */
342
+ float size; /* Current interpolated world size */
343
+ float norm_age; /* Normalized age t in [0..1] */
344
+ uint32_t rgba; /* Current interpolated & envelope-faded RGBA (0xRRGGBBAA) */
345
+ uint8_t kind; /* Material tag */
346
+ uint8_t pad[3];
347
+ } lam_particle_draw_t;
348
+
349
+ typedef struct lam_particle_sys lam_particle_sys_t;
350
+
351
+ lam_particle_sys_t *lam_particle_sys_create(size_t capacity, float default_gravity_z);
352
+ void lam_particle_sys_destroy(lam_particle_sys_t *ps);
353
+ void lam_particle_sys_clear(lam_particle_sys_t *ps);
354
+
355
+ size_t lam_particle_emit(lam_particle_sys_t *ps, const lam_particle_emitter_t *em);
356
+
357
+ void lam_particle_step(lam_particle_sys_t *ps, float dt,
358
+ float wind_vx, float wind_vy, float wind_vz,
359
+ lam_particle_surface_fn surface_fn, void *user_ctx);
360
+
361
+ size_t lam_particle_gather(const lam_particle_sys_t *ps,
362
+ lam_particle_draw_t *out_draw, size_t max_out);
363
+
364
+ size_t lam_particle_active_count(const lam_particle_sys_t *ps);
365
+ size_t lam_particle_capacity(const lam_particle_sys_t *ps);
366
+
367
+ #ifdef __cplusplus
368
+ }
369
+ #endif
370
+
371
+ #endif /* TTYPT_LAM_H */
372
+ #endif /* LAM_H */
@@ -0,0 +1,286 @@
1
+ #ifndef TTYPT_WEBGL_H
2
+ #define TTYPT_WEBGL_H
3
+
4
+ /*
5
+ * webgl.h — Canonical WebGL 1/2 graphics interface for WebAssembly and native C.
6
+ * Implements two-level WASM import namespace "webgl" with native fallback.
7
+ */
8
+
9
+ #include <stdint.h>
10
+ #include <stddef.h>
11
+
12
+ #ifdef __cplusplus
13
+ extern "C" {
14
+ #endif
15
+
16
+ typedef unsigned int GLenum;
17
+ typedef unsigned int GLuint;
18
+ typedef int GLint;
19
+ typedef int GLsizei;
20
+ typedef float GLfloat;
21
+ typedef float GLclampf;
22
+ typedef unsigned char GLboolean;
23
+
24
+ #define GL_FALSE 0
25
+ #define GL_TRUE 1
26
+
27
+ #define GL_COLOR_BUFFER_BIT 0x00004000
28
+ #define GL_DEPTH_BUFFER_BIT 0x00000100
29
+
30
+ #define GL_POINTS 0x0000
31
+ #define GL_LINES 0x0001
32
+ #define GL_TRIANGLES 0x0004
33
+ #define GL_TRIANGLE_STRIP 0x0005
34
+ #define GL_TRIANGLE_FAN 0x0006
35
+
36
+ #define GL_BYTE 0x1400
37
+ #define GL_UNSIGNED_BYTE 0x1401
38
+ #define GL_SHORT 0x1402
39
+ #define GL_UNSIGNED_SHORT 0x1403
40
+ #define GL_INT 0x1404
41
+ #define GL_UNSIGNED_INT 0x1405
42
+ #define GL_FLOAT 0x1406
43
+
44
+ #define GL_FRAGMENT_SHADER 0x8B30
45
+ #define GL_VERTEX_SHADER 0x8B31
46
+
47
+ #define GL_ARRAY_BUFFER 0x8892
48
+ #define GL_ELEMENT_ARRAY_BUFFER 0x8893
49
+
50
+ #define GL_STREAM_DRAW 0x88E0
51
+ #define GL_STATIC_DRAW 0x88E4
52
+ #define GL_DYNAMIC_DRAW 0x88E8
53
+
54
+ #define GL_COMPILE_STATUS 0x8B81
55
+ #define GL_LINK_STATUS 0x8B82
56
+
57
+ #define GL_DEPTH_TEST 0x0B71
58
+ #define GL_BLEND 0x0BE2
59
+ #define GL_CULL_FACE 0x0B44
60
+ #define GL_LESS 0x0201
61
+ #define GL_LEQUAL 0x0203
62
+ #define GL_SRC_ALPHA 0x0302
63
+ #define GL_ONE_MINUS_SRC_ALPHA 0x0303
64
+ #define GL_TEXTURE_2D 0x0DE1
65
+ #define GL_TEXTURE0 0x84C0
66
+ #define GL_TEXTURE1 0x84C1
67
+ #define GL_TEXTURE2 0x84C2
68
+ #define GL_TEXTURE_MAG_FILTER 0x2800
69
+ #define GL_TEXTURE_MIN_FILTER 0x2801
70
+ #define GL_TEXTURE_WRAP_S 0x2802
71
+ #define GL_TEXTURE_WRAP_T 0x2803
72
+ #define GL_NEAREST 0x2600
73
+ #define GL_LINEAR 0x2601
74
+ #define GL_CLAMP_TO_EDGE 0x812F
75
+ #define GL_RGBA 0x1908
76
+ #define GL_R16I 0x8233
77
+ #define GL_RED_INTEGER 0x8D94
78
+ #define GL_UNPACK_ALIGNMENT 0x0CF5
79
+ #define GL_POLYGON_OFFSET_FILL 0x8037
80
+
81
+ #ifdef __wasm__
82
+ __attribute__((import_module("webgl"), import_name("glViewport")))
83
+ void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
84
+
85
+ __attribute__((import_module("webgl"), import_name("glClearColor")))
86
+ void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
87
+
88
+ __attribute__((import_module("webgl"), import_name("glClear")))
89
+ void glClear(GLenum mask);
90
+
91
+ __attribute__((import_module("webgl"), import_name("glEnable")))
92
+ void glEnable(GLenum cap);
93
+
94
+ __attribute__((import_module("webgl"), import_name("glDisable")))
95
+ void glDisable(GLenum cap);
96
+
97
+ __attribute__((import_module("webgl"), import_name("glDepthFunc")))
98
+ void glDepthFunc(GLenum func);
99
+
100
+ __attribute__((import_module("webgl"), import_name("glDepthMask")))
101
+ void glDepthMask(GLboolean flag);
102
+
103
+ __attribute__((import_module("webgl"), import_name("glBlendFunc")))
104
+ void glBlendFunc(GLenum sfactor, GLenum dfactor);
105
+
106
+ __attribute__((import_module("webgl"), import_name("glColorMask")))
107
+ void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
108
+
109
+ __attribute__((import_module("webgl"), import_name("glPolygonOffset")))
110
+ void glPolygonOffset(GLfloat factor, GLfloat units);
111
+
112
+ __attribute__((import_module("webgl"), import_name("glCreateShader")))
113
+ GLuint glCreateShader(GLenum type);
114
+
115
+ __attribute__((import_module("webgl"), import_name("glShaderSource")))
116
+ void glShaderSource(GLuint shader, const char *src, size_t len);
117
+
118
+ __attribute__((import_module("webgl"), import_name("glCompileShader")))
119
+ void glCompileShader(GLuint shader);
120
+
121
+ __attribute__((import_module("webgl"), import_name("glGetShaderParameter")))
122
+ GLint glGetShaderParameter(GLuint shader, GLenum pname);
123
+
124
+ __attribute__((import_module("webgl"), import_name("glCreateProgram")))
125
+ GLuint glCreateProgram(void);
126
+
127
+ __attribute__((import_module("webgl"), import_name("glAttachShader")))
128
+ void glAttachShader(GLuint program, GLuint shader);
129
+
130
+ __attribute__((import_module("webgl"), import_name("glLinkProgram")))
131
+ void glLinkProgram(GLuint program);
132
+
133
+ __attribute__((import_module("webgl"), import_name("glGetProgramParameter")))
134
+ GLint glGetProgramParameter(GLuint program, GLenum pname);
135
+
136
+ __attribute__((import_module("webgl"), import_name("glUseProgram")))
137
+ void glUseProgram(GLuint program);
138
+
139
+ __attribute__((import_module("webgl"), import_name("glCreateBuffer")))
140
+ GLuint glCreateBuffer(void);
141
+
142
+ __attribute__((import_module("webgl"), import_name("glBindBuffer")))
143
+ void glBindBuffer(GLenum target, GLuint buffer);
144
+
145
+ __attribute__((import_module("webgl"), import_name("glBufferData")))
146
+ void glBufferData(GLenum target, const void *data, size_t size, GLenum usage);
147
+
148
+ __attribute__((import_module("webgl"), import_name("glCreateTexture")))
149
+ GLuint glCreateTexture(void);
150
+
151
+ __attribute__((import_module("webgl"), import_name("glDeleteTexture")))
152
+ void glDeleteTexture(GLuint texture);
153
+
154
+ __attribute__((import_module("webgl"), import_name("glBindTexture")))
155
+ void glBindTexture(GLenum target, GLuint texture);
156
+
157
+ __attribute__((import_module("webgl"), import_name("glActiveTexture")))
158
+ void glActiveTexture(GLenum texture);
159
+
160
+ __attribute__((import_module("webgl"), import_name("glTexParameteri")))
161
+ void glTexParameteri(GLenum target, GLenum pname, GLint param);
162
+
163
+ __attribute__((import_module("webgl"), import_name("glPixelStorei")))
164
+ void glPixelStorei(GLenum pname, GLint param);
165
+
166
+ __attribute__((import_module("webgl"), import_name("glTexImage2D")))
167
+ void glTexImage2D(GLenum target, GLint level, GLint internalformat,
168
+ GLsizei width, GLsizei height, GLint border,
169
+ GLenum format, GLenum type, const void *pixels);
170
+
171
+ __attribute__((import_module("webgl"), import_name("glEnableVertexAttribArray")))
172
+ void glEnableVertexAttribArray(GLuint index);
173
+
174
+ __attribute__((import_module("webgl"), import_name("glDisableVertexAttribArray")))
175
+ void glDisableVertexAttribArray(GLuint index);
176
+
177
+ __attribute__((import_module("webgl"), import_name("glVertexAttribPointer")))
178
+ void glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, size_t offset);
179
+
180
+ __attribute__((import_module("webgl"), import_name("glDrawArrays")))
181
+ void glDrawArrays(GLenum mode, GLint first, GLsizei count);
182
+
183
+ __attribute__((import_module("webgl"), import_name("glDrawElements")))
184
+ void glDrawElements(GLenum mode, GLsizei count, GLenum type, size_t offset);
185
+
186
+ __attribute__((import_module("webgl"), import_name("glGetAttribLocation")))
187
+ GLint glGetAttribLocation(GLuint program, const char *name, size_t len);
188
+
189
+ __attribute__((import_module("webgl"), import_name("glBindAttribLocation")))
190
+ void glBindAttribLocation(GLuint program, GLuint index, const char *name, size_t len);
191
+
192
+ __attribute__((import_module("webgl"), import_name("glGetUniformLocation")))
193
+ GLint glGetUniformLocation(GLuint program, const char *name, size_t len);
194
+
195
+ __attribute__((import_module("webgl"), import_name("glUniform1i")))
196
+ void glUniform1i(GLint location, GLint v0);
197
+
198
+ __attribute__((import_module("webgl"), import_name("glUniform1f")))
199
+ void glUniform1f(GLint location, GLfloat v0);
200
+
201
+ __attribute__((import_module("webgl"), import_name("glUniform2f")))
202
+ void glUniform2f(GLint location, GLfloat v0, GLfloat v1);
203
+
204
+ __attribute__((import_module("webgl"), import_name("glUniform3f")))
205
+ void glUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
206
+
207
+ __attribute__((import_module("webgl"), import_name("glUniform4f")))
208
+ void glUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
209
+
210
+ __attribute__((import_module("webgl"), import_name("glUniform2fv")))
211
+ void glUniform2fv(GLint location, GLsizei count, const GLfloat *value);
212
+
213
+ __attribute__((import_module("webgl"), import_name("glUniform3fv")))
214
+ void glUniform3fv(GLint location, GLsizei count, const GLfloat *value);
215
+
216
+ __attribute__((import_module("webgl"), import_name("glUniformMatrix4fv")))
217
+ void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
218
+
219
+ __attribute__((import_module("webgl"), import_name("glDeleteShader")))
220
+ void glDeleteShader(GLuint shader);
221
+
222
+ __attribute__((import_module("webgl"), import_name("glDeleteProgram")))
223
+ void glDeleteProgram(GLuint program);
224
+
225
+ __attribute__((import_module("webgl"), import_name("glDeleteBuffer")))
226
+ void glDeleteBuffer(GLuint buffer);
227
+
228
+ #else
229
+
230
+ static inline void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) { (void)x; (void)y; (void)width; (void)height; }
231
+ static inline void glClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) { (void)r; (void)g; (void)b; (void)a; }
232
+ static inline void glClear(GLenum mask) { (void)mask; }
233
+ static inline void glEnable(GLenum cap) { (void)cap; }
234
+ static inline void glDisable(GLenum cap) { (void)cap; }
235
+ static inline void glDepthFunc(GLenum func) { (void)func; }
236
+ static inline void glDepthMask(GLboolean flag) { (void)flag; }
237
+ static inline void glBlendFunc(GLenum sfactor, GLenum dfactor) { (void)sfactor; (void)dfactor; }
238
+ static inline void glColorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a) { (void)r; (void)g; (void)b; (void)a; }
239
+ static inline void glPolygonOffset(GLfloat factor, GLfloat units) { (void)factor; (void)units; }
240
+ static inline GLuint glCreateShader(GLenum type) { (void)type; return 1; }
241
+ static inline void glShaderSource(GLuint s, const char *src, size_t len) { (void)s; (void)src; (void)len; }
242
+ static inline void glCompileShader(GLuint s) { (void)s; }
243
+ static inline GLint glGetShaderParameter(GLuint s, GLenum p) { (void)s; (void)p; return 1; }
244
+ static inline GLuint glCreateProgram(void) { return 1; }
245
+ static inline void glAttachShader(GLuint p, GLuint s) { (void)p; (void)s; }
246
+ static inline void glLinkProgram(GLuint p) { (void)p; }
247
+ static inline GLint glGetProgramParameter(GLuint p, GLenum param) { (void)p; (void)param; return 1; }
248
+ static inline void glUseProgram(GLuint p) { (void)p; }
249
+ static inline GLuint glCreateBuffer(void) { return 1; }
250
+ static inline void glBindBuffer(GLenum t, GLuint b) { (void)t; (void)b; }
251
+ static inline void glBufferData(GLenum t, const void *d, size_t s, GLenum u) { (void)t; (void)d; (void)s; (void)u; }
252
+ static inline GLuint glCreateTexture(void) { return 1; }
253
+ static inline void glDeleteTexture(GLuint t) { (void)t; }
254
+ static inline void glBindTexture(GLenum t, GLuint tex) { (void)t; (void)tex; }
255
+ static inline void glActiveTexture(GLenum t) { (void)t; }
256
+ static inline void glTexParameteri(GLenum t, GLenum p, GLint v) { (void)t; (void)p; (void)v; }
257
+ static inline void glPixelStorei(GLenum p, GLint v) { (void)p; (void)v; }
258
+ static inline void glTexImage2D(GLenum t, GLint l, GLint inf, GLsizei w, GLsizei h, GLint b, GLenum f, GLenum ty, const void *px)
259
+ { (void)t; (void)l; (void)inf; (void)w; (void)h; (void)b; (void)f; (void)ty; (void)px; }
260
+ static inline void glEnableVertexAttribArray(GLuint i) { (void)i; }
261
+ static inline void glDisableVertexAttribArray(GLuint i) { (void)i; }
262
+ static inline void glVertexAttribPointer(GLuint i, GLint s, GLenum t, GLboolean n, GLsizei st, size_t o) { (void)i; (void)s; (void)t; (void)n; (void)st; (void)o; }
263
+ static inline void glDrawArrays(GLenum m, GLint f, GLsizei c) { (void)m; (void)f; (void)c; }
264
+ static inline void glDrawElements(GLenum m, GLsizei c, GLenum t, size_t o) { (void)m; (void)c; (void)t; (void)o; }
265
+ static inline GLint glGetAttribLocation(GLuint p, const char *n, size_t l) { (void)p; (void)n; (void)l; return 0; }
266
+ static inline void glBindAttribLocation(GLuint p, GLuint i, const char *n, size_t l) { (void)p; (void)i; (void)n; (void)l; }
267
+ static inline GLint glGetUniformLocation(GLuint p, const char *n, size_t l) { (void)p; (void)n; (void)l; return 1; }
268
+ static inline void glUniform1i(GLint l, GLint v0) { (void)l; (void)v0; }
269
+ static inline void glUniform1f(GLint l, GLfloat v0) { (void)l; (void)v0; }
270
+ static inline void glUniform2f(GLint l, GLfloat v0, GLfloat v1) { (void)l; (void)v0; (void)v1; }
271
+ static inline void glUniform3f(GLint l, GLfloat v0, GLfloat v1, GLfloat v2) { (void)l; (void)v0; (void)v1; (void)v2; }
272
+ static inline void glUniform4f(GLint l, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { (void)l; (void)v0; (void)v1; (void)v2; (void)v3; }
273
+ static inline void glUniform2fv(GLint l, GLsizei c, const GLfloat *v) { (void)l; (void)c; (void)v; }
274
+ static inline void glUniform3fv(GLint l, GLsizei c, const GLfloat *v) { (void)l; (void)c; (void)v; }
275
+ static inline void glUniformMatrix4fv(GLint l, GLsizei c, GLboolean t, const GLfloat *v) { (void)l; (void)c; (void)t; (void)v; }
276
+ static inline void glDeleteShader(GLuint s) { (void)s; }
277
+ static inline void glDeleteProgram(GLuint p) { (void)p; }
278
+ static inline void glDeleteBuffer(GLuint b) { (void)b; }
279
+
280
+ #endif
281
+
282
+ #ifdef __cplusplus
283
+ }
284
+ #endif
285
+
286
+ #endif /* TTYPT_WEBGL_H */