Hi,<br><br>The following commit:<br><a href="http://vtk.org/gitweb?p=VTK.git;a=commit;h=2eb0792e" target="_blank">http://vtk.org/gitweb?p=VTK.git;a=commit;h=2eb0792e</a><br>introduces a new method IntializeFromCurrentContext() method in vtkRenderWindow an derived classes (vtk[Win32|X|Cocoa]OpenGLRenderWindow).<br>
<br>This method has been developed to link an preexisting rendering context/render window to an instance of vtkRenderWindow (an OpenGL context of a vtkOpenGLRenderWindow to be more precise).<br>The actual behaviour of vtkRenderWindow performed just before the first rendering step is:<br>
- create a new rendering window and link it to a new OpenGL context if some native window ids/handles (for instance X Display+Drawable on Linux, HWND and HDC on Windows...) was not previously set by the user<br> - OR create and link a new OpenGL context to the window the user defined by furnishing the previously cited window handles.<br>
<br>This behavior is enough in most situations but in some case you may want to associate the vtkRenderWindow to a window created by a GUI API which do not give you access to the native window handles (Java SWT for instance).<br>
However, this API may offer you a way to create an OpenGL canvas in which you would like to make the VTK visualization.<br>
This is where the new IntializeFromCurrentContext() method is useful: from the current OpenGL context it retrieves the associated window handles (low level OpenGL context API offer such functionalities) and associate it to the vtkRenderWindow instance together with the OpenGL context. In this particular case VTK will not create window nor OpenGL context any more but will inherit it from the one discovered by the new function.<br>
<br>You will find here:<br clear="all"><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/GLUT" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/GLUT</a><br>an example of how to make it work with the famous GLUT library.<br>
<br>What do you think about that? Any suggestions?<br><br>PS : the code has been tested under Windows & Linux - however the Cocoa (MacOS X) code is available too.<br>PS2 : for now, vtk*OpenGLRenderWindow destroy the OpenGL context when they are deleted which may not always be a good idea. I will had a member variable to avoid that when the class has not created the context by itself.<br>
<br>-- <br><b>Joachim Pouderoux</b><br>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font size="1"><i>PhD, R&D Enginee</i>r</font> <br><b><font size="1"><a href="http://www.kitware.fr" target="_blank">Kitware SAS</a></font></b><br>
</blockquote>
<br>