vtkOpenGLPolyDataMapper2D.h 4.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkOpenGLPolyDataMapper2D.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
// .NAME vtkOpenGLPolyDataMapper2D - 2D PolyData support for OpenGL
// .SECTION Description
// vtkOpenGLPolyDataMapper2D provides 2D PolyData annotation support for
// vtk under OpenGL.  Normally the user should use vtkPolyDataMapper2D
// which in turn will use this class.

// .SECTION See Also
// vtkPolyDataMapper2D

24 25
#ifndef vtkOpenGLPolyDataMapper2D_h
#define vtkOpenGLPolyDataMapper2D_h
26 27 28

#include "vtkRenderingOpenGL2Module.h" // For export macro
#include "vtkPolyDataMapper2D.h"
Ken Martin's avatar
Ken Martin committed
29
#include "vtkOpenGLHelper.h" // used for ivars
Ken Martin's avatar
Ken Martin committed
30
#include <string> // For API.
Ken Martin's avatar
Ken Martin committed
31
#include <vector> //for ivars
32

Ken Martin's avatar
Ken Martin committed
33 34 35
class vtkOpenGLBufferObject;
class vtkOpenGLHelper;
class vtkOpenGLVertexBufferObject;
Ken Martin's avatar
Ken Martin committed
36
class vtkPoints;
Ken Martin's avatar
Ken Martin committed
37
class vtkRenderer;
38
class vtkTextureObject;
39

40
class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLPolyDataMapper2D : public vtkPolyDataMapper2D
41 42
{
public:
43 44
  vtkTypeMacro(vtkOpenGLPolyDataMapper2D, vtkPolyDataMapper2D);
  static vtkOpenGLPolyDataMapper2D *New();
45 46 47 48 49 50
  virtual void PrintSelf(ostream& os, vtkIndent indent);

  // Description:
  // Actually draw the poly data.
  void RenderOverlay(vtkViewport* viewport, vtkActor2D* actor);

51 52 53 54 55 56
  // Description:
  // Release any graphics resources that are being consumed by this mapper.
  // The parameter window could be used to determine which graphic
  // resources to release.
  void ReleaseGraphicsResources(vtkWindow *);

57
protected:
58 59
  vtkOpenGLPolyDataMapper2D();
  ~vtkOpenGLPolyDataMapper2D();
60

Ken Martin's avatar
Ken Martin committed
61 62 63 64 65 66 67 68
  // the following is all extra stuff to work around the
  // fact that gl_PrimitiveID does not work correctly on
  // Apple devices with AMD graphics hardware. See apple
  // bug ID 20747550
  bool HaveAppleBug;
  std::vector<float> AppleBugPrimIDs;
  vtkOpenGLBufferObject *AppleBugPrimIDBuffer;

69 70
  // Description:
  // Does the shader source need to be recomputed
71 72
  virtual bool GetNeedToRebuildShaders(
    vtkOpenGLHelper &cellBO, vtkViewport *ren, vtkActor2D *act);
73

74 75
  // Description:
  // Build the shader source code
76
  virtual void BuildShaders(std::string &VertexCode,
77 78 79
                           std::string &fragmentCode,
                           std::string &geometryCode,
                           vtkViewport *ren, vtkActor2D *act);
Ken Martin's avatar
Ken Martin committed
80

81 82
  // Description:
  // Determine what shader to use and compile/link it
83 84
  virtual void UpdateShaders(vtkOpenGLHelper &cellBO,
    vtkViewport *viewport, vtkActor2D *act);
85

86 87
  // Description:
  // Set the shader parameteres related to the mapper/input data, called by UpdateShader
Ken Martin's avatar
Ken Martin committed
88
  virtual void SetMapperShaderParameters(vtkOpenGLHelper &cellBO, vtkViewport *ren, vtkActor2D *act);
89 90


Ken Martin's avatar
Ken Martin committed
91 92
    // Description:
  // Set the shader parameteres related to the Camera
Ken Martin's avatar
Ken Martin committed
93
  void SetCameraShaderParameters(vtkOpenGLHelper &cellBO, vtkViewport *viewport, vtkActor2D *act);
Ken Martin's avatar
Ken Martin committed
94 95 96

  // Description:
  // Set the shader parameteres related to the property
Ken Martin's avatar
Ken Martin committed
97
  void SetPropertyShaderParameters(vtkOpenGLHelper &cellBO, vtkViewport *viewport, vtkActor2D *act);
Ken Martin's avatar
Ken Martin committed
98

99 100
  // Description:
  // Update the scene when necessary.
Ken Martin's avatar
Ken Martin committed
101
  void UpdateVBO(vtkActor2D *act, vtkViewport *viewport);
102

103
  // The VBO and its layout.
Ken Martin's avatar
Ken Martin committed
104
  vtkOpenGLVertexBufferObject *VBO;
105 106

  // Structures for the various cell types we render.
Ken Martin's avatar
Ken Martin committed
107 108 109 110
  vtkOpenGLHelper Points;
  vtkOpenGLHelper Lines;
  vtkOpenGLHelper Tris;
  vtkOpenGLHelper TriStrips;
111
  vtkOpenGLHelper *LastBoundBO;
112

113
  vtkTextureObject *CellScalarTexture;
Ken Martin's avatar
Ken Martin committed
114
  vtkOpenGLBufferObject *CellScalarBuffer;
115 116 117
  bool HaveCellScalars;
  int PrimitiveIDOffset;

118
  vtkTimeStamp VBOUpdateTime; // When was the VBO updated?
Ken Martin's avatar
Ken Martin committed
119
  vtkPoints *TransformedPoints;
120

121 122 123
  // do we have wide lines that require special handling
  virtual bool HaveWideLines(vtkViewport *, vtkActor2D *);

124
private:
125 126
  vtkOpenGLPolyDataMapper2D(const vtkOpenGLPolyDataMapper2D&);  // Not implemented.
  void operator=(const vtkOpenGLPolyDataMapper2D&);  // Not implemented.
127 128 129
};

#endif