[vtk-developers] Direct OpenGL Calls with derived vtkOpenGLPolyDataMapper

Brad Hollister behollis at sci.utah.edu
Wed Mar 16 19:15:21 EDT 2016


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()
 


More information about the vtk-developers mailing list