VTK  9.1.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
vtkOpenGLFramebufferObject Class Reference

Internal class which encapsulates OpenGL FramebufferObject. More...

#include <vtkOpenGLFramebufferObject.h>

Inheritance diagram for vtkOpenGLFramebufferObject:
[legend]
Collaboration diagram for vtkOpenGLFramebufferObject:
[legend]

Public Types

typedef vtkFrameBufferObjectBase Superclass
 
- Public Types inherited from vtkFrameBufferObjectBase
typedef vtkObject Superclass
 

Public Member Functions

virtual vtkTypeBool IsA (const char *type)
 Return 1 if this class is the same type of (or a subclass of) the named class. More...
 
vtkOpenGLFramebufferObjectNewInstance () const
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses. More...
 
void Bind ()
 Make the draw frame buffer active. More...
 
void Bind (unsigned int mode)
 
void UnBind ()
 Unbind this buffer. More...
 
void UnBind (unsigned int mode)
 
void InitializeViewport (int width, int height)
 Set up ortho viewport with scissor, lighting, blend, and depth disabled. More...
 
virtual unsigned int GetActiveReadBuffer ()
 
unsigned int GetActiveDrawBuffer (unsigned int id)
 
void RenderQuad (int minX, int maxX, int minY, int maxY, vtkShaderProgram *program, vtkOpenGLVertexArrayObject *vao)
 Renders a quad at the given location with pixel coordinates. More...
 
vtkTextureObjectGetColorAttachmentAsTextureObject (unsigned int num)
 Return the texture object bound to the passed attachment number. More...
 
int GetNumberOfColorAttachments ()
 Return the number of color attachments for the given mode. More...
 
unsigned int GetMaximumNumberOfActiveTargets ()
 Returns the maximum number of targets that can be rendered to at one time. More...
 
unsigned int GetMaximumNumberOfRenderTargets ()
 Returns the maximum number of render targets available. More...
 
int CheckFrameBufferStatus (unsigned int mode)
 Validate the current FBO configuration (attachments, formats, etc) prints detected errors to vtkErrorMacro. More...
 
virtual void ReleaseGraphicsResources (vtkWindow *win)
 Deactivate and UnBind. More...
 
virtual unsigned int GetFBOIndex ()
 
vtkPixelBufferObjectDownloadColor1 (int extent[4], int vtkType, int channel)
 Download data from the read color attachment of the currently bound FBO into the returned PBO. More...
 
vtkPixelBufferObjectDownloadColor3 (int extent[4], int vtkType)
 
vtkPixelBufferObjectDownloadColor4 (int extent[4], int vtkType)
 
vtkPixelBufferObjectDownloadDepth (int extent[4], int vtkType)
 Download data from the depth attachment of the currently bound FBO. More...
 
vtkPixelBufferObjectDownload (int extent[4], int vtkType, int nComps, int oglType, int oglFormat)
 Download data from the read buffer of the current FBO. More...
 
void Resize (int width, int height)
 Resize all FO attachments. More...
 
int GetMultiSamples ()
 
void SetContext (vtkRenderWindow *context)
 Get/Set the context. More...
 
vtkOpenGLRenderWindowGetContext ()
 Get/Set the context. More...
 
void SaveCurrentBindingsAndBuffers ()
 Store/Restore the current framebuffer bindings and buffers. More...
 
void SaveCurrentBindingsAndBuffers (unsigned int mode)
 Store/Restore the current framebuffer bindings and buffers. More...
 
void RestorePreviousBindingsAndBuffers ()
 Store/Restore the current framebuffer bindings and buffers. More...
 
void RestorePreviousBindingsAndBuffers (unsigned int mode)
 Store/Restore the current framebuffer bindings and buffers. More...
 
bool Start (int width, int height)
 User must take care that width/height match the dimensions of the user defined texture attachments. More...
 
bool StartNonOrtho (int width, int height)
 User must take care that width/height match the dimensions of the user defined texture attachments. More...
 
void ActivateDrawBuffers (unsigned int n)
 
void ActivateDrawBuffers (unsigned int *ids, int n)
 
void ActivateDrawBuffer (unsigned int id)
 
void ActivateReadBuffer (unsigned int id)
 
void ActivateBuffer (unsigned int id)
 
void DeactivateDrawBuffers ()
 
void DeactivateReadBuffer ()
 
void AddColorAttachment (unsigned int attId, vtkTextureObject *tex, unsigned int zslice=0, unsigned int format=0, unsigned int mipmapLevel=0)
 Directly assign/remove a texture to color attachments. More...
 
void AddColorAttachment (unsigned int attId, vtkRenderbuffer *tex)
 Directly assign/remove a texture to color attachments. More...
 
