-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaxes.h
79 lines (59 loc) · 1.57 KB
/
axes.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
#ifndef AXES_H
#define AXES_H
#include <aem/stringbuf.h>
#include "shader.h"
// must match value in grid_linear.f.glsl
#define GRID_ORDERS 5
extern struct aem_stringbuf graphics_axes_shader_path;
enum graphics_axes_grid_type
{
GRID_LIN,
GRID_LOG,
};
struct graphics_axes_axis
{
double (*fwd)(double x);
double (*rev)(double x); // inverse of fwd: x == fwd(rev(x)) for all x
};
struct graphics_axes_uniforms
{
int origin;
int scale;
int grid_scale;
int grid_intensity;
};
struct graphics_axes
{
// public
double xmid;
double ymid;
double dp;
int width;
int height;
enum graphics_axes_grid_type grid_type_x;
enum graphics_axes_grid_type grid_type_y;
double grid_base_x;
double grid_base_y;
// private
struct graphics_shader_program grid_shader;
struct graphics_axes_uniforms uniforms;
// updated by graphics_axes_recalculate
double xmin;
double xmax;
double ymin;
double ymax;
double grid_stress_x;
double grid_stress_y;
double grid_scl_x;
double grid_scl_y;
float grid_scale[GRID_ORDERS];
float grid_intensity[GRID_ORDERS];
};
void graphics_axes_new(struct graphics_axes *axes);
void graphics_axes_dtor(struct graphics_axes *axes);
void graphics_axes_recalculate(struct graphics_axes *axes);
void graphics_axes_zoom(struct graphics_axes *axes, double x, double y, double factor);
void graphics_axes_uniforms_setup(struct graphics_axes_uniforms *u, struct graphics_shader_program *pgm);
void graphics_axes_shader_render(struct graphics_axes *axes, struct graphics_axes_uniforms *u);
void graphics_axes_render(struct graphics_axes *axes);
#endif /* AXES_H */