GPU-Accelerated Coverage  0.1.0
Compute coverage tours for known environment with articulated objects on GPU
Programs.h
1 /*
2  * Copyright (c) 2018, Stefan Osswald
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef INCLUDE_ARTICULATION_PROGRAMS_H_
32 #define INCLUDE_ARTICULATION_PROGRAMS_H_
33 
34 #include GL_INCLUDE
35 
36 namespace gpu_coverage {
37 
42 protected:
50  virtual ~AbstractProgram();
51 
52 public:
59  static void setOpenGLVersion();
60 
64  void use() const;
65 
70  inline bool isReady() const {
71  return ready;
72  }
73 
74 protected:
75  const GLuint program;
76  bool ready;
77 
84  GLuint createShader(const GLenum shaderType, const GLchar* const code, const char * const name) const;
91  GLuint loadShader(const GLenum shaderType, const char * const filename) const;
92 
98  bool link(const char * const name) const;
99 };
100 
104 struct LocationsMVP {
105  GLint modelMatrix;
106  GLint viewMatrix[6];
108  GLint normalMatrix[6];
109  GLint mvp;
110 
114  : modelMatrix(-1), projectionMatrix(-1), mvp(-1) {
115  for (size_t i = 0; i < 6; ++i) {
116  viewMatrix[i] = -1;
117  normalMatrix[i] = -1;
118  }
119  }
120 };
121 
127  GLint lightAmbient;
128  GLint lightDiffuse;
130 
135  : lightPosition(-1), lightAmbient(-1), lightDiffuse(-1), lightSpecular(-1) {
136  }
137 };
138 
147  GLint textureUnit;
148  GLint hasTexture;
149 
154  : materialAmbient(-1), materialDiffuse(-1), materialSpecular(-1), materialShininess(-1), textureUnit(-1),
155  hasTexture(-1) {
156  }
157 };
158 
160 public:
161  ProgramPano();
162  ~ProgramPano();
163  LocationsMVP locationsMVP;
164  LocationsLight locationsLight;
165  LocationsMaterial locationsMaterial;
166  bool hasTesselationShader;
167 };
168 
170 public:
171  ProgramPanoEval();
172  ~ProgramPanoEval();
173  struct Locations {
174  GLint textureUnit;
175  GLint integral;
176  GLint resolution;
177  Locations()
178  : textureUnit(-1), integral(-1), resolution(-1) {
179  }
180  } locations;
181 };
182 
184 public:
187  LocationsMVP locationsMVP;
188  LocationsMaterial locationsMaterial;
189 };
190 
192 public:
195  LocationsMVP locationsMVP;
196  LocationsLight locationsLight;
197  LocationsMaterial locationsMaterial;
198 };
199 
201 public:
204  LocationsMVP locationsMVP;
205  struct Locations {
206  GLint color;
207  Locations()
208  : color(-1) {
209  }
210  } locations;
211 };
212 
214 public:
217  LocationsMVP locationsMVP;
218 };
219 
224 protected:
225  AbstractProgramMapProjection(const char * const name);
226  public:
228 
229  struct Locations {
230  GLint textureUnit;
231  Locations()
232  : textureUnit(-1) {
233  }
234  } locations;
235 };
236 
238 public:
241 };
242 
244 public:
247 };
248 
250 public:
253 };
254 
256 public:
259 };
260 
262 public:
265  LocationsMVP locationsMVP;
266 };
267 
269 public:
272  LocationsMVP locationsMVP;
273  struct Locations {
274  GLint resolution;
275  Locations()
276  : resolution(-1) {
277  }
278  } locations;
279 };
280 
282 public:
285  struct Locations {
286  GLint textureUnit;
287  GLint stepSize;
288  GLint resolution;
289  Locations()
290  : textureUnit(-1), stepSize(-1), resolution(-1) {
291  }
292  } locations;
293 };
294 
296 public:
299  struct Locations {
300  GLint textureUnit;
301  GLint resolution;
302  Locations()
303  : textureUnit(-1), resolution(-1) {
304  }
305  } locations;
306 };
307 
309 public:
310  ProgramCostMap();
311  ~ProgramCostMap();
312  struct Locations {
313  GLint textureUnit;
314  GLint resolution;
315  Locations()
316  : textureUnit(-1), resolution(-1) {
317  }
318  } locations;
319 };
320 
322 public:
325  struct Locations {
326  GLint textureUnit;
327  GLint resolution;
328  Locations()
329  : textureUnit(-1), resolution(-1) {
330  }
331  } locations;
332 };
333 
335 public:
338  //LocationsMVP locationsMVP;
339  struct Locations {
340  GLint resolution;
341  GLint costmapTextureUnit;
342  GLint robotPixel;
343  Locations()
344  : resolution(-1), costmapTextureUnit(-1), robotPixel(-1) {
345  }
346  } locations;
347 };
348 
350 public:
353  struct Locations {
354  GLint resolution;
355  GLint costmapTextureUnit;
356  GLint inputTextureUnit;
357  Locations()
358  : resolution(-1), costmapTextureUnit(-1), inputTextureUnit(-1) {
359  }
360  } locations;
361 };
362 
364 public:
367  struct Locations {
368  GLint resolution;
369  GLint textureUnit;
370  Locations()
371  : resolution(-1), textureUnit(-1) {
372  }
373  } locations;
374  LocationsMaterial locationsMaterial;
375  LocationsMVP locationsMVP;
376 };
377 
379 public:
382  struct Locations {
383  GLint textureUnit;
384  Locations()
385  : textureUnit(-1) {
386  }
387  } locations;
388 };
389 
391 public:
394  struct Locations {
395  GLint textureUnit;
396  Locations()
397  : textureUnit(-1) {
398  }
399  } locations;
400 };
401 
403 public:
406 };
407 
409 public:
412  struct Locations {
413  GLint textureUnit;
414  GLint minDist;
415  GLint maxDist;
416  Locations()
417  : textureUnit(-1), minDist(-1), maxDist(-1) {
418  }
419  } locations;
420 };
421 
423 public:
424  ProgramTLEdge();
425  ~ProgramTLEdge();
426  struct Locations {
427  GLint textureUnit;
428  GLint width;
429  GLint height;
430  Locations()
431  : textureUnit(-1), width(-1), height(-1) {
432  }
433  } locations;
434 };
435 
437 public:
438  ProgramTLStep();
439  ~ProgramTLStep();
440  struct Locations {
441  GLint textureUnit;
442  GLint width;
443  GLint height;
444  Locations()
445  : textureUnit(-1), width(-1), height(-1) {
446  }
447  } locations;
448 };
449 
451 public:
454  struct Locations {
455  GLint resolution;
456  GLint robotPosition;
457  Locations()
458  : resolution(-1), robotPosition(-1) {
459  }
460  } locations;
461 };
462 
464 public:
467  struct Locations {
468  GLint textureUnit;
469  GLint resolution;
470  Locations()
471  : textureUnit(-1), resolution(-1) {
472  }
473  } locations;
474 };
475 
476 
478 public:
481  struct Locations {
482  GLint textureUnit;
483  GLint width;
484  GLint height;
485  Locations()
486  : textureUnit(-1), width(-1), height(-1) {
487  }
488  } locations;
489 };
490 
492 public:
493  ProgramUtility1();
494  ~ProgramUtility1();
495  struct Locations {
496  GLint utilityUnit;
497  GLint gain1Unit;
498  Locations()
499  : utilityUnit(-1), gain1Unit(-1) {
500  }
501  } locations;
502 };
503 
505 public:
506  ProgramUtility2();
507  ~ProgramUtility2();
508  struct Locations {
509  GLint utilityUnit;
510  GLint gain1Unit;
511  GLint gain2Unit;
512  Locations()
513  : utilityUnit(-1), gain1Unit(-1), gain2Unit(-1) {
514  }
515  } locations;
516 };
517 
518 
519 } /* namespace gpu_coverage */
520 
521 #endif /* INCLUDE_ARTICULATION_PROGRAMS_H_ */
Definition: Programs.h:390
Definition: Programs.h:349
Locations of light source shader variables.
Definition: Programs.h:125
Definition: Programs.h:268
Definition: Programs.h:308
GLint lightPosition
vec4 position of the light source in homogeneous coordinates.
Definition: Programs.h:126
Definition: Programs.h:422
Definition: Programs.h:426
Definition: Programs.h:249
Definition: Programs.h:436
GLint materialShininess
float shininess factor of the material.
Definition: Programs.h:146
GLint lightDiffuse
vec3 diffuse color of the light source.
Definition: Programs.h:128
Definition: Programs.h:504
Definition: Programs.h:169
Definition: Programs.h:255
Definition: Programs.h:477
Definition: Programs.h:321
LocationsMVP()
Constructor, initalizes all locations to invalid.
Definition: Programs.h:113
virtual ~AbstractProgram()
Destructor.
Locations of material shader variables.
Definition: Programs.h:142
GLint materialDiffuse
vec3 diffuse color of the material.
Definition: Programs.h:144
Definition: Programs.h:463
GLint projectionMatrix
4x4 Projection matrix.
Definition: Programs.h:107
GLuint loadShader(const GLenum shaderType, const char *const filename) const
Create a shader from a file.
bool isReady() const
Returns true if the program is ready to be used.
Definition: Programs.h:70
Definition: Programs.h:450
Definition: Programs.h:491
Definition: Programs.h:183
Locations of model, view, and projection shader variables.
Definition: Programs.h:104
Definition: Programs.h:159
bool ready
True if program is ready, see isReady().
Definition: Programs.h:76
GLint modelMatrix
4x4 Model matrix.
Definition: Programs.h:105
Abstract superclass for all shader programs.
Definition: Programs.h:41
LocationsMaterial()
Constructor, initalizes all locations to invalid.
Definition: Programs.h:153
LocationsLight()
Constructor, initalizes all locations to invalid.
Definition: Programs.h:134
Definition: Programs.h:281
Definition: Programs.h:312
static void setOpenGLVersion()
Reads versions and available extensions from the GPU.
Definition: Programs.h:363
Definition: Programs.h:191
GLint mvp
4x4 Pre-multiplied model-view-projection matrix.
Definition: Programs.h:109
Definition: AbstractCamera.h:41
GLint materialSpecular
vec3 specular color of the material.
Definition: Programs.h:145
GLint lightSpecular
vec3 specular color of the light source.
Definition: Programs.h:129
GLint lightAmbient
vec3 RGB ambient color of the light source.
Definition: Programs.h:127
Definition: Programs.h:295
Definition: Programs.h:440
GLuint createShader(const GLenum shaderType, const GLchar *const code, const char *const name) const
Create a shader from source code.
Definition: Programs.h:243
Definition: Programs.h:200
Definition: Programs.h:334
Definition: Programs.h:378
GLint textureUnit
ID of the texture unit holding the diffuse material texture.
Definition: Programs.h:147
const GLuint program
OpenGL program ID.
Definition: Programs.h:75
GLint materialAmbient
vec3 ambient color of the material.
Definition: Programs.h:143
bool link(const char *const name) const
Link the associated shader stages.
void use() const
Bind this program to the GPU.
Abstract superclass for all shader programs projecting panoramas to texture images.
Definition: Programs.h:223
Definition: Programs.h:213
GLint hasTexture
True if the texture unit should be used, false if material parameters should be used.
Definition: Programs.h:148
Definition: Programs.h:261
Definition: Programs.h:402