Point Cloud Library (PCL) 1.12.0
Loading...
Searching...
No Matches
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
35class vtkCellArray;
36class vtkDataArray;
37class vtkObject;
38class vtkPoints;
39class vtkUnsignedCharArray;
40class vtkOpenGLExtensionManager;
41class vtkRenderWindow;
42
43class PCL_DEPRECATED(1, 13, "The OpenGL backend of VTK is deprecated. Please switch to the OpenGL2 backend.")
44PCL_EXPORTS vtkVertexBufferObject : public vtkObject
45{
46public:
47
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,
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
98 void SetUserDefinedAttribute(int index, bool normalized=false, int stride=0);
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.
158
159 // Description:
160 // Returns if the context supports the required extensions.
161 static bool IsSupported(vtkRenderWindow* renWin);
162
163//ETX
164//BTX
165protected:
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.
177
178 // Description:
179 // Destroys the pixel buffer object.
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
202
203 vtkWeakPointer<vtkRenderWindow> Context;
204
205
206private:
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};
bool Upload(vtkPoints *points)
bool Upload(vtkDataArray *array)
bool Upload(vtkDataArray *array, int attributeType, int arrayType)
vtkGetMacro(Size, unsigned int)
void ResetUserDefinedAttribute()
vtkSetMacro(Usage, int)
vtkGetMacro(Count, unsigned int)
bool UploadNormals(vtkDataArray *normals)
void SetUserDefinedAttribute(int index, bool normalized=false, int stride=0)
bool Upload(vtkUnsignedCharArray *colors)
bool Upload(unsigned int *indices, unsigned int count)
vtkGetMacro(ArrayType, unsigned int)
void PrintSelf(ostream &os, vtkIndent indent) override
bool Upload(vtkCellArray *verts)
vtkTypeMacro(vtkVertexBufferObject, vtkObject)
bool LoadRequiredExtensions(vtkOpenGLExtensionManager *mgr)
vtkRenderWindow * GetContext()
static bool IsSupported(vtkRenderWindow *renWin)
vtkGetMacro(Usage, int)
bool UploadColors(vtkDataArray *colors)
vtkGetMacro(Handle, unsigned int)
void SetAttributeNormalized(bool normalized)
static vtkVertexBufferObject * New()
void SetContext(vtkRenderWindow *context)
bool Upload(GLvoid *data)
vtkWeakPointer< vtkRenderWindow > Context
Defines all the PCL and non-PCL macros used.
#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