gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
DepthMap.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2017, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
35 #ifndef __DepthMap_h
36 #define __DepthMap_h
37 
38 
56 //******************************************************************************
57 // Include
58 //******************************************************************************
59 #include <vector>
60 
61 #ifndef __Matrix4x4_h
62 #include "gVirtualXRay/Matrix4x4.h"
63 #endif
64 
65 #ifndef __OpenGLUtilities_h
67 #endif
68 
69 #ifndef __PolygonMesh_h
71 #endif
72 
73 #ifndef __Shader_h
74 #include "gVirtualXRay/Shader.h"
75 #endif
76 
77 
78 //******************************************************************************
79 // namespace
80 //******************************************************************************
81 namespace gVirtualXRay {
82 
83 //==============================================================================
89 //==============================================================================
90 class DepthMap {
91 
92 public:
93  //--------------------------------------------------------------------------
95  /*
96  * @param texture_size: size of the side of the buffer (default: 8192)
97  */
98  //--------------------------------------------------------------------------
99  DepthMap(int map_size = 8192);
100 
101 
102  //--------------------------------------------------------------------------
104  //--------------------------------------------------------------------------
105  ~DepthMap();
106 
107 
108  void release();
109 
110 
111  //--------------------------------------------------------------------------
113  //--------------------------------------------------------------------------
114  void initialize();
115 
116 
117  //--------------------------------------------------------------------------
121 
125  //--------------------------------------------------------------------------
126  void render(std::vector<PolygonMesh*>& mesh_set,
127  Matrix4x4<float> const& proj_matrix);
128 
129 
130  //--------------------------------------------------------------------------
134 
139  //--------------------------------------------------------------------------
140  void render(std::vector<PolygonMesh*>& mesh_set,
141  Matrix4x4<float> const& proj_matrix,
142  std::vector< Matrix4x4<float> > const& model_matrix_set);
143 
144 
145  //--------------------------------------------------------------------------
147  //--------------------------------------------------------------------------
148  unsigned int getMapTexture() const;
149 
150 
151 //******************************************************************************
152 private:
154  DepthMap(DepthMap const&);
155 
156 
158  bool m_is_initialized;
159 
160 
161  Shader m_depth_shader;
162 
163 
165  unsigned int m_map_frame_buffer,
166  m_map_texture;
167 
168 
169  int m_map_size;
170 };
171 
172 
173 } // namespace gVirtualXRay
174 
175 
176 #endif // __DepthMap_h
Class to handle GLSL shaders.
void initialize()
Initialize the buffers.
DepthMap(int map_size=8192)
default constructor
Template class to handle a 4x4 matrixs.
unsigned int getMapTexture() const
Get the texture.
~DepthMap()
destructor
Shader is a class to handle shaders written in GLSL.
Definition: Shader.h:87
Some utility functions about OpenGL. Now supports GLSL450 and OpenGL 4.5.
DepthMap is a class to render to a buffer in order to create, for exemple, a shadow map...
Definition: DepthMap.h:90
Class to handle polygon (triangles) meshes.
Matrix4x4 is a template class to handle a 4 by 4 matrix.
Definition: Matrix4x4.h:89
void render(std::vector< PolygonMesh *> &mesh_set, Matrix4x4< float > const &proj_matrix)