Here is a suggestion how the implementation should look like:
Code: Select all
void View3DInventorViewer::setAntiAliasingMode(View3DInventorViewer::AntiAliasing mode)
{
int buffers = 1;
SbBool smoothing = false;
switch( mode ) {
case Smoothing:
smoothing = true;
break;
case MSAA2x:
buffers = 2;
break;
case MSAA4x:
buffers = 4;
break;
case MSAA8x:
buffers = 8;
break;
case None:
default:
break;
};
if (getGLRenderAction()->isSmoothing() != smoothing)
getGLRenderAction()->setSmoothing(smoothing);
#if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 5)
if (getSampleBuffers() != buffers)
setSampleBuffers(buffers);
#else
if (buffers > 1)
Base::Console().Warning("Multisampling is not supported by SoQT < 1.5, this anti-aliasing mode is disabled");
#endif
}
View3DInventorViewer::AntiAliasing View3DInventorViewer::getAntiAliasingMode() const
{
if (getGLRenderAction()->isSmoothing())
return Smoothing;
#if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 5)
int buffers = getSampleBuffers();
switch(buffers) {
case 1:
return None;
case 2:
return MSAA2x;
case 4:
return MSAA4x;
case 8:
return MSAA8x;
default:
const_cast<View3DInventorViewer*>(this)->setSampleBuffers(1);
return None;
};
#else
return None;
#endif
}