GPU-Accelerated Coverage  0.1.0
Compute coverage tours for known environment with articulated objects on GPU
Renderer.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_RENDERER_H_
32 #define INCLUDE_ARTICULATION_RENDERER_H_
33 
34 #include <gpu_coverage/AbstractRenderer.h>
35 #include <gpu_coverage/CameraPerspective.h>
36 #include <gpu_coverage/CoordinateAxes.h>
37 #include <gpu_coverage/Programs.h>
38 
39 namespace gpu_coverage {
40 
44 class Renderer: public AbstractRenderer {
45 public:
54  Renderer(const Scene * const scene, const bool renderToWindow, const bool renderToTexture);
55 
59  virtual ~Renderer();
60 
66  virtual void display();
67 
72  inline const GLuint& getTexture() const {
73  return textures[COLOR];
74  }
75 
80  inline const int& getTextureHeight() const {
81  return height;
82  }
83 
88  inline const int& getTextureWidth() const {
89  return width;
90  }
91 
96  void setCamera(CameraPerspective * cameraNew) {
97  camera = cameraNew;
98  }
99 
100 protected:
101  const bool renderToWindow;
102  const bool renderToTexture;
103  const int width;
104  const int height;
105 
107 
112 
113  GLuint framebuffer;
114  GLuint textures[2];
115  GLuint vao;
116  GLuint vbo;
117 
121  enum TextureRole {
122  COLOR = 0,
123  DEPTH = 1
124  };
125 
126 };
127 
128 } /* namespace gpu_coverage */
129 
130 #endif /* INCLUDE_ARTICULATION_RENDERER_H_ */
Renderer for rendering a 3D scene using textures and materials.
Definition: Renderer.h:44
CameraPerspective * camera
Active camera used for rendering.
Definition: Renderer.h:106
Depth buffer.
Definition: Renderer.h:123
GLuint framebuffer
Framebuffer for offscreen rendering.
Definition: Renderer.h:113
const int height
Height of the off-screen texture in pixels.
Definition: Renderer.h:104
Renders a coordinate axes system.
Definition: CoordinateAxes.h:46
ProgramVisualTexture progVisualTexture
Shader program for rendering a mesh with materials and/or textures.
Definition: Renderer.h:108
GLuint vbo
Vertex buffer object.
Definition: Renderer.h:116
Scene graph corresponding to Assimp&#39;s aiScene.
Definition: Scene.h:59
const int & getTextureWidth() const
Width of the result texture.
Definition: Renderer.h:88
const int width
Width of the off-screen texture in pixels.
Definition: Renderer.h:103
CoordinateAxes coordinateAxes
Coordinate axes scene object.
Definition: Renderer.h:111
const GLuint & getTexture() const
Returns the OpenGL texture ID of the result texture.
Definition: Renderer.h:72
Perspective projection camera.
Definition: CameraPerspective.h:45
ProgramShowTexture * progShowTexture
Program for rendering a texture to a framebuffer.
Definition: Renderer.h:110
const Scene *const scene
Pointer to the scene to be rendered.
Definition: AbstractRenderer.h:101
const bool renderToTexture
True if renderer should render to an off-screen texture.
Definition: Renderer.h:102
virtual ~Renderer()
Destructor.
Color buffer.
Definition: Renderer.h:122
const int & getTextureHeight() const
Height of the result texture.
Definition: Renderer.h:80
Definition: Programs.h:191
Abstract superclass for all renderers.
Definition: AbstractRenderer.h:45
Definition: AbstractCamera.h:41
GLuint textures[2]
Color and depth textures for offscreen rendering.
Definition: Renderer.h:114
Definition: Programs.h:378
TextureRole
Texture roles.
Definition: Renderer.h:121
ProgramVisualVertexcolor progVisualVertexcolor
Shader program for rendering a mesh with per-vertex colors.
Definition: Renderer.h:109
Renderer(const Scene *const scene, const bool renderToWindow, const bool renderToTexture)
Constructor.
const bool renderToWindow
True if renderer should render to the window framebufer.
Definition: Renderer.h:101
GLuint vao
Vertex array object.
Definition: Renderer.h:115
Definition: Programs.h:213
virtual void display()
Renders the scene.
void setCamera(CameraPerspective *cameraNew)
Change the active camera used for rendering.
Definition: Renderer.h:96