VTK
vtkOpenGLFXAAFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOpenGLFXAAFilter.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 
40 #ifndef vtkOpenGLFXAAFilter_h
41 #define vtkOpenGLFXAAFilter_h
42 
43 #include "vtkRenderingOpenGL2Module.h" // For export macro
44 #include "vtkObject.h"
45 #include "vtkFXAAOptions.h" // For DebugOptions enum
46 
47 #include <string> // For std::string
48 
49 class vtkFXAAOptions;
52 class vtkOpenGLRenderer;
54 class vtkShaderProgram;
55 class vtkTextureObject;
57 
58 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLFXAAFilter: public vtkObject
59 {
60 public:
61  static vtkOpenGLFXAAFilter* New();
63  void PrintSelf(ostream &os, vtkIndent indent) override;
64 
68  void Execute(vtkOpenGLRenderer *ren);
69 
73  void ReleaseGraphicsResources();
74 
80  void UpdateConfiguration(vtkFXAAOptions *opts);
81 
83 
87  vtkSetClampMacro(RelativeContrastThreshold, float, 0.f, 1.f)
88  vtkGetMacro(RelativeContrastThreshold, float)
89  vtkSetClampMacro(HardContrastThreshold, float, 0.f, 1.f)
90  vtkGetMacro(HardContrastThreshold, float)
91  vtkSetClampMacro(SubpixelBlendLimit, float, 0.f, 1.f)
92  vtkGetMacro(SubpixelBlendLimit, float)
93  vtkSetClampMacro(SubpixelContrastThreshold, float, 0.f, 1.f)
94  vtkGetMacro(SubpixelContrastThreshold, float)
95  virtual void SetUseHighQualityEndpoints(bool val);
96  vtkGetMacro(UseHighQualityEndpoints, bool)
97  vtkBooleanMacro(UseHighQualityEndpoints, bool)
98  vtkSetClampMacro(EndpointSearchIterations, int, 0, VTK_INT_MAX)
99  vtkGetMacro(EndpointSearchIterations, int)
100  virtual void SetDebugOptionValue(vtkFXAAOptions::DebugOption opt);
101  vtkGetMacro(DebugOptionValue, vtkFXAAOptions::DebugOption)
103 
104 protected:
106  ~vtkOpenGLFXAAFilter() override;
107 
108  void Prepare();
109  void FreeGLObjects();
110  void CreateGLObjects();
111  void LoadInput();
112  void ApplyFilter();
113  void SubstituteFragmentShader(std::string &fragShader);
114  void Finalize();
115 
116  void StartTimeQuery(vtkOpenGLRenderTimer *timer);
117  void EndTimeQuery(vtkOpenGLRenderTimer *timer);
118  void PrintBenchmark();
119 
120  // Cache GL state that we modify
121  bool BlendState;
122  bool DepthTestState;
123 
124  int Viewport[4]; // x, y, width, height
125 
126  // Used to measure execution time:
127  vtkOpenGLRenderTimer *PreparationTimer;
129 
130  // Parameters:
131  float RelativeContrastThreshold;
132  float HardContrastThreshold;
133  float SubpixelBlendLimit;
134  float SubpixelContrastThreshold;
135  int EndpointSearchIterations;
136 
137  bool UseHighQualityEndpoints;
138  vtkFXAAOptions::DebugOption DebugOptionValue;
139 
140  // Set to true when the shader definitions change so we know when to rebuild.
141  bool NeedToRebuildShader;
142 
143  vtkOpenGLRenderer *Renderer;
145 
147 
148 private:
149  vtkOpenGLFXAAFilter(const vtkOpenGLFXAAFilter&) = delete;
150  void operator=(const vtkOpenGLFXAAFilter&) = delete;
151 };
152 
153 #endif // vtkOpenGLFXAAFilter_h
abstract base class for most VTK objects
Definition: vtkObject.h:59
#define VTK_INT_MAX
Definition: vtkType.h:159
a simple class to control print indentation
Definition: vtkIndent.h:39
The VertexArrayObject class uses, or emulates, vertex array objects.
abstracts an OpenGL texture object.
Class to make rendering a full screen quad easier.
OpenGL buffer object.
Perform FXAA antialiasing on the current framebuffer.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
OpenGL renderer.
Asynchronously measures GPU execution time for a single event.
Configuration for FXAA implementations.
The ShaderProgram uses one or more Shader objects.