VTK  9.2.20220807
Public Member Functions | Public Attributes | List of all members
vtkOpenGLQuadHelper Class Reference

Class to make rendering a full screen quad easier. More...

#include <vtkOpenGLQuadHelper.h>

Collaboration diagram for vtkOpenGLQuadHelper:
[legend]

Public Member Functions

 vtkOpenGLQuadHelper (vtkOpenGLRenderWindow *, const char *vs, const char *fs, const char *gs, bool flipY=false)
 Create a quadhelper with the provided shaders. More...
 
 ~vtkOpenGLQuadHelper ()
 
void Render ()
 
void ReleaseGraphicsResources (vtkWindow *)
 Release graphics resources. More...
 

Public Attributes

vtkShaderProgramProgram
 
vtkTimeStamp ShaderSourceTime
 
vtkOpenGLVertexArrayObjectVAO
 
unsigned int ShaderChangeValue
 

Detailed Description

Class to make rendering a full screen quad easier.

vtkOpenGLQuadHelper is designed to be used by classes in VTK that need to render a quad to the screen with a shader program. This happens often with render passes or other advanced rendering techniques.

Note that when releasing graphics resources instances of this class should be destroyed. A common use pattern is to conditionally create the instance where used and delete it in ReleaseGraphicsResources and the destructor.

It is possible to flip the Y direction of the quad texture coordinate by turning on the flipY option in the constructor. This can be useful when rendering in an external context having a different convention than OpenGL e.g. OpenGL-D3D shared textures. Off by default if unspecified.

Example usage:

if (!this->QuadHelper)
{
this->QuadHelper = vtkOpenGLQualHelper(renWin, vs, fs, gs);
}
renWin->GetShaderCache()->ReadyShaderProgram(this->QuadHelper->Program);
aTexture->Activate();
this->QuadHelper->Program->SetUniformi("aTexture", aTexture->GetTextureUnit());
this->QuadHelper->Render();
aTexture->Deactivate();
See also
vtkOpenGLRenderUtilities

Definition at line 62 of file vtkOpenGLQuadHelper.h.

Constructor & Destructor Documentation

◆ vtkOpenGLQuadHelper()

vtkOpenGLQuadHelper::vtkOpenGLQuadHelper ( vtkOpenGLRenderWindow ,
const char *  vs,
const char *  fs,
const char *  gs,
bool  flipY = false 
)

Create a quadhelper with the provided shaders.

If the vertex is nullptr then the default is used. Turning on the flipY option reverts the y component of the quad texture coordinates in order to flip the rendered texture. Note that this class should be destroyed upon ReleaseGraphicsResources.

◆ ~vtkOpenGLQuadHelper()

vtkOpenGLQuadHelper::~vtkOpenGLQuadHelper ( )

Member Function Documentation

◆ Render()

void vtkOpenGLQuadHelper::Render ( )

◆ ReleaseGraphicsResources()

void vtkOpenGLQuadHelper::ReleaseGraphicsResources ( vtkWindow )

Release graphics resources.

In general, there's no need to call this explicitly, since vtkOpenGLQuadHelper will invoke it appropriately when needed.

Member Data Documentation

◆ Program

vtkShaderProgram* vtkOpenGLQuadHelper::Program

Definition at line 65 of file vtkOpenGLQuadHelper.h.

◆ ShaderSourceTime

vtkTimeStamp vtkOpenGLQuadHelper::ShaderSourceTime

Definition at line 66 of file vtkOpenGLQuadHelper.h.

◆ VAO

vtkOpenGLVertexArrayObject* vtkOpenGLQuadHelper::VAO

Definition at line 67 of file vtkOpenGLQuadHelper.h.

◆ ShaderChangeValue

unsigned int vtkOpenGLQuadHelper::ShaderChangeValue

Definition at line 68 of file vtkOpenGLQuadHelper.h.


The documentation for this class was generated from the following file: