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);
47 
49 
53  void DrawPoly(const float *verts, int n, const unsigned char *colors, int nc);
54 
59  void DrawLines(const float *verts, int n, const unsigned char *colors, int nc);
60 
64  void DrawPoints(const float *verts, int n,
65  const unsigned char *colors, int nc);
66 
70  void DrawTriangleMesh(const float *mesh, int n,
71  const unsigned char *colors, int nc);
72 
78  void ApplyPen(vtkPen *pen);
79 
85  void ApplyBrush(vtkBrush *brush);
86 
91 
96 
101 
105  void PushMatrix();
106 
110  void PopMatrix();
111 
116  void SetClipping(const vtkRecti &rect);
117 
121  void EnableClipping(bool enable);
122 
124 
131  void EnableClippingPlane(int i, double *planeEquation);
132  void DisableClippingPlane(int i);
134 
139 
143  virtual void Begin(vtkViewport* viewport);
144 
145 protected:
148 
152  virtual void EnableDepthBuffer();
153 
157  virtual void DisableDepthBuffer();
158 
159  vtkOpenGLHelper *VCBO; // vertex + color
161  vtkOpenGLHelper *VBO; // vertex
163 
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:
190  vtkOpenGLContextDevice3D(const vtkOpenGLContextDevice3D &) VTK_DELETE_FUNCTION;
191  void operator=(const vtkOpenGLContextDevice3D &) VTK_DELETE_FUNCTION;
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
vtkBrush
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:38
vtkOpenGLContextDevice3D::Renderer
vtkRenderer * Renderer
We need to store a pointer to get the camera mats.
Definition: vtkOpenGLContextDevice3D.h:184
vtkOpenGLContextDevice3D
OpenGL class drawing 3D primitives.
Definition: vtkOpenGLContextDevice3D.h:36
vtkOpenGLContextDevice3D::EnableClippingPlane
void EnableClippingPlane(int i, double *planeEquation)
Enable/Disable the specified clipping plane.
vtkOpenGLContextDevice3D::PopMatrix
void PopMatrix()
Pop the current matrix off of the stack.
vtkOpenGLContextDevice3D::DrawLines
void DrawLines(const float *verts, int n, const unsigned char *colors, int nc)
Draw lines defined by specified pair of points.
vtkOpenGLContextDevice3D::BuildVBO
void BuildVBO(vtkOpenGLHelper *cbo, const float *v, int nv, const unsigned char *coolors, int nc, float *tcoords)
vtkOpenGLContextDevice3D::ApplyBrush
void ApplyBrush(vtkBrush *brush)
Apply the supplied brush which controls the outlines of shapes, as well as lines, points and related ...
vtkOpenGLContextDevice3D::ReadyVCBOProgram
void ReadyVCBOProgram()
vtkContextDevice3D
Abstract class for drawing 3D primitives.
Definition: vtkContextDevice3D.h:42
vtkOpenGLContextDevice3D::VCBO
vtkOpenGLHelper * VCBO
Definition: vtkOpenGLContextDevice3D.h:159
vtkOpenGLContextDevice3D::Initialize
void Initialize(vtkRenderer *, vtkOpenGLContextDevice2D *)
This must be set during initialization.
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
vtkOpenGLContextDevice3D::ReadyVBOProgram
void ReadyVBOProgram()
vtkOpenGLContextDevice3D::ClippingPlaneValues
std::vector< double > ClippingPlaneValues
Definition: vtkOpenGLContextDevice3D.h:187
vtkOpenGLContextDevice3D::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkOpenGLContextDevice3D::ModelMatrix
vtkTransform * ModelMatrix
Definition: vtkOpenGLContextDevice3D.h:174
vtkOpenGLContextDevice3D::HaveWideLines
virtual bool HaveWideLines()
vtkOpenGLContextDevice3D::SetMatrix
void SetMatrix(vtkMatrix4x4 *m)
Set the model view matrix for the display.
vtkOpenGLContextDevice2D
Class for drawing 2D primitives using OpenGL 1.1+.
Definition: vtkOpenGLContextDevice2D.h:46
vtkOpenGLContextDevice3D::CoreDrawTriangles
void CoreDrawTriangles(std::vector< float > &tverts)
vtkShaderProgram
The ShaderProgram uses one or more Shader objects.
Definition: vtkShaderProgram.h:45
vtkOpenGLContextDevice3D::DrawPoly
void DrawPoly(const float *verts, int n, const unsigned char *colors, int nc)
Draw a polyline between the specified points.
vtkOpenGLHelper
Definition: vtkOpenGLHelper.h:31
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
vtkOpenGLContextDevice3D::DrawPoints
void DrawPoints(const float *verts, int n, const unsigned char *colors, int nc)
Draw points at the vertex positions specified.
vtkOpenGLContextDevice3D::~vtkOpenGLContextDevice3D
~vtkOpenGLContextDevice3D()
vtkContextDevice3D.h
vtkOpenGLContextDevice3D::EnableClipping
void EnableClipping(bool enable)
Enable or disable the clipping of the scene.
vtkOpenGLContextDevice3D::DrawTriangleMesh
void DrawTriangleMesh(const float *mesh, int n, const unsigned char *colors, int nc)
Draw triangles to generate the specified mesh.
vtkNew< vtkBrush >
vtkOpenGLContextDevice3D::ApplyPen
void ApplyPen(vtkPen *pen)
Apply the supplied pen which controls the outlines of shapes, as well as lines, points and related pr...
vtkOpenGLContextDevice3D::GetMatrix
void GetMatrix(vtkMatrix4x4 *m)
Set the model view matrix for the display.
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:48
vtkOpenGLContextDevice3D::DisableDepthBuffer
virtual void DisableDepthBuffer()
End drawing, turn off the depth buffer.
vtkNew.h
vtkOpenGLContextDevice3D::Begin
virtual void Begin(vtkViewport *viewport)
Begin drawing, pass in the viewport to set up the view.
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:64
vtkOpenGLContextDevice3D::New
static vtkOpenGLContextDevice3D * New()
vtkOpenGLContextDevice3D::DisableClippingPlane
void DisableClippingPlane(int i)
vtkOpenGLContextDevice3D::RenderWindow
vtkOpenGLRenderWindow * RenderWindow
The OpenGL render window being used by the device.
Definition: vtkOpenGLContextDevice3D.h:179
vtkOpenGLContextDevice3D::EnableDepthBuffer
virtual void EnableDepthBuffer()
Begin drawing, turn on the depth buffer.
vtkRecti
Definition: vtkRect.h:288
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:39
vtkOpenGLContextDevice3D::PushMatrix
void PushMatrix()
Push the current matrix onto the stack.
vtkPen
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:40
vtkOpenGLContextDevice3D::SetMatrices
void SetMatrices(vtkShaderProgram *prog)
vtkOpenGLContextDevice3D::vtkOpenGLContextDevice3D
vtkOpenGLContextDevice3D()
vtkOpenGLContextDevice3D::VBO
vtkOpenGLHelper * VBO
Definition: vtkOpenGLContextDevice3D.h:161
vtkOpenGLContextDevice3D::ClippingPlaneStates
std::vector< bool > ClippingPlaneStates
Definition: vtkOpenGLContextDevice3D.h:186
vtkOpenGLContextDevice3D::MultiplyMatrix
void MultiplyMatrix(vtkMatrix4x4 *m)
Multiply the current model view matrix by the supplied one.
vtkOpenGLContextDevice3D::SetClipping
void SetClipping(const vtkRecti &rect)
Supply a float array of length 4 with x1, y1, width, height specifying clipping region for the device...