VTK  9.1.0
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 "vtkContextDevice3D.h"
29#include "vtkNew.h" // For ivars.
30#include "vtkRenderingContextOpenGL2Module.h" // For export macro
31#include <vector> // STL Header
32
33class vtkBrush;
35class vtkOpenGLHelper;
37class vtkPen;
38class vtkRenderer;
40class vtkTransform;
41
42class VTKRENDERINGCONTEXTOPENGL2_EXPORT vtkOpenGLContextDevice3D : public vtkContextDevice3D
43{
44public:
46 void PrintSelf(ostream& os, vtkIndent indent) override;
47
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, const unsigned char* colors, int nc) override;
65
69 void DrawTriangleMesh(const float* mesh, int n, const unsigned char* colors, int nc) override;
70
76 void ApplyPen(vtkPen* pen) override;
77
83 void ApplyBrush(vtkBrush* brush) override;
84
88 void SetMatrix(vtkMatrix4x4* m) override;
89
93 void GetMatrix(vtkMatrix4x4* m) override;
94
98 void MultiplyMatrix(vtkMatrix4x4* m) override;
99
103 void PushMatrix() override;
104
108 void PopMatrix() override;
109
114 void SetClipping(const vtkRecti& rect) override;
115
119 void EnableClipping(bool enable) override;
120
122
129 void EnableClippingPlane(int i, double* planeEquation) override;
130 void DisableClippingPlane(int i) override;
132
137
141 virtual void Begin(vtkViewport* viewport);
142
143protected:
146
150 virtual void EnableDepthBuffer();
151
155 virtual void DisableDepthBuffer();
156
157 vtkOpenGLHelper* VCBO; // vertex + color
161
163 void BuildVBO(vtkOpenGLHelper* cbo, const float* v, int nv, const unsigned char* coolors, int nc,
164 float* tcoords);
165 void CoreDrawTriangles(std::vector<float>& tverts);
166
167 // do we have wide lines that require special handling
168 virtual bool HaveWideLines();
169
171
176
181
182 std::vector<bool> ClippingPlaneStates;
183 std::vector<double> ClippingPlaneValues;
184
185private:
187 void operator=(const vtkOpenGLContextDevice3D&) = delete;
188
190
193 class Private;
194 Private* Storage;
196
197 // we need a pointer to this because only
198 // the 2D device gets a Begin and sets up
199 // the ortho matrix
200 vtkOpenGLContextDevice2D* Device2D;
201
202 vtkNew<vtkBrush> Brush;
203 vtkNew<vtkPen> Pen;
204};
205
206#endif
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:97
Abstract class for drawing 3D primitives.
a simple class to control print indentation
Definition: vtkIndent.h:113
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
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.
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)
static vtkOpenGLContextDevice3D * New()
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.
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.
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:136
abstract specification for renderers
Definition: vtkRenderer.h:173
The ShaderProgram uses one or more Shader objects.
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
abstract specification for Viewports
Definition: vtkViewport.h:47