vtkOpenGLRenderPass.h 2.84 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkOpenGLRenderPass.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.

=========================================================================*/

16 17 18 19 20 21 22
/**
 * @class   vtkOpenGLRenderPass
 * @brief   Abstract render pass with shader modifications.
 *
 *
 * Allows a render pass to update shader code using a new virtual API.
*/
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

#ifndef vtkOpenGLRenderPass_h
#define vtkOpenGLRenderPass_h

#include "vtkRenderingOpenGL2Module.h" // For export macro
#include "vtkRenderPass.h"

#include <string> // For std::string

class vtkAbstractMapper;
class vtkInformationObjectBaseVectorKey;
class vtkProp;
class vtkShaderProgram;

class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderPass: public vtkRenderPass
{
public:
  vtkTypeMacro(vtkOpenGLRenderPass, vtkRenderPass)
  virtual void PrintSelf(ostream &os, vtkIndent indent);

43 44 45 46 47
  /**
   * Use vtkShaderProgram::Substitute to replace //VTK::XXX:YYY declarations in
   * the shader sources.
   * Return false on error.
   */
48 49 50 51 52
  virtual bool ReplaceShaderValues(std::string &vertexShader,
                                   std::string &geometryShader,
                                   std::string &fragmentShader,
                                   vtkAbstractMapper *mapper, vtkProp *prop);

53 54 55 56
  /**
   * Update the uniforms of the shader program.
   * Return false on error.
   */
57 58 59
  virtual bool SetShaderParameters(vtkShaderProgram *program,
                                   vtkAbstractMapper *mapper, vtkProp *prop);

60 61 62 63 64 65 66
  /**
   * For multi-stage render passes that need to change shader code during a
   * single pass, use this method to notify a mapper that the shader needs to be
   * rebuilt (rather than reuse the last cached shader. This method should
   * return the last time that the shader stage changed, or 0 if the shader
   * is single-stage.
   */
67
  virtual vtkMTimeType GetShaderStageMTime();
68

69 70 71
  /**
   * Key containing information about the current pass.
   */
72 73 74 75 76 77
  static vtkInformationObjectBaseVectorKey *RenderPasses();

protected:
  vtkOpenGLRenderPass();
  ~vtkOpenGLRenderPass();

78 79 80
  /**
   * Call before rendering to update the actors' information keys.
   */
81 82
  void PreRender(const vtkRenderState *s);

83 84 85
  /**
   * Call after rendering to clean up the actors' information keys.
   */
86 87 88
  void PostRender(const vtkRenderState *s);

private:
89
  vtkOpenGLRenderPass(const vtkOpenGLRenderPass&) VTK_DELETE_FUNCTION;
90
  void operator=(const vtkOpenGLRenderPass&) VTK_DELETE_FUNCTION;
91 92 93
};

#endif // vtkOpenGLRenderPass_h