File: vtkOpenGLGL2PSHelper.h

package info (click to toggle)
paraview 4.0.1-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 526,572 kB
  • sloc: cpp: 2,284,430; ansic: 816,374; python: 239,936; xml: 70,162; tcl: 48,295; fortran: 39,116; yacc: 5,466; java: 3,518; perl: 3,107; lex: 1,620; sh: 1,555; makefile: 932; asm: 471; pascal: 228
file content (109 lines) | stat: -rw-r--r-- 3,652 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkOpenGLGL2PSHelper.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 vtkOpenGLGL2PSHelper - Helper functionality for GL2PS exporting.
//
// .SECTION Description
// vtkOpenGLGL2PSHelper provides a number of static variables and methods that
// are used during GL2PS exporting. The rational behind this class is that GL
// does not include all of the information that GL2PS needs into its feedback
// buffer, and in certain situations GL2PS function calls need to be made
// alongside their GL equivalents, notably glLineWidth and glPointSize.
//
// The static variables in this class are set by vtkGL2PSUtilities at the
// beginning of a GL2PS export render. This class fakes GL2PS calls like
// gl2psLineWidth in order to keep GL2PS from being a module dependency for
// vtkRenderingOpenGL.

#ifndef __vtkOpenGLGL2PSHelper_h
#define __vtkOpenGLGL2PSHelper_h

#include "vtkRenderingOpenGLModule.h" // For export macro
#include "vtkOpenGL.h" // for GL defines.

class VTKRENDERINGOPENGL_EXPORT vtkOpenGLGL2PSHelper
{
public:

  // Description:
  // Call alongside glLineWidth(lineWidth) to inform GL2PS of the change.
  static void SetLineWidth(float lineWidth)
  {
    if (vtkOpenGLGL2PSHelper::InGL2PSRender)
      {
      glPassThrough(vtkOpenGLGL2PSHelper::LineWidthToken);
      glPassThrough(vtkOpenGLGL2PSHelper::LineWidthFactor * lineWidth);
      }
  }

  // Description:
  // Call alongside glPointSize(pointSize) to inform GL2PS of the change.
  static void SetPointSize(float pointSize)
  {
    if (vtkOpenGLGL2PSHelper::InGL2PSRender)
    {
      glPassThrough(vtkOpenGLGL2PSHelper::PointSizeToken);
      glPassThrough(vtkOpenGLGL2PSHelper::PointSizeFactor * pointSize);
    }
  }

  // Description:
  // Call alongside glEnable(GL_LINE_STIPPLE) to inform GL2PS of the change.
  // This must be called *after* calling glLineStipple(factor, pattern).
  static void EnableStipple()
  {
    if (vtkOpenGLGL2PSHelper::InGL2PSRender)
    {
      GLint tmp;
      glPassThrough(vtkOpenGLGL2PSHelper::StippleBeginToken);
      glGetIntegerv(GL_LINE_STIPPLE_PATTERN, &tmp);
      glPassThrough(static_cast<GLfloat>(tmp));
      glGetIntegerv(GL_LINE_STIPPLE_REPEAT, &tmp);
      glPassThrough(static_cast<GLfloat>(tmp));
    }
  }

  // Description:
  // Call alongside glDisable(GL_LINE_STIPPLE) to inform GL2PS of the change.
  static void DisableStipple()
  {
    if (vtkOpenGLGL2PSHelper::InGL2PSRender)
    {
      glPassThrough(vtkOpenGLGL2PSHelper::StippleEndToken);
    }
  }


protected:
  friend class vtkGL2PSUtilities;

  static bool InGL2PSRender;
  static GLfloat PointSizeFactor;
  static GLfloat LineWidthFactor;
  static GLfloat PointSizeToken;
  static GLfloat LineWidthToken;
  static GLfloat StippleBeginToken;
  static GLfloat StippleEndToken;

private:
  // static-only class -- no need to construct/destroy.
  vtkOpenGLGL2PSHelper();
  ~vtkOpenGLGL2PSHelper();
  vtkOpenGLGL2PSHelper(const vtkOpenGLGL2PSHelper &); // Not implemented.
  void operator=(const vtkOpenGLGL2PSHelper &);   // Not implemented.
};

#endif //__vtkOpenGLGL2PSHelper_h
// VTK-HeaderTest-Exclude: vtkOpenGLGL2PSHelper.h