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 
24 #ifndef vtkOpenGLContextDevice3D_h
25 #define vtkOpenGLContextDevice3D_h
26 
27 #include "vtkRenderingContextOpenGL2Module.h" // For export macro
28 #include "vtkContextDevice3D.h"
29 #include "vtkNew.h" // For ivars.
30 #include <vector> // STL Header
31 
32 class vtkBrush;
34 class vtkOpenGLHelper;
36 class vtkPen;
37 class vtkRenderer;
38 class vtkShaderProgram;
39 class vtkTransform;
40 
41 class VTKRENDERINGCONTEXTOPENGL2_EXPORT vtkOpenGLContextDevice3D : public vtkContextDevice3D
42 {
43 public:
45  void PrintSelf(ostream &os, vtkIndent indent);
46 
47  static vtkOpenGLContextDevice3D * New();
48 
50  void DrawPoly(const float *verts, int n, const unsigned char *colors, int nc);
51 
53  void DrawLines(const float *verts, int n, const unsigned char *colors, int nc);
54 
56 
57  void DrawPoints(const float *verts, int n,
58  const unsigned char *colors, int nc);
60 
62 
63  void DrawTriangleMesh(const float *mesh, int n,
64  const unsigned char *colors, int nc);
66 
71  void ApplyPen(vtkPen *pen);
72 
77  void ApplyBrush(vtkBrush *brush);
78 
80  void SetMatrix(vtkMatrix4x4 *m);
81 
83  void GetMatrix(vtkMatrix4x4 *m);
84 
87 
89  void PushMatrix();
90 
92  void PopMatrix();
93 
96  void SetClipping(const vtkRecti &rect);
97 
99  void EnableClipping(bool enable);
100 
102 
107  void EnableClippingPlane(int i, double *planeEquation);
108  void DisableClippingPlane(int i);
110 
112  void Initialize(vtkRenderer *, vtkOpenGLContextDevice2D *);
113 
115  virtual void Begin(vtkViewport* viewport);
116 
117 protected:
120 
122  virtual void EnableDepthBuffer();
123 
125  virtual void DisableDepthBuffer();
126 
127  vtkOpenGLHelper *VCBO; // vertex + color
128  void ReadyVCBOProgram();
129  vtkOpenGLHelper *VBO; // vertex
130  void ReadyVBOProgram();
131 
132  void SetMatrices(vtkShaderProgram *prog);
133  void BuildVBO(vtkOpenGLHelper *cbo,
134  const float *v, int nv,
135  const unsigned char *coolors, int nc,
136  float *tcoords);
137  void CoreDrawTriangles(std::vector<float> &tverts);
138 
139  // do we have wide lines that require special handling
140  virtual bool HaveWideLines();
141 
143 
146 
149 
150  std::vector<bool> ClippingPlaneStates;
151  std::vector<double> ClippingPlaneValues;
152 
153 private:
154  vtkOpenGLContextDevice3D(const vtkOpenGLContextDevice3D &); // Not implemented.
155  void operator=(const vtkOpenGLContextDevice3D &); // Not implemented.
156 
158 
159  class Private;
160  Private *Storage;
162 
163  // we need a pointer to this because only
164  // the 2D device gets a Begin and sets up
165  // the ortho matrix
166  vtkOpenGLContextDevice2D *Device2D;
167 
168  vtkNew<vtkBrush> Brush;
169  vtkNew<vtkPen> Pen;
170 };
171 
172 #endif
OpenGL rendering window.
virtual void MultiplyMatrix(vtkMatrix4x4 *m)=0
virtual void DrawTriangleMesh(const float *mesh, int n, const unsigned char *colors, int nc)=0
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
Abstract class for drawing 3D primitives.
virtual void DisableClippingPlane(int i)=0
abstract specification for Viewports
Definition: vtkViewport.h:46
Class for drawing 2D primitives using OpenGL 1.1+.
static vtkContextDevice3D * New()
abstract specification for renderers
Definition: vtkRenderer.h:63
std::vector< double > ClippingPlaneValues
virtual void ApplyPen(vtkPen *pen)=0
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
std::vector< bool > ClippingPlaneStates
vtkOpenGLRenderWindow * RenderWindow
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:36
virtual void SetMatrix(vtkMatrix4x4 *m)=0
virtual void DrawPoints(const float *verts, int n, const unsigned char *colors=0, int nc=0)=0
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void DrawLines(const float *verts, int n, const unsigned char *colors=0, int nc=0)=0
virtual void EnableClipping(bool enable)=0
virtual void SetClipping(const vtkRecti &rect)=0
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:38
virtual void PopMatrix()=0
virtual void ApplyBrush(vtkBrush *brush)=0
OpenGL class drawing 3D primitives.
virtual void PushMatrix()=0
virtual void GetMatrix(vtkMatrix4x4 *m)=0
virtual void DrawPoly(const float *verts, int n, const unsigned char *colors=0, int nc=0)=0
virtual void EnableClippingPlane(int i, double *planeEquation)=0
The ShaderProgram uses one or more Shader objects.