Skip to content
Snippets Groups Projects
Commit 36350987 authored by Sean McBride's avatar Sean McBride
Browse files

Create the NSOpenGLPixelFormat and NSOpenGLContext before the NSView/NSWindow

The motivation here is that if we switch to NSOpenGLView, we'll need the NSOpenGLPixelFormat to construct it. Seems to make no difference creating it before or after currently.

Also moved the code that sets the NSWindow title higher up where the NSWindow is created.
parent a12cdb6a
No related branches found
No related tags found
No related merge requests found
......@@ -692,6 +692,9 @@ void vtkCocoaRenderWindow::CreateAWindow()
// where vtkRenderWindows are created but never shown.
NSApplication* app = [NSApplication sharedApplication];
// Create the NSOpenGLPixelFormat and NSOpenGLContext.
this->CreateGLContext();
// create an NSWindow only if neither an NSView nor an NSWindow have
// been specified already. This is the case for a 'pure vtk application'.
// If you are using vtk in a 'regular Mac application' you should call
......@@ -773,6 +776,10 @@ void vtkCocoaRenderWindow::CreateAWindow()
this->SetRootWindow(theWindow);
this->WindowCreated = 1;
// Since we created the NSWindow, give it a title.
NSString* winName = [NSString stringWithFormat:@"Visualization Toolkit - Cocoa #%u", count++];
this->SetWindowName([winName UTF8String]);
// makeKeyAndOrderFront: will show the window
if (this->ShowWindow)
{
......@@ -878,15 +885,6 @@ void vtkCocoaRenderWindow::CreateAWindow()
}
}
this->CreateGLContext();
// Change the window title, but only if it was created by vtk
if (this->WindowCreated)
{
NSString* winName = [NSString stringWithFormat:@"Visualization Toolkit - Cocoa #%u", count++];
this->SetWindowName([winName cStringUsingEncoding:NSASCIIStringEncoding]);
}
// the error "invalid drawable" in the console from this call can appear
// but only early in the app's lifetime (ie sometime during launch)
// IMPORTANT: this is necessary to update the context here in case of
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment