Commit 1e4d2bc3 authored by David Gobbi's avatar David Gobbi Committed by Code Review
Browse files

Merge topic 'osx-multi-samples' into master

23f6ba79 Implement multi-sample antialiasing on OS X.
parents f13dbb86 23f6ba79
...@@ -37,7 +37,6 @@ int TestMultipleRenderers(int , char * []) ...@@ -37,7 +37,6 @@ int TestMultipleRenderers(int , char * [])
{ {
VTK_CREATE(vtkRenderWindow, renwin); VTK_CREATE(vtkRenderWindow, renwin);
renwin->SetMultiSamples(4);
renwin->SetSize(800, 640); renwin->SetSize(800, 640);
VTK_CREATE(vtkRenderWindowInteractor, iren); VTK_CREATE(vtkRenderWindowInteractor, iren);
......
...@@ -232,7 +232,6 @@ vtkCarbonRenderWindow::vtkCarbonRenderWindow() ...@@ -232,7 +232,6 @@ vtkCarbonRenderWindow::vtkCarbonRenderWindow()
this->Internal = new vtkCarbonRenderWindowInternal(this); this->Internal = new vtkCarbonRenderWindowInternal(this);
this->ApplicationInitialized = 0; this->ApplicationInitialized = 0;
this->ContextId = 0; this->ContextId = 0;
this->MultiSamples = 0;
this->WindowId = 0; this->WindowId = 0;
this->ParentId = 0; this->ParentId = 0;
this->RootWindow = 0; this->RootWindow = 0;
......
...@@ -56,7 +56,6 @@ vtkCocoaRenderWindow::vtkCocoaRenderWindow() ...@@ -56,7 +56,6 @@ vtkCocoaRenderWindow::vtkCocoaRenderWindow()
this->WindowCreated = 0; this->WindowCreated = 0;
this->ViewCreated = 0; this->ViewCreated = 0;
this->MultiSamples = 8;
this->SetWindowName("Visualization Toolkit - Cocoa"); this->SetWindowName("Visualization Toolkit - Cocoa");
this->CursorHidden = 0; this->CursorHidden = 0;
this->ForceMakeCurrent = 0; this->ForceMakeCurrent = 0;
...@@ -728,19 +727,58 @@ void vtkCocoaRenderWindow::CreateAWindow() ...@@ -728,19 +727,58 @@ void vtkCocoaRenderWindow::CreateAWindow()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void vtkCocoaRenderWindow::CreateGLContext() void vtkCocoaRenderWindow::CreateGLContext()
{ {
NSOpenGLPixelFormatAttribute attribs[] = // keep trying to get different pixelFormats until successful
NSOpenGLPixelFormat* pixelFormat = nil;
while (pixelFormat == nil)
{ {
NSOpenGLPFAAccelerated, int i = 0;
NSOpenGLPFADepthSize, NSOpenGLPixelFormatAttribute attribs[20];
(NSOpenGLPixelFormatAttribute)32,
(this->DoubleBuffer != 0) ? attribs[i++] = NSOpenGLPFAAccelerated;
(NSOpenGLPixelFormatAttribute)NSOpenGLPFADoubleBuffer : attribs[i++] = NSOpenGLPFADepthSize;
(NSOpenGLPixelFormatAttribute)nil, attribs[i++] = (NSOpenGLPixelFormatAttribute)32;
(NSOpenGLPixelFormatAttribute)nil
}; if (this->MultiSamples != 0)
{
NSOpenGLPixelFormat* pixelFormat = [[[NSOpenGLPixelFormat alloc] attribs[i++] = NSOpenGLPFASampleBuffers;
initWithAttributes:attribs] autorelease]; attribs[i++] = (NSOpenGLPixelFormatAttribute)1;
attribs[i++] = NSOpenGLPFASamples;
attribs[i++] = (NSOpenGLPixelFormatAttribute)(this->MultiSamples);
attribs[i++] = NSOpenGLPFAMultisample;
}
if (this->DoubleBuffer != 0)
{
attribs[i++] = NSOpenGLPFADoubleBuffer;
}
attribs[i++] = (NSOpenGLPixelFormatAttribute)0;
// make sure that size of array was not exceeded
assert(sizeof(NSOpenGLPixelFormatAttribute)*i < sizeof(attribs));
pixelFormat = [[[NSOpenGLPixelFormat alloc]
initWithAttributes:attribs] autorelease];
if (pixelFormat == nil)
{
if (this->MultiSamples == 0)
{
// after trying with no multisamples, we are done
break;
}
else if (this->MultiSamples < 4)
{
// next time try with no multisamples
this->MultiSamples = 0;
}
else
{
this->MultiSamples /= 2;
}
}
}
NSOpenGLContext* context = [[[NSOpenGLContext alloc] NSOpenGLContext* context = [[[NSOpenGLContext alloc]
initWithFormat:pixelFormat initWithFormat:pixelFormat
shareContext:nil] autorelease]; shareContext:nil] autorelease];
......
...@@ -39,7 +39,12 @@ vtkCxxSetObjectMacro(vtkOpenGLRenderWindow, HardwareSupport, vtkOpenGLHardwareSu ...@@ -39,7 +39,12 @@ vtkCxxSetObjectMacro(vtkOpenGLRenderWindow, HardwareSupport, vtkOpenGLHardwareSu
vtkCxxSetObjectMacro(vtkOpenGLRenderWindow, TextureUnitManager, vtkTextureUnitManager); vtkCxxSetObjectMacro(vtkOpenGLRenderWindow, TextureUnitManager, vtkTextureUnitManager);
// Initialize static member that controls global maximum number of multisamples // Initialize static member that controls global maximum number of multisamples
// (off by default on Apple because it causes problems on some Mac models).
#if defined(__APPLE__)
static int vtkOpenGLRenderWindowGlobalMaximumNumberOfMultiSamples = 0;
#else
static int vtkOpenGLRenderWindowGlobalMaximumNumberOfMultiSamples = 8; static int vtkOpenGLRenderWindowGlobalMaximumNumberOfMultiSamples = 8;
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void vtkOpenGLRenderWindow::SetGlobalMaximumNumberOfMultiSamples(int val) void vtkOpenGLRenderWindow::SetGlobalMaximumNumberOfMultiSamples(int val)
......
...@@ -45,7 +45,6 @@ vtkWin32OpenGLRenderWindow::vtkWin32OpenGLRenderWindow() ...@@ -45,7 +45,6 @@ vtkWin32OpenGLRenderWindow::vtkWin32OpenGLRenderWindow()
this->ApplicationInstance = NULL; this->ApplicationInstance = NULL;
this->Palette = NULL; this->Palette = NULL;
this->ContextId = 0; this->ContextId = 0;
this->MultiSamples = 8;
this->WindowId = 0; this->WindowId = 0;
this->ParentId = 0; this->ParentId = 0;
this->NextWindowId = 0; this->NextWindowId = 0;
......
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