-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
rendering_plugins.h
111 lines (94 loc) · 2.77 KB
/
rendering_plugins.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
#ifndef RENDERING_PLUGINS_H
#define RENDERING_PLUGINS_H
#include "convection.h"
extern const double r_inner;
extern const unsigned int nr, ntheta;
extern const double flattening;
//Useful constants
static const short vertices_per_triangle = 3;
static const short vertices_per_line = 2;
static const short coordinates_per_vertex = 2;
static const short colors_per_vertex = 3;
static const short triangles_per_quad = 2;
/******************************************
Interface for rendering plugins.
There is space in the center of the
domain which could be used to display
various things of interest/supporting
data. Define a basic plugin architecture
for accomplishing this.
******************************************/
class RenderingPlugin
{
public:
RenderingPlugin( const ConvectionSimulator &sim ) : sim(sim) {}
void setup();
void draw();
void cleanup();
protected:
const ConvectionSimulator ∼
};
class Core : RenderingPlugin
{
public:
Core( const ConvectionSimulator &sim ) : RenderingPlugin(sim) {}
void setup();
void draw();
void cleanup();
private:
//Data for rendering with OpenGL
GLfloat* vertices;
GLfloat* vertex_colors;
GLuint* triangle_vertex_indices;
GLuint plugin_program;
GLuint plugin_vertices;
GLuint plugin_vertex_colors;
GLuint plugin_triangle_vertex_indices;
GLint plugin_attribute_coord2d;
GLint plugin_attribute_v_color;
};
class Axis : RenderingPlugin
{
public:
Axis( const ConvectionSimulator &sim ) : RenderingPlugin(sim) {}
void setup();
void draw();
void cleanup();
private:
//Data for rendering with OpenGL
GLfloat* vertices;
GLfloat* vertex_colors;
GLuint* triangle_vertex_indices;
GLuint plugin_program;
GLuint plugin_vertices;
GLuint plugin_vertex_colors;
GLuint plugin_triangle_vertex_indices;
GLint plugin_attribute_coord2d;
GLint plugin_attribute_v_color;
};
class Seismograph : RenderingPlugin
{
public:
Seismograph( const ConvectionSimulator &sim ) : RenderingPlugin(sim),
n_lines(1000),
n_vertices(n_lines+1 /*endpoint*/ + vertices_per_triangle /*seismometer*/)
{}
void setup();
void draw();
void cleanup();
void clear_record();
private:
const unsigned int n_lines;
const unsigned int n_vertices;
//Data for rendering with OpenGL
GLfloat* vertices;
GLfloat* vertex_colors;
GLuint* line_vertex_indices;
GLuint plugin_program;
GLuint plugin_vertices;
GLuint plugin_vertex_colors;
GLuint plugin_line_vertex_indices;
GLint plugin_attribute_coord2d;
GLint plugin_attribute_v_color;
};
#endif