<div dir="ltr"><div>Hi Steve,</div><div><br></div><div>Here is some code that I use to bind a VTK window to a QWidget. My guess is that something similar should work with GTK. I have been using this on OS X with vtkCocoaRenderWindow.</div><div><br></div><div>void BindRenderWindow(vtkRenderWindow *window, QWidget *widget)<br></div><div>{</div><div><div> // Unmap the window if it is already mapped somewhere else.</div><div> if (window->GetMapped()) {</div><div> window->Finalize();</div><div> }</div></div><div> // Create the connection</div><div> window->SetWindowId(reinterpret_cast<void *>(widget->winId()));</div><div> // Note that we must call the superclass SetSize()/SetPosition()</div><div> // (we just want to set the member variables, with no side-effects)</div><div> window->vtkRenderWindow::SetSize(widget->width(), widget->height());</div><div> window->vtkRenderWindow::SetPosition(widget->x(), widget->y());</div><div> // Prepare for rendering</div><div> if (widget->isVisible()) {</div><div> window->Start();</div><div> }</div><div> // Call SetSize() again, to synchronize the window to the widget</div><div> window->SetSize(widget->width(), widget->height());</div><div>}</div><div><br></div><div>Some further notes:</div><div>1) I disable Qt's paint engine, so that Qt itself doesn't draw in the window. GTK may be similar.</div><div>2) You probably will not need GtkGLExt (for Qt, I didn't have to use QGLWidget).</div><div><br></div><div> - David</div><div><br></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 24, 2017 at 12:12 PM, Langer, Stephen A. (Fed) <span dir="ltr"><<a href="mailto:stephen.langer@nist.gov" target="_blank">stephen.langer@nist.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi --<br>
<br>
Is there a simple way to get vtk to work inside a gtk+2 program on macOS? If there isn't a simple way, is there a difficult one?<br>
<br>
I'm trying to get a program that uses gtk+2 and vtk to work with a modern version of vtk -- I'm upgrading from 5.10.1 to 7.1.1 or 8.0.1. On Linux, the following code creates a vtk render window and a gtk widget containing it:<br>
vtkRenderWindow *render_win = vtkRenderWindow::New();<br>
GtkWidget *drawing_area = gtk_drawing_area_new();<br>
Display *disp = GDK_DISPLAY();<br>
render_win->SetDisplayId(disp)<wbr>;<br>
followed eventually by<br>
XID wid = GDK_WINDOW_XID(drawing_area-><wbr>window);<br>
render_win->SetWindowId(wid);<br>
after receiving the gtk "realize" signal on the drawing_area.<br>
<br>
On macOS, I'd like to use the Cocoa version of gtk+2 and vtkCocoaRenderWindow, but I can't figure out how to embed the render window into a gtk widget. All the examples I've found on-line aren't really applicable.<br>
<br>
GtkGLExt might be applicable, but it doesn't look like it's being maintained.<br>
<br>
An alternative would be to use X11, but native Mac OpenGL doesn't understand X11, so I tried installing mesa from macports , rebuilding vtk with VTK_USE_X instead of VTK_USE_COCOA, and linking to /opt/local/lib instead of /System/Library/Frameworks/<wbr>OpenGL.framework. Then I can use the same code as on Linux, but vtk complains about the context not supporting OpenGL 3.2, and then crashes:<br>
ERROR: In /Users/langer/UTIL/VTK/VTK-7.<wbr>1.1/Rendering/OpenGL2/<wbr>vtkTextureObject.cxx, line 440<br>
vtkTextureObject (0x7f9eafdb1690): failed at glGenTextures 1 OpenGL errors detected<br>
0 : (1280) Invalid enum<br>
<br>
Thanks,<br>
Steve<br></blockquote></div></div></div>