void RemoveColorAttachment (unsigned int index)
 Directly assign/remove a texture to color attachments. More...
 
void RemoveColorAttachments (unsigned int num)
 Directly assign/remove a texture to color attachments. More...
 
void AddDepthAttachment ()
 Directly assign/remove a texture/renderbuffer to depth attachments. More...
 
void AddDepthAttachment (vtkTextureObject *tex)
 Directly assign/remove a texture/renderbuffer to depth attachments. More...
 
void AddDepthAttachment (vtkRenderbuffer *tex)
 Directly assign/remove a texture/renderbuffer to depth attachments. More...
 
void RemoveDepthAttachment ()
 Directly assign/remove a texture/renderbuffer to depth attachments. More...
 
vtkTextureObjectGetDepthAttachmentAsTextureObject ()
 Directly assign/remove a texture/renderbuffer to depth attachments. More...
 
bool PopulateFramebuffer (int width, int height)
 Convenience method to populate a framebuffer with attachments created as well. More...
 
bool PopulateFramebuffer (int width, int height, bool useTextures, int numberOfColorAttachments, int colorDataType, bool wantDepthAttachment, int depthBitplanes, int multisamples, bool wantStencilAttachment=false)
 Convenience method to populate a framebuffer with attachments created as well. More...
 
int * GetLastSize () override
 Dimensions in pixels of the framebuffer. More...
 
void GetLastSize (int &_arg1, int &_arg2) override
 Dimensions in pixels of the framebuffer. More...
 
void GetLastSize (int _arg[2]) override
 Dimensions in pixels of the framebuffer. More...
 
- Public Member Functions inherited from vtkFrameBufferObjectBase
virtual vtkTypeBool IsA (const char *type)
 Return 1 if this class is the same type of (or a subclass of) the named class. More...
 
vtkFrameBufferObjectBaseNewInstance () const
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses. More...
 
- Public Member Functions inherited from vtkObject
 vtkBaseTypeMacro (vtkObject, vtkObjectBase)
 
virtual void DebugOn ()
 Turn debugging output on. More...
 
virtual void DebugOff ()
 Turn debugging output off. More...
 
bool GetDebug ()
 Get the value of the debug flag. More...
 
void SetDebug (bool debugFlag)
 Set the value of the debug flag. More...
 
virtual void Modified ()
 Update the modification time for this object. More...
 
virtual vtkMTimeType GetMTime ()
 Return this object's modified time. More...
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses. More...
 
void RemoveObserver (unsigned long tag)
 
void RemoveObservers (unsigned long event)
 
void RemoveObservers (const char *event)
 
void RemoveAllObservers ()
 
vtkTypeBool HasObserver (unsigned long event)
 
vtkTypeBool HasObserver (const char *event)
 
int InvokeEvent (unsigned long event)
 
