Browse Source

add name to GraphicsWindow constructor

David Rose 22 years ago
parent
commit
51ebbba986
1 changed files with 20 additions and 6 deletions
  1. 20 6
      direct/src/showbase/ShowBase.py

+ 20 - 6
direct/src/showbase/ShowBase.py

@@ -52,6 +52,8 @@ class ShowBase(DirectObject.DirectObject):
         else:
         else:
             vfs = None
             vfs = None
 
 
+        self.nextWindowIndex = 1
+
         # Store dconfig variables
         # Store dconfig variables
         self.sfxActive = self.config.GetBool('audio-sfx-active', 1)
         self.sfxActive = self.config.GetBool('audio-sfx-active', 1)
         self.musicActive = self.config.GetBool('audio-music-active', 1)
         self.musicActive = self.config.GetBool('audio-music-active', 1)
@@ -340,7 +342,7 @@ class ShowBase(DirectObject.DirectObject):
                     self.notify.info("Could not make graphics pipe %s." % (pipeType.getName()))
                     self.notify.info("Could not make graphics pipe %s." % (pipeType.getName()))
 
 
     def openWindow(self, props = None, pipe = None, gsg = None,
     def openWindow(self, props = None, pipe = None, gsg = None,
-                   type = None):
+                   type = None, name = None):
         """
         """
         Creates a window and adds it to the list of windows that are
         Creates a window and adds it to the list of windows that are
         to be updated every frame.
         to be updated every frame.
@@ -371,11 +373,23 @@ class ShowBase(DirectObject.DirectObject):
         if props == None:
         if props == None:
             props = self.defaultWindowProps
             props = self.defaultWindowProps
 
 
-        if type == 'onscreen':
-            win = self.graphicsEngine.makeWindow(pipe, gsg)
-        elif type == 'offscreen':
-            win = self.graphicsEngine.makeBuffer(
-                pipe, gsg, props.getXSize(), props.getYSize(), 0)
+        if name == None:
+            name = 'window%s' % (self.nextWindowIndex)
+            self.nextWindowIndex += 1
+
+        # Temporary try .. except for old Pandas.
+        try:
+            if type == 'onscreen':
+                win = self.graphicsEngine.makeWindow(pipe, gsg, name)
+            elif type == 'offscreen':
+                win = self.graphicsEngine.makeBuffer(
+                    pipe, gsg, name, props.getXSize(), props.getYSize(), 0)
+        except:
+            if type == 'onscreen':
+                win = self.graphicsEngine.makeWindow(pipe, gsg)
+            elif type == 'offscreen':
+                win = self.graphicsEngine.makeBuffer(
+                    pipe, gsg, props.getXSize(), props.getYSize(), 0)
             
             
         if win == None:
         if win == None:
             # Couldn't create a window!
             # Couldn't create a window!