Commit 149919e1 authored by Ken Martin's avatar Ken Martin Committed by Kitware Robot

Merge topic 'fix_point_picking_with_msaa'

3e03d8c6 point pickig with msaa was using a msaa depth buffer
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2132
parents 8efc9038 3e03d8c6
......@@ -77,10 +77,20 @@ public:
// extensions.
void SetContext(vtkRenderWindow *context)
{
if (this->Context != context)
if (this->Context == context)
{
this->MultisampleSupport = true;
return;
}
if (context)
{
this->MultisampleSupport = (context->GetMultiSamples() > 0);
}
else
{
this->MultisampleSupport = false;
}
this->Context = static_cast<vtkOpenGLRenderWindow *>(context);
}
// Description:
......@@ -175,11 +185,23 @@ void vtkOpenGLHardwareSelector::PreCapturePass(int pass)
{
annotate(std::string("Starting pass: ") +
this->PassTypeToString(static_cast<PassTypes>(pass)));
// Disable multisample, and blending
vtkRenderWindow *rwin = this->Renderer->GetRenderWindow();
this->Internals->SetContext(rwin);
this->Internals->OriginalMultisample = this->Internals->QueryMultisampling();
this->Internals->EnableMultisampling(false);
this->Internals->OriginalBlending = this->Internals->QueryBlending();
this->Internals->EnableBlending(false);
}
//----------------------------------------------------------------------------
void vtkOpenGLHardwareSelector::PostCapturePass(int pass)
{
// Restore multisample, and blending.
this->Internals->EnableMultisampling(this->Internals->OriginalMultisample);
this->Internals->EnableBlending(this->Internals->OriginalBlending);
annotate(std::string("Pass complete: ") +
this->PassTypeToString(static_cast<PassTypes>(pass)));
}
......@@ -191,9 +213,22 @@ void vtkOpenGLHardwareSelector::BeginSelection()
if (this->FieldAssociation == vtkDataObject::FIELD_ASSOCIATION_POINTS)
{
vtkRenderWindow *rwin = this->Renderer->GetRenderWindow();
this->Internals->SetContext(rwin);
// Disable multisample, and blending before writing the zbuffer
this->Internals->OriginalMultisample = this->Internals->QueryMultisampling();
this->Internals->EnableMultisampling(false);
this->Internals->OriginalBlending = this->Internals->QueryBlending();
this->Internals->EnableBlending(false);
rwin->SwapBuffersOff();
rwin->Render();
this->Renderer->PreserveDepthBufferOn();
// Restore multisample, and blending.
this->Internals->EnableMultisampling(this->Internals->OriginalMultisample);
this->Internals->EnableBlending(this->Internals->OriginalBlending);
}
return this->Superclass::BeginSelection();
......@@ -238,20 +273,12 @@ void vtkOpenGLHardwareSelector::SavePixelBuffer(int passNo)
}
//----------------------------------------------------------------------------
void vtkOpenGLHardwareSelector::BeginRenderProp(vtkRenderWindow *context)
void vtkOpenGLHardwareSelector::BeginRenderProp(vtkRenderWindow *)
{
#ifdef vtkOpenGLHardwareSelectorDEBUG
cerr << "=====vtkOpenGLHardwareSelector::BeginRenderProp" << endl;
#endif
this->Internals->SetContext(context);
// Disable multisample, and blending.
this->Internals->OriginalMultisample = this->Internals->QueryMultisampling();
this->Internals->EnableMultisampling(false);
this->Internals->OriginalBlending = this->Internals->QueryBlending();
this->Internals->EnableBlending(false);
}
//----------------------------------------------------------------------------
......@@ -260,10 +287,6 @@ void vtkOpenGLHardwareSelector::EndRenderProp(vtkRenderWindow *)
#ifdef vtkOpenGLHardwareSelectorDEBUG
cerr << "=====vtkOpenGLHardwareSelector::EndRenderProp" << endl;
#endif
// Restore multisample, and blending.
this->Internals->EnableMultisampling(this->Internals->OriginalMultisample);
this->Internals->EnableBlending(this->Internals->OriginalBlending);
}
//----------------------------------------------------------------------------
......
......@@ -630,6 +630,13 @@ void vtkOpenGLRenderer::DevicePickRender()
this->RenderWindow->MakeCurrent();
vtkOpenGLClearErrorMacro();
bool msaaWasEnabled = false;
if (this->RenderWindow->GetMultiSamples() > 0 && glIsEnabled(GL_MULTISAMPLE))
{
glDisable(GL_MULTISAMPLE);
msaaWasEnabled = true;
}
this->UpdateCamera();
this->UpdateLightGeometry();
this->UpdateLights();
......@@ -638,6 +645,10 @@ void vtkOpenGLRenderer::DevicePickRender()
this->PickInfo->PerformedHardwarePick = true;
if (msaaWasEnabled)
{
glEnable(GL_MULTISAMPLE);
}
vtkOpenGLCheckErrorMacro("failed after DevicePickRender");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment