title: How to resize a GLUT window?
body: <pre><code>from OpenGL.extensions import alternate
  from OpenGL.GL import *
  from OpenGL.GL.ARB.multitexture import *
  from OpenGL.GLU import *
  from OpenGL.GLUT import *
  
  
  class TestTexture():
  
      def __init__(self):
          self.window_width = 800
          self.window_height = 800
  
      def init(self):
          glClearColor(0.0, 0.0, 0.0, 0.0)
          glMatrixMode(GL_PROJECTION)
          glLoadIdentity()
          glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0)
          glMatrixMode(GL_MODELVIEW)
          glLoadIdentity()
          glEnable(GL_TEXTURE_2D)
  
      def display(self):
          glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
          glLoadIdentity()
  
          glBegin(GL_TRIANGLES)
          glVertex3f(-1.0, 0.0, 0.0)
          glVertex3f(1.0, 0.0, 0.0)
          glVertex3f(0.0, 1.0, 0.0)
          glEnd()
  
          glFlush()
          glutSwapBuffers()
  
      def reshape(self, w, h):
          self.window_width = w
          self.window_height = h
          glViewport(0, 0, self.window_width, self.window_height)
  
      def animate(self):
          glutPostRedisplay()
  
      def visible(self, vis):
          if (vis == GLUT_VISIBLE):
              glutIdleFunc(self.animate)
          else:
              glutIdleFunc(0)
  
      def key_pressed(self, *args):
          if args[0] == b"\x1b":
              sys.exit()
  
      def run(self):
          glutInit(sys.argv)
          glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
          glutInitWindowSize(self.window_width, self.window_height)
          glutInitWindowPosition(800, 100)
          glutCreateWindow(b'MCVE')
          glutDisplayFunc(self.display)
          glutReshapeFunc(self.reshape)
          glutIdleFunc(self.animate)
          glutVisibilityFunc(self.visible)
          glutKeyboardFunc(self.key_pressed)
  
          self.init()
          glutMainLoop()
  
  if __name__ == "__main__":
      TestTexture().run()
  </code></pre>
  
  <p>I've already tried few things in order to resize&amp;refresh properly this window but no luck so far. When the window is resized the scene should be rendered properly on real-time but it's not, instead the scene is updated only when you release the mouse (reshape function is not called) or maybe when it's being resized it gets a little chance to update but the final result is definitely not cool at all.</p>
  
  <p>Worth mentioning that a pyqt opengl app is resizing ok and the <a href="https://www.sevenforums.com/tutorials/75059-show-window-contents-outline-while-dragging.html" rel="nofollow noreferrer">show window contents while dragging</a> option is enabled.</p>
  
  <p>The test has been made on windows7, PyOpenGL==3.1.1 and python3.5.1_x86</p>
  
  <p>So the question would be, how can I resize&amp;refresh a glut window properly on realtime?</p>