VTK
vtkOpenGLContextDevice3D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOpenGLContextDevice3D.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 
25 #ifndef vtkOpenGLContextDevice3D_h
26 #define vtkOpenGLContextDevice3D_h
27 
28 #include "vtkRenderingContextOpenGL2Module.h" // For export macro
29 #include "vtkContextDevice3D.h"
30 #include "vtkNew.h" // For ivars.
31 #include <vector> // STL Header
32 
33 class vtkBrush;
35 class vtkOpenGLHelper;
37 class vtkPen;
38 class vtkRenderer;
39 class vtkShaderProgram;
40 class vtkTransform;
41 
42 class VTKRENDERINGCONTEXTOPENGL2_EXPORT vtkOpenGLContextDevice3D : public vtkContextDevice3D
43 {
44 public:
46  void PrintSelf(ostream &os, vtkIndent indent) override;
47 
48  static vtkOpenGLContextDevice3D * New();
49 
53  void DrawPoly(const float *verts, int n, const unsigned char *colors, int nc) override;
54 
59  void DrawLines(const float *verts, int n, const unsigned char *colors, int nc) override;
60 
64  void DrawPoints(const float *verts, int n,
65  const unsigned char *colors, int nc) override;
66 
70  void DrawTriangleMesh(const float *mesh, int n,
71  const unsigned char *colors, int nc) override;
72 
78  void ApplyPen(vtkPen *pen) override;
79 
85  void ApplyBrush(vtkBrush *brush) override;
86 
90  void SetMatrix(vtkMatrix4x4 *m) override;
91 
95  void GetMatrix(vtkMatrix4x4 *m) override;
96 
100  void MultiplyMatrix(vtkMatrix4x4 *m) override;
101 
105  void PushMatrix() override;
106 
110  void PopMatrix() override;
111 
116  void SetClipping(const vtkRecti &rect) override;
117 
121  void EnableClipping(bool enable) override;
122 
124 
131  void EnableClippingPlane(int i, double *planeEquation) override;
132  void DisableClippingPlane(int i) override;
134 
138  void Initialize(vtkRenderer *, vtkOpenGLContextDevice2D *);
139 
143  virtual void Begin(vtkViewport* viewport);
144 
145 protected:
147  ~vtkOpenGLContextDevice3D() override;
148 
152  virtual void EnableDepthBuffer();
153 
157  virtual void DisableDepthBuffer();
158 
159  vtkOpenGLHelper *VCBO; // vertex + color
160  void ReadyVCBOProgram();
161  vtkOpenGLHelper *VBO; // vertex
162  void ReadyVBOProgram();
163 
164  void SetMatrices(vtkShaderProgram *prog);
165  void BuildVBO(vtkOpenGLHelper *cbo,
166  const float *v, int nv,
167  const unsigned char *coolors, int nc,
168  float *tcoords);
169  void CoreDrawTriangles(std::vector<float> &tverts);
170 
171  // do we have wide lines that require special handling
172  virtual bool HaveWideLines();
173 
175 
180 
185 
186  std::vector<bool> ClippingPlaneStates;
187  std::vector<double> ClippingPlaneValues;
188 
189 private:
191  void operator=(const vtkOpenGLContextDevice3D &) = delete;
192 
194 
197  class Private;
198  Private *Storage;
200 
201  // we need a pointer to this because only
202  // the 2D device gets a Begin and sets up
203  // the ortho matrix
204  vtkOpenGLContextDevice2D *Device2D;
205 
206  vtkNew<vtkBrush> Brush;
207  vtkNew<vtkPen> Pen;
208 };
209 
210 #endif
OpenGL rendering window.
virtual void MultiplyMatrix(vtkMatrix4x4 *m)=0
Multiply the current model view matrix by the supplied one.
virtual void DrawTriangleMesh(const float *mesh, int n, const unsigned char *colors, int nc)=0
Draw triangles to generate the specified mesh.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
Abstract class for drawing 3D primitives.
virtual void DisableClippingPlane(int i)=0
Enable/Disable the specified clipping plane.
abstract specification for Viewports
Definition: vtkViewport.h:47
Class for drawing 2D primitives using OpenGL 1.1+.
static vtkContextDevice3D * New()
abstract specification for renderers
Definition: vtkRenderer.h:63
std::vector< double > ClippingPlaneValues
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void ApplyPen(vtkPen *pen)=0
Apply the supplied pen which controls the outlines of shapes, as well as lines, points and related pr...
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
virtual void DrawPoly(const float *verts, int n, const unsigned char *colors=nullptr, int nc=0)=0
Draw a polyline between the specified points.
std::vector< bool > ClippingPlaneStates
vtkOpenGLRenderWindow * RenderWindow
The OpenGL render window being used by the device.
vtkRenderer * Renderer
We need to store a pointer to get the camera mats.
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:40
virtual void SetMatrix(vtkMatrix4x4 *m)=0
Set the model view matrix for the display.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void DrawPoints(const float *verts, int n, const unsigned char *colors=nullptr, int nc=0)=0
Draw points at the vertex positions specified.
virtual void DrawLines(const float *verts, int n, const unsigned char *colors=nullptr, int nc=0)=0
Draw lines defined by specified pair of points.
virtual void EnableClipping(bool enable)=0
Enable or disable the clipping of the scene.
virtual void SetClipping(const vtkRecti &rect)=0
Supply a float array of length 4 with x1, y1, width, height specifying clipping region for the device...
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:39
virtual void PopMatrix()=0
Pop the current matrix off of the stack.
virtual void ApplyBrush(vtkBrush *brush)=0
Apply the supplied brush which controls the outlines of shapes, as well as lines, points and related ...
OpenGL class drawing 3D primitives.
virtual void PushMatrix()=0
Push the current matrix onto the stack.
virtual void GetMatrix(vtkMatrix4x4 *m)=0
Set the model view matrix for the display.
virtual void EnableClippingPlane(int i, double *planeEquation)=0
Enable/Disable the specified clipping plane.
The ShaderProgram uses one or more Shader objects.