gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
VBO.inl
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2014, 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 
62 //******************************************************************************
63 // Include
64 //******************************************************************************
65 #include <cstring>
66 
67 #ifndef GVXR_OPENGL_UTILITIES_H
69 #endif
70 
71 
72 //******************************************************************************
73 // define
74 //******************************************************************************
75 #define VBO_BUFFER_OFFSET(a) ((char*)NULL + (a))
76 #define VERTEX_SET_ID 0
77 #define TEXT_COORD_SET_ID 1
78 #define NORMAL_SET_ID 2
79 #define ADDITIONAL_DATA_ID 3
80 #define INDEX_SET_ID 4
81 
82 
83 //******************************************************************************
84 // namespace
85 //******************************************************************************
86 namespace gVirtualXRay {
87 
88 
89 //----------------
90 inline VBO::~VBO()
91 //----------------
92 {
93  destroy();
94 }
95 
96 
97 //------------------------------
98 inline bool VBO::isReady() const
99 //-----------------------------
100 {
101  return ((m_number_of_vertices && m_id_set[0]) ? true : false);
102 }
103 
104 
105 //--------------------------------------------
106 inline void VBO::setBufferUsageHint(int aFlag)
107 //--------------------------------------------
108 {
109  m_storage_type = aFlag;
110 }
111 
112 
113 //----------------------------------------
114 inline int VBO::getBufferUsageHint() const
115 //----------------------------------------
116 {
117  return (m_storage_type);
118 }
119 
120 
121 //--------------------------------------
122 inline int VBO::getPrimitiveType() const
123 //--------------------------------------
124 {
125  return (m_primitive_type);
126 }
127 
128 
129 //-----------------------------------------
130 inline VBO& VBO::operator=(const VBO& aVBO)
131 //-----------------------------------------
132 {
133  memcpy(m_id_set, aVBO.m_id_set, sizeof(m_id_set));
134 
140 
145  m_index_size = aVBO.m_index_size;
146 
152 
154 
156 
158 
159  return (*this);
160 }
161 
162 
163 //----------------------------------------------------
164 inline unsigned int VBO::getOpenglMajorVersion() const
165 //----------------------------------------------------
166 {
167  return m_opengl_major_version;
168 }
169 
170 
171 } // namespace gVirtualXRay
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
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
unsigned int getOpenglMajorVersion() const
Accessor on the major version of OpenGL that was used to create the VBO.
Definition: VBO.inl:164
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_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
Some utility functions about OpenGL. Now supports GLSL450 and OpenGL 4.5.
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
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
unsigned int m_number_of_vertices
Number of vertices.
Definition: VBO.h:292
void setBufferUsageHint(int aFlag)
Definition: VBO.inl:106