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: ...@@ -77,10 +77,20 @@ public:
// extensions. // extensions.
void SetContext(vtkRenderWindow *context) 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: // Description:
...@@ -175,11 +185,23 @@ void vtkOpenGLHardwareSelector::PreCapturePass(int pass) ...@@ -175,11 +185,23 @@ void vtkOpenGLHardwareSelector::PreCapturePass(int pass)
{ {
annotate(std::string("Starting pass: ") + annotate(std::string("Starting pass: ") +
this->PassTypeToString(static_cast<PassTypes>(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) 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: ") + annotate(std::string("Pass complete: ") +
this->PassTypeToString(static_cast<PassTypes>(pass))); this->PassTypeToString(static_cast<PassTypes>(pass)));
} }
...@@ -191,9 +213,22 @@ void vtkOpenGLHardwareSelector::BeginSelection() ...@@ -191,9 +213,22 @@ void vtkOpenGLHardwareSelector::BeginSelection()
if (this->FieldAssociation == vtkDataObject::FIELD_ASSOCIATION_POINTS) if (this->FieldAssociation == vtkDataObject::FIELD_ASSOCIATION_POINTS)
{ {
vtkRenderWindow *rwin = this->Renderer->GetRenderWindow(); 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->SwapBuffersOff();
rwin->Render(); rwin->Render();
this->Renderer->PreserveDepthBufferOn(); this->Renderer->PreserveDepthBufferOn();
// Restore multisample, and blending.
this->Internals->EnableMultisampling(this->Internals->OriginalMultisample);
this->Internals->EnableBlending(this->Internals->OriginalBlending);
} }
return this->Superclass::BeginSelection(); return this->Superclass::BeginSelection();
...@@ -238,20 +273,12 @@ void vtkOpenGLHardwareSelector::SavePixelBuffer(int passNo) ...@@ -238,20 +273,12 @@ void vtkOpenGLHardwareSelector::SavePixelBuffer(int passNo)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void vtkOpenGLHardwareSelector::BeginRenderProp(vtkRenderWindow *context) void vtkOpenGLHardwareSelector::BeginRenderProp(vtkRenderWindow *)
{ {
#ifdef vtkOpenGLHardwareSelectorDEBUG #ifdef vtkOpenGLHardwareSelectorDEBUG
cerr << "=====vtkOpenGLHardwareSelector::BeginRenderProp" << endl; cerr << "=====vtkOpenGLHardwareSelector::BeginRenderProp" << endl;
#endif #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 *) ...@@ -260,10 +287,6 @@ void vtkOpenGLHardwareSelector::EndRenderProp(vtkRenderWindow *)
#ifdef vtkOpenGLHardwareSelectorDEBUG #ifdef vtkOpenGLHardwareSelectorDEBUG
cerr << "=====vtkOpenGLHardwareSelector::EndRenderProp" << endl; cerr << "=====vtkOpenGLHardwareSelector::EndRenderProp" << endl;
#endif #endif
// Restore multisample, and blending.
this->Internals->EnableMultisampling(this->Internals->OriginalMultisample);
this->Internals->EnableBlending(this->Internals->OriginalBlending);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
......
...@@ -630,6 +630,13 @@ void vtkOpenGLRenderer::DevicePickRender() ...@@ -630,6 +630,13 @@ void vtkOpenGLRenderer::DevicePickRender()
this->RenderWindow->MakeCurrent(); this->RenderWindow->MakeCurrent();
vtkOpenGLClearErrorMacro(); vtkOpenGLClearErrorMacro();
bool msaaWasEnabled = false;
if (this->RenderWindow->GetMultiSamples() > 0 && glIsEnabled(GL_MULTISAMPLE))
{
glDisable(GL_MULTISAMPLE);
msaaWasEnabled = true;
}
this->UpdateCamera(); this->UpdateCamera();
this->UpdateLightGeometry(); this->UpdateLightGeometry();
this->UpdateLights(); this->UpdateLights();
...@@ -638,6 +645,10 @@ void vtkOpenGLRenderer::DevicePickRender() ...@@ -638,6 +645,10 @@ void vtkOpenGLRenderer::DevicePickRender()
this->PickInfo->PerformedHardwarePick = true; this->PickInfo->PerformedHardwarePick = true;
if (msaaWasEnabled)
{
glEnable(GL_MULTISAMPLE);
}
vtkOpenGLCheckErrorMacro("failed after DevicePickRender"); 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