-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuffer.h
More file actions
58 lines (49 loc) · 1.64 KB
/
Copy pathbuffer.h
File metadata and controls
58 lines (49 loc) · 1.64 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
#ifndef buffer_H
#define buffer_H
#include <gl.h>
#include <stddef.h> // size_t, for the GL-name pools below
typedef int PBindex;
typedef enum Bwhich {
current = 0,
other = 1,
screen = 2
} Bwhich;
typedef struct format {
GLint format;
GLint iformat;
} format;
#define BE_1D \
(format) { .format = GL_RED, .iformat = GL_R32F }
#define BE_2D \
(format) { .format = GL_RG, .iformat = GL_RG32F }
#define BE_3D \
(format) { .format = GL_RGB, .iformat = GL_RGB32F }
#define BE_4D \
(format) { .format = GL_RGBA, .iformat = GL_RGBA32F }
// Growable GL-name array (nob.h's dynamic-array layout, so nob_da_append works on it).
typedef struct GLuintArray {
GLuint *items;
size_t count;
size_t capacity;
} GLuintArray;
typedef struct Buffer {
const char *name;
PBindex current;
PBindex other;
int width;
int height;
GLuint minmag_filter;
GLuint wrap_st;
format dim;
// Pointers to the pools, not into them: the pools grow as each sim claims its slots, and a
// realloc moves the items. The pool structs themselves have stable addresses.
const GLuintArray *textures;
const GLuintArray *framebuffers;
} Buffer;
void buffer_allocate(Buffer *b, const Bwhich which, const PBindex index, const int width, const int height, const char *data);
void buffer_reallocate(Buffer *b, const Bwhich which, const int width, const int height);
void buffer_flip(Buffer *b);
void buffer_bind(Buffer *b, const Bwhich which);
void buffer_update(Buffer *b); // draw a fullscreen quad (4-vertex triangle strip)
void buffer_update_n(Buffer *b, const int P); // draw P points
#endif /* buffer_H */