Index: director.py
===================================================================
--- director.py	(revision 880)
+++ director.py	(working copy)
@@ -470,15 +488,29 @@
         self.dispatch_event("on_resize", width, height)
 
     def set_projection(self):
-        '''Sets a 3D projection mantaining the aspect ratio of the original window size'''
-
+        '''
+        Sets a 3D projection mantaining the aspect ratio of the
+        original window size.
+        '''
         width, height = self.window.width, self.window.height
+        if height <= 0:
+            height = 1
+        if width <= 0:
+            width = 1
         ow, oh = self.get_window_size()
 
-        glViewport(0, 0, width, height)
+        if (float(width)/height) > self._window_aspect:
+            width = int(height * self._window_aspect)
+        if (float(width)/height) < self._window_aspect:
+            height = int(width * self._window_aspect)
+
+        self._offset_x = (self.window.width - width) // 2
+        self._offset_y = (self.window.height - height) // 2
+
+        glViewport(self._offset_x, self._offset_y, width, height)
         glMatrixMode(GL_PROJECTION)
         glLoadIdentity()
-        gluPerspective(60, 1.0*width/height, 0.1, 3000.0)
+        gluPerspective(60, self._window_aspect, 0.1, 3000.0)
         glMatrixMode(GL_MODELVIEW)
 
         glLoadIdentity()