int InvokeEvent (const char *event)
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkCommandGetCommand (unsigned long tag)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObserver (vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObservers (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
void RemoveObservers (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkTypeBool HasObserver (unsigned long event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
vtkTypeBool HasObserver (const char *event, vtkCommand *)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Allow user to set the AbortFlagOn() with the return value of the callback method. More...
 
int InvokeEvent (unsigned long event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
int InvokeEvent (const char *event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 Return the class name as a string. More...
 
virtual vtkTypeBool IsA (const char *name)
 Return 1 if this class is the same type of (or a subclass of) the named class. More...
 
virtual vtkIdType GetNumberOfGenerationsFromBase (const char *name)
 Given the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
virtual void Delete ()
 Delete a VTK object. More...
 
virtual void FastDelete ()
 Delete a reference to this object. More...
 
void InitializeObjectBase ()
 
void Print (ostream &os)
 Print an object to an ostream. More...
 
virtual void Register (vtkObjectBase *o)
 Increase the reference count (mark as used by another object). More...
 
virtual void UnRegister (vtkObjectBase *o)
 Decrease the reference count (release by another object). More...
 
int GetReferenceCount ()
 Return the current reference count of this object. More...
 
void SetReferenceCount (int)
 Sets the reference count. More...
 
bool GetIsInMemkind () const
 A local state flag that remembers whether this object lives in the normal or extended memory space. More...
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 Methods invoked by print to print information about the object including superclasses. More...
 

Static Public Member Functions

static vtkOpenGLFramebufferObjectNew ()
 
static vtkTypeBool IsTypeOf (const char *type)
 
static vtkOpenGLFramebufferObjectSafeDownCast (vtkObjectBase *o)
 
static bool IsSupported (vtkOpenGLRenderWindow *)
 Returns if the context supports the required extensions. More...
 
static bool GetFrameBufferStatus (unsigned int mode, const char *&desc)
 Validate the current FBO configuration (attachments, formats, etc) return false if the FBO is incomplete. More...
 
static int Blit (const int srcExt[4], const int destExt[4], unsigned int bits, unsigned int mapping)
 Copy from the currently bound READ FBO to the currently bound DRAW FBO. More...
 
static void Download (int extent[4], int vtkType, int nComps, int oglType, int oglFormat, vtkPixelBufferObject *pbo)
 
static unsigned int GetDrawMode ()
 
static unsigned int GetReadMode ()
 
static unsigned int GetBothMode ()
 
- Static Public Member Functions inherited from vtkFrameBufferObjectBase
static vtkTypeBool IsTypeOf (const char *type)
 
static vtkFrameBufferObjectBaseSafeDownCast (vtkObjectBase *o)
 
- Static Public Member Functions inherited from vtkObject
static vtkObjectNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void BreakOnError ()
 This method is called when vtkErrorMacro executes. More...
 
static void SetGlobalWarningDisplay (int val)
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOn ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOff ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static int GetGlobalWarningDisplay ()
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
- Static Public Member Functions inherited from vtkObjectBase
static vtkTypeBool IsTypeOf (const char *name)
 Return 1 if this class type is the same type of (or a subclass of) the named class. More...
 
static vtkIdType GetNumberOfGenerationsFromBaseType (const char *name)
 Given a the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class). More...
 
static vtkObjectBaseNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void SetMemkindDirectory (const char *directoryname)
 The name of a directory, ideally mounted -o dax, to memory map an extended memory space within. More...
 
static bool GetUsingMemkind ()
 A global state flag that controls whether vtkObjects are constructed in the usual way (the default) or within the extended memory space. More...
 

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 
void AttachColorBuffer (unsigned int index)
 Attach a specific buffer. More...
 
void AttachDepthBuffer ()
 
void CreateFBO ()
 
void DestroyFBO ()
 
void DestroyDepthBuffer (vtkWindow *win)
 
void DestroyColorBuffers (vtkWindow *win)
 
void ActivateBuffers ()
 
void UpdateSize ()
 
void DisplayFrameBufferAttachments ()
 Display all the attachments of the current framebuffer object. More...
 
void DisplayFrameBufferAttachment (unsigned int uattachment)
 Display a given attachment for the current framebuffer object. More...
 
void DisplayDrawBuffers ()
 Display the draw buffers. More...
 
void DisplayReadBuffer ()
 Display the read buffer. More...
 
void DisplayBuffer (int value)
 Display any buffer (convert value into string). More...
 
int GetOpenGLType (int vtkType)
 Given a vtk type get a compatible open gl type. More...
 
 vtkOpenGLFramebufferObject ()
 
 ~vtkOpenGLFramebufferObject () override
 
- Protected Member Functions inherited from vtkFrameBufferObjectBase
virtual vtkObjectBaseNewInstanceInternal () const
 
 vtkFrameBufferObjectBase ()
 
 ~vtkFrameBufferObjectBase () override
 
- Protected Member Functions inherited from vtkObject
 vtkObject ()
 
 ~vtkObject () override
 
void RegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
 These methods allow a command to exclusively grab all events. More...
 
void InternalReleaseFocus ()
 These methods allow a command to exclusively grab all events. More...
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void RegisterInternal (vtkObjectBase *, vtkTypeBool check)
 
virtual void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check)
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Static Protected Member Functions

static bool LoadRequiredExtensions (vtkOpenGLRenderWindow *)
 Load all necessary extensions. More...
 
- Static Protected Member Functions inherited from vtkObjectBase
static vtkMallocingFunction GetCurrentMallocFunction ()
 
static vtkReallocingFunction GetCurrentReallocFunction ()
 
static vtkFreeingFunction GetCurrentFreeFunction ()
 
static vtkFreeingFunction GetAlternateFreeFunction ()
 

Protected Attributes

vtkGenericOpenGLResourceFreeCallbackResourceCallback
 
vtkOpenGLRenderWindowContext
 
unsigned int FBOIndex
 
bool DrawBindingSaved
 
bool ReadBindingSaved
 
bool DrawBufferSaved
 
bool ReadBufferSaved
 
int LastSize [2]
 
std::vector< unsigned int > ActiveBuffers
 
unsigned int ActiveReadBuffer
 
vtkFOInfo * DepthBuffer
 
std::map< unsigned int, vtkFOInfo * > ColorBuffers
 
- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
- Protected Attributes inherited from vtkObjectBase
std::atomic< int32_t > ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Detailed Description

Internal class which encapsulates OpenGL FramebufferObject.

Before delving into this class it is best to have some background in some OpenGL terms. OpenGL has a notion of a currently bound Framebuffers for drawing and reading. It can be the default framebuffer such as created with a standard window/context or it can be a user created Framebuffer objects. When draw and read commands are invoked, they apply to the current draw and/or read frambuffers.

A framebuffer consists of color buffers and an optional depth buffer. The FramebufferObject does not hold the memory for these buffers, it just keeps track of what buffers are attached to it. The buffers themselves hold the storage for the pixels/depths.

In the context of this discussion a buffer can be either a vtkTextureObject (both 2D or a slice of a 3D texture) or a vtkRenderbuffer. In some cases a renderbuffer may be faster or more lightweight but you cannot pass a renderbuffer into a shader for sampling in a later pass like you can a texture.

You attach these buffers to the Framebuffer using methods such as AddColorAttachment or AddDepthAttachment In normal usage a buffer is Attached to a FramebufferObject and then some or all of the attached buffers are activated for drawing or reading.

When you have a framebuffer bound along with some buffers attached to it you can then activate specific buffers for drawing or reading. So you have draw and read framebuffer objects (bindings) and then for the currently bound FramebufferObjects you have active draw and read buffers.

A single FramebufferObject can be bound to both Draw and Read. You cannot assign and activate a TextureObject for drawing on the FO and at the same time pass it in as a Texture to the shader program. That type of operation is very common and must be done in two steps.

Typical use cases: The simplest example

fbo->SetContext(renWin);
fbo->SaveCurrentBindingsAndBuffers();
fbo->PopulateFramebuffer(width, height);
...
fbo->RestorePreviousBindingsAndBuffers();
@ height
Definition: vtkX3D.h:260

If you wish to use a texture you created

fbo->SetContext(renWin);
fbo->SaveCurrentBindingsAndBuffers();
fbo->Bind();
fbo->AddColorAttachment(0, vtkTextureObj);
fbo->AddDepthAttachment(); // auto create depth buffer
fbo->ActivateBuffer(0);
...
fbo->RestorePreviousBindingsAndBuffers();

If you will be using a FO repeatedly then it is best to create it attach the buffers and then use as needed for example

Typical use case:

// setup the FBO once
fbo->SetContext(renWin);
fbo->SaveCurrentBindingsAndBuffers();
fbo->AddColorAttachment(0, vtkTextureObj);
fbo->AddDepthAttachment(); // auto create depth buffer
fbo->RestorePreviousBindingsAndBuffers();
// use it many times
fbo->SaveCurrentBindingsAndBuffers();
fbo->Bind();
fbo->ActivateBuffer(0);
... // render here etc
fbo->RestorePreviousBindingsAndBuffers();

If you with to only bind the framebuffer for drawing or reading there are mode specific versions of some methods that only apply to the mode specified Draw/Read/Both. The mode argument uses OpenGL constants so this class provides convenience methods to return them named GetDrawMode() GetReadMode() and GetBothMode() so that your code does not need to be polluted with OpenGL headers/constants.

This class replaces both vtkFrameBufferObject and vtkFrameBufferObject2 and contins methods from both of them. Most methods from FO2 should work with this class. Just rename FBO2 to FBO and make sure to Save and Restore the bindings and buffers. If you have been using the old FO class, which had comments in the header saying not to use it. Then you are in for a bit more of a conversion but generally it should still be easy. Use the code samples above (or any of the classes in OpenGL2 that currently use FBOs) to guide you. They have all been converted to this class. Where previously a DepthBuffer was automatically created for you, you now need to do it explicitly using AddDepthAttachment().

Note the capitalization of FramebufferObject

See also
vtkTextureObject, vtkRenderbufferObject

Definition at line 181 of file vtkOpenGLFramebufferObject.h.

Member Typedef Documentation

◆ Superclass

Definition at line 185 of file vtkOpenGLFramebufferObject.h.

Constructor & Destructor Documentation

◆ vtkOpenGLFramebufferObject()

vtkOpenGLFramebufferObject::vtkOpenGLFramebufferObject ( )
protected

◆ ~vtkOpenGLFramebufferObject()

vtkOpenGLFramebufferObject::~vtkOpenGLFramebufferObject ( )
overrideprotected

Member Function Documentation

◆ New()

static vtkOpenGLFramebufferObject * vtkOpenGLFramebufferObject::New ( )
static

◆ IsTypeOf()

static vtkTypeBool vtkOpenGLFramebufferObject::IsTypeOf ( const char *  type)
static

◆ IsA()

virtual vtkTypeBool vtkOpenGLFramebufferObject::IsA ( const char *  name)
virtual

Return 1 if this class is the same type of (or a subclass of) the named class.

Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkFrameBufferObjectBase.

◆ SafeDownCast()

static vtkOpenGLFramebufferObject * vtkOpenGLFramebufferObject::SafeDownCast ( vtkObjectBase o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkOpenGLFramebufferObject::NewInstanceInternal ( ) const
protectedvirtual

Reimplemented from vtkFrameBufferObjectBase.

◆ NewInstance()

vtkOpenGLFramebufferObject * vtkOpenGLFramebufferObject::NewInstance ( ) const

◆ PrintSelf()

void vtkOpenGLFramebufferObject::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
overridevirtual

Methods invoked by print to print information about the object including superclasses.

Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkFrameBufferObjectBase.

◆ SetContext()

void vtkOpenGLFramebufferObject::SetContext ( vtkRenderWindow context)

Get/Set the context.

Context must be a vtkOpenGLRenderWindow. This does not increase the reference count of the context to avoid reference loops. SetContext() may raise an error if the OpenGL context does not support the required OpenGL extensions.

◆ GetContext()

vtkOpenGLRenderWindow * vtkOpenGLFramebufferObject::GetContext ( )

Get/Set the context.

Context must be a vtkOpenGLRenderWindow. This does not increase the reference count of the context to avoid reference loops. SetContext() may raise an error if the OpenGL context does not support the required OpenGL extensions.

◆ Bind() [1/2]

void vtkOpenGLFramebufferObject::Bind ( )

Make the draw frame buffer active.

◆ Bind() [2/2]

void vtkOpenGLFramebufferObject::Bind ( unsigned int  mode)

◆ UnBind() [1/2]

void vtkOpenGLFramebufferObject::UnBind ( )

Unbind this buffer.

◆ UnBind() [2/2]

void vtkOpenGLFramebufferObject::UnBind ( unsigned int  mode)

◆ SaveCurrentBindingsAndBuffers() [1/2]

void vtkOpenGLFramebufferObject::SaveCurrentBindingsAndBuffers ( )

Store/Restore the current framebuffer bindings and buffers.

◆ SaveCurrentBindingsAndBuffers() [2/2]

void vtkOpenGLFramebufferObject::SaveCurrentBindingsAndBuffers ( unsigned int  mode)

Store/Restore the current framebuffer bindings and buffers.

◆ RestorePreviousBindingsAndBuffers() [1/2]

void vtkOpenGLFramebufferObject::RestorePreviousBindingsAndBuffers ( )

Store/Restore the current framebuffer bindings and buffers.

◆ RestorePreviousBindingsAndBuffers() [2/2]

void vtkOpenGLFramebufferObject::RestorePreviousBindingsAndBuffers ( unsigned int  mode)

Store/Restore the current framebuffer bindings and buffers.

◆ Start()

bool vtkOpenGLFramebufferObject::Start ( int  width,
int  height 
)

User must take care that width/height match the dimensions of the user defined texture attachments.

This method makes the "active buffers" the buffers that will get drawn into by subsequent drawing calls. Note that this does not clear the render buffers i.e. no glClear() calls are made by either of these methods. It's up to the caller to clear the buffers if needed.

◆ StartNonOrtho()

bool vtkOpenGLFramebufferObject::StartNonOrtho ( int  width,
int  height 
)

User must take care that width/height match the dimensions of the user defined texture attachments.

This method makes the "active buffers" the buffers that will get drawn into by subsequent drawing calls. Note that this does not clear the render buffers i.e. no glClear() calls are made by either of these methods. It's up to the caller to clear the buffers if needed.

◆ InitializeViewport()

void vtkOpenGLFramebufferObject::InitializeViewport ( int  width,
int  height 
)

Set up ortho viewport with scissor, lighting, blend, and depth disabled.

The method affects the current bound FBO.

◆ ActivateDrawBuffers() [1/2]

void vtkOpenGLFramebufferObject::ActivateDrawBuffers ( unsigned int  n)

◆ ActivateDrawBuffers() [2/2]

void vtkOpenGLFramebufferObject::ActivateDrawBuffers ( unsigned int *  ids,
int  n 
)

◆ ActivateDrawBuffer()

void vtkOpenGLFramebufferObject::ActivateDrawBuffer ( unsigned int  id)

◆ ActivateReadBuffer()

void vtkOpenGLFramebufferObject::ActivateReadBuffer ( unsigned int  id)

◆ ActivateBuffer()

void vtkOpenGLFramebufferObject::ActivateBuffer ( unsigned int  id)
inline

Definition at line 248 of file vtkOpenGLFramebufferObject.h.

◆ DeactivateDrawBuffers()

void vtkOpenGLFramebufferObject::DeactivateDrawBuffers ( )

◆ DeactivateReadBuffer()

void vtkOpenGLFramebufferObject::DeactivateReadBuffer ( )

◆ GetActiveReadBuffer()

virtual unsigned int vtkOpenGLFramebufferObject::GetActiveReadBuffer ( )
virtual

◆ GetActiveDrawBuffer()

unsigned int vtkOpenGLFramebufferObject::GetActiveDrawBuffer ( unsigned int  id)

◆ RenderQuad()

void vtkOpenGLFramebufferObject::RenderQuad ( int  minX,
int  maxX,
int  minY,
int  maxY,
vtkShaderProgram program,
vtkOpenGLVertexArrayObject vao 
)

Renders a quad at the given location with pixel coordinates.

This method is provided as a convenience, since we often render quads in a FBO.

Precondition
positive_minX: minX>=0
increasing_x: minX<=maxX
valid_maxX: maxX<LastSize[0]
positive_minY: minY>=0
increasing_y: minY<=maxY
valid_maxY: maxY<LastSize[1]

◆ AddColorAttachment() [1/2]

void vtkOpenGLFramebufferObject::AddColorAttachment ( unsigned int  attId,
vtkTextureObject tex,
unsigned int  zslice = 0,
unsigned int  format = 0,
unsigned int  mipmapLevel = 0 
)

Directly assign/remove a texture to color attachments.

◆ AddColorAttachment() [2/2]

void vtkOpenGLFramebufferObject::AddColorAttachment ( unsigned int  attId,
vtkRenderbuffer tex 
)

Directly assign/remove a texture to color attachments.

◆ RemoveColorAttachment()

void vtkOpenGLFramebufferObject::RemoveColorAttachment ( unsigned int  index)

Directly assign/remove a texture to color attachments.

◆ RemoveColorAttachments()

void vtkOpenGLFramebufferObject::RemoveColorAttachments ( unsigned int  num)

Directly assign/remove a texture to color attachments.

◆ GetColorAttachmentAsTextureObject()

vtkTextureObject * vtkOpenGLFramebufferObject::GetColorAttachmentAsTextureObject ( unsigned int  num)

Return the texture object bound to the passed attachment number.

In the case that a renderbuffer is used, this will return nullptr.

◆ GetNumberOfColorAttachments()

int vtkOpenGLFramebufferObject::GetNumberOfColorAttachments ( )

Return the number of color attachments for the given mode.

◆ AddDepthAttachment() [1/3]

void vtkOpenGLFramebufferObject::AddDepthAttachment ( )

Directly assign/remove a texture/renderbuffer to depth attachments.

◆ AddDepthAttachment() [2/3]

void vtkOpenGLFramebufferObject::AddDepthAttachment ( vtkTextureObject tex)

Directly assign/remove a texture/renderbuffer to depth attachments.

◆ AddDepthAttachment() [3/3]

void vtkOpenGLFramebufferObject::AddDepthAttachment ( vtkRenderbuffer tex)

Directly assign/remove a texture/renderbuffer to depth attachments.

◆ RemoveDepthAttachment()

void vtkOpenGLFramebufferObject::RemoveDepthAttachment ( )

Directly assign/remove a texture/renderbuffer to depth attachments.

◆ GetDepthAttachmentAsTextureObject()

vtkTextureObject * vtkOpenGLFramebufferObject::GetDepthAttachmentAsTextureObject ( )

Directly assign/remove a texture/renderbuffer to depth attachments.

◆ PopulateFramebuffer() [1/2]

bool vtkOpenGLFramebufferObject::PopulateFramebuffer ( int  width,
int  height 
)

Convenience method to populate a framebuffer with attachments created as well.

Returns true if a complete valid Framebuffer was created

◆ PopulateFramebuffer() [2/2]

bool vtkOpenGLFramebufferObject::PopulateFramebuffer ( int  width,
int  height,
bool  useTextures,
int  numberOfColorAttachments,
int  colorDataType,
bool  wantDepthAttachment,
int  depthBitplanes,
int  multisamples,
bool  wantStencilAttachment = false 
)

Convenience method to populate a framebuffer with attachments created as well.

Returns true if a complete valid Framebuffer was created

◆ GetMaximumNumberOfActiveTargets()

unsigned int vtkOpenGLFramebufferObject::GetMaximumNumberOfActiveTargets ( )

Returns the maximum number of targets that can be rendered to at one time.

This limits the active targets set by SetActiveTargets(). The return value is valid only if GetContext is non-null.

◆ GetMaximumNumberOfRenderTargets()

unsigned int vtkOpenGLFramebufferObject::GetMaximumNumberOfRenderTargets ( )

Returns the maximum number of render targets available.

This limits the available attachment points for SetColorAttachment(). The return value is valid only if GetContext is non-null.

◆ GetLastSize() [1/3]

int * vtkOpenGLFramebufferObject::GetLastSize ( )
inlineoverridevirtual

Dimensions in pixels of the framebuffer.

Implements vtkFrameBufferObjectBase.

Definition at line 336 of file vtkOpenGLFramebufferObject.h.

◆ GetLastSize() [2/3]

void vtkOpenGLFramebufferObject::GetLastSize ( int &  _arg1,
int &  _arg2 
)
inlineoverridevirtual

Dimensions in pixels of the framebuffer.

Implements vtkFrameBufferObjectBase.

Definition at line 342 of file vtkOpenGLFramebufferObject.h.

◆ GetLastSize() [3/3]

void vtkOpenGLFramebufferObject::GetLastSize ( int  _arg[2])
inlineoverridevirtual

Dimensions in pixels of the framebuffer.

Implements vtkFrameBufferObjectBase.

Definition at line 349 of file vtkOpenGLFramebufferObject.h.

◆ IsSupported()

static bool vtkOpenGLFramebufferObject::IsSupported ( vtkOpenGLRenderWindow *   )
inlinestatic

Returns if the context supports the required extensions.

Extension will be loaded when the context is set.

Definition at line 356 of file vtkOpenGLFramebufferObject.h.

◆ CheckFrameBufferStatus()

int vtkOpenGLFramebufferObject::CheckFrameBufferStatus ( unsigned int  mode)

Validate the current FBO configuration (attachments, formats, etc) prints detected errors to vtkErrorMacro.

◆ ReleaseGraphicsResources()

virtual void vtkOpenGLFramebufferObject::ReleaseGraphicsResources ( vtkWindow win)
virtual

Deactivate and UnBind.

◆ GetFrameBufferStatus()

static bool vtkOpenGLFramebufferObject::GetFrameBufferStatus ( unsigned int  mode,
const char *&  desc 
)
static

Validate the current FBO configuration (attachments, formats, etc) return false if the FBO is incomplete.

Assigns description a literal containing a description of the status. Low level api.

◆ GetFBOIndex()

virtual unsigned int vtkOpenGLFramebufferObject::GetFBOIndex ( )
virtual

◆ Blit()

static int vtkOpenGLFramebufferObject::Blit ( const int  srcExt[4],
const int  destExt[4],
unsigned int  bits,
unsigned int  mapping 
)
static

Copy from the currently bound READ FBO to the currently bound DRAW FBO.

The method is static so that one doesn't need to ccreate an instance when transferring between attachments in the default FBO.

◆ DownloadColor1()

vtkPixelBufferObject * vtkOpenGLFramebufferObject::DownloadColor1 ( int  extent[4],
int  vtkType,
int  channel 
)

Download data from the read color attachment of the currently bound FBO into the returned PBO.

The PBO must be free'd when you are finished with it. The number of components in the PBO is the same as in the name of the specific download function. When downloading a single color channel, the channel must be identified by index, 1->red, 2->green, 3-> blue.

◆ DownloadColor3()

vtkPixelBufferObject * vtkOpenGLFramebufferObject::DownloadColor3 ( int  extent[4],
int  vtkType 
)

◆ DownloadColor4()

vtkPixelBufferObject * vtkOpenGLFramebufferObject::DownloadColor4 ( int  extent[4],
int  vtkType 
)

◆ DownloadDepth()

vtkPixelBufferObject * vtkOpenGLFramebufferObject::DownloadDepth ( int  extent[4],
int  vtkType 
)

Download data from the depth attachment of the currently bound FBO.

The returned PBO must be Delete'd by the caller. The returned PBO has one component.

◆ Download() [1/2]

vtkPixelBufferObject * vtkOpenGLFramebufferObject::Download ( int  extent[4],
int  vtkType,
int  nComps,
int  oglType,
int  oglFormat 
)

Download data from the read buffer of the current FBO.

These are low level methods. In the static variant a PBO must be passed in since we don't have access to a context. The static method is provided so that one may download from the default FBO.

◆ Download() [2/2]

static void vtkOpenGLFramebufferObject::Download ( int  extent[4],
int  vtkType,
int  nComps,
int  oglType,
int  oglFormat,
vtkPixelBufferObject pbo 
)
static

◆ GetDrawMode()

static unsigned int vtkOpenGLFramebufferObject::GetDrawMode ( )
static

◆ GetReadMode()

static unsigned int vtkOpenGLFramebufferObject::GetReadMode ( )
static

◆ GetBothMode()

static unsigned int vtkOpenGLFramebufferObject::GetBothMode ( )
static

◆ Resize()

void vtkOpenGLFramebufferObject::Resize ( int  width,
int  height 
)

Resize all FO attachments.

◆ GetMultiSamples()

int vtkOpenGLFramebufferObject::GetMultiSamples ( )

◆ AttachColorBuffer()

void vtkOpenGLFramebufferObject::AttachColorBuffer ( unsigned int  index)
protected

Attach a specific buffer.

◆ AttachDepthBuffer()

void vtkOpenGLFramebufferObject::AttachDepthBuffer ( )
protected

◆ LoadRequiredExtensions()

static bool vtkOpenGLFramebufferObject::LoadRequiredExtensions ( vtkOpenGLRenderWindow )
inlinestaticprotected

Load all necessary extensions.

Definition at line 446 of file vtkOpenGLFramebufferObject.h.

◆ CreateFBO()

void vtkOpenGLFramebufferObject::CreateFBO ( )
protected

◆ DestroyFBO()

void vtkOpenGLFramebufferObject::DestroyFBO ( )
protected

◆ DestroyDepthBuffer()

void vtkOpenGLFramebufferObject::DestroyDepthBuffer ( vtkWindow win)
protected

◆ DestroyColorBuffers()

void vtkOpenGLFramebufferObject::DestroyColorBuffers ( vtkWindow win)
protected

◆ ActivateBuffers()

void vtkOpenGLFramebufferObject::ActivateBuffers ( )
protected

◆ UpdateSize()

void vtkOpenGLFramebufferObject::UpdateSize ( )
protected

◆ DisplayFrameBufferAttachments()

void vtkOpenGLFramebufferObject::DisplayFrameBufferAttachments ( )
protected

Display all the attachments of the current framebuffer object.

◆ DisplayFrameBufferAttachment()

void vtkOpenGLFramebufferObject::DisplayFrameBufferAttachment ( unsigned int  uattachment)
protected

Display a given attachment for the current framebuffer object.

◆ DisplayDrawBuffers()

void vtkOpenGLFramebufferObject::DisplayDrawBuffers ( )
protected

Display the draw buffers.

◆ DisplayReadBuffer()

void vtkOpenGLFramebufferObject::DisplayReadBuffer ( )
protected

Display the read buffer.

◆ DisplayBuffer()

void vtkOpenGLFramebufferObject::DisplayBuffer ( int  value)
protected

Display any buffer (convert value into string).

◆ GetOpenGLType()

int vtkOpenGLFramebufferObject::GetOpenGLType ( int  vtkType)
protected

Given a vtk type get a compatible open gl type.

Member Data Documentation

◆ ResourceCallback

vtkGenericOpenGLResourceFreeCallback* vtkOpenGLFramebufferObject::ResourceCallback
protected

Definition at line 448 of file vtkOpenGLFramebufferObject.h.

◆ Context

vtkOpenGLRenderWindow* vtkOpenGLFramebufferObject::Context
protected

Definition at line 499 of file vtkOpenGLFramebufferObject.h.

◆ FBOIndex

unsigned int vtkOpenGLFramebufferObject::FBOIndex
protected

Definition at line 501 of file vtkOpenGLFramebufferObject.h.

◆ DrawBindingSaved

bool vtkOpenGLFramebufferObject::DrawBindingSaved
protected

Definition at line 503 of file vtkOpenGLFramebufferObject.h.

◆ ReadBindingSaved

bool vtkOpenGLFramebufferObject::ReadBindingSaved
protected

Definition at line 504 of file vtkOpenGLFramebufferObject.h.

◆ DrawBufferSaved

bool vtkOpenGLFramebufferObject::DrawBufferSaved
protected

Definition at line 505 of file vtkOpenGLFramebufferObject.h.

◆ ReadBufferSaved

bool vtkOpenGLFramebufferObject::ReadBufferSaved
protected

Definition at line 506 of file vtkOpenGLFramebufferObject.h.

◆ LastSize

int vtkOpenGLFramebufferObject::LastSize[2]
protected

Definition at line 508 of file vtkOpenGLFramebufferObject.h.

◆ ActiveBuffers

std::vector<unsigned int> vtkOpenGLFramebufferObject::ActiveBuffers
protected

Definition at line 509 of file vtkOpenGLFramebufferObject.h.

◆ ActiveReadBuffer

unsigned int vtkOpenGLFramebufferObject::ActiveReadBuffer
protected

Definition at line 510 of file vtkOpenGLFramebufferObject.h.

◆ DepthBuffer

vtkFOInfo* vtkOpenGLFramebufferObject::DepthBuffer
protected

Definition at line 512 of file vtkOpenGLFramebufferObject.h.

◆ ColorBuffers

std::map<unsigned int, vtkFOInfo*> vtkOpenGLFramebufferObject::ColorBuffers
protected

Definition at line 513 of file vtkOpenGLFramebufferObject.h.


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