'viewport specifies the arguments to glViewport. If None, then we use self.opts[\'viewport\']
region specifies the sub-region of self.opts[\'viewport\'] that should be rendered.
Note that we may use viewport != self.opts[\'viewport\'] when exporting.'

def paintGL(self, region=None, viewport=None, useItemNames=False):

    if (viewport is None):
        glViewport(*self.getViewport())
    else:
        glViewport(*viewport)
    self.setProjection(region=region)
    self.setModelview()
    bgcolor = self.opts['bgcolor']
    glClearColor(*bgcolor)
    glClear((GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT))
    self.drawItemTree(useItemNames=useItemNames)
