Browse Source

remove old make_graphics_window function

David Rose 23 years ago
parent
commit
ad00ca3a21
3 changed files with 57 additions and 90 deletions
  1. 55 28
      direct/src/showbase/ShowBase.py
  2. 2 61
      direct/src/showbase/showBase.cxx
  3. 0 1
      direct/src/showbase/showBase.h

+ 55 - 28
direct/src/showbase/ShowBase.py

@@ -99,7 +99,7 @@ class ShowBase(DirectObject.DirectObject):
         self.dgTrav = DataGraphTraverser()
 
         # base.win is the main, or only window; base.winList is a list of
-        # *all* windows.  Similarly with base.pipeList and base.camList.
+        # *all* windows.  Similarly with base.camList.
         self.win = None
         self.winList = []
         self.mainWinMinimized = 0
@@ -189,14 +189,7 @@ class ShowBase(DirectObject.DirectObject):
         is closed cleanly, so that we free system resources, restore
         the desktop and keyboard functionality, etc.
         """
-        # Temporary try .. except for new window code
-        try:
-            # new window code
-            self.graphicsEngine.removeAllWindows()
-        except:
-            # old window code
-            for win in self.winList:
-                win.closeWindow()
+        self.graphicsEngine.removeAllWindows()
         del self.win
         del self.winList
         del self.pipe
@@ -209,6 +202,55 @@ class ShowBase(DirectObject.DirectObject):
         if self.oldexitfunc:
             self.oldexitfunc()
 
+    def makeDefaultPipe(self):
+        """makeDefaultPipe(self)
+        Creates the default GraphicsPipe, which will be used to make
+        windows unless otherwise specified.
+        """
+        assert(self.pipe == None)
+        selection = GraphicsPipeSelection.getGlobalPtr()
+        selection.printPipeTypes()
+        self.pipe = selection.makeDefaultPipe()
+        if not self.pipe:
+            self.notify.error("No graphics pipe is available!  Check your Configrc!")
+        self.notify.info("Default graphics pipe is %s (%s)." % (self.pipe.getInterfaceName(), self.pipe.getType().getName()))
+        self.pipeList.append(self.pipe)
+
+    def makeAllPipes(self):
+        """makeAllPipes(self)
+        Creates all GraphicsPipes that the system knows about and fill up
+        self.pipeList with them.
+        """
+        shouldPrintPipes = 0
+        selection = GraphicsPipeSelection.getGlobalPtr()
+        selection.loadAuxModules()
+
+        # First, we should make sure the default pipe exists.
+        if self.pipe == None:
+            self.makeDefaultPipe()
+
+        # Now go through the list of known pipes, and make each one if
+        # we don't have one already.
+        numPipeTypes = selection.getNumPipeTypes()
+        for i in range(numPipeTypes):
+            pipeType = selection.getPipeType(i)
+
+            # Do we already have a pipe of this type on the list?
+            # This operation is n-squared, but presumably there won't
+            # be more than a handful of pipe types, so who cares.
+            already = 0
+            for pipe in self.pipeList:
+                if pipe.getType() == pipeType:
+                    already = 1
+
+            if not already:
+                pipe = selection.makePipe(pipeType)
+                if pipe:
+                    self.notify.info("Got aux graphics pipe %s (%s)." % (pipe.getInterfaceName(), pipe.getType().getName()))
+                    self.pipeList.append(pipe)
+                else:
+                    self.notify.info("Could not make graphics pipe %s." % (pipeType.getName()))
+
     def openWindow(self):
         """openWindow(self)
         Invokes ChanConfig to create a window and adds it to the list
