code: def on_resize(self, event):
          
          self.context.set_viewport(0, 0, event.size[0], event.size[1])
          for visual in self.visuals:
              visual.on_resize(event.size)
          self.update()
docs: Resize the OpenGL context.