Developer documentation
Version 3.0.3-105-gd3941f44
shaders.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __gui_mrview_tool_connectome_shaders_h__
18#define __gui_mrview_tool_connectome_shaders_h__
19
20#include "gui/opengl/shader.h"
21
23
24namespace MR
25{
26 namespace GUI
27 {
28 namespace MRView
29 {
30 namespace Tool
31 {
32
33
34 class Connectome;
35
36
37 class ShaderBase : public GL::Shader::Program { MEMALIGN(ShaderBase)
38 public:
40 virtual ~ShaderBase() { }
41
42 virtual bool need_update (const Connectome&) const = 0;
43 virtual void update (const Connectome&) = 0;
44
45 void start (const Connectome& parent) {
47 if (*this == 0 || need_update (parent)) {
48 recompile (parent);
49 }
52 }
53
54 protected:
58
59 private:
60 void recompile (const Connectome& parent);
61 };
62
63
64
65 class NodeShader : public ShaderBase
66 { MEMALIGN(NodeShader)
67 public:
68 NodeShader() : ShaderBase () { }
69 ~NodeShader() { }
70 bool need_update (const Connectome&) const override;
71 void update (const Connectome&) override;
72 private:
73 node_geometry_t geometry;
74 node_colour_t colour;
75 size_t colourmap_index;
76 bool use_alpha;
77 };
78
79
80
81 class EdgeShader : public ShaderBase
82 { MEMALIGN(EdgeShader)
83 public:
84 EdgeShader() : ShaderBase () { }
85 ~EdgeShader() { }
86 bool need_update (const Connectome&) const override;
87 void update (const Connectome&) override;
88 private:
89 edge_geometry_t geometry;
90 edge_colour_t colour;
91 size_t colourmap_index;
92 bool use_alpha;
93 };
94
95
96
97 }
98 }
99 }
100}
101
102#endif
103
104
105
106
std::string fragment_shader_source
Definition: shaders.h:55
std::string geometry_shader_source
Definition: shaders.h:55
void assert_context_is_current(QWidget *glarea=nullptr)
Definition: gl.h:100
Definition: base.h:24