[vtkusers] Can I derive from vtkOpenGLRenderWindow for a yet unsupported window system?

David Cole david.cole at kitware.com
Tue Apr 8 16:38:03 EDT 2008


Some classes are more special than others. :-)  vtkRenderWindow subclasses
depend on the graphics factory to create the "correct" subclass when
vtkRenderWindow::New is called. Therefore, to add to the vtkRenderWindow
hierarchy, you need to modify the graphics factory or provide your own "New"
implementation that bypasses the graphics factory.

Modifying the graphics factory directly has the benefit of creating your
specific subclass even if client applications use "vtkRenderWindow::New" in
their source code...

HTH,
David


On Tue, Apr 8, 2008 at 4:07 PM, Christian Banks <cryo80home at yahoo.com>
wrote:

> Hello,
> I am looking for an example or some general comments, how I can extend the
> vtkOpenGLRenderWindow for a very special OpenGL library
> (vtkXOpenGLRenderWindow is not applicable, because I want to run VTK on an
> embedded system with a custom window system).
>
> Currently I am more or less duplicating vtkXOpenGLRenderWindow with
> changes where necessary to account for the window system that replaces X11.
> Compilation of the new class vtkNewOpenGLRenderWindow is successful.
>
> Unfortunately the following call in a VTK application always results in
> renWin being a vtkXOpenGLRenderWindow, not the desired
> vtkNewOpenGLRenderWindow:
>
> vtkRenderWindow *renWin = vtkNewOpenGLRenderWindow::New();
>
> The reason is that New() is inherited from vtkRenderWindow::New(), which
> calls vtkGraphicsFactory::CreateInstance("vtkRenderWindow") which finally
> executes "return vtkXOpenGLRenderWindow::New();".
>
> Is it necessary to dig through the vtkRenderWindow hierarchy and replace
> each occurrence of vtkXOpenGLRenderWindow with vtkNewOpenGLRenderWindow?
> Or is there a way with less modifications of the vtk sources, for example
> overriding vtkNewOpenGLRenderWindow::New(), but how does it have to look
> like? I found that I cannot simply ignore the chain of calls down to
> vtkGraphicsFactory::CreateInstance(), but on the other hand my impression is
> that it is unnecessarily complicated if I have to modify several classes if
> all I want is to derive from vtkOpenGLRenderWindow.
>
> Any comments are appreciated!
>
> Thank you in advance
> cryo
>
> ------------------------------
> You rock. That's why Blockbuster's offering you one month of Blockbuster
> Total Access<http://us.rd.yahoo.com/evt=47523/*http://tc.deals.yahoo.com/tc/blockbuster/text5.com>,
> No Cost.
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080408/a0f02867/attachment.htm>


More information about the vtkusers mailing list