Skip to content
Snippets Groups Projects
Commit 8839c436 authored by Lucas Gandel's avatar Lucas Gandel
Browse files

Check frame buffer bindings on StereoUpdate()

Make sure that the current frame buffer is bound to both the draw and read
buffers. This is required for volume mappers to sample the depth texture
copied from the read buffer.
The flag controlling this behavior is set to off by default to avoid
unnecessary checks and bindings.
parent 537c0d72
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ vtkExternalOpenGLRenderWindow::vtkExternalOpenGLRenderWindow()
{
this->AutomaticWindowPositionAndResize = 1;
this->UseExternalContent = true;
this->CheckFrameBufferBinding = 0;
}
//----------------------------------------------------------------------------
......@@ -92,6 +93,29 @@ void vtkExternalOpenGLRenderWindow::Start(void)
this->OffScreenFramebuffer->Bind();
}
//----------------------------------------------------------------------------
void vtkExternalOpenGLRenderWindow::StereoUpdate()
{
if (this->CheckFrameBufferBinding)
{
// Get the id of the buffer bound to GL_DRAW_FRAMEBUFFER target
GLint drawFrameBufferBinding;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFrameBufferBinding);
// Get the id of the buffer bound to GL_READ_FRAMEBUFFER target
GLint readFrameBufferBinding;
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFrameBufferBinding);
// Make sure the current frame buffer is bound to both draw and read targets.
if (readFrameBufferBinding != drawFrameBufferBinding)
{
glBindFramebuffer(GL_FRAMEBUFFER, drawFrameBufferBinding);
}
}
this->Superclass::StereoUpdate();
}
//----------------------------------------------------------------------------
bool vtkExternalOpenGLRenderWindow::IsCurrent(void)
{
......
......@@ -57,6 +57,12 @@ public:
*/
void Start(void) override;
/**
* Check frame buffer bindings according to the CheckFrameBufferBinding flag
* and perform stereo update.
*/
void StereoUpdate() override;
/**
* Tells if this window is the current graphics context for the calling
* thread.
......@@ -91,6 +97,15 @@ public:
vtkBooleanMacro(UseExternalContent, bool);
//@}
/**
* Check that the current FBO is bound to both the GL_DRAW_FRAMEBUFFER and
* GL_READ_FRAMEBUFFER targets and bind it otherwise.
* This flag is off by default to avoid unnecessary checks and bindings.
*/
vtkGetMacro(CheckFrameBufferBinding, vtkTypeBool);
vtkSetMacro(CheckFrameBufferBinding, vtkTypeBool);
vtkBooleanMacro(CheckFrameBufferBinding, vtkTypeBool);
protected:
vtkExternalOpenGLRenderWindow();
~vtkExternalOpenGLRenderWindow() override;
......@@ -98,6 +113,8 @@ protected:
int AutomaticWindowPositionAndResize;
bool UseExternalContent;
vtkTypeBool CheckFrameBufferBinding;
private:
vtkExternalOpenGLRenderWindow(const vtkExternalOpenGLRenderWindow&) = delete;
void operator=(const vtkExternalOpenGLRenderWindow&) = delete;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment