VTK
vtkOpenGLVertexBufferObject.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4 
5  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #ifndef vtkOpenGLVertexBufferObject_h
15 #define vtkOpenGLVertexBufferObject_h
16 
17 #include "vtkRenderingOpenGL2Module.h" // for export macro
18 #include "vtkOpenGLBufferObject.h"
19 
20 
29 // useful union for stuffing colors into a float
31 {
32  unsigned char c[4];
33  float f;
34 };
35 
36 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLVertexBufferObject :
38 {
39 public:
42  void PrintSelf(ostream& os, vtkIndent indent);
43 
44  // Take the points, and pack them into this VBO. This currently
45  // takes whatever the input type might be and packs them into a VBO using
46  // floats for the vertices and normals, and unsigned char for the colors (if
47  // the array is non-null).
48  void CreateVBO(vtkPoints *points, unsigned int numPoints,
49  vtkDataArray *normals,
50  vtkDataArray *tcoords,
51  unsigned char *colors, int colorComponents);
52 
53  void AppendVBO(vtkPoints *points, unsigned int numPoints,
54  vtkDataArray *normals,
55  vtkDataArray *tcoords,
56  unsigned char *colors, int colorComponents);
57 
58  // Sizes/offsets are all in bytes as OpenGL API expects them.
59  size_t VertexCount; // Number of vertices in the VBO
60  int Stride; // The size of a complete vertex + attributes
61  int VertexOffset; // Offset of the vertex
62  int NormalOffset; // Offset of the normal
63  int TCoordOffset; // Offset of the texture coordinates
64  int TCoordComponents; // Number of texture dimensions
65  int ColorOffset; // Offset of the color
66  int ColorComponents; // Number of color components
67  std::vector<float> PackedVBO; // the data
68 
69 protected:
72 
73 private:
75  void operator=(const vtkOpenGLVertexBufferObject&); // Not implemented
76 };
77 
78 #endif
void PrintSelf(ostream &os, vtkIndent indent)
OpenGL vertex buffer object.
unsigned char c[4]
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
static vtkOpenGLBufferObject * New()
OpenGL buffer object.
represent and manipulate 3D points
Definition: vtkPoints.h:38