[vtk-developers] Direct OpenGL Calls with derived vtkOpenGLPolyDataMapper

David Gobbi david.gobbi at gmail.com
Wed Mar 16 19:34:17 EDT 2016


Hi Brad,

Overriding a virtual C++ method in Python only works if the method is
called from Python.  In this case, the Render method is being called from
C++.

 - David

On Wed, Mar 16, 2016 at 5:15 PM, Brad Hollister <behollis at sci.utah.edu>
wrote:

> How would it be possible to call directly to OpenGL with a derived mapper
> object (simple example below) and draw into the VTK window using Python?
> I've tried a similar bit of code, but the overriden Render() is never
> called. A few old forum emails state that it is possible to override the
> Render function (or maybe Draw() with 7.0) and issue calls directly to
> OpenGL for the current VTK render window.
>
> class vtkOpenGLPolyDataMapperCustom(vtkOpenGLPolyDataMapper):
>     def __init__(self):
>         print "calling init in derived class"
>         vtkOpenGLPolyDataMapper.__init__(self)
>
>     def Render( self, ren, act ):
>         print 'Render overriden function is being called...'
>         ren.GetRenderWindow().MakeCurrent()
>         self.drawUsingOpenGL()
>
>     def drawUsingOpenGL(self):
>         glLoadIdentity()
>         glBegin(GL_QUADS)
>         glVertex3f(-1.0, 1.0, 0.0)
>         glVertex3f(-1.1, 1.0, 0.0)
>         glVertex3f(-1.1, 0.5, 0.0)
>         glVertex3f(-1.0, 0.5, 0.0)
>         glEnd()
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20160316/3698499c/attachment.html>


More information about the vtk-developers mailing list