VTK  9.3.0
vtkOpenGLContextDevice3D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
13 #ifndef vtkOpenGLContextDevice3D_h
14 #define vtkOpenGLContextDevice3D_h
15 
16 #include "vtkContextDevice3D.h"
17 #include "vtkNew.h" // For ivars.
18 #include "vtkRenderingContextOpenGL2Module.h" // For export macro
19 
20 #include <cstdint> // For std::uintptr_t
21 #include <vector> // STL Header
22 
23 VTK_ABI_NAMESPACE_BEGIN
24 class vtkBrush;
26 class vtkOpenGLHelper;
28 class vtkPen;
30 class vtkFloatArray;
31 class vtkRenderer;
32 class vtkShaderProgram;
33 class vtkTransform;
34 
35 class VTKRENDERINGCONTEXTOPENGL2_EXPORT vtkOpenGLContextDevice3D : public vtkContextDevice3D
36 {
37 public:
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
42 
46  void DrawPoly(const float* verts, int n, const unsigned char* colors, int nc) override;
47 
52  void DrawLines(const float* verts, int n, const unsigned char* colors, int nc) override;
53 
57  void DrawPoints(const float* verts, int n, const unsigned char* colors, int nc) override;
58  void DrawPoints(
59  vtkDataArray* positions, vtkUnsignedCharArray* colors, std::uintptr_t cacheIdentifier) override;
60 
64  void DrawTriangleMesh(const float* mesh, int n, const unsigned char* colors, int nc) override;
66  vtkDataArray* positions, vtkUnsignedCharArray* colors, std::uintptr_t cacheIdentifier) override;
67 
73  void ApplyPen(vtkPen* pen) override;
74 
80  void ApplyBrush(vtkBrush* brush) override;
81 
85  void SetMatrix(vtkMatrix4x4* m) override;
86 
90  void GetMatrix(vtkMatrix4x4* m) override;
91 
95  void MultiplyMatrix(vtkMatrix4x4* m) override;
96 
100  void PushMatrix() override;
101 
105  void PopMatrix() override;
106 
111  void SetClipping(const vtkRecti& rect) override;
112 
116  void EnableClipping(bool enable) override;
117 
119 
126  void EnableClippingPlane(int i, double* planeEquation) override;
127  void DisableClippingPlane(int i) override;
129 
134 
138  virtual void Begin(vtkViewport* viewport);
139 
143  void ReleaseCache(std::uintptr_t cacheIdentifier) override;
144 
145 protected:
148 
152  virtual void EnableDepthBuffer();
153 
157  virtual void DisableDepthBuffer();
158 
159  vtkOpenGLHelper* VCBO; // vertex + color
161  vtkOpenGLHelper* VBO; // vertex
163 
165  void BuildVBO(vtkOpenGLHelper* cbo, const float* v, int nv, const unsigned char* coolors, int nc,
166  float* tcoords);
167  void CoreDrawTriangles(std::vector<float>& tverts);
168 
169  // do we have wide lines that require special handling
170  virtual bool HaveWideLines();
171 
173 
178 
183 
184  std::vector<bool> ClippingPlaneStates;
185  std::vector<double> ClippingPlaneValues;
186 
187 private:
189  void operator=(const vtkOpenGLContextDevice3D&) = delete;
190 
192 
195  class Private;
196  Private* Storage;
198 
199  // we need a pointer to this because only
200  // the 2D device gets a Begin and sets up
201  // the ortho matrix
202  vtkOpenGLContextDevice2D* Device2D;
203 
204  vtkNew<vtkBrush> Brush;
205  vtkNew<vtkPen> Pen;
206 };
207 
208 VTK_ABI_NAMESPACE_END
209 #endif
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:39
Abstract class for drawing 3D primitives.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:40
a simple class to control print indentation
Definition: vtkIndent.h:38
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:40
Class for drawing 2D primitives using OpenGL 1.1+.
OpenGL class drawing 3D primitives.
void SetMatrices(vtkShaderProgram *prog)
void DrawLines(const float *verts, int n, const unsigned char *colors, int nc) override
Draw lines defined by specified pair of points.
std::vector< double > ClippingPlaneValues
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void ReleaseCache(std::uintptr_t cacheIdentifier) override
Ask the buffer object builder to erase cache entry for given identifier.
virtual void DisableDepthBuffer()
End drawing, turn off the depth buffer.
void ApplyBrush(vtkBrush *brush) override
Apply the supplied brush which controls the outlines of shapes, as well as lines, points and related ...
void CoreDrawTriangles(std::vector< float > &tverts)
void DrawPoints(vtkDataArray *positions, vtkUnsignedCharArray *colors, std::uintptr_t cacheIdentifier) override
void SetClipping(const vtkRecti &rect) override
Supply a float array of length 4 with x1, y1, width, height specifying clipping region for the device...
void DisableClippingPlane(int i) override
Enable/Disable the specified clipping plane.
void DrawPoly(const float *verts, int n, const unsigned char *colors, int nc) override
Draw a polyline between the specified points.
virtual bool HaveWideLines()
~vtkOpenGLContextDevice3D() override
void DrawTriangleMesh(const float *mesh, int n, const unsigned char *colors, int nc) override
Draw triangles to generate the specified mesh.
void SetMatrix(vtkMatrix4x4 *m) override
Set the model view matrix for the display.
void Initialize(vtkRenderer *, vtkOpenGLContextDevice2D *)
This must be set during initialization.
void EnableClipping(bool enable) override
Enable or disable the clipping of the scene.
void DrawTriangleMesh(vtkDataArray *positions, vtkUnsignedCharArray *colors, std::uintptr_t cacheIdentifier) override
virtual void EnableDepthBuffer()
Begin drawing, turn on the depth buffer.
void PopMatrix() override
Pop the current matrix off of the stack.
void MultiplyMatrix(vtkMatrix4x4 *m) override
Multiply the current model view matrix by the supplied one.
void DrawPoints(const float *verts, int n, const unsigned char *colors, int nc) override
Draw points at the vertex positions specified.
static vtkOpenGLContextDevice3D * New()
std::vector< bool > ClippingPlaneStates
vtkOpenGLRenderWindow * RenderWindow
The OpenGL render window being used by the device.
void BuildVBO(vtkOpenGLHelper *cbo, const float *v, int nv, const unsigned char *coolors, int nc, float *tcoords)
void GetMatrix(vtkMatrix4x4 *m) override
Set the model view matrix for the display.
void ApplyPen(vtkPen *pen) override
Apply the supplied pen which controls the outlines of shapes, as well as lines, points and related pr...
vtkRenderer * Renderer
We need to store a pointer to get the camera mats.
virtual void Begin(vtkViewport *viewport)
Begin drawing, pass in the viewport to set up the view.
void EnableClippingPlane(int i, double *planeEquation) override
Enable/Disable the specified clipping plane.
void PushMatrix() override
Push the current matrix onto the stack.
OpenGL rendering window.
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:38
abstract specification for renderers
Definition: vtkRenderer.h:71
The ShaderProgram uses one or more Shader objects.
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
dynamic, self-adjusting array of unsigned char
abstract specification for Viewports
Definition: vtkViewport.h:54