VTK
vtkOpenGLVertexArrayObject.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 vtkOpenGLVertexArrayObject_h
15 #define vtkOpenGLVertexArrayObject_h
16 
17 #include "vtkRenderingOpenGL2Module.h" // for export macro
18 #include "vtkObject.h"
19 #include <string> // For API.
20 
21 class vtkShaderProgram;
24 
36 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLVertexArrayObject : public vtkObject
37 {
38 public:
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
43  void Bind();
44 
45  void Release();
46 
47  void ReleaseGraphicsResources();
48 
49  void ShaderProgramChanged();
50 
51  bool AddAttributeArray(vtkShaderProgram *program,
52  vtkOpenGLBufferObject *buffer,
53  const std::string &name, int offset, size_t stride,
54  int elementType, int elementTupleSize, bool normalize)
55  {
56  return this->AddAttributeArrayWithDivisor(program, buffer, name,
57  offset,stride,elementType, elementTupleSize, normalize, 0, false);
58  }
59 
60  bool AddAttributeArray(vtkShaderProgram *program,
62  const std::string &name, int offset, bool normalize);
63 
64  bool AddAttributeArrayWithDivisor(vtkShaderProgram *program,
65  vtkOpenGLBufferObject *buffer,
66  const std::string &name, int offset, size_t stride,
67  int elementType, int elementTupleSize, bool normalize,
68  int divisor, bool isMatrix);
69 
70  bool AddAttributeMatrixWithDivisor(vtkShaderProgram *program,
71  vtkOpenGLBufferObject *buffer,
72  const std::string &name, int offset, size_t stride,
73  int elementType, int elementTupleSize, bool normalize,
74  int divisor, int tupleOffset);
75 
76  bool RemoveAttributeArray(const std::string &name);
77 
78  // Force this VAO to emulate a vertex array object even if
79  // the system supports VAOs. This can be useful in cases where
80  // the vertex array object does not handle all extensions.
81  void SetForceEmulation(bool val);
82 
83 protected:
85  ~vtkOpenGLVertexArrayObject() override;
86 
87 private:
89  const vtkOpenGLVertexArrayObject&) = delete;
90  void operator=(const vtkOpenGLVertexArrayObject&) = delete;
91  class Private;
92  Private *Internal;
93 };
94 
95 #endif // vtkOpenGLVertexArrayObject_h
abstract base class for most VTK objects
Definition: vtkObject.h:59
a simple class to control print indentation
Definition: vtkIndent.h:39
The VertexArrayObject class uses, or emulates, vertex array objects.
OpenGL buffer object.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
The ShaderProgram uses one or more Shader objects.