gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
VBO.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 __VBO_h
36 #define __VBO_h
37 
38 
66 //******************************************************************************
67 // Include
68 //******************************************************************************
69 #ifndef __gVirtualXRayConfig_h
71 #endif
72 
73 
74 //******************************************************************************
75 // namespace
76 //******************************************************************************
77 namespace gVirtualXRay {
78 
79 
80 //==============================================================================
85 //==============================================================================
86 class VBO
87 //------------------------------------------------------------------------------
88 {
89 //******************************************************************************
90 public:
91  //--------------------------------------------------------------------------
93  //--------------------------------------------------------------------------
94  VBO();
95 
96 
97  //--------------------------------------------------------------------------
99  //--------------------------------------------------------------------------
100  virtual ~VBO();
101 
102 
103  //--------------------------------------------------------------------------
105  //--------------------------------------------------------------------------
106  virtual void destroy();
107 
108 
109  //--------------------------------------------------------------------------
111  //--------------------------------------------------------------------------
112  void reset();
113 
114 
115  //--------------------------------------------------------------------------
117 
159  //--------------------------------------------------------------------------
160  virtual void setVertexData(int aPrimitiveType,
161  const unsigned int aNumberOfVertices = 0,
162  unsigned int aNumberOfCompontentsPerVertex = 0,
163  int aVertexDataType = 0,
164  const void* apVertices = 0,
165  const unsigned int aNumberOfNormals = 0,
166  unsigned int aNumberOfCompontentsPerNormal = 0,
167  int aNormalDataType = 0,
168  const void* apNormals = 0,
169  const unsigned int aNumberOfTextureCoordinates = 0,
170  unsigned int aNumberOfCompontentsPerCoord = 0,
171  int aCoordDataType = 0,
172  const void* apTextureCoordinates = 0,
173  const unsigned int aNumberOfAdditionalData = 0,
174  unsigned int aNumberOfCompontentsPerAdditionalData = 0,
175  int anAdditionalDataType = 0,
176  const void* apAdditionalData = 0) = 0;
177 
178 
179  //--------------------------------------------------------------------------
181 
188  //--------------------------------------------------------------------------
189  virtual void setIndexData(const unsigned int aNumberOfIndexes,
190  int anIndexDataType,
191  const void* apIndexSet) = 0;
192 
193 
194  //--------------------------------------------------------------------------
196  //--------------------------------------------------------------------------
197  virtual void display() const = 0;
198 
199 
200  //--------------------------------------------------------------------------
202 
205  //--------------------------------------------------------------------------
206  bool isReady() const;
207 
208 
209  //--------------------------------------------------------------------------
217 
220  //--------------------------------------------------------------------------
221  void setBufferUsageHint(int aFlag);
222 
223 
224  //--------------------------------------------------------------------------
226 
229  //--------------------------------------------------------------------------
230  int getBufferUsageHint() const;
231 
232 
233  //--------------------------------------------------------------------------
235 
238  //--------------------------------------------------------------------------
239  int getPrimitiveType() const;
240 
241 
242  //--------------------------------------------------------------------------
244 
248  //--------------------------------------------------------------------------
249  virtual VBO& operator=(const VBO& aVbo);
250 
251 
252  //--------------------------------------------------------------------------
254 
257  //--------------------------------------------------------------------------
258  unsigned int getOpenglMajorVersion() const;
259 
260 
261 //******************************************************************************
262 protected:
264  unsigned int m_id_set[5];
265 
266 
268  unsigned int m_number_of_normals;
269 
270 
273 
274 
277 
278 
281 
282 
285 
286 
289 
290 
292  unsigned int m_number_of_vertices;
293 
294 
297 
298 
300  unsigned int m_number_of_indices;
301 
302 
304  unsigned int m_normal_size;
305 
306 
309 
310 
313 
314 
316  unsigned int m_vertex_size;
317 
318 
320  unsigned int m_index_size;
321 
322 
325 
328 
329 
333 
334 
337 
338 
342 
343 
349 
350 
354 
355 
359 };
360 
361 
362 } // namespace gVirtualXRay
363 
364 
365 //******************************************************************************
366 #include "VBO.inl"
367 
368 
369 #endif // __VBO_h
unsigned int m_number_of_compontents_per_texture_coord
Number of components per texture coordinate.
Definition: VBO.h:288
int m_storage_type
Definition: VBO.h:353
virtual VBO & operator=(const VBO &aVbo)
Copy operator.
Definition: VBO.inl:130
unsigned int m_opengl_major_version
Definition: VBO.h:358
int m_texture_coordinate_data_type
Definition: VBO.h:332
int m_index_data_type
Definition: VBO.h:341
virtual void setIndexData(const unsigned int aNumberOfIndexes, int anIndexDataType, const void *apIndexSet)=0
Set the index.
unsigned int m_number_of_compontents_per_normal
Number of components per normal.
Definition: VBO.h:272
unsigned int m_number_of_indices
Number of indices.
Definition: VBO.h:300
virtual void destroy()
Release the data on the GPU.
unsigned int m_texture_coordinate_size
Size in bytes of the array of texture coordinates.
Definition: VBO.h:312
unsigned int m_additional_data_size
Size in bytes of the array of additional data.
Definition: VBO.h:308
unsigned int m_id_set[5]
ID of VBOs.
Definition: VBO.h:264
int getPrimitiveType() const
Accessor on the primitive type.
Definition: VBO.inl:122
unsigned int m_vertex_size
Size in bytes of the array of vertices.
Definition: VBO.h:316
VBO()
Default constructor.
virtual void display() const =0
Display the triangular mesh using OpenGL.
unsigned int getOpenglMajorVersion() const
Accessor on the major version of OpenGL that was used to create the VBO.
Definition: VBO.inl:164
Class to handle vertex buffer objects (VBOs).
unsigned int m_normal_size
Size in bytes of the array of normal vectors.
Definition: VBO.h:304
unsigned int m_number_of_normals
Number of normal vectors.
Definition: VBO.h:268
unsigned int m_number_of_compontents_per_vertex
Number of components per vertex.
Definition: VBO.h:296
unsigned int m_number_of_compontents_per_additional_data
Number of components per additional data.
Definition: VBO.h:280
unsigned int m_number_of_texture_coordinates
Number of texture coordinates.
Definition: VBO.h:284
int m_primitive_type
Definition: VBO.h:348
bool isReady() const
Check if the vertex buffer object is ready.
Definition: VBO.inl:98
int m_vertex_data_type
Data type of vertices; valid values are GL_FLOAT and GL_DOUBLE.
Definition: VBO.h:336
unsigned int m_index_size
Size in bytes of the array of indices.
Definition: VBO.h:320
VBO is a class to handle a vertex buffer object (VBO).
Definition: VBO.h:86
int m_additional_data_type
Data type of additional data; valid values are GL_FLOAT and GL_DOUBLE.
Definition: VBO.h:327
int m_normal_data_type
Data type of normal vectors; valid values are GL_FLOAT and GL_DOUBLE.
Definition: VBO.h:324
virtual ~VBO()
Destructor.
Definition: VBO.inl:90
void reset()
Reset the data.
int getBufferUsageHint() const
Accessor on the buffer usage hint.
Definition: VBO.inl:114
unsigned int m_number_of_additional_data
Number of additional data.
Definition: VBO.h:276
virtual void setVertexData(int aPrimitiveType, const unsigned int aNumberOfVertices=0, unsigned int aNumberOfCompontentsPerVertex=0, int aVertexDataType=0, const void *apVertices=0, const unsigned int aNumberOfNormals=0, unsigned int aNumberOfCompontentsPerNormal=0, int aNormalDataType=0, const void *apNormals=0, const unsigned int aNumberOfTextureCoordinates=0, unsigned int aNumberOfCompontentsPerCoord=0, int aCoordDataType=0, const void *apTextureCoordinates=0, const unsigned int aNumberOfAdditionalData=0, unsigned int aNumberOfCompontentsPerAdditionalData=0, int anAdditionalDataType=0, const void *apAdditionalData=0)=0
Set the vertex data.
unsigned int m_number_of_vertices
Number of vertices.
Definition: VBO.h:292
void setBufferUsageHint(int aFlag)
Definition: VBO.inl:106