Point Cloud Library (PCL)
1.12.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
visualization
vtk
vtkVertexBufferObject.h
1
/*=========================================================================
2
3
Program: Visualization Toolkit
4
Module: vtkPixelBufferObject.h
5
6
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7
All rights reserved.
8
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10
This software is distributed WITHOUT ANY WARRANTY; without even
11
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
PURPOSE. See the above copyright notice for more information.
13
14
=========================================================================*/
15
// .NAME vtkVertexBufferObject - abstracts an OpenGL vertex buffer object.
16
// .SECTION Description
17
// Provides low-level access to GPU memory. Used to pass raw data to GPU.
18
// The data is uploaded into a vertex buffer.
19
// .SECTION See Also
20
// OpenGL Vertex Buffer Object Extension Spec (ARB_vertex_buffer_object):
21
// http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt
22
// .SECTION Caveats
23
// Since most GPUs don't support double format all double data is converted to
24
// float and then uploaded.
25
// DON'T PLAY WITH IT YET.
26
27
#pragma once
28
29
#include "vtkObject.h"
30
#include "vtkWeakPointer.h"
31
32
#include "vtkgl.h"
// Needed for gl data types exposed in API
33
#include <
pcl/pcl_macros.h
>
34
35
class
vtkCellArray;
36
class
vtkDataArray;
37
class
vtkObject;
38
class
vtkPoints;
39
class
vtkUnsignedCharArray;
40
class
vtkOpenGLExtensionManager;
41
class
vtkRenderWindow;
42
43
class
PCL_DEPRECATED
(1, 13,
"The OpenGL backend of VTK is deprecated. Please switch to the OpenGL2 backend."
)
44
PCL_EXPORTS
vtkVertexBufferObject
:
public
vtkObject
45
{
46
public
:
47
48
static
vtkVertexBufferObject
*
New
();
49
vtkTypeMacro
(
vtkVertexBufferObject
, vtkObject);
50
void
PrintSelf
(ostream& os, vtkIndent indent)
override
;
51
52
// Description:
53
// Get/Set the context. Context must be a vtkOpenGLRenderWindow.
54
// This does not increase the reference count of the
55
// context to avoid reference loops.
56
// SetContext() may raise an error is the OpenGL context does not support the
57
// required OpenGL extensions.
58
void
SetContext
(vtkRenderWindow* context);
59
vtkRenderWindow*
GetContext
();
60
61
//BTX
62
// Usage values.
63
enum
64
{
65
StreamDraw
=0,
66
StreamRead
,
67
StreamCopy
,
68
StaticDraw
,
69
StaticRead
,
70
StaticCopy
,
71
DynamicDraw
,
72
DynamicRead
,
73
DynamicCopy
,
74
NumberOfUsages
75
};
76
//ETX
77
78
// Description:
79
// Usage is a performance hint.
80
// Valid values are:
81
// - StreamDraw specified once by A, used few times S
82
// - StreamRead specified once by R, queried a few times by A
83
// - StreamCopy specified once by R, used a few times S
84
// - StaticDraw specified once by A, used many times S
85
// - StaticRead specified once by R, queried many times by A
86
// - StaticCopy specified once by R, used many times S
87
// - DynamicDraw respecified repeatedly by A, used many times S
88
// - DynamicRead respecified repeatedly by R, queried many times by A
89
// - DynamicCopy respecified repeatedly by R, used many times S
90
// A: the application
91
// S: as the source for GL drawing and image specification commands.
92
// R: reading data from the GL
93
// Initial value is StaticDraw, as in OpenGL spec.
94
vtkGetMacro
(
Usage
,
int
);
95
vtkSetMacro
(
Usage
,
int
);
96
97
int
GetAttributeIndex
();
98
void
SetUserDefinedAttribute
(
int
index,
bool
normalized=
false
,
int
stride=0);
99
void
ResetUserDefinedAttribute
();
100
101
void
SetAttributeNormalized
(
bool
normalized);
102
103
// Description:
104
// Set point data
105
bool
Upload
(vtkPoints *points);
106
107
// Description:
108
// Set indice data
109
bool
Upload
(vtkCellArray *verts);
110
111
// Description:
112
// Set indice data
113
bool
Upload
(
unsigned
int
*indices,
unsigned
int
count);
114
115
// Description:
116
// Set color data
117
bool
Upload
(vtkUnsignedCharArray *colors);
118
119
// Description:
120
// Set color data
121
bool
Upload
(vtkDataArray *array);
122
bool
Upload
(vtkDataArray *array,
int
attributeType,
int
arrayType);
123
bool
UploadNormals
(vtkDataArray *normals);
124
bool
UploadColors
(vtkDataArray *colors);
125
126
127
// Description:
128
// Get the size of the data loaded into the GPU. Size is in the number of
129
// elements of the uploaded Type.
130
vtkGetMacro
(
Size
,
unsigned
int
);
131
132
// Description:
133
// Get the size of the data loaded into the GPU. Size is in the number of
134
// elements of the uploaded Type.
135
vtkGetMacro
(
Count
,
unsigned
int
);
136
137
// Description:
138
// Get the openGL buffer handle.
139
vtkGetMacro
(
Handle
,
unsigned
int
);
140
141
// Description:
142
// Inactivate the buffer.
143
void
UnBind
();
144
145
// Description:
146
// Make the buffer active.
147
void
Bind
();
148
149
// Description:
150
// Allocate the memory. size is in number of bytes. type is a VTK type.
151
// void Allocate(unsigned int size, int type);
152
153
//BTX
154
155
// Description:
156
// Release the memory allocated without destroying the PBO handle.
157
void
ReleaseMemory
();
158
159
// Description:
160
// Returns if the context supports the required extensions.
161
static
bool
IsSupported
(vtkRenderWindow* renWin);
162
163
//ETX
164
//BTX
165
protected
:
166
vtkVertexBufferObject
();
167
~vtkVertexBufferObject
();
168
169
// Description:
170
// Loads all required OpenGL extensions. Must be called every time a new
171
// context is set.
172
bool
LoadRequiredExtensions
(vtkOpenGLExtensionManager* mgr);
173
174
// Description:
175
// Create the pixel buffer object.
176
void
CreateBuffer
();
177
178
// Description:
179
// Destroys the pixel buffer object.
180
void
DestroyBuffer
();
181
182
// Description:
183
// Uploads data to buffer object
184
bool
Upload
(GLvoid* data);
185
186
// Description:
187
// Get the openGL buffer handle.
188
vtkGetMacro
(
ArrayType
,
unsigned
int
);
189
190
int
Usage
;
191
unsigned
int
Size
;
192
unsigned
int
Count
;
193
unsigned
int
Handle
;
194
unsigned
int
ArrayType
;
195
unsigned
int
BufferTarget
;
196
197
int
AttributeIndex
;
198
int
AttributeSize
;
199
int
AttributeType
;
200
int
AttributeNormalized
;
201
int
AttributeStride
;
202
203
vtkWeakPointer<vtkRenderWindow>
Context
;
204
205
206
private
:
207
vtkVertexBufferObject
(
const
vtkVertexBufferObject
&);
// Not implemented.
208
void
operator=(
const
vtkVertexBufferObject
&);
// Not implemented.
209
210
// Helper to get data type sizes when passing to opengl
211
int
GetDataTypeSize(
int
type);
212
//ETX
213
};
vtkVertexBufferObject::vtkVertexBufferObject
vtkVertexBufferObject()
vtkVertexBufferObject::Upload
bool Upload(vtkPoints *points)
vtkVertexBufferObject::Upload
bool Upload(vtkDataArray *array)
vtkVertexBufferObject::Upload
bool Upload(vtkDataArray *array, int attributeType, int arrayType)
vtkVertexBufferObject::Size
unsigned int Size
Definition
vtkVertexBufferObject.h:191
vtkVertexBufferObject::StreamRead
@ StreamRead
Definition
vtkVertexBufferObject.h:66
vtkVertexBufferObject::DynamicRead
@ DynamicRead
Definition
vtkVertexBufferObject.h:72
vtkVertexBufferObject::StaticRead
@ StaticRead
Definition
vtkVertexBufferObject.h:69
vtkVertexBufferObject::DynamicDraw
@ DynamicDraw
Definition
vtkVertexBufferObject.h:71
vtkVertexBufferObject::StreamCopy
@ StreamCopy
Definition
vtkVertexBufferObject.h:67
vtkVertexBufferObject::DynamicCopy
@ DynamicCopy
Definition
vtkVertexBufferObject.h:73
vtkVertexBufferObject::StaticDraw
@ StaticDraw
Definition
vtkVertexBufferObject.h:68
vtkVertexBufferObject::StreamDraw
@ StreamDraw
Definition
vtkVertexBufferObject.h:65
vtkVertexBufferObject::StaticCopy
@ StaticCopy
Definition
vtkVertexBufferObject.h:70
vtkVertexBufferObject::NumberOfUsages
@ NumberOfUsages
Definition
vtkVertexBufferObject.h:74
vtkVertexBufferObject::vtkGetMacro
vtkGetMacro(Size, unsigned int)
vtkVertexBufferObject::Handle
unsigned int Handle
Definition
vtkVertexBufferObject.h:193
vtkVertexBufferObject::GetAttributeIndex
int GetAttributeIndex()
vtkVertexBufferObject::DestroyBuffer
void DestroyBuffer()
vtkVertexBufferObject::ResetUserDefinedAttribute
void ResetUserDefinedAttribute()
vtkVertexBufferObject::vtkSetMacro
vtkSetMacro(Usage, int)
vtkVertexBufferObject::vtkGetMacro
vtkGetMacro(Count, unsigned int)
vtkVertexBufferObject::CreateBuffer
void CreateBuffer()
vtkVertexBufferObject::AttributeIndex
int AttributeIndex
Definition
vtkVertexBufferObject.h:197
vtkVertexBufferObject::UploadNormals
bool UploadNormals(vtkDataArray *normals)
vtkVertexBufferObject::SetUserDefinedAttribute
void SetUserDefinedAttribute(int index, bool normalized=false, int stride=0)
vtkVertexBufferObject::Upload
bool Upload(vtkUnsignedCharArray *colors)
vtkVertexBufferObject::Upload
bool Upload(unsigned int *indices, unsigned int count)
vtkVertexBufferObject::vtkGetMacro
vtkGetMacro(ArrayType, unsigned int)
vtkVertexBufferObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
vtkVertexBufferObject::BufferTarget
unsigned int BufferTarget
Definition
vtkVertexBufferObject.h:195
vtkVertexBufferObject::Upload
bool Upload(vtkCellArray *verts)
vtkVertexBufferObject::vtkTypeMacro
vtkTypeMacro(vtkVertexBufferObject, vtkObject)
vtkVertexBufferObject::AttributeNormalized
int AttributeNormalized
Definition
vtkVertexBufferObject.h:200
vtkVertexBufferObject::LoadRequiredExtensions
bool LoadRequiredExtensions(vtkOpenGLExtensionManager *mgr)
vtkVertexBufferObject::GetContext
vtkRenderWindow * GetContext()
vtkVertexBufferObject::IsSupported
static bool IsSupported(vtkRenderWindow *renWin)
vtkVertexBufferObject::ReleaseMemory
void ReleaseMemory()
vtkVertexBufferObject::~vtkVertexBufferObject
~vtkVertexBufferObject()
vtkVertexBufferObject::vtkGetMacro
vtkGetMacro(Usage, int)
vtkVertexBufferObject::AttributeSize
int AttributeSize
Definition
vtkVertexBufferObject.h:198
vtkVertexBufferObject::UploadColors
bool UploadColors(vtkDataArray *colors)
vtkVertexBufferObject::vtkGetMacro
vtkGetMacro(Handle, unsigned int)
vtkVertexBufferObject::SetAttributeNormalized
void SetAttributeNormalized(bool normalized)
vtkVertexBufferObject::New
static vtkVertexBufferObject * New()
vtkVertexBufferObject::Bind
void Bind()
vtkVertexBufferObject::ArrayType
unsigned int ArrayType
Definition
vtkVertexBufferObject.h:194
vtkVertexBufferObject::SetContext
void SetContext(vtkRenderWindow *context)
vtkVertexBufferObject::AttributeType
int AttributeType
Definition
vtkVertexBufferObject.h:199
vtkVertexBufferObject::Usage
int Usage
Definition
vtkVertexBufferObject.h:190
vtkVertexBufferObject::AttributeStride
int AttributeStride
Definition
vtkVertexBufferObject.h:201
vtkVertexBufferObject::Count
unsigned int Count
Definition
vtkVertexBufferObject.h:192
vtkVertexBufferObject::Upload
bool Upload(GLvoid *data)
vtkVertexBufferObject::Context
vtkWeakPointer< vtkRenderWindow > Context
Definition
vtkVertexBufferObject.h:203
vtkVertexBufferObject::UnBind
void UnBind()
pcl_macros.h
Defines all the PCL and non-PCL macros used.
PCL_DEPRECATED
#define PCL_DEPRECATED(Major, Minor, Message)
macro for compatibility across compilers and help remove old deprecated items for the Major....
Definition
pcl_macros.h:156