@@ -216,18 +258,11 @@ class ShowBase(DirectObject.DirectObject):
         """
 
         if self.pipe == None:
-            self.pipe = makeGraphicsPipe()
-            self.pipeList.append(self.pipe)
+            self.makeDefaultPipe()
 
-        # Temporary try .. except for new window code.
-        try:
-            # old window code
-            chanConfig = makeGraphicsWindow(self.graphicsEngine, self.pipe, self.render)
-        except:
-            # new window code
-            chanString = self.config.GetString('chan-config', 'single')
-            chanConfig = ChanConfig(self.graphicsEngine, self.pipe, chanString,
-                                    self.render)
+        chanString = self.config.GetString('chan-config', 'single')
+        chanConfig = ChanConfig(self.graphicsEngine, self.pipe, chanString,
+                                self.render)
             
         win = chanConfig.getWin()
 
@@ -243,14 +278,6 @@ class ShowBase(DirectObject.DirectObject):
             self.win = win
 
         self.winList.append(win)
-        # temporary try..except to support new window code
-        try:
-            # new window code
-            self.graphicsEngine.addWindow(win)
-        except:
-            # old window code
-            pass
-
         self.getCameras(chanConfig)
         return win
 

+ 2 - 61
direct/src/showbase/showBase.cxx

@@ -24,19 +24,7 @@
 #include "renderBuffer.h"
 #include "get_config_path.h"
 #include "camera.h"
-
-// You should define this unless you don't have the new GraphicsWindow
-// code yet.  drose checked this in to Panda at around 12:30pm on
-// Thursday, Jan 9; if you haven't updated your Panda since then you
-// should either go update it (and prepare for a long build) or just
-// comment this out to run for the short term with the old code.
-#define NEW_WINDOW_CODE 1
-
-#ifdef NEW_WINDOW_CODE
 #include "graphicsPipeSelection.h"
-#else
-#include "interactiveGraphicsPipe.h"
-#endif
 
 
 ConfigureDef(config_showbase);
@@ -49,52 +37,6 @@ get_particle_path() {
   return get_config_path("particle-path", particle_path);
 }
 
-// Default channel config
-std::string chan_config = "single";
-std::string window_title = "Panda3D";
-
-
-PT(GraphicsPipe) 
-make_graphics_pipe() {
-  PT(GraphicsPipe) main_pipe;
-
-#ifdef NEW_WINDOW_CODE
-  GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
-  selection->resolve_modules();
-
-  nout << "Known pipe types:" << endl;
-  int num_pipe_types = selection->get_num_pipe_types();
-  for (int i = 0; i < num_pipe_types; i++) {
-    nout << "  " << selection->get_pipe_type(i) << "\n";
-  }
-
-  main_pipe = selection->make_default_pipe();
-
-#else  // NEW_WINDOW_CODE
-
-  // load display modules
-  GraphicsPipe::resolve_modules();
-
-  nout << "Known pipe types:" << endl;
-  GraphicsPipe::get_factory().write_types(nout, 2);
-
-  // Create a window
-  main_pipe = GraphicsPipe::get_factory().
-    make_instance(InteractiveGraphicsPipe::get_class_type());
-
-#endif  // NEW_WINDOW_CODE
-
-  if (main_pipe == (GraphicsPipe*)0L) {
-    nout << "No interactive pipe is available!  Check your Configrc!\n";
-    return NULL;
-  }
-
-  nout << "Opened a '" << main_pipe->get_type().get_name()
-       << "' interactive graphics pipe." << endl;
-
-  return main_pipe;
-}
-
 // Throw the "NewFrame" event in the C++ world.  Some of the lerp code
 // depends on receiving this.
 void 
@@ -148,9 +90,8 @@ void add_fullscreen_testsize(unsigned int xsize,unsigned int ysize) {
 }
 
 void runtest_fullscreen_sizes(GraphicsWindow *win) {
-#ifndef NEW_WINDOW_CODE
-    (void) win->verify_window_sizes(num_fullscreen_testsizes,fullscreen_testsizes);
-#endif  // NEW_WINDOW_CODE
+  // TODO.
+  //  win->verify_window_sizes(num_fullscreen_testsizes,fullscreen_testsizes);
 }
 
 bool query_fullscreen_testresult(unsigned int xsize,unsigned int ysize) {

+ 0 - 1
direct/src/showbase/showBase.h

@@ -42,7 +42,6 @@ BEGIN_PUBLISH
 
 EXPCL_DIRECT DSearchPath &get_particle_path();
 
-EXPCL_DIRECT PT(GraphicsPipe) make_graphics_pipe();
 EXPCL_DIRECT void throw_new_frame();
 
 EXPCL_DIRECT void take_snapshot(GraphicsWindow *win, const string &name);