Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
shadercallback.h
Go to the documentation of this file.
1 #ifndef SHADERCALLBACK_H
2 #define SHADERCALLBACK_H
3 
4 #include <vtkCommand.h>
5 #include <vtkSmartPointer.h>
6 
7 
8 //OpenGL
9 #include <GL/glew.h>
10 #include <glut.h> //Framework on Mac
11 
12 // -----------------------------------------------------------------------
13 // Update a uniform in the shader for each render. We do this with a
14 // callback for the UpdateShaderEvent
15 class ShaderCallback : public vtkCommand
16 {
17 public:
18  static ShaderCallback *New();
19 
20  virtual void Execute(vtkObject *, unsigned long event, void*cbo);
21 
23 
24  vtkSmartPointer<class vtkOpenGLRenderWindow> mRenderWindow; //containing the opengl context
25  //vtkSmartPointer<class vtkCubeSource> mCube;
26  vtkSmartPointer<class vtkOpenGLBufferObject> mColorBufferObject; //color data
27  vtkSmartPointer<class vtkOpenGLBufferObject> mTextureBufferObject; //texture coordinate data
28  vtkSmartPointer<class vtkTextureObject> mTextureObject1; //texture object -> glsl: sampler
29  vtkSmartPointer<class vtkTextureObject> mTextureObject2; //texture object -> glsl: sampler
30 
31  //void test2(unsigned long event, void *cbo);
32  void test(unsigned long event, void *cbo);
33 };
34 
35 //Need one texture coordinate per vertex in the model
36 //40 lines with 3 values each = 120
37 static int numberOfTextureCoordinates = 40;
38 static int numberOfComponentsPerTexture = 3;
39 static const GLfloat texture_data[] = {
40  1.0f, 1.0f, 1.0f,
41  1.0f, 1.0f, 0.0f,
42  1.0f, 0.0f, 0.0f,
43  0.0f, 0.0f, 0.0f,
44  0.0f, 0.0f, 1.0f,
45  0.0f, 1.0f, 1.0f,
46  0.0f, 1.0f, 0.0f,
47  1.0f, 0.0f, 1.0f,
48  1.0f, 1.0f, 1.0f,
49  1.0f, 1.0f, 0.0f,
50  1.0f, 0.0f, 0.0f,
51  0.0f, 0.0f, 0.0f,
52  0.0f, 0.0f, 1.0f,
53  0.0f, 1.0f, 1.0f,
54  0.0f, 1.0f, 0.0f,
55  1.0f, 0.0f, 1.0f,
56  1.0f, 1.0f, 1.0f,
57  1.0f, 1.0f, 0.0f,
58  1.0f, 0.0f, 0.0f,
59  0.0f, 0.0f, 0.0f,
60  0.0f, 0.0f, 1.0f,
61  0.0f, 1.0f, 1.0f,
62  0.0f, 1.0f, 0.0f,
63  1.0f, 0.0f, 1.0f,
64  1.0f, 1.0f, 1.0f,
65  1.0f, 1.0f, 0.0f,
66  1.0f, 0.0f, 0.0f,
67  0.0f, 0.0f, 0.0f,
68  0.0f, 0.0f, 1.0f,
69  0.0f, 1.0f, 1.0f,
70  0.0f, 1.0f, 0.0f,
71  1.0f, 0.0f, 1.0f,
72  1.0f, 1.0f, 1.0f,
73  1.0f, 1.0f, 0.0f,
74  1.0f, 0.0f, 0.0f,
75  0.0f, 0.0f, 0.0f,
76  0.0f, 0.0f, 1.0f,
77  0.0f, 1.0f, 1.0f,
78  0.0f, 1.0f, 0.0f,
79  1.0f, 0.0f, 1.0f,
80  1.0f, 1.0f, 1.0f,
81  1.0f, 1.0f, 0.0f,
82  1.0f, 0.0f, 0.0f,
83  0.0f, 0.0f, 0.0f,
84  0.0f, 0.0f, 1.0f,
85  0.0f, 1.0f, 1.0f,
86  0.0f, 1.0f, 0.0f,
87  1.0f, 0.0f, 1.0f
88 };
89 
90 
91 //81 lines with 3 values each == 243 values
92 static int numberOfColors = 81;
93 static int numberOfComponentsPerColor = 3;
94 static const GLfloat color_data[] = {
95  1.0f, 0.0f, 0.0f,
96  0.0f, 1.0f, 0.0f,
97  0.0f, 0.0f, 1.0f,
98  0.822f, 0.569f, 0.201f,
99  0.435f, 0.602f, 0.223f,
100  0.310f, 0.747f, 0.185f,
101  0.597f, 0.770f, 0.761f,
102  0.559f, 0.436f, 0.730f,
103  0.359f, 0.583f, 0.152f,
104  0.483f, 0.596f, 0.789f,
105  0.559f, 0.861f, 0.639f,
106  0.195f, 0.548f, 0.859f,
107  0.014f, 0.184f, 0.576f,
108  0.771f, 0.328f, 0.970f,
109  0.406f, 0.615f, 0.116f,
110  0.676f, 0.977f, 0.133f,
111  0.971f, 0.572f, 0.833f,
112  0.140f, 0.616f, 0.489f,
113  0.997f, 0.513f, 0.064f,
114  0.945f, 0.719f, 0.592f,
115  0.543f, 0.021f, 0.978f,
116  0.279f, 0.317f, 0.505f,
117  0.167f, 0.620f, 0.077f,
118  0.347f, 0.857f, 0.137f,
119  0.055f, 0.953f, 0.042f,
120  0.714f, 0.505f, 0.345f,
121  0.783f, 0.290f, 0.734f,
122  0.722f, 0.645f, 0.174f,
123  0.302f, 0.455f, 0.848f,
124  0.225f, 0.587f, 0.040f,
125  0.517f, 0.713f, 0.338f,
126  0.053f, 0.959f, 0.120f,
127  0.393f, 0.621f, 0.362f,
128  0.673f, 0.211f, 0.457f,
129  0.820f, 0.883f, 0.371f,
130  0.982f, 0.099f, 0.879f,
131  0.140f, 0.616f, 0.489f,
132  0.997f, 0.513f, 0.064f,
133  0.945f, 0.719f, 0.592f,
134  0.543f, 0.021f, 0.978f,
135  0.279f, 0.317f, 0.505f,
136  0.167f, 0.620f, 0.077f,
137  0.347f, 0.857f, 0.137f,
138  0.055f, 0.953f, 0.042f,
139  0.714f, 0.505f, 0.345f,
140  0.783f, 0.290f, 0.734f,
141  0.722f, 0.645f, 0.174f,
142  0.302f, 0.455f, 0.848f,
143  0.225f, 0.587f, 0.040f,
144  0.517f, 0.713f, 0.338f,
145  0.053f, 0.959f, 0.120f,
146  0.393f, 0.621f, 0.362f,
147  0.673f, 0.211f, 0.457f,
148  0.820f, 0.883f, 0.371f,
149  0.982f, 0.099f, 0.879f,
150  0.302f, 0.455f, 0.848f,
151  0.225f, 0.587f, 0.040f,
152  0.517f, 0.713f, 0.338f,
153  0.053f, 0.959f, 0.120f,
154  0.393f, 0.621f, 0.362f,
155  0.673f, 0.211f, 0.457f,
156  0.820f, 0.883f, 0.371f,
157  0.982f, 0.099f, 0.879f,
158  0.140f, 0.616f, 0.489f,
159  0.997f, 0.513f, 0.064f,
160  0.945f, 0.719f, 0.592f,
161  0.543f, 0.021f, 0.978f,
162  0.279f, 0.317f, 0.505f,
163  0.167f, 0.620f, 0.077f,
164  0.347f, 0.857f, 0.137f,
165  0.055f, 0.953f, 0.042f,
166  0.714f, 0.505f, 0.345f,
167  0.783f, 0.290f, 0.734f,
168  0.722f, 0.645f, 0.174f,
169  0.302f, 0.455f, 0.848f,
170  0.225f, 0.587f, 0.040f,
171  0.517f, 0.713f, 0.338f,
172  0.053f, 0.959f, 0.120f,
173  0.393f, 0.621f, 0.362f,
174  0.673f, 0.211f, 0.457f,
175  0.820f, 0.883f, 0.371f,
176  0.982f, 0.099f, 0.879f
177 };
178 
179 
180 
181 #endif // SHADERCALLBACK_H
vtkSmartPointer< class vtkOpenGLRenderWindow > mRenderWindow
virtual void Execute(vtkObject *, unsigned long event, void *cbo)
vtkSmartPointer< class vtkOpenGLBufferObject > mTextureBufferObject
static ShaderCallback * New()
void test(unsigned long event, void *cbo)
vtkSmartPointer< class vtkTextureObject > mTextureObject1
vtkSmartPointer< class vtkTextureObject > mTextureObject2
vtkSmartPointer< class vtkOpenGLBufferObject > mColorBufferObject