Browse Source

new window code

David Rose 23 years ago
parent
commit
ea59108287
100 changed files with 7993 additions and 4031 deletions
  1. 6 4
      direct/src/showbase/showBase.cxx
  2. 2 2
      dtool/src/dtoolbase/dllbase.txt
  3. 0 23
      panda/metalibs/pandadx/Sources.pp
  4. 0 23
      panda/metalibs/pandadx/pandadx.cxx
  5. 0 13
      panda/metalibs/pandadx/pandadx.h
  6. 2 2
      panda/metalibs/pandadx8/Sources.pp
  7. 1 3
      panda/metalibs/pandadx8/pandadx8.cxx
  8. 3 2
      panda/metalibs/pandagl/Sources.pp
  9. 6 0
      panda/metalibs/pandagl/pandagl.cxx
  10. 29 25
      panda/src/chancfg/chancfg.cxx
  11. 6 3
      panda/src/chancfg/chancfg.h
  12. 3 2
      panda/src/device/mouseAndKeyboard.cxx
  13. 40 37
      panda/src/display/Sources.pp
  14. 1 0
      panda/src/display/clearableRegion.h
  15. 12 75
      panda/src/display/config_display.cxx
  16. 3 18
      panda/src/display/config_display.h
  17. 10 160
      panda/src/display/displayRegion.I
  18. 224 9
      panda/src/display/displayRegion.cxx
  19. 22 20
      panda/src/display/displayRegion.h
  20. 2 3
      panda/src/display/display_composite2.cxx
  21. 0 14
      panda/src/display/graphicsChannel.I
  22. 54 28
      panda/src/display/graphicsChannel.cxx
  23. 18 27
      panda/src/display/graphicsChannel.h
  24. 11 22
      panda/src/display/graphicsEngine.I
  25. 585 296
      panda/src/display/graphicsEngine.cxx
  26. 55 47
      panda/src/display/graphicsEngine.h
  27. 0 29
      panda/src/display/graphicsLayer.I
  28. 78 43
      panda/src/display/graphicsLayer.cxx
  29. 18 27
      panda/src/display/graphicsLayer.h
  30. 0 18
      panda/src/display/graphicsPipe.I
  31. 61 268
      panda/src/display/graphicsPipe.cxx
  32. 36 90
      panda/src/display/graphicsPipe.h
  33. 57 0
      panda/src/display/graphicsPipeSelection.I
  34. 251 0
      panda/src/display/graphicsPipeSelection.cxx
  35. 86 0
      panda/src/display/graphicsPipeSelection.h
  36. 55 29
      panda/src/display/graphicsStateGuardian.cxx
  37. 4 5
      panda/src/display/graphicsStateGuardian.h
  38. 26 423
      panda/src/display/graphicsWindow.I
  39. 639 410
      panda/src/display/graphicsWindow.cxx
  40. 93 232
      panda/src/display/graphicsWindow.h
  41. 3 3
      panda/src/display/graphicsWindowInputDevice.cxx
  42. 3 3
      panda/src/display/graphicsWindowInputDevice.h
  43. 0 73
      panda/src/display/interactiveGraphicsPipe.cxx
  44. 0 51
      panda/src/display/interactiveGraphicsPipe.h
  45. 0 61
      panda/src/display/noninteractiveGraphicsPipe.cxx
  46. 0 52
      panda/src/display/noninteractiveGraphicsPipe.h
  47. 0 78
      panda/src/display/pipeSpec.I
  48. 0 55
      panda/src/display/pipeSpec.cxx
  49. 0 60
      panda/src/display/pipeSpec.h
  50. 1 0
      panda/src/display/renderBuffer.h
  51. 664 0
      panda/src/display/windowProperties.I
  52. 220 0
      panda/src/display/windowProperties.cxx
  53. 173 0
      panda/src/display/windowProperties.h
  54. 1 1
      panda/src/distort/nonlinearImager.cxx
  55. 0 29
      panda/src/dxgsg/Sources.pp
  56. 0 4
      panda/src/dxgsg/dxgsg_composite1.cxx
  57. 36 0
      panda/src/dxgsg7/Sources.pp
  58. 51 44
      panda/src/dxgsg7/config_dxgsg7.cxx
  59. 9 7
      panda/src/dxgsg7/config_dxgsg7.h
  60. 4 4
      panda/src/dxgsg7/dxGeomNodeContext7.I
  61. 4 4
      panda/src/dxgsg7/dxGeomNodeContext7.cxx
  62. 10 10
      panda/src/dxgsg7/dxGeomNodeContext7.h
  63. 75 71
      panda/src/dxgsg7/dxGraphicsStateGuardian7.I
  64. 158 383
      panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx
  65. 23 37
      panda/src/dxgsg7/dxGraphicsStateGuardian7.h
  66. 7 7
      panda/src/dxgsg7/dxSavedFrameBuffer7.I
  67. 3 3
      panda/src/dxgsg7/dxSavedFrameBuffer7.cxx
  68. 9 9
      panda/src/dxgsg7/dxSavedFrameBuffer7.h
  69. 57 57
      panda/src/dxgsg7/dxTextureContext7.cxx
  70. 11 11
      panda/src/dxgsg7/dxTextureContext7.h
  71. 7 0
      panda/src/dxgsg7/dxgsg7_composite1.cxx
  72. 1516 0
      panda/src/dxgsg7/dxgsg7base.cxx
  73. 3 3
      panda/src/dxgsg7/dxgsg7base.h
  74. 2 3
      panda/src/dxgsg7/wdxGraphicsPipe7.I
  75. 63 0
      panda/src/dxgsg7/wdxGraphicsPipe7.cxx
  76. 60 0
      panda/src/dxgsg7/wdxGraphicsPipe7.h
  77. 2 2
      panda/src/dxgsg7/wdxGraphicsWindow7.I
  78. 1331 0
      panda/src/dxgsg7/wdxGraphicsWindow7.cxx
  79. 92 0
      panda/src/dxgsg7/wdxGraphicsWindow7.h
  80. 10 3
      panda/src/dxgsg8/Sources.pp
  81. 55 38
      panda/src/dxgsg8/config_dxgsg8.cxx
  82. 9 3
      panda/src/dxgsg8/config_dxgsg8.h
  83. 18 18
      panda/src/dxgsg8/d3dfont8.cxx
  84. 3 3
      panda/src/dxgsg8/dxGeomNodeContext8.I
  85. 2 2
      panda/src/dxgsg8/dxGeomNodeContext8.cxx
  86. 8 8
      panda/src/dxgsg8/dxGeomNodeContext8.h
  87. 81 77
      panda/src/dxgsg8/dxGraphicsStateGuardian8.I
  88. 149 208
      panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx
  89. 17 26
      panda/src/dxgsg8/dxGraphicsStateGuardian8.h
  90. 7 7
      panda/src/dxgsg8/dxSavedFrameBuffer8.I
  91. 2 2
      panda/src/dxgsg8/dxSavedFrameBuffer8.cxx
  92. 7 7
      panda/src/dxgsg8/dxSavedFrameBuffer8.h
  93. 49 49
      panda/src/dxgsg8/dxTextureContext8.cxx
  94. 10 10
      panda/src/dxgsg8/dxTextureContext8.h
  95. 2 0
      panda/src/dxgsg8/dxgsg8_composite1.cxx
  96. 0 1
      panda/src/dxgsg8/dxgsg8base.h
  97. 2 12
      panda/src/dxgsg8/wdxGraphicsPipe8.I
  98. 339 0
      panda/src/dxgsg8/wdxGraphicsPipe8.cxx
  99. 109 0
      panda/src/dxgsg8/wdxGraphicsPipe8.h
  100. 17 0
      panda/src/dxgsg8/wdxGraphicsWindow8.I

+ 6 - 4
direct/src/showbase/showBase.cxx

@@ -25,10 +25,12 @@
 #include "get_config_path.h"
 #include "get_config_path.h"
 #include "camera.h"
 #include "camera.h"
 
 
-// Don't define this unless you have drose's new GraphicsWindow code,
-// which is currently a work in progress.  You probably won't have it
-// unless you are drose.
-//#define NEW_WINDOW_CODE 1
+// 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
 #ifdef NEW_WINDOW_CODE
 #include "graphicsPipeSelection.h"
 #include "graphicsPipeSelection.h"

+ 2 - 2
dtool/src/dtoolbase/dllbase.txt

@@ -7,7 +7,7 @@
 ; release dlls
 ; release dlls
 
 
 libpanda         0x0000000060000000 0x004b0000
 libpanda         0x0000000060000000 0x004b0000
-libpandadx       0x0000000061000000 0x00090000
+libpandadx8      0x0000000061000000 0x00090000
 libpandadx7      0x0000000061000000 0x00050000
 libpandadx7      0x0000000061000000 0x00050000
 libpandagl       0x0000000061000000 0x00040000
 libpandagl       0x0000000061000000 0x00040000
 libpandaexpress  0x00000000605d0000 0x00140000
 libpandaexpress  0x00000000605d0000 0x00140000
@@ -25,7 +25,7 @@ libframework     0x0000000060a50000 0x00020000
 ; debug dlls
 ; debug dlls
 
 
 libpanda_d       0x0000000060000000 0x007c0000
 libpanda_d       0x0000000060000000 0x007c0000
-libpandadx_d     0x00000000607c0000 0x000f0000
+libpandadx8_d    0x00000000607c0000 0x000f0000
 libpandadx7_d    0x00000000608b0000 0x00070000
 libpandadx7_d    0x00000000608b0000 0x00070000
 libpandagl_d     0x0000000060920000 0x00050000
 libpandagl_d     0x0000000060920000 0x00050000
 libpandaexpress_d 0x0000000060970000 0x00210000
 libpandaexpress_d 0x0000000060970000 0x00210000

+ 0 - 23
panda/metalibs/pandadx/Sources.pp

@@ -1,23 +0,0 @@
-#define BUILD_DIRECTORY $[HAVE_DX]
-
-// DIR_TYPE "metalib" indicates we are building a shared library that
-// consists mostly of references to other shared libraries.  Under
-// Windows, this directly produces a DLL (as opposed to the regular
-// src libraries, which don't produce anything but a pile of OBJ files
-// under Windows).
-
-#define DIR_TYPE metalib
-#define BUILDING_DLL BUILDING_PANDADX
-
-#define COMPONENT_LIBS \
-    dxgsg wdxdisplay
-#define LOCAL_LIBS gsgbase display express
-#define OTHER_LIBS dtoolconfig dtool
-
-#begin metalib_target
-  #define TARGET pandadx7
-  #define SOURCES pandadx.cxx  
-  #define WIN_SYS_LIBS \
-     ddraw.lib dxguid.lib winmm.lib \
-     kernel32.lib gdi32.lib user32.lib $[WIN_SYS_LIBS]
-#end metalib_target

+ 0 - 23
panda/metalibs/pandadx/pandadx.cxx

@@ -1,23 +0,0 @@
-// Filename: pandadx.cxx
-// Created by:  drose (15May00)
-// 
-////////////////////////////////////////////////////////////////////
-
-#include "pandadx.h"
-
-#include <config_dxgsg.h>
-#include <config_wdxdisplay.h>
-
-////////////////////////////////////////////////////////////////////
-//     Function: init_libpandadx
-//  Description: Initializes the library.  This must be called at
-//               least once before any of the functions or classes in
-//               this library can be used.  Normally it will be
-//               called by the static initializers and need not be
-//               called explicitly, but special cases exist.
-////////////////////////////////////////////////////////////////////
-void
-init_libpandadx() {
-  init_libdxgsg();
-  init_libwdxdisplay();
-}

+ 0 - 13
panda/metalibs/pandadx/pandadx.h

@@ -1,13 +0,0 @@
-// Filename: pandadx.h
-// Created by:  drose (2Jan01)
-// 
-////////////////////////////////////////////////////////////////////
-
-#ifndef PANDADX_H
-#define PANDADX_H
-
-#include <pandabase.h>
-
-EXPCL_PANDADX void init_libpandadx();
-
-#endif

+ 2 - 2
panda/metalibs/pandadx8/Sources.pp

@@ -10,12 +10,12 @@
 #define BUILDING_DLL BUILDING_PANDADX
 #define BUILDING_DLL BUILDING_PANDADX
 
 
 #define COMPONENT_LIBS \
 #define COMPONENT_LIBS \
-    dxgsg8 wdxdisplay8
+    dxgsg8
 #define LOCAL_LIBS gsgbase display express gobj
 #define LOCAL_LIBS gsgbase display express gobj
 #define OTHER_LIBS dtoolconfig dtool
 #define OTHER_LIBS dtoolconfig dtool
 
 
 #begin metalib_target
 #begin metalib_target
-  #define TARGET pandadx
+  #define TARGET pandadx8
   #define SOURCES pandadx8.cxx
   #define SOURCES pandadx8.cxx
   #define WIN_SYS_LIBS \
   #define WIN_SYS_LIBS \
      ddraw.lib dxguid.lib winmm.lib \
      ddraw.lib dxguid.lib winmm.lib \

+ 1 - 3
panda/metalibs/pandadx8/pandadx8.cxx

@@ -5,8 +5,7 @@
 
 
 #include "pandadx8.h"
 #include "pandadx8.h"
 
 
-#include <config_dxgsg8.h>
-#include <config_wdxdisplay8.h>
+#include "config_dxgsg8.h"
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libpandadx
 //     Function: init_libpandadx
@@ -19,5 +18,4 @@
 void
 void
 init_libpandadx8() {
 init_libpandadx8() {
   init_libdxgsg8();
   init_libdxgsg8();
-  init_libwdxdisplay8();
 }
 }

+ 3 - 2
panda/metalibs/pandagl/Sources.pp

@@ -12,8 +12,9 @@
   // We don't have any components if we're linking the GL library
   // We don't have any components if we're linking the GL library
   // directly into Panda.
   // directly into Panda.
   #define COMPONENT_LIBS \
   #define COMPONENT_LIBS \
-      glgsg glxdisplay wgldisplay glutdisplay \
-      sgidisplay sgiglxdisplay sgiglutdisplay
+      glgsg glxdisplay  \
+      sgidisplay sgiglxdisplay \
+      wgldisplay
 #endif
 #endif
 
 
 #define LOCAL_LIBS gsgbase display express
 #define LOCAL_LIBS gsgbase display express

+ 6 - 0
panda/metalibs/pandagl/pandagl.cxx

@@ -7,9 +7,12 @@
 
 
 #ifndef LINK_IN_GL
 #ifndef LINK_IN_GL
 #include <config_glgsg.h>
 #include <config_glgsg.h>
+// Temporarily commented out for development on wgldisplay
+/*
 #ifdef HAVE_WGL
 #ifdef HAVE_WGL
 #include <config_wgldisplay.h>
 #include <config_wgldisplay.h>
 #endif
 #endif
+*/
 #endif
 #endif
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -24,8 +27,11 @@ void
 init_libpandagl() {
 init_libpandagl() {
 #ifndef LINK_IN_GL
 #ifndef LINK_IN_GL
   init_libglgsg();
   init_libglgsg();
+// Temporarily commented out for development on wgldisplay
+  /*
 #ifdef HAVE_WGL
 #ifdef HAVE_WGL
   init_libwgldisplay();
   init_libwgldisplay();
 #endif
 #endif
+  */
 #endif
 #endif
 }
 }

+ 29 - 25
panda/src/chancfg/chancfg.cxx

@@ -19,6 +19,8 @@
 #include "chancfg.h"
 #include "chancfg.h"
 #include "notify.h"
 #include "notify.h"
 #include "displayRegion.h"
 #include "displayRegion.h"
+#include "graphicsPipe.h"
+#include "graphicsEngine.h"
 #include "graphicsChannel.h"
 #include "graphicsChannel.h"
 #include "hardwareChannel.h"
 #include "hardwareChannel.h"
 #include "camera.h"
 #include "camera.h"
@@ -335,7 +337,8 @@ void ChanConfig::chan_eval(GraphicsWindow* win, WindowItem& W, LayoutItem& L,
   return;
   return;
 }
 }
 
 
-ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &render,
+ChanConfig::ChanConfig(GraphicsEngine *engine, GraphicsPipe* pipe, 
+                       std::string cfg, const NodePath &render,
                        ChanCfgOverrides& overrides) {
                        ChanCfgOverrides& overrides) {
   ReadChanConfigData();
   ReadChanConfigData();
   // check to make sure we know everything we need to
   // check to make sure we know everything we need to
@@ -400,9 +403,9 @@ ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &rend
   origY = overrides.defined(ChanCfgOverrides::OrigY) ?
   origY = overrides.defined(ChanCfgOverrides::OrigY) ?
             overrides.getInt(ChanCfgOverrides::OrigY) : origY;
             overrides.getInt(ChanCfgOverrides::OrigY) : origY;
 
 
-  bool border = !chanconfig.GetBool("no-border", !W.getBorder());
+  bool undecorated = chanconfig.GetBool("undecorated", !W.getBorder());
   bool fullscreen = chanconfig.GetBool("fullscreen", false);
   bool fullscreen = chanconfig.GetBool("fullscreen", false);
-  bool use_cursor = chanconfig.GetBool("cursor-visible", W.getCursor());
+  bool use_cursor = !chanconfig.GetBool("cursor-hidden", !W.getCursor());
   int want_depth_bits = chanconfig.GetInt("want-depth-bits", 1);
   int want_depth_bits = chanconfig.GetInt("want-depth-bits", 1);
   int want_color_bits = chanconfig.GetInt("want-color-bits", 1);
   int want_color_bits = chanconfig.GetInt("want-color-bits", 1);
 
 
@@ -411,28 +414,27 @@ ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &rend
   float win_background_b = chanconfig.GetFloat("win-background-b", 0.41);
   float win_background_b = chanconfig.GetFloat("win-background-b", 0.41);
 
 
   // visual?  nope, that's handled with the mode.
   // visual?  nope, that's handled with the mode.
-  uint mask = 0x0;  // ?!  this really should come from the win config
-  mask = overrides.defined(ChanCfgOverrides::Mask) ?
-           overrides.getUInt(ChanCfgOverrides::Mask) : mask;
+  int framebuffer_mode = 
+    WindowProperties::FM_rgba | 
+    WindowProperties::FM_double_buffer | 
+    WindowProperties::FM_depth;
+  framebuffer_mode = overrides.defined(ChanCfgOverrides::Mask) ?
+    overrides.getUInt(ChanCfgOverrides::Mask) : framebuffer_mode;
   std::string title = cfg;
   std::string title = cfg;
   title = overrides.defined(ChanCfgOverrides::Title) ?
   title = overrides.defined(ChanCfgOverrides::Title) ?
             overrides.getString(ChanCfgOverrides::Title) : title;
             overrides.getString(ChanCfgOverrides::Title) : title;
 
 
-  GraphicsWindow::Properties props;
-  props._xorg = origX;
-  props._yorg = origY;
-  props._xsize = sizeX;
-  props._ysize = sizeY;
-  props._title = title;
-  props._mask = mask;
-  props._border = border;
-  props._fullscreen = fullscreen;
-  props._want_depth_bits = want_depth_bits;
-  props._want_color_bits = want_color_bits;
-  props._bCursorIsVisible = use_cursor;
-
-  props.set_clear_color(Colorf(win_background_r, win_background_g, 
-                               win_background_b, 1.0f));
+  WindowProperties props;
+  props.set_open(true);
+  props.set_origin(origX, origY);
+  props.set_size(sizeX, sizeY);
+  props.set_title(title);
+  props.set_framebuffer_mode(framebuffer_mode);
+  props.set_undecorated(undecorated);
+  props.set_fullscreen(fullscreen);
+  props.set_depth_bits(want_depth_bits);
+  props.set_color_bits(want_color_bits);
+  props.set_cursor_hidden(!use_cursor);
 
 
 
 
   // stereo prep?
   // stereo prep?
@@ -442,13 +444,17 @@ ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &rend
                         overrides.getBool(ChanCfgOverrides::Cameras) : true;
                         overrides.getBool(ChanCfgOverrides::Cameras) : true;
 
 
   // open that sucker
   // open that sucker
-  PT(GraphicsWindow) win = pipe->make_window(props);
+  PT(GraphicsWindow) win = engine->make_window(pipe);
   if(win == (GraphicsWindow *)NULL) {
   if(win == (GraphicsWindow *)NULL) {
     chancfg_cat.error() << "Could not create window" << endl;
     chancfg_cat.error() << "Could not create window" << endl;
     _graphics_window = (GraphicsWindow *)NULL;
     _graphics_window = (GraphicsWindow *)NULL;
     return;
     return;
   }
   }
 
 
+  win->request_properties(props);
+  win->set_clear_color(Colorf(win_background_r, win_background_g, 
+                              win_background_b, 1.0f));
+
   // make channels and display regions
   // make channels and display regions
   ChanViewport V(0.0f, 1.0f, 0.0f, 1.0f);
   ChanViewport V(0.0f, 1.0f, 0.0f, 1.0f);
   chan_eval(win, W, L, S, V, W.getChanOffset()+1, sizeX, sizeY, 
   chan_eval(win, W, L, S, V, W.getChanOffset()+1, sizeX, sizeY, 
@@ -459,9 +465,7 @@ ChanConfig::ChanConfig(GraphicsPipe* pipe, std::string cfg, const NodePath &rend
   // sanity check
   // sanity check
   if (config_sanity_check) {
   if (config_sanity_check) {
     nout << "ChanConfig Sanity check:" << endl
     nout << "ChanConfig Sanity check:" << endl
-         << "window - " << (void*)win << endl
-         << "  width = " << win->get_width() << "  height = " << win->get_height() << endl
-         << "  xorig = " << win->get_xorg() << "  yorig = " << win->get_yorg()<< endl;
+         << "window - " << (void*)win << endl;
 
 
     int max_channel_index = win->get_max_channel_index();
     int max_channel_index = win->get_max_channel_index();
     for (int c = 0; c < max_channel_index; c++) {
     for (int c = 0; c < max_channel_index; c++) {

+ 6 - 3
panda/src/chancfg/chancfg.h

@@ -26,13 +26,15 @@
 #include "chanwindow.h"
 #include "chanwindow.h"
 #include "chanshare.h"
 #include "chanshare.h"
 
 
-#include "graphicsPipe.h"
 #include "graphicsWindow.h"
 #include "graphicsWindow.h"
 #include "pandaNode.h"
 #include "pandaNode.h"
 #include "nodePath.h"
 #include "nodePath.h"
 
 
 #include "pmap.h"
 #include "pmap.h"
 
 
+class GraphicsEngine;
+class GraphicsPipe;
+
 class EXPCL_PANDA ChanCfgOverrides {
 class EXPCL_PANDA ChanCfgOverrides {
 public:
 public:
   enum Field { OrigX, OrigY, SizeX, SizeY, Title, Mask, Cameras };
   enum Field { OrigX, OrigY, SizeX, SizeY, Title, Mask, Cameras };
@@ -114,8 +116,9 @@ private:
          SVec& S, ChanViewport& V, int hw_offset, 
          SVec& S, ChanViewport& V, int hw_offset, 
          int xsize, int ysize, const NodePath &render, bool want_cameras);
          int xsize, int ysize, const NodePath &render, bool want_cameras);
 PUBLISHED:
 PUBLISHED:
-  ChanConfig(GraphicsPipe*, std::string, const NodePath &render,
-    ChanCfgOverrides& = ChanOverrideNone);
+  ChanConfig(GraphicsEngine *engine, GraphicsPipe *pipe,
+             std::string cfg, const NodePath &render,
+             ChanCfgOverrides& = ChanOverrideNone);
   INLINE PandaNode *get_group_node(const int node_index) const;
   INLINE PandaNode *get_group_node(const int node_index) const;
   INLINE int get_group_membership(const int dr_index) const;
   INLINE int get_group_membership(const int dr_index) const;
   INLINE int get_num_groups(void) const;
   INLINE int get_num_groups(void) const;

+ 3 - 2
panda/src/device/mouseAndKeyboard.cxx

@@ -78,8 +78,9 @@ do_transmit_data(const DataNodeTransmit &, DataNodeTransmit &output) {
       _pixel_xy->set_value(LPoint2f(mdata._xpos, mdata._ypos));
       _pixel_xy->set_value(LPoint2f(mdata._xpos, mdata._ypos));
       output.set_data(_pixel_xy_output, EventParameter(_pixel_xy));
       output.set_data(_pixel_xy_output, EventParameter(_pixel_xy));
 
 
-      int w = _window->get_width();
-      int h = _window->get_height();
+      WindowProperties properties = _window->get_properties();
+      int w = properties.get_x_size();
+      int h = properties.get_y_size();
 
 
       // Normalize pixel motion to range [-1,1].
       // Normalize pixel motion to range [-1,1].
       float xf = (float)(2 * mdata._xpos) / (float)w - 1.0f;
       float xf = (float)(2 * mdata._xpos) / (float)w - 1.0f;

+ 40 - 37
panda/src/display/Sources.pp

@@ -10,39 +10,41 @@
   #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx 
   #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx 
  
  
   #define SOURCES  \
   #define SOURCES  \
-     config_display.h \
-     clearableRegion.I clearableRegion.h \
-     displayRegion.I displayRegion.h  \
-     displayRegionStack.I \
-     displayRegionStack.h \
-     frameBufferStack.I frameBufferStack.h \
-     geomContext.I geomContext.h geomNodeContext.I geomNodeContext.h \
-     graphicsChannel.I graphicsChannel.h \
-     graphicsEngine.I graphicsEngine.h \
-     graphicsLayer.I  \
-     graphicsLayer.h graphicsPipe.I graphicsPipe.N graphicsPipe.h  \
-     graphicsStateGuardian.I graphicsStateGuardian.N  \
-     graphicsStateGuardian.h graphicsWindow.I graphicsWindow.N  \
-     graphicsWindow.h graphicsWindowInputDevice.I  \
-     graphicsWindowInputDevice.h hardwareChannel.I  \
-     hardwareChannel.h interactiveGraphicsPipe.I  \
-     interactiveGraphicsPipe.h \
-     lensStack.I lensStack.h \
-     noninteractiveGraphicsPipe.I  \
-     noninteractiveGraphicsPipe.h pipeSpec.I pipeSpec.h  \
-     savedFrameBuffer.I savedFrameBuffer.h
-     
+    config_display.h \
+    clearableRegion.I clearableRegion.h \
+    displayRegion.I displayRegion.h  \
+    displayRegionStack.I \
+    displayRegionStack.h \
+    frameBufferStack.I frameBufferStack.h \
+    geomContext.I geomContext.h geomNodeContext.I geomNodeContext.h \
+    graphicsChannel.I graphicsChannel.h \
+    graphicsEngine.I graphicsEngine.h \
+    graphicsLayer.I  \
+    graphicsLayer.h graphicsPipe.I graphicsPipe.h  \
+    graphicsPipeSelection.I graphicsPipeSelection.h \
+    graphicsStateGuardian.I \
+    graphicsStateGuardian.h graphicsWindow.I \
+    graphicsWindow.h graphicsWindowInputDevice.I  \
+    graphicsWindowInputDevice.h \
+    windowProperties.I windowProperties.h \
+    hardwareChannel.I  \
+    hardwareChannel.h \
+    lensStack.I lensStack.h \
+    savedFrameBuffer.I savedFrameBuffer.h
+    
  #define INCLUDED_SOURCES  \
  #define INCLUDED_SOURCES  \
-     config_display.cxx \
-     clearableRegion.cxx \
-     displayRegion.cxx \
-     geomContext.cxx geomNodeContext.cxx graphicsChannel.cxx  \
-     graphicsEngine.cxx \
-     graphicsLayer.cxx graphicsPipe.cxx graphicsStateGuardian.cxx  \
-     graphicsWindow.cxx graphicsWindowInputDevice.cxx  \
-     hardwareChannel.cxx interactiveGraphicsPipe.cxx  \
-     noninteractiveGraphicsPipe.cxx pipeSpec.cxx  \
-     savedFrameBuffer.cxx
+    config_display.cxx \
+    clearableRegion.cxx \
+    displayRegion.cxx \
+    geomContext.cxx geomNodeContext.cxx graphicsChannel.cxx  \
+    graphicsEngine.cxx \
+    graphicsLayer.cxx graphicsPipe.cxx \
+    graphicsPipeSelection.cxx \
+    graphicsStateGuardian.cxx  \
+    graphicsWindow.cxx graphicsWindowInputDevice.cxx  \
+    windowProperties.cxx \
+    hardwareChannel.cxx \
+    savedFrameBuffer.cxx
 
 
   #define INSTALL_HEADERS \
   #define INSTALL_HEADERS \
     config_display.h \
     config_display.h \
@@ -54,14 +56,15 @@
     graphicsChannel.I graphicsChannel.h \
     graphicsChannel.I graphicsChannel.h \
     graphicsEngine.I graphicsEngine.h \
     graphicsEngine.I graphicsEngine.h \
     graphicsLayer.I graphicsLayer.h \
     graphicsLayer.I graphicsLayer.h \
-    graphicsPipe.I graphicsPipe.h graphicsStateGuardian.I \
+    graphicsPipe.I graphicsPipe.h \
+    graphicsPipeSelection.I graphicsPipeSelection.h \
+    graphicsStateGuardian.I \
     graphicsStateGuardian.h graphicsWindow.I graphicsWindow.h \
     graphicsStateGuardian.h graphicsWindow.I graphicsWindow.h \
     graphicsWindowInputDevice.I graphicsWindowInputDevice.h \
     graphicsWindowInputDevice.I graphicsWindowInputDevice.h \
-    hardwareChannel.I hardwareChannel.h interactiveGraphicsPipe.I \
-    interactiveGraphicsPipe.h \
+    windowProperties.I windowProperties.h \
+    hardwareChannel.I hardwareChannel.h \
     lensStack.I lensStack.h \
     lensStack.I lensStack.h \
-    noninteractiveGraphicsPipe.I \
-    noninteractiveGraphicsPipe.h pipeSpec.I pipeSpec.h renderBuffer.h \
+    renderBuffer.h \
     savedFrameBuffer.I savedFrameBuffer.h
     savedFrameBuffer.I savedFrameBuffer.h
 
 
   #define IGATESCAN all
   #define IGATESCAN all

+ 1 - 0
panda/src/display/clearableRegion.h

@@ -53,6 +53,7 @@ PUBLISHED:
   INLINE bool is_any_clear_active() const;
   INLINE bool is_any_clear_active() const;
 
 
 private:
 private:
+  // This data needs to be cycled.
   enum Flags {
   enum Flags {
     F_clear_color_active = 0x0001,
     F_clear_color_active = 0x0001,
     F_clear_depth_active = 0x0002,
     F_clear_depth_active = 0x0002,

+ 12 - 75
panda/src/display/config_display.cxx

@@ -21,8 +21,6 @@
 #include "graphicsStateGuardian.h"
 #include "graphicsStateGuardian.h"
 #include "savedFrameBuffer.h"
 #include "savedFrameBuffer.h"
 #include "graphicsPipe.h"
 #include "graphicsPipe.h"
-#include "interactiveGraphicsPipe.h"
-#include "noninteractiveGraphicsPipe.h"
 #include "graphicsWindow.h"
 #include "graphicsWindow.h"
 #include "graphicsChannel.h"
 #include "graphicsChannel.h"
 #include "graphicsLayer.h"
 #include "graphicsLayer.h"
@@ -36,28 +34,11 @@ NotifyCategoryDef(display, "");
 NotifyCategoryDef(gsg, display_cat);
 NotifyCategoryDef(gsg, display_cat);
 
 
 static Config::ConfigTable::Symbol *disp;
 static Config::ConfigTable::Symbol *disp;
-static Config::ConfigTable::Symbol *guard;
-static Config::ConfigTable::Symbol *preferred_pipe;
-static Config::ConfigTable::Symbol *preferred_window;
-static Config::ConfigTable::Symbol *preferred_gsg;
 
 
 ConfigureFn(config_display) {
 ConfigureFn(config_display) {
   init_libdisplay();
   init_libdisplay();
 }
 }
 
 
-const string pipe_spec_machine = config_display.GetString("pipe-machine", "");
-const string pipe_spec_filename = config_display.GetString("pipe-filename",
-                                                           "outfile-%03f.rib");
-const int pipe_spec_pipe_number = config_display.GetInt("pipe-number", -1);
-const bool pipe_spec_is_file = config_display.Defined("pipe-filename")
-                               || config_display.GetBool("pipe-file", false);
-const bool pipe_spec_is_remote = config_display.Defined("pipe-machine")
-                                 || config_display.GetBool("pipe-remote",
-                                                           false);
-
-const bool compare_state_by_pointer =
-config_display.GetBool("compare-state-by-pointer", true);
-
 // This is normally true; set it false to disable view-frustum culling
 // This is normally true; set it false to disable view-frustum culling
 // (primarily useful for debugging).
 // (primarily useful for debugging).
 const bool view_frustum_cull = config_display.GetBool("view-frustum-cull", true);
 const bool view_frustum_cull = config_display.GetBool("view-frustum-cull", true);
@@ -67,59 +48,32 @@ const bool view_frustum_cull = config_display.GetBool("view-frustum-cull", true)
 // of per-frame overhead to count these things up.
 // of per-frame overhead to count these things up.
 const bool pstats_unused_states = config_display.GetBool("pstats-unused-states", false);
 const bool pstats_unused_states = config_display.GetBool("pstats-unused-states", false);
 
 
-// This is the default threading model to use when the GraphicsEngine
-// is created, e.g. app-cull-draw or appculldraw or some such.  (See
-// GraphicsEngine::set_threading_model()).
+// This is the default threading model to use for new windows.  Use
+// empty string for single-threaded, or something like "cull/draw" for
+// a 3-stage pipeline.  See GraphicsEngine::set_threading_model().
 
 
 // Warning!  The code that uses this is currently experimental and
 // Warning!  The code that uses this is currently experimental and
 // incomplete, and will almost certainly crash!  Do not set
 // incomplete, and will almost certainly crash!  Do not set
 // threading-model to anything other than its default of a
 // threading-model to anything other than its default of a
 // single-threaded model unless you are developing Panda's threading
 // single-threaded model unless you are developing Panda's threading
 // system!
 // system!
-const string threading_model = config_display.GetString("threading-model", "appculldraw");
+const string threading_model = config_display.GetString("threading-model", "");
+
+// Use this to specify a particular pipe you prefer to use, when more
+// than one GraphicsPipe is available (for instance, if both GL and DX
+// are linked in).  This should be the name of the type preferred, or
+// a substring unique to the type name.
+const string preferred_pipe = config_display.GetString("preferred-pipe", "");
 
 
 
 
-Config::ConfigTable::Symbol::iterator pipe_modules_begin(void) {
+Config::ConfigTable::Symbol::iterator display_modules_begin(void) {
   return disp->begin();
   return disp->begin();
 }
 }
 
 
-Config::ConfigTable::Symbol::iterator pipe_modules_end(void) {
+Config::ConfigTable::Symbol::iterator display_modules_end(void) {
   return disp->end();
   return disp->end();
 }
 }
 
 
-Config::ConfigTable::Symbol::iterator gsg_modules_begin(void) {
-  return guard->begin();
-}
-
-Config::ConfigTable::Symbol::iterator gsg_modules_end(void) {
-  return guard->end();
-}
-
-
-Config::ConfigTable::Symbol::iterator preferred_pipe_begin(void) {
-  return preferred_pipe->begin();
-}
-
-Config::ConfigTable::Symbol::iterator preferred_pipe_end(void) {
-  return preferred_pipe->end();
-}
-
-Config::ConfigTable::Symbol::iterator preferred_window_begin(void) {
-  return preferred_window->begin();
-}
-
-Config::ConfigTable::Symbol::iterator preferred_window_end(void) {
-  return preferred_window->end();
-}
-
-Config::ConfigTable::Symbol::iterator preferred_gsg_begin(void) {
-  return preferred_gsg->begin();
-}
-
-Config::ConfigTable::Symbol::iterator preferred_gsg_end(void) {
-  return preferred_gsg->end();
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libdisplay
 //     Function: init_libdisplay
 //  Description: Initializes the library.  This must be called at
 //  Description: Initializes the library.  This must be called at
@@ -141,14 +95,7 @@ init_libdisplay() {
   GraphicsStateGuardian::GsgWindow::init_type();
   GraphicsStateGuardian::GsgWindow::init_type();
   SavedFrameBuffer::init_type();
   SavedFrameBuffer::init_type();
   GraphicsPipe::init_type();
   GraphicsPipe::init_type();
-  GraphicsPipe::PipeParam::init_type();
-  GraphicsPipe::PipeSpec::init_type();
-  InteractiveGraphicsPipe::init_type();
-  NoninteractiveGraphicsPipe::init_type();
   GraphicsWindow::init_type();
   GraphicsWindow::init_type();
-  GraphicsWindow::WindowParam::init_type();
-  GraphicsWindow::WindowProps::init_type();
-  GraphicsWindow::WindowPipe::init_type();
   GraphicsChannel::init_type();
   GraphicsChannel::init_type();
   GraphicsLayer::init_type();
   GraphicsLayer::init_type();
   HardwareChannel::init_type();
   HardwareChannel::init_type();
@@ -157,15 +104,5 @@ init_libdisplay() {
   GeomContext::init_type();
   GeomContext::init_type();
 
 
   disp = new Config::ConfigTable::Symbol;
   disp = new Config::ConfigTable::Symbol;
-  guard = new Config::ConfigTable::Symbol;
-  preferred_pipe = new Config::ConfigTable::Symbol;
-  preferred_window = new Config::ConfigTable::Symbol;
-  preferred_gsg = new Config::ConfigTable::Symbol;
-
   config_display.GetAll("load-display", *disp);
   config_display.GetAll("load-display", *disp);
-  config_display.GetAll("load-gsg", *guard);
-
-  config_display.GetAll("preferred-pipe", *preferred_pipe);
-  config_display.GetAll("preferred-window", *preferred_window);
-  config_display.GetAll("preferred-gsg", *preferred_gsg);
 }
 }

+ 3 - 18
panda/src/display/config_display.h

@@ -29,29 +29,14 @@
 NotifyCategoryDecl(display, EXPCL_PANDA, EXPTP_PANDA);
 NotifyCategoryDecl(display, EXPCL_PANDA, EXPTP_PANDA);
 NotifyCategoryDecl(gsg, EXPCL_PANDA, EXPTP_PANDA);
 NotifyCategoryDecl(gsg, EXPCL_PANDA, EXPTP_PANDA);
 
 
-extern const string pipe_spec_machine;
-extern const string pipe_spec_filename;
-extern const int pipe_spec_pipe_number;
-extern const bool pipe_spec_is_file;
-extern const bool pipe_spec_is_remote;
-
-extern const bool compare_state_by_pointer;
 extern const bool view_frustum_cull;
 extern const bool view_frustum_cull;
 extern const bool pstats_unused_states;
 extern const bool pstats_unused_states;
 
 
 extern const string threading_model;
 extern const string threading_model;
+extern const string preferred_pipe;
 
 
-extern Config::ConfigTable::Symbol::iterator pipe_modules_begin(void);
-extern Config::ConfigTable::Symbol::iterator pipe_modules_end(void);
-extern Config::ConfigTable::Symbol::iterator gsg_modules_begin(void);
-extern Config::ConfigTable::Symbol::iterator gsg_modules_end(void);
-
-extern Config::ConfigTable::Symbol::iterator preferred_pipe_begin();
-extern Config::ConfigTable::Symbol::iterator preferred_pipe_end();
-extern Config::ConfigTable::Symbol::iterator preferred_window_begin();
-extern Config::ConfigTable::Symbol::iterator preferred_window_end();
-extern Config::ConfigTable::Symbol::iterator preferred_gsg_begin();
-extern Config::ConfigTable::Symbol::iterator preferred_gsg_end();
+extern Config::ConfigTable::Symbol::iterator display_modules_begin(void);
+extern Config::ConfigTable::Symbol::iterator display_modules_end(void);
 
 
 extern EXPCL_PANDA void init_libdisplay();
 extern EXPCL_PANDA void init_libdisplay();
 
 

+ 10 - 160
panda/src/display/displayRegion.I

@@ -16,110 +16,10 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::get_dimensions
-//       Access: Public
-//  Description: Retrieves the coordinates of the DisplayRegion's
-//               rectangle within its GraphicsLayer.  These numbers
-//               will be in the range [0..1].
-////////////////////////////////////////////////////////////////////
-INLINE void DisplayRegion::
-get_dimensions(float &l, float &r, float &b, float &t) const {
-  l = _l;
-  r = _r;
-  b = _b;
-  t = _t;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::get_left
-//       Access: Public
-//  Description: Retrieves the x coordinate of the left edge of the
-//               rectangle within its GraphicsLayer.  This number
-//               will be in the range [0..1].
-////////////////////////////////////////////////////////////////////
-INLINE float DisplayRegion::
-get_left() const {
-  return _l;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::get_right
-//       Access: Public
-//  Description: Retrieves the x coordinate of the right edge of the
-//               rectangle within its GraphicsLayer.  This number
-//               will be in the range [0..1].
-////////////////////////////////////////////////////////////////////
-INLINE float DisplayRegion::
-get_right() const {
-  return _r;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::get_bottom
-//       Access: Public
-//  Description: Retrieves the y coordinate of the bottom edge of 
-//               the rectangle within its GraphicsLayer.  This 
-//               number will be in the range [0..1].
-////////////////////////////////////////////////////////////////////
-INLINE float DisplayRegion::
-get_bottom() const {
-  return _b;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::get_top
-//       Access: Public
-//  Description: Retrieves the y coordinate of the top edge of the
-//               rectangle within its GraphicsLayer.  This number
-//               will be in the range [0..1].
-////////////////////////////////////////////////////////////////////
-INLINE float DisplayRegion::
-get_top() const {
-  return _t;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::get_layer
-//       Access: Public
-//  Description: Returns the layer associated with this particular
-//               DisplayRegion, or NULL if no layer is associated
-//               (or if the layer was deleted).
-////////////////////////////////////////////////////////////////////
-INLINE GraphicsLayer *DisplayRegion::
-get_layer() const {
-  return _layer;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::get_camera
-//       Access: Public
-//  Description: Returns the camera associated with this
-//               DisplayRegion, or NULL if no camera is associated.
-////////////////////////////////////////////////////////////////////
-INLINE const NodePath &DisplayRegion::
-get_camera() const {
-  return _camera;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::set_active
-//       Access: Public
-//  Description: Sets the active flag associated with the
-//               DisplayRegion.  If the DisplayRegion is marked
-//               inactive, nothing is rendered.
-////////////////////////////////////////////////////////////////////
-INLINE void DisplayRegion::
-set_active(bool active) {
-  if (active != _active) {
-    _active = active;
-    win_display_regions_changed();
-  }
-}
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: DisplayRegion::is_active
 //     Function: DisplayRegion::is_active
-//       Access: Public
+//       Access: Published
 //  Description: Returns the active flag associated with the
 //  Description: Returns the active flag associated with the
 //               DisplayRegion.
 //               DisplayRegion.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -129,67 +29,17 @@ is_active() const {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::compute_pixels
-//       Access: Public
-//  Description: Computes the pixel locations of the DisplayRegion
-//               within its layer, given the size of the layer in
-//               pixels.
+//     Function: DisplayRegion::do_compute_pixels
+//       Access: Private
+//  Description: The private implementation of compute_pixels, this
+//               assumes that we already have the lock.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void DisplayRegion::
 INLINE void DisplayRegion::
-compute_pixels(const int x, const int y) {
-  _pl = int((_l * x) + 0.5);
-  _pr = int((_r * x) + 0.5);
-  _pb = int((_b * y) + 0.5);
-  _pt = int((_t * y) + 0.5);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::get_pixels
-//       Access: Public
-//  Description: Retrieves the coordinates of the DisplayRegion within
-//               its layer, in pixels.
-////////////////////////////////////////////////////////////////////
-INLINE void DisplayRegion::
-get_pixels(int &pl, int &pr, int &pb, int &pt) const {
-  pl = _pl;
-  pr = _pr;
-  pb = _pb;
-  pt = _pt;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::get_region_pixels
-//       Access: Public
-//  Description: Retrieves the coordinates of the DisplayRegion within
-//               its layer, as the pixel location of its bottom-left
-//               corner, along with a pixel width and height.
-////////////////////////////////////////////////////////////////////
-INLINE void DisplayRegion::
-get_region_pixels(int &xo, int &yo, int &w, int &h) const {
-  xo = _pl;
-  yo = _pb;
-  w = _pr - _pl;
-  h = _pt - _pb;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::get_pixel_width
-//       Access: Public
-//  Description: Returns the width of the DisplayRegion in pixels.
-////////////////////////////////////////////////////////////////////
-INLINE int DisplayRegion::
-get_pixel_width() const {
-  return _pr - _pl;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DisplayRegion::get_pixel_height
-//       Access: Public
-//  Description: Returns the height of the DisplayRegion in pixels.
-////////////////////////////////////////////////////////////////////
-INLINE int DisplayRegion::
-get_pixel_height() const {
-  return _pt - _pb;
+do_compute_pixels(int x_size, int y_size) {
+  _pl = int((_l * x_size) + 0.5);
+  _pr = int((_r * x_size) + 0.5);
+  _pb = int((_b * y_size) + 0.5);
+  _pt = int((_t * y_size) + 0.5);
 }
 }
 
 
 
 

+ 224 - 9
panda/src/display/displayRegion.cxx

@@ -24,6 +24,7 @@
 #include "displayRegion.h"
 #include "displayRegion.h"
 #include "camera.h"
 #include "camera.h"
 #include "dcast.h"
 #include "dcast.h"
+#include "mutexHolder.h"
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -38,6 +39,7 @@ DisplayRegion(GraphicsLayer *layer) :
   _camera_node((Camera *)NULL),
   _camera_node((Camera *)NULL),
   _active(true)
   _active(true)
 {
 {
+  compute_pixels();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -53,6 +55,7 @@ DisplayRegion(GraphicsLayer *layer, const float l,
   _camera_node((Camera *)NULL),
   _camera_node((Camera *)NULL),
   _active(true)
   _active(true)
 {
 {
+  compute_pixels();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -102,9 +105,77 @@ DisplayRegion::
   set_camera(NodePath());
   set_camera(NodePath());
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::get_dimensions
+//       Access: Published
+//  Description: Retrieves the coordinates of the DisplayRegion's
+//               rectangle within its GraphicsLayer.  These numbers
+//               will be in the range [0..1].
+////////////////////////////////////////////////////////////////////
+void DisplayRegion::
+get_dimensions(float &l, float &r, float &b, float &t) const {
+  MutexHolder holder(_lock);
+  l = _l;
+  r = _r;
+  b = _b;
+  t = _t;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::get_left
+//       Access: Published
+//  Description: Retrieves the x coordinate of the left edge of the
+//               rectangle within its GraphicsLayer.  This number
+//               will be in the range [0..1].
+////////////////////////////////////////////////////////////////////
+float DisplayRegion::
+get_left() const {
+  MutexHolder holder(_lock);
+  return _l;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::get_right
+//       Access: Published
+//  Description: Retrieves the x coordinate of the right edge of the
+//               rectangle within its GraphicsLayer.  This number
+//               will be in the range [0..1].
+////////////////////////////////////////////////////////////////////
+float DisplayRegion::
+get_right() const {
+  MutexHolder holder(_lock);
+  return _r;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::get_bottom
+//       Access: Published
+//  Description: Retrieves the y coordinate of the bottom edge of 
+//               the rectangle within its GraphicsLayer.  This 
+//               number will be in the range [0..1].
+////////////////////////////////////////////////////////////////////
+float DisplayRegion::
+get_bottom() const {
+  MutexHolder holder(_lock);
+  return _b;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::get_top
+//       Access: Published
+//  Description: Retrieves the y coordinate of the top edge of the
+//               rectangle within its GraphicsLayer.  This number
+//               will be in the range [0..1].
+////////////////////////////////////////////////////////////////////
+float DisplayRegion::
+get_top() const {
+  MutexHolder holder(_lock);
+  return _t;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: DisplayRegion::set_dimensions
 //     Function: DisplayRegion::set_dimensions
-//       Access: Public
+//       Access: Published
 //  Description: Changes the portion of the framebuffer this
 //  Description: Changes the portion of the framebuffer this
 //               DisplayRegion corresponds to.  The parameters range
 //               DisplayRegion corresponds to.  The parameters range
 //               from 0 to 1, where 0,0 is the lower left corner and
 //               from 0 to 1, where 0,0 is the lower left corner and
@@ -113,6 +184,7 @@ DisplayRegion::
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void DisplayRegion::
 void DisplayRegion::
 set_dimensions(float l, float r, float b, float t) {
 set_dimensions(float l, float r, float b, float t) {
+  MutexHolder holder(_lock);
   _l = l;
   _l = l;
   _r = r;
   _r = r;
   _b = b;
   _b = b;
@@ -120,49 +192,68 @@ set_dimensions(float l, float r, float b, float t) {
 
 
   const GraphicsWindow *win = get_window();
   const GraphicsWindow *win = get_window();
   if (win != (GraphicsWindow *)NULL) {
   if (win != (GraphicsWindow *)NULL) {
-    compute_pixels(win->get_width(), win->get_height());
+    WindowProperties properties = win->get_properties();
+    if (properties.has_size()) {
+      do_compute_pixels(properties.get_x_size(), properties.get_y_size());
+    }
   }
   }
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::get_layer
+//       Access: Published
+//  Description: Returns the layer associated with this particular
+//               DisplayRegion, or NULL if no layer is associated
+//               (or if the layer was deleted).
+////////////////////////////////////////////////////////////////////
+GraphicsLayer *DisplayRegion::
+get_layer() const {
+  MutexHolder holder(_lock);
+  return _layer;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: DisplayRegion::get_channel
 //     Function: DisplayRegion::get_channel
-//       Access: Public
+//       Access: Published
 //  Description: Returns the GraphicsChannel that this DisplayRegion is
 //  Description: Returns the GraphicsChannel that this DisplayRegion is
 //               ultimately associated with, or NULL if no channel is
 //               ultimately associated with, or NULL if no channel is
 //               associated.
 //               associated.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsChannel *DisplayRegion::
 GraphicsChannel *DisplayRegion::
 get_channel() const {
 get_channel() const {
+  MutexHolder holder(_lock);
   return (_layer != (GraphicsLayer *)NULL) ? _layer->get_channel() : NULL;
   return (_layer != (GraphicsLayer *)NULL) ? _layer->get_channel() : NULL;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: DisplayRegion::get_window
 //     Function: DisplayRegion::get_window
-//       Access: Public
+//       Access: Published
 //  Description: Returns the GraphicsWindow that this DisplayRegion is
 //  Description: Returns the GraphicsWindow that this DisplayRegion is
 //               ultimately associated with, or NULL if no window is
 //               ultimately associated with, or NULL if no window is
 //               associated.
 //               associated.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsWindow *DisplayRegion::
 GraphicsWindow *DisplayRegion::
 get_window() const {
 get_window() const {
+  MutexHolder holder(_lock);
   return (_layer != (GraphicsLayer *)NULL) ? _layer->get_window() : NULL;
   return (_layer != (GraphicsLayer *)NULL) ? _layer->get_window() : NULL;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: DisplayRegion::get_pipe
 //     Function: DisplayRegion::get_pipe
-//       Access: Public
+//       Access: Published
 //  Description: Returns the GraphicsPipe that this DisplayRegion is
 //  Description: Returns the GraphicsPipe that this DisplayRegion is
 //               ultimately associated with, or NULL if no pipe is
 //               ultimately associated with, or NULL if no pipe is
 //               associated.
 //               associated.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsPipe *DisplayRegion::
 GraphicsPipe *DisplayRegion::
 get_pipe() const {
 get_pipe() const {
+  MutexHolder holder(_lock);
   return (_layer != (GraphicsLayer *)NULL) ? _layer->get_pipe() : NULL;
   return (_layer != (GraphicsLayer *)NULL) ? _layer->get_pipe() : NULL;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: DisplayRegion::set_camera
 //     Function: DisplayRegion::set_camera
-//       Access: Public
+//       Access: Published
 //  Description: Sets the camera that is associated with this
 //  Description: Sets the camera that is associated with this
 //               DisplayRegion.  There is a one-to-one association
 //               DisplayRegion.  There is a one-to-one association
 //               between cameras and DisplayRegions; if this camera
 //               between cameras and DisplayRegions; if this camera
@@ -175,6 +266,7 @@ get_pipe() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void DisplayRegion::
 void DisplayRegion::
 set_camera(const NodePath &camera) {
 set_camera(const NodePath &camera) {
+  MutexHolder holder(_lock);
   Camera *camera_node = (Camera *)NULL;
   Camera *camera_node = (Camera *)NULL;
   if (!camera.is_empty()) {
   if (!camera.is_empty()) {
     DCAST_INTO_V(camera_node, camera.node());
     DCAST_INTO_V(camera_node, camera.node());
@@ -195,13 +287,135 @@ set_camera(const NodePath &camera) {
   _camera = camera;
   _camera = camera;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::get_camera
+//       Access: Published
+//  Description: Returns the camera associated with this
+//               DisplayRegion, or NULL if no camera is associated.
+////////////////////////////////////////////////////////////////////
+const NodePath &DisplayRegion::
+get_camera() const {
+  MutexHolder holder(_lock);
+  return _camera;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::set_active
+//       Access: Published
+//  Description: Sets the active flag associated with the
+//               DisplayRegion.  If the DisplayRegion is marked
+//               inactive, nothing is rendered.
+////////////////////////////////////////////////////////////////////
+void DisplayRegion::
+set_active(bool active) {
+  MutexHolder holder(_lock);
+  if (active != _active) {
+    _active = active;
+    win_display_regions_changed();
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::compute_pixels
+//       Access: Published
+//  Description: Computes the pixel locations of the DisplayRegion
+//               within its layer.  The DisplayRegion will request the
+//               size from the window.
+////////////////////////////////////////////////////////////////////
+void DisplayRegion::
+compute_pixels() {
+  const GraphicsWindow *win = get_window();
+  if (win != (GraphicsWindow *)NULL) {
+    MutexHolder holder(_lock);
+    WindowProperties properties = win->get_properties();
+    if (!properties.has_size()) {
+      // If the window doesn't know its size yet, maybe it will
+      // eventually be given the size it's requesting.
+      properties = win->get_requested_properties();
+    }
+
+    if (properties.has_size()) {
+      do_compute_pixels(properties.get_x_size(), properties.get_y_size());
+    } else {
+      do_compute_pixels(0, 0);
+    }
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::compute_pixels
+//       Access: Published
+//  Description: Computes the pixel locations of the DisplayRegion
+//               within its layer, given the size of the layer in
+//               pixels.
+////////////////////////////////////////////////////////////////////
+void DisplayRegion::
+compute_pixels(int x_size, int y_size) {
+  MutexHolder holder(_lock);
+  do_compute_pixels(x_size, y_size);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::get_pixels
+//       Access: Published
+//  Description: Retrieves the coordinates of the DisplayRegion within
+//               its layer, in pixels.
+////////////////////////////////////////////////////////////////////
+void DisplayRegion::
+get_pixels(int &pl, int &pr, int &pb, int &pt) const {
+  MutexHolder holder(_lock);
+  pl = _pl;
+  pr = _pr;
+  pb = _pb;
+  pt = _pt;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::get_region_pixels
+//       Access: Published
+//  Description: Retrieves the coordinates of the DisplayRegion within
+//               its layer, as the pixel location of its bottom-left
+//               corner, along with a pixel width and height.
+////////////////////////////////////////////////////////////////////
+void DisplayRegion::
+get_region_pixels(int &xo, int &yo, int &w, int &h) const {
+  MutexHolder holder(_lock);
+  xo = _pl;
+  yo = _pb;
+  w = _pr - _pl;
+  h = _pt - _pb;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::get_pixel_width
+//       Access: Published
+//  Description: Returns the width of the DisplayRegion in pixels.
+////////////////////////////////////////////////////////////////////
+int DisplayRegion::
+get_pixel_width() const {
+  MutexHolder holder(_lock);
+  return _pr - _pl;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DisplayRegion::get_pixel_height
+//       Access: Published
+//  Description: Returns the height of the DisplayRegion in pixels.
+////////////////////////////////////////////////////////////////////
+int DisplayRegion::
+get_pixel_height() const {
+  MutexHolder holder(_lock);
+  return _pt - _pb;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: DisplayRegion::output
 //     Function: DisplayRegion::output
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void DisplayRegion::
 void DisplayRegion::
 output(ostream &out) const {
 output(ostream &out) const {
+  MutexHolder holder(_lock);
   out << "DisplayRegion(" << _l << " " << _r << " " << _b << " " << _t
   out << "DisplayRegion(" << _l << " " << _r << " " << _b << " " << _t
       << ")=pixels(" << _pl << " " << _pr << " " << _pb << " " << _pt
       << ")=pixels(" << _pl << " " << _pr << " " << _pb << " " << _pt
       << ")";
       << ")";
@@ -209,11 +423,12 @@ output(ostream &out) const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: DisplayRegion::win_display_regions_changed
 //     Function: DisplayRegion::win_display_regions_changed
-//       Access: Public
+//       Access: Private
 //  Description: Intended to be called when the active state on a
 //  Description: Intended to be called when the active state on a
 //               nested channel or layer or display region changes,
 //               nested channel or layer or display region changes,
 //               forcing the window to recompute its list of active
 //               forcing the window to recompute its list of active
-//               display regions.
+//               display regions.  It is assumed the lock is already
+//               held.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void DisplayRegion::
 void DisplayRegion::
 win_display_regions_changed() {
 win_display_regions_changed() {

+ 22 - 20
panda/src/display/displayRegion.h

@@ -25,6 +25,7 @@
 #include "nodePath.h"
 #include "nodePath.h"
 #include "cullResult.h"
 #include "cullResult.h"
 #include "pointerTo.h"
 #include "pointerTo.h"
+#include "mutex.h"
 
 
 #include "plist.h"
 #include "plist.h"
 
 
@@ -41,50 +42,51 @@ class Camera;
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDA DisplayRegion : public ReferenceCount, public ClearableRegion {
 class EXPCL_PANDA DisplayRegion : public ReferenceCount, public ClearableRegion {
 public:
 public:
-  DisplayRegion(GraphicsLayer *);
-  DisplayRegion(GraphicsLayer *,
+  DisplayRegion(GraphicsLayer *layer);
+  DisplayRegion(GraphicsLayer *layer,
                 const float l, const float r,
                 const float l, const float r,
                 const float b, const float t);
                 const float b, const float t);
   DisplayRegion(int xsize, int ysize);
   DisplayRegion(int xsize, int ysize);
 private:
 private:
-  DisplayRegion(const DisplayRegion &);
-  void operator = (const DisplayRegion &);
+  DisplayRegion(const DisplayRegion &copy);
+  void operator = (const DisplayRegion &copy);
 
 
 public:
 public:
   ~DisplayRegion();
   ~DisplayRegion();
 
 
 PUBLISHED:
 PUBLISHED:
-  INLINE void get_dimensions(float &l, float &r, float &b, float &t) const;
-  INLINE float get_left() const;
-  INLINE float get_right() const;
-  INLINE float get_bottom() const;
-  INLINE float get_top() const;
+  void get_dimensions(float &l, float &r, float &b, float &t) const;
+  float get_left() const;
+  float get_right() const;
+  float get_bottom() const;
+  float get_top() const;
   void set_dimensions(float l, float r, float b, float t);
   void set_dimensions(float l, float r, float b, float t);
 
 
-  INLINE GraphicsLayer *get_layer() const;
+  GraphicsLayer *get_layer() const;
   GraphicsChannel *get_channel() const;
   GraphicsChannel *get_channel() const;
   GraphicsWindow *get_window() const;
   GraphicsWindow *get_window() const;
   GraphicsPipe *get_pipe() const;
   GraphicsPipe *get_pipe() const;
 
 
   void set_camera(const NodePath &camera);
   void set_camera(const NodePath &camera);
-  INLINE const NodePath &get_camera() const;
+  const NodePath &get_camera() const;
 
 
-  INLINE void set_active(bool active);
+  void set_active(bool active);
   INLINE bool is_active() const;
   INLINE bool is_active() const;
 
 
-  INLINE void compute_pixels(const int x, const int y);
-  INLINE void get_pixels(int &pl, int &pr, int &pb, int &pt) const;
-  INLINE void get_region_pixels(int &xo, int &yo, int &w, int &h) const;
+  void compute_pixels();
+  void compute_pixels(int x_size, int y_size);
+  void get_pixels(int &pl, int &pr, int &pb, int &pt) const;
+  void get_region_pixels(int &xo, int &yo, int &w, int &h) const;
 
 
-  INLINE int get_pixel_width() const;
-  INLINE int get_pixel_height() const;
+  int get_pixel_width() const;
+  int get_pixel_height() const;
 
 
   void output(ostream &out) const;
   void output(ostream &out) const;
 
 
-public:
+private:
   void win_display_regions_changed();
   void win_display_regions_changed();
-
-protected:
+  INLINE void do_compute_pixels(int x_size, int y_size);
+  Mutex _lock;
 
 
   float _l;
   float _l;
   float _r;
   float _r;

+ 2 - 3
panda/src/display/display_composite2.cxx

@@ -1,6 +1,5 @@
 #include "config_display.cxx"
 #include "config_display.cxx"
+#include "graphicsPipeSelection.cxx"
 #include "hardwareChannel.cxx"
 #include "hardwareChannel.cxx"
-#include "interactiveGraphicsPipe.cxx"
-#include "noninteractiveGraphicsPipe.cxx"
-#include "pipeSpec.cxx"
 #include "savedFrameBuffer.cxx"
 #include "savedFrameBuffer.cxx"
+#include "windowProperties.cxx"

+ 0 - 14
panda/src/display/graphicsChannel.I

@@ -17,20 +17,6 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsChannel::set_active
-//       Access: Public
-//  Description: Sets the active flag on the channel.  If the channel
-//               is marked as inactive, nothing will be rendered.
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsChannel::
-set_active(bool active) {
-  if (active != _is_active) {
-    _is_active = active;
-    win_display_regions_changed();
-  }
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::is_active
 //     Function: GraphicsChannel::is_active
 //       Access: Public
 //       Access: Public

+ 54 - 28
panda/src/display/graphicsChannel.cxx

@@ -18,18 +18,17 @@
 
 
 #include "graphicsChannel.h"
 #include "graphicsChannel.h"
 #include "graphicsWindow.h"
 #include "graphicsWindow.h"
+#include "graphicsLayer.h"
 #include "config_display.h"
 #include "config_display.h"
+#include "mutexHolder.h"
 
 
 #include "pmap.h"
 #include "pmap.h"
 
 
-////////////////////////////////////////////////////////////////////
-// Static variables
-////////////////////////////////////////////////////////////////////
 TypeHandle GraphicsChannel::_type_handle;
 TypeHandle GraphicsChannel::_type_handle;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::Constructor
 //     Function: GraphicsChannel::Constructor
-//       Access: Public
+//       Access: Protected
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsChannel::
 GraphicsChannel::
@@ -41,7 +40,9 @@ GraphicsChannel() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::Constructor
 //     Function: GraphicsChannel::Constructor
 //       Access: Public
 //       Access: Public
-//  Description:
+//  Description: This is public just so derived window types can
+//               easily call it.  Don't call it directly; instead, use
+//               GraphicsWindow::get_channel() to get a channel.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsChannel::
 GraphicsChannel::
 GraphicsChannel(GraphicsWindow *window)
 GraphicsChannel(GraphicsWindow *window)
@@ -56,9 +57,8 @@ GraphicsChannel(GraphicsWindow *window)
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE GraphicsChannel::
 INLINE GraphicsChannel::
-GraphicsChannel(const GraphicsChannel&) {
-  display_cat.error()
-    << "GraphicsChannels should never be copied" << endl;
+GraphicsChannel(const GraphicsChannel &) {
+  nassertv(false);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -66,16 +66,14 @@ GraphicsChannel(const GraphicsChannel&) {
 //       Access: Private
 //       Access: Private
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE GraphicsChannel &GraphicsChannel::
-operator=(const GraphicsChannel&) {
-  display_cat.error()
-  << "GraphicsChannels should never be assigned" << endl;
-  return *this;
+INLINE void GraphicsChannel::
+operator = (const GraphicsChannel &) {
+  nassertv(false);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::Destructor
 //     Function: GraphicsChannel::Destructor
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsChannel::
 GraphicsChannel::
@@ -88,7 +86,9 @@ GraphicsChannel::
   for (li = _layers.begin();
   for (li = _layers.begin();
        li != _layers.end();
        li != _layers.end();
        ++li) {
        ++li) {
-    (*li)->_channel = NULL;
+    GraphicsLayer *layer = (*li);
+    MutexHolder holder(layer->_lock);
+    layer->_channel = NULL;
   }
   }
 
 
   // We don't need to remove ourself from the windows's list of
   // We don't need to remove ourself from the windows's list of
@@ -98,7 +98,7 @@ GraphicsChannel::
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::make_layer
 //     Function: GraphicsChannel::make_layer
-//       Access: Public
+//       Access: Published
 //  Description: Creates a new GraphicsLayer, associated with the
 //  Description: Creates a new GraphicsLayer, associated with the
 //               window, at the indicated index position.  If the
 //               window, at the indicated index position.  If the
 //               index position negative or past the end of the array,
 //               index position negative or past the end of the array,
@@ -108,6 +108,7 @@ GraphicsChannel::
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsLayer *GraphicsChannel::
 GraphicsLayer *GraphicsChannel::
 make_layer(int index) {
 make_layer(int index) {
+  MutexHolder holder(_lock);
   PT(GraphicsLayer) layer = new GraphicsLayer(this);
   PT(GraphicsLayer) layer = new GraphicsLayer(this);
   if (index < 0 || index >= (int)_layers.size()) {
   if (index < 0 || index >= (int)_layers.size()) {
     _layers.push_back(layer);
     _layers.push_back(layer);
@@ -119,29 +120,33 @@ make_layer(int index) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::get_num_layers
 //     Function: GraphicsChannel::get_num_layers
-//       Access: Public
+//       Access: Published
 //  Description: Returns the number of layers currently associated
 //  Description: Returns the number of layers currently associated
 //               with the channel.
 //               with the channel.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 int GraphicsChannel::
 int GraphicsChannel::
 get_num_layers() const {
 get_num_layers() const {
+  MutexHolder holder(_lock);
   return _layers.size();
   return _layers.size();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::get_layer
 //     Function: GraphicsChannel::get_layer
-//       Access: Public
+//       Access: Published
 //  Description: Returns the nth layer associated with the channel.
 //  Description: Returns the nth layer associated with the channel.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsLayer *GraphicsChannel::
 GraphicsLayer *GraphicsChannel::
 get_layer(int index) const {
 get_layer(int index) const {
-  nassertr(index >= 0 && index < (int)_layers.size(), NULL);
-  return _layers[index];
+  MutexHolder holder(_lock);
+  if (index >= 0 && index < (int)_layers.size()) {
+    return _layers[index];
+  }
+  return NULL;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::move_layer
 //     Function: GraphicsChannel::move_layer
-//       Access: Public
+//       Access: Published
 //  Description: Changes the ordering of the layers so that the
 //  Description: Changes the ordering of the layers so that the
 //               indicated layer will move to the indicated position.
 //               indicated layer will move to the indicated position.
 //               If to_index is negative or past the end of the array,
 //               If to_index is negative or past the end of the array,
@@ -149,6 +154,7 @@ get_layer(int index) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsChannel::
 void GraphicsChannel::
 move_layer(int from_index, int to_index) {
 move_layer(int from_index, int to_index) {
+  MutexHolder holder(_lock);
   nassertv(from_index >= 0 && from_index < (int)_layers.size());
   nassertv(from_index >= 0 && from_index < (int)_layers.size());
   PT(GraphicsLayer) layer = _layers[from_index];
   PT(GraphicsLayer) layer = _layers[from_index];
 
 
@@ -170,19 +176,20 @@ move_layer(int from_index, int to_index) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::remove_layer
 //     Function: GraphicsChannel::remove_layer
-//       Access: Public
+//       Access: Published
 //  Description: Removes the nth layer.  This changes the numbers of
 //  Description: Removes the nth layer.  This changes the numbers of
 //               all subsequent layers.
 //               all subsequent layers.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsChannel::
 void GraphicsChannel::
 remove_layer(int index) {
 remove_layer(int index) {
+  MutexHolder holder(_lock);
   nassertv(index >= 0 && index < (int)_layers.size());
   nassertv(index >= 0 && index < (int)_layers.size());
   _layers.erase(_layers.begin() + index);
   _layers.erase(_layers.begin() + index);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::get_window
 //     Function: GraphicsChannel::get_window
-//       Access: Public
+//       Access: Published
 //  Description: Returns the GraphicsWindow that this channel is
 //  Description: Returns the GraphicsWindow that this channel is
 //               associated with.  It is possible that the
 //               associated with.  It is possible that the
 //               GraphicsWindow might have been deleted while an
 //               GraphicsWindow might have been deleted while an
@@ -192,21 +199,38 @@ remove_layer(int index) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsWindow *GraphicsChannel::
 GraphicsWindow *GraphicsChannel::
 get_window() const {
 get_window() const {
+  MutexHolder holder(_lock);
   return _window;
   return _window;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::get_pipe
 //     Function: GraphicsChannel::get_pipe
-//       Access: Public
+//       Access: Published
 //  Description: Returns the GraphicsPipe that this channel is
 //  Description: Returns the GraphicsPipe that this channel is
 //               ultimately associated with, or NULL if no pipe is
 //               ultimately associated with, or NULL if no pipe is
 //               associated.
 //               associated.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsPipe *GraphicsChannel::
 GraphicsPipe *GraphicsChannel::
 get_pipe() const {
 get_pipe() const {
+  MutexHolder holder(_lock);
   return (_window != (GraphicsWindow *)NULL) ? _window->get_pipe() : NULL;
   return (_window != (GraphicsWindow *)NULL) ? _window->get_pipe() : NULL;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsChannel::set_active
+//       Access: Published
+//  Description: Sets the active flag on the channel.  If the channel
+//               is marked as inactive, nothing will be rendered.
+////////////////////////////////////////////////////////////////////
+void GraphicsChannel::
+set_active(bool active) {
+  MutexHolder holder(_lock);
+  if (active != _is_active) {
+    _is_active = active;
+    win_display_regions_changed();
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::window_resized
 //     Function: GraphicsChannel::window_resized
 //       Access: Public, Virtual
 //       Access: Public, Virtual
@@ -215,25 +239,27 @@ get_pipe() const {
 //               adjust the channel to account for it.
 //               adjust the channel to account for it.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsChannel::
 void GraphicsChannel::
-window_resized(int x, int y) {
+window_resized(int x_size, int y_size) {
   // By default, a normal GraphicsChannel fills the whole window, and
   // By default, a normal GraphicsChannel fills the whole window, and
   // so when the window resizes so does the channel, by the same
   // so when the window resizes so does the channel, by the same
   // amount.
   // amount.
+  MutexHolder holder(_lock);
   GraphicsLayers::iterator li;
   GraphicsLayers::iterator li;
   for (li = _layers.begin();
   for (li = _layers.begin();
        li != _layers.end();
        li != _layers.end();
        ++li) {
        ++li) {
-    (*li)->channel_resized(x, y);
+    (*li)->channel_resized(x_size, y_size);
   }
   }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsChannel::win_display_regions_changed
 //     Function: GraphicsChannel::win_display_regions_changed
-//       Access: Public
+//       Access: Private
 //  Description: Intended to be called when the active state on a
 //  Description: Intended to be called when the active state on a
 //               nested channel or layer or display region changes,
 //               nested channel or layer or display region changes,
 //               forcing the window to recompute its list of active
 //               forcing the window to recompute its list of active
-//               display regions.
+//               display regions.  It is assumed the lock is already
+//               held.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsChannel::
 void GraphicsChannel::
 win_display_regions_changed() {
 win_display_regions_changed() {

+ 18 - 27
panda/src/display/graphicsChannel.h

@@ -17,22 +17,14 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 #ifndef GRAPHICSCHANNEL_H
 #ifndef GRAPHICSCHANNEL_H
 #define GRAPHICSCHANNEL_H
 #define GRAPHICSCHANNEL_H
-//
-////////////////////////////////////////////////////////////////////
-// Includes
-////////////////////////////////////////////////////////////////////
-#include <pandabase.h>
 
 
+#include "pandabase.h"
 #include "graphicsLayer.h"
 #include "graphicsLayer.h"
-
-#include <typedReferenceCount.h>
-#include <pointerTo.h>
-
+#include "typedReferenceCount.h"
+#include "pointerTo.h"
+#include "mutex.h"
 #include "pvector.h"
 #include "pvector.h"
 
 
-////////////////////////////////////////////////////////////////////
-// Defines
-////////////////////////////////////////////////////////////////////
 class GraphicsChannel;
 class GraphicsChannel;
 class GraphicsPipe;
 class GraphicsPipe;
 class GraphicsWindow;
 class GraphicsWindow;
@@ -48,14 +40,17 @@ class CullHandler;
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDA GraphicsChannel : public TypedReferenceCount {
 class EXPCL_PANDA GraphicsChannel : public TypedReferenceCount {
 protected:
 protected:
-
   GraphicsChannel();
   GraphicsChannel();
 
 
 public:
 public:
-  GraphicsChannel(GraphicsWindow *);
-  virtual ~GraphicsChannel();
+  GraphicsChannel(GraphicsWindow *window);
+
+private:
+  GraphicsChannel(const GraphicsChannel &copy);
+  void operator = (const GraphicsChannel &copy);
 
 
 PUBLISHED:
 PUBLISHED:
+  virtual ~GraphicsChannel();
   GraphicsLayer *make_layer(int index = -1);
   GraphicsLayer *make_layer(int index = -1);
   int get_num_layers() const;
   int get_num_layers() const;
   GraphicsLayer *get_layer(int index) const;
   GraphicsLayer *get_layer(int index) const;
@@ -65,28 +60,23 @@ PUBLISHED:
   GraphicsWindow *get_window() const;
   GraphicsWindow *get_window() const;
   GraphicsPipe *get_pipe() const;
   GraphicsPipe *get_pipe() const;
 
 
+  void set_active(bool active);
+  INLINE bool is_active() const;
+
 public:
 public:
-  virtual void window_resized(int x, int y);
+  virtual void window_resized(int x_size, int y_size);
 
 
+private:
   void win_display_regions_changed();
   void win_display_regions_changed();
 
 
-PUBLISHED:
-  INLINE void set_active(bool active);
-  INLINE bool is_active() const;
-
-private:
+protected:
+  Mutex _lock;
   GraphicsWindow *_window;
   GraphicsWindow *_window;
   bool _is_active;
   bool _is_active;
 
 
   typedef pvector< PT(GraphicsLayer) > GraphicsLayers;
   typedef pvector< PT(GraphicsLayer) > GraphicsLayers;
   GraphicsLayers _layers;
   GraphicsLayers _layers;
 
 
-private:
-
-  GraphicsChannel(const GraphicsChannel&);
-  GraphicsChannel& operator=(const GraphicsChannel&);
-
-
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {
     return _type_handle;
     return _type_handle;
@@ -105,6 +95,7 @@ private:
   static TypeHandle _type_handle;
   static TypeHandle _type_handle;
 
 
   friend class GraphicsWindow;
   friend class GraphicsWindow;
+  friend class GraphicsLayer;
 };
 };
 
 
 #include "graphicsChannel.I"
 #include "graphicsChannel.I"

+ 11 - 22
panda/src/display/graphicsEngine.I

@@ -18,28 +18,17 @@
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsEngine::get_threading_model
+//     Function: GraphicsEngine::make_window
 //       Access: Published
 //       Access: Published
-//  Description: Returns the current threading model in use; see
-//               set_threading_model().
-////////////////////////////////////////////////////////////////////
-INLINE GraphicsEngine::ThreadingModel GraphicsEngine::
-get_threading_model() const {
-  return _threading_model;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsEngine::start_cull
-//       Access: Private
-//  Description: Starts the cull stage for the current frame.  This
-//               may or may not execute within a sub-thread, according
-//               to the current threading model.
+//  Description: Creates a new window using the indicated GraphicsPipe
+//               and returns it.  The GraphicsEngine becomes the owner
+//               of the window; it will persist at least until
+//               remove_window() is called later.
+//
+//               This flavor of make_window() uses the default
+//               threading model, specified via set_threading_model().
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void GraphicsEngine::
-start_cull() {
-  if (_cull_sorting) {
-    cull_bin_draw();
-  } else {
-    cull_and_draw_together();
-  }
+INLINE GraphicsWindow *GraphicsEngine::
+make_window(GraphicsPipe *pipe) {
+  return make_window(pipe, get_threading_model());
 }
 }

File diff suppressed because it is too large
+ 585 - 296
panda/src/display/graphicsEngine.cxx


+ 55 - 47
panda/src/display/graphicsEngine.h

@@ -31,6 +31,7 @@
 
 
 class Pipeline;
 class Pipeline;
 class DisplayRegion;
 class DisplayRegion;
+class GraphicsPipe;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : GraphicsEngine
 //       Class : GraphicsEngine
@@ -43,44 +44,40 @@ class DisplayRegion;
 //               required.
 //               required.
 //
 //
 //               The GraphicsEngine is responsible for managing the
 //               The GraphicsEngine is responsible for managing the
-//               cull and draw processes.  The application simply
-//               calls engine->render_frame() and considers it done.
+//               various cull and draw threads.  The application
+//               simply calls engine->render_frame() and considers it
+//               done.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDA GraphicsEngine : public Namable {
+class EXPCL_PANDA GraphicsEngine {
 PUBLISHED:
 PUBLISHED:
   GraphicsEngine(Pipeline *pipeline = NULL);
   GraphicsEngine(Pipeline *pipeline = NULL);
   ~GraphicsEngine();
   ~GraphicsEngine();
 
 
-  void add_window(GraphicsWindow *window);
+  void set_threading_model(const string &threading_model);
+  string get_threading_model() const;
+
+  INLINE GraphicsWindow *make_window(GraphicsPipe *pipe);
+  GraphicsWindow *make_window(GraphicsPipe *pipe,
+                              const string &threading_model);
   bool remove_window(GraphicsWindow *window);
   bool remove_window(GraphicsWindow *window);
+  void remove_all_windows();
 
 
   void render_frame();
   void render_frame();
-  void render_subframe(GraphicsStateGuardian *gsg, DisplayRegion *dr);
-
-  enum ThreadingModel {
-    TM_invalid,
-    TM_appculldraw,
-    TM_appcull_draw,
-    TM_app_culldraw,
-    TM_app_cull_draw,
-    TM_appcdraw,
-    TM_app_cdraw,
-  };
-
-  void set_threading_model(ThreadingModel threading_model);
-  INLINE ThreadingModel get_threading_model() const;
-
-public:
-  static ThreadingModel string_threading_model(const string &string);
+  void render_subframe(GraphicsStateGuardian *gsg, DisplayRegion *dr,
+                       bool cull_sorting);
   
   
 private:
 private:
-  INLINE void start_cull();
-  void cull_and_draw_together();
+  typedef pset< PT(GraphicsWindow) > Windows;
+
+  void cull_and_draw_together(const Windows &wlist);
   void cull_and_draw_together(GraphicsStateGuardian *gsg, DisplayRegion *dr);
   void cull_and_draw_together(GraphicsStateGuardian *gsg, DisplayRegion *dr);
 
 
-  void cull_bin_draw();
+  void cull_bin_draw(const Windows &wlist);
   void cull_bin_draw(GraphicsStateGuardian *gsg, DisplayRegion *dr);
   void cull_bin_draw(GraphicsStateGuardian *gsg, DisplayRegion *dr);
 
 
+  void process_events(const GraphicsEngine::Windows &wlist);
+  void flip_windows(const GraphicsEngine::Windows &wlist);
+
   PT(SceneSetup) setup_scene(const NodePath &camera, 
   PT(SceneSetup) setup_scene(const NodePath &camera, 
                              GraphicsStateGuardian *gsg);
                              GraphicsStateGuardian *gsg);
   void do_cull(CullHandler *cull_handler, SceneSetup *scene_setup,
   void do_cull(CullHandler *cull_handler, SceneSetup *scene_setup,
@@ -90,17 +87,42 @@ private:
 
 
   bool setup_gsg(GraphicsStateGuardian *gsg, SceneSetup *scene_setup);
   bool setup_gsg(GraphicsStateGuardian *gsg, SceneSetup *scene_setup);
 
 
+  void do_remove_window(GraphicsWindow *window);
   void terminate_threads();
   void terminate_threads();
 
 
+  // The WindowRenderer class records the stages of the pipeline that
+  // each thread (including the main thread, a.k.a. "app") should
+  // process, and the list of windows for each stage.
+  class WindowRenderer {
+  public:
+    void add_window(Windows &wlist, GraphicsWindow *window);
+    void remove_window(GraphicsWindow *window);
+    void do_frame(GraphicsEngine *engine);
+    void do_flip(GraphicsEngine *engine);
+    void do_release(GraphicsEngine *engine);
+    void do_close(GraphicsEngine *engine);
+    void do_pending(GraphicsEngine *engine);
+
+    Windows _cull;    // cull stage
+    Windows _cdraw;   // cull-and-draw-together stage
+    Windows _draw;    // draw stage
+    Windows _window;  // window stage, i.e. process windowing events 
+    Windows _pending_release; // moved from _draw, pending release_gsg.
+    Windows _pending_close;   // moved from _window, pending close.
+    Mutex _wl_lock;
+  };
+
   enum ThreadState {
   enum ThreadState {
     TS_wait,
     TS_wait,
     TS_do_frame,
     TS_do_frame,
+    TS_do_flip,
+    TS_do_release,
     TS_terminate
     TS_terminate
   };
   };
 
 
-  class CullThread : public Thread {
+  class RenderThread : public Thread, public WindowRenderer {
   public:
   public:
-    CullThread(const string &name, GraphicsEngine *engine);
+    RenderThread(const string &name, GraphicsEngine *engine);
     virtual void thread_main();
     virtual void thread_main();
 
 
     GraphicsEngine *_engine;
     GraphicsEngine *_engine;
@@ -109,37 +131,23 @@ private:
     ThreadState _thread_state;
     ThreadState _thread_state;
   };
   };
 
 
-  class DrawThread : public Thread {
-  public:
-    DrawThread(const string &name, GraphicsEngine *engine);
-    virtual void thread_main();
-
-    GraphicsEngine *_engine;
-    Mutex _cv_mutex;
-    ConditionVar _cv;
-    ThreadState _thread_state;
-  };
+  WindowRenderer *get_window_renderer(const string &name);
 
 
   Pipeline *_pipeline;
   Pipeline *_pipeline;
-
-  typedef pset<PT(GraphicsWindow)> Windows;
   Windows _windows;
   Windows _windows;
 
 
-  ThreadingModel _threading_model;
-  bool _cull_sorting;
+  WindowRenderer _app;
+  typedef pmap<string, PT(RenderThread) > Threads;
+  Threads _threads;
+  string _threading_model;
 
 
-  PT(CullThread) _cull_thread;
-  PT(DrawThread) _draw_thread;
+  Mutex _lock;
 
 
   static PStatCollector _cull_pcollector;
   static PStatCollector _cull_pcollector;
   static PStatCollector _draw_pcollector;
   static PStatCollector _draw_pcollector;
-
-  friend class CullThread;
+  friend class WindowRenderer;
 };
 };
 
 
-ostream &
-operator << (ostream &out, GraphicsEngine::ThreadingModel threading_model);
-
 #include "graphicsEngine.I"
 #include "graphicsEngine.I"
 
 
 #endif
 #endif

+ 0 - 29
panda/src/display/graphicsLayer.I

@@ -16,34 +16,6 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsLayer::get_channel
-//       Access: Published
-//  Description: Returns the GraphicsChannel that this layer is
-//               associated with.  It is possible that the
-//               GraphicsChannel might have been deleted while an
-//               outstanding PT(GraphicsLayer) prevented all of its
-//               children layers from also being deleted; in this
-//               unlikely case, get_channel() may return NULL.
-////////////////////////////////////////////////////////////////////
-INLINE GraphicsChannel *GraphicsLayer::
-get_channel() const {
-  return _channel;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsLayer::set_active
-//       Access: Published
-//  Description: Sets the active flag on the layer.  If the layer
-//               is marked as inactive, nothing will be rendered.
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsLayer::
-set_active(bool active) {
-  if (active != _is_active) {
-    _is_active = active;
-    win_display_regions_changed();
-  }
-}
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::is_active
 //     Function: GraphicsLayer::is_active
@@ -54,4 +26,3 @@ INLINE bool GraphicsLayer::
 is_active() const {
 is_active() const {
   return _is_active;
   return _is_active;
 }
 }
-

+ 78 - 43
panda/src/display/graphicsLayer.cxx

@@ -20,20 +20,19 @@
 #include "graphicsChannel.h"
 #include "graphicsChannel.h"
 #include "graphicsWindow.h"
 #include "graphicsWindow.h"
 #include "config_display.h"
 #include "config_display.h"
+#include "notify.h"
+#include "mutexHolder.h"
 
 
 #include <algorithm>
 #include <algorithm>
 
 
-#include <notify.h>
 
 
-////////////////////////////////////////////////////////////////////
-// Static variables
-////////////////////////////////////////////////////////////////////
 TypeHandle GraphicsLayer::_type_handle;
 TypeHandle GraphicsLayer::_type_handle;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::Constructor
 //     Function: GraphicsLayer::Constructor
-//       Access: Public
-//  Description:
+//       Access: Private
+//  Description: Use GraphicsChannel::make_layer() to make a new
+//               layer.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsLayer::
 GraphicsLayer::
 GraphicsLayer() {
 GraphicsLayer() {
@@ -44,7 +43,8 @@ GraphicsLayer() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::Constructor
 //     Function: GraphicsLayer::Constructor
 //       Access: Public
 //       Access: Public
-//  Description:
+//  Description: Use GraphicsChannel::make_layer() to make a new
+//               layer.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsLayer::
 GraphicsLayer::
 GraphicsLayer(GraphicsChannel *channel)
 GraphicsLayer(GraphicsChannel *channel)
@@ -58,10 +58,9 @@ GraphicsLayer(GraphicsChannel *channel)
 //       Access: Private
 //       Access: Private
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE GraphicsLayer::
-GraphicsLayer(const GraphicsLayer&) {
-  display_cat.error()
-    << "GraphicsLayers should never be copied" << endl;
+GraphicsLayer::
+GraphicsLayer(const GraphicsLayer &) {
+  nassertv(false);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -69,16 +68,14 @@ GraphicsLayer(const GraphicsLayer&) {
 //       Access: Private
 //       Access: Private
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE GraphicsLayer &GraphicsLayer::
-operator=(const GraphicsLayer&) {
-  display_cat.error()
-  << "GraphicsLayers should never be assigned" << endl;
-  return *this;
+void GraphicsLayer::
+operator = (const GraphicsLayer &) {
+  nassertv(false);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::Destructor
 //     Function: GraphicsLayer::Destructor
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsLayer::
 GraphicsLayer::
@@ -91,7 +88,9 @@ GraphicsLayer::
   for (dri = _display_regions.begin();
   for (dri = _display_regions.begin();
        dri != _display_regions.end();
        dri != _display_regions.end();
        ++dri) {
        ++dri) {
-    (*dri)->_layer = NULL;
+    DisplayRegion *dr = (*dri);
+    MutexHolder holder(dr->_lock);
+    dr->_layer = NULL;
   }
   }
   win_display_regions_changed();
   win_display_regions_changed();
 
 
@@ -102,17 +101,15 @@ GraphicsLayer::
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::make_display_region
 //     Function: GraphicsLayer::make_display_region
-//       Access: Public
+//       Access: Published
 //  Description: Creates a new DisplayRegion that covers the entire
 //  Description: Creates a new DisplayRegion that covers the entire
 //               layer.
 //               layer.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 DisplayRegion *GraphicsLayer::
 DisplayRegion *GraphicsLayer::
 make_display_region() {
 make_display_region() {
   PT(DisplayRegion) dr = new DisplayRegion(this);
   PT(DisplayRegion) dr = new DisplayRegion(this);
-  const GraphicsWindow *win = get_window();
-  if (win != (GraphicsWindow *)NULL) {
-    dr->compute_pixels(win->get_width(), win->get_height());
-  }
+
+  MutexHolder holder(_lock);
   _display_regions.push_back(dr);
   _display_regions.push_back(dr);
   win_display_regions_changed();
   win_display_regions_changed();
   return dr;
   return dr;
@@ -120,7 +117,7 @@ make_display_region() {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::make_display_region
 //     Function: GraphicsLayer::make_display_region
-//       Access: Public
+//       Access: Published
 //  Description: Creates a new DisplayRegion that covers the indicated
 //  Description: Creates a new DisplayRegion that covers the indicated
 //               sub-rectangle within the layer.
 //               sub-rectangle within the layer.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -128,10 +125,8 @@ DisplayRegion *GraphicsLayer::
 make_display_region(float l, float r, float b, float t) {
 make_display_region(float l, float r, float b, float t) {
   nassertr(this != (GraphicsLayer *)NULL, NULL);
   nassertr(this != (GraphicsLayer *)NULL, NULL);
   PT(DisplayRegion) dr = new DisplayRegion(this, l, r, b, t);
   PT(DisplayRegion) dr = new DisplayRegion(this, l, r, b, t);
-  const GraphicsWindow *win = get_window();
-  if (win != (GraphicsWindow *)NULL) {
-    dr->compute_pixels(win->get_width(), win->get_height());
-  }
+
+  MutexHolder holder(_lock);
   _display_regions.push_back(dr);
   _display_regions.push_back(dr);
   win_display_regions_changed();
   win_display_regions_changed();
   return dr;
   return dr;
@@ -139,36 +134,43 @@ make_display_region(float l, float r, float b, float t) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::get_num_drs
 //     Function: GraphicsLayer::get_num_drs
-//       Access: Public
+//       Access: Published
 //  Description: Returns the number of DisplayRegions associated with
 //  Description: Returns the number of DisplayRegions associated with
 //               the layer.
 //               the layer.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 int GraphicsLayer::
 int GraphicsLayer::
 get_num_drs() const {
 get_num_drs() const {
+  MutexHolder holder(_lock);
   return _display_regions.size();
   return _display_regions.size();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::get_dr
 //     Function: GraphicsLayer::get_dr
-//       Access: Public
+//       Access: Published
 //  Description: Returns the nth DisplayRegion associated with the
 //  Description: Returns the nth DisplayRegion associated with the
-//               layer.
+//               layer.  This might return NULL if another thread has
+//               recently removed a DisplayRegion.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 DisplayRegion *GraphicsLayer::
 DisplayRegion *GraphicsLayer::
 get_dr(int index) const {
 get_dr(int index) const {
-  nassertr(index >= 0 && index < (int)_display_regions.size(), NULL);
-  return _display_regions[index];
+  MutexHolder holder(_lock);
+  if (index >= 0 && index < (int)_display_regions.size()) {
+    return _display_regions[index];
+  } else {
+    return NULL;
+  }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::remove_dr
 //     Function: GraphicsLayer::remove_dr
-//       Access: Public
+//       Access: Published
 //  Description: Removes (and possibly deletes) the nth DisplayRegion
 //  Description: Removes (and possibly deletes) the nth DisplayRegion
 //               associated with the layer.  All subsequent index
 //               associated with the layer.  All subsequent index
 //               numbers will shift down one.
 //               numbers will shift down one.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsLayer::
 void GraphicsLayer::
 remove_dr(int index) {
 remove_dr(int index) {
+  MutexHolder holder(_lock);
   nassertv(index >= 0 && index < (int)_display_regions.size());
   nassertv(index >= 0 && index < (int)_display_regions.size());
   _display_regions[index]->_layer = NULL;
   _display_regions[index]->_layer = NULL;
   _display_regions.erase(_display_regions.begin() + index);
   _display_regions.erase(_display_regions.begin() + index);
@@ -177,7 +179,7 @@ remove_dr(int index) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::remove_dr
 //     Function: GraphicsLayer::remove_dr
-//       Access: Public
+//       Access: Published
 //  Description: Removes (and possibly deletes) the indicated
 //  Description: Removes (and possibly deletes) the indicated
 //               DisplayRegion associated with the layer.  All
 //               DisplayRegion associated with the layer.  All
 //               subsequent index numbers will shift down one.
 //               subsequent index numbers will shift down one.
@@ -186,8 +188,7 @@ remove_dr(int index) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool GraphicsLayer::
 bool GraphicsLayer::
 remove_dr(DisplayRegion *display_region) {
 remove_dr(DisplayRegion *display_region) {
-  // For whatever reason, VC++ considers == ambiguous unless we
-  // compare it to a PT(DisplayRegion) instead of a DisplayRegion*.
+  MutexHolder holder(_lock);
   PT(DisplayRegion) ptdr = display_region;
   PT(DisplayRegion) ptdr = display_region;
   DisplayRegions::iterator dri =
   DisplayRegions::iterator dri =
     find(_display_regions.begin(), _display_regions.end(), ptdr);
     find(_display_regions.begin(), _display_regions.end(), ptdr);
@@ -200,40 +201,73 @@ remove_dr(DisplayRegion *display_region) {
   return false;
   return false;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsLayer::get_channel
+//       Access: Published
+//  Description: Returns the GraphicsChannel that this layer is
+//               associated with.  It is possible that the
+//               GraphicsChannel might have been deleted while an
+//               outstanding PT(GraphicsLayer) prevented all of its
+//               children layers from also being deleted; in this
+//               unlikely case, get_channel() may return NULL.
+////////////////////////////////////////////////////////////////////
+GraphicsChannel *GraphicsLayer::
+get_channel() const {
+  MutexHolder holder(_lock);
+  return _channel;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::get_window
 //     Function: GraphicsLayer::get_window
-//       Access: Public
+//       Access: Published
 //  Description: Returns the GraphicsWindow that this layer is
 //  Description: Returns the GraphicsWindow that this layer is
 //               ultimately associated with, or NULL if no window is
 //               ultimately associated with, or NULL if no window is
 //               associated.
 //               associated.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsWindow *GraphicsLayer::
 GraphicsWindow *GraphicsLayer::
 get_window() const {
 get_window() const {
-  nassertr(this != (GraphicsLayer *)NULL, NULL);
+  MutexHolder holder(_lock);
   return (_channel != (GraphicsChannel *)NULL) ? _channel->get_window() : NULL;
   return (_channel != (GraphicsChannel *)NULL) ? _channel->get_window() : NULL;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::get_pipe
 //     Function: GraphicsLayer::get_pipe
-//       Access: Public
+//       Access: Published
 //  Description: Returns the GraphicsPipe that this layer is
 //  Description: Returns the GraphicsPipe that this layer is
 //               ultimately associated with, or NULL if no pipe is
 //               ultimately associated with, or NULL if no pipe is
 //               associated.
 //               associated.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsPipe *GraphicsLayer::
 GraphicsPipe *GraphicsLayer::
 get_pipe() const {
 get_pipe() const {
+  MutexHolder holder(_lock);
   return (_channel != (GraphicsChannel *)NULL) ? _channel->get_pipe() : NULL;
   return (_channel != (GraphicsChannel *)NULL) ? _channel->get_pipe() : NULL;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsLayer::set_active
+//       Access: Published
+//  Description: Sets the active flag on the layer.  If the layer
+//               is marked as inactive, nothing will be rendered.
+////////////////////////////////////////////////////////////////////
+void GraphicsLayer::
+set_active(bool active) {
+  MutexHolder holder(_lock);
+  if (active != _is_active) {
+    _is_active = active;
+    win_display_regions_changed();
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::channel_resized
 //     Function: GraphicsLayer::channel_resized
-//       Access: Public, Virtual
+//       Access: Public
 //  Description: This is called whenever the parent channel has been
 //  Description: This is called whenever the parent channel has been
 //               resized; it should do whatever needs to be done to
 //               resized; it should do whatever needs to be done to
 //               adjust the layer to account for it.
 //               adjust the layer to account for it.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsLayer::
 void GraphicsLayer::
 channel_resized(int x, int y) {
 channel_resized(int x, int y) {
+  MutexHolder holder(_lock);
   // Since a layer always fills the whole channel, when the channel
   // Since a layer always fills the whole channel, when the channel
   // resizes so does the layer, by the same amount.
   // resizes so does the layer, by the same amount.
   DisplayRegions::iterator dri;
   DisplayRegions::iterator dri;
@@ -246,11 +280,12 @@ channel_resized(int x, int y) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsLayer::win_display_regions_changed
 //     Function: GraphicsLayer::win_display_regions_changed
-//       Access: Public
+//       Access: Private
 //  Description: Intended to be called when the active state on a
 //  Description: Intended to be called when the active state on a
 //               nested channel or layer or display region changes,
 //               nested channel or layer or display region changes,
 //               forcing the window to recompute its list of active
 //               forcing the window to recompute its list of active
-//               display regions.
+//               display regions.  It is assumed the lock is already
+//               held.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsLayer::
 void GraphicsLayer::
 win_display_regions_changed() {
 win_display_regions_changed() {

+ 18 - 27
panda/src/display/graphicsLayer.h

@@ -19,21 +19,14 @@
 #ifndef GRAPHICSLAYER_H
 #ifndef GRAPHICSLAYER_H
 #define GRAPHICSLAYER_H
 #define GRAPHICSLAYER_H
 
 
-////////////////////////////////////////////////////////////////////
-// Includes
-////////////////////////////////////////////////////////////////////
-#include <pandabase.h>
+#include "pandabase.h"
 
 
 #include "displayRegion.h"
 #include "displayRegion.h"
-
-#include <typedReferenceCount.h>
-#include <pointerTo.h>
-
+#include "typedReferenceCount.h"
+#include "pointerTo.h"
+#include "mutex.h"
 #include "pvector.h"
 #include "pvector.h"
 
 
-////////////////////////////////////////////////////////////////////
-// Defines
-////////////////////////////////////////////////////////////////////
 class GraphicsChannel;
 class GraphicsChannel;
 class GraphicsWindow;
 class GraphicsWindow;
 class GraphicsPipe;
 class GraphicsPipe;
@@ -50,15 +43,17 @@ class CullHandler;
 //               without clearing the framebuffer between layers.
 //               without clearing the framebuffer between layers.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDA GraphicsLayer : public TypedReferenceCount {
 class EXPCL_PANDA GraphicsLayer : public TypedReferenceCount {
-protected:
-
+private:
   GraphicsLayer();
   GraphicsLayer();
-  GraphicsLayer(GraphicsChannel *);
+  GraphicsLayer(GraphicsChannel *channel);
 
 
-public:
-  virtual ~GraphicsLayer();
+private:
+  GraphicsLayer(const GraphicsLayer &copy);
+  void operator = (const GraphicsLayer &copy);
 
 
 PUBLISHED:
 PUBLISHED:
+  virtual ~GraphicsLayer();
+
   DisplayRegion *make_display_region();
   DisplayRegion *make_display_region();
   DisplayRegion *make_display_region(float l, float r,
   DisplayRegion *make_display_region(float l, float r,
                                      float b, float t);
                                      float b, float t);
@@ -68,31 +63,26 @@ PUBLISHED:
   void remove_dr(int index);
   void remove_dr(int index);
   bool remove_dr(DisplayRegion *display_region);
   bool remove_dr(DisplayRegion *display_region);
 
 
-  INLINE GraphicsChannel *get_channel() const;
+  GraphicsChannel *get_channel() const;
   GraphicsWindow *get_window() const;
   GraphicsWindow *get_window() const;
   GraphicsPipe *get_pipe() const;
   GraphicsPipe *get_pipe() const;
 
 
+  void set_active(bool active);
+  INLINE bool is_active() const;
+
 public:
 public:
   void channel_resized(int x, int y);
   void channel_resized(int x, int y);
 
 
+private:
   void win_display_regions_changed();
   void win_display_regions_changed();
 
 
-PUBLISHED:
-  INLINE void set_active(bool active);
-  INLINE bool is_active() const;
-
-private:
+  Mutex _lock;
   GraphicsChannel *_channel;
   GraphicsChannel *_channel;
   bool _is_active;
   bool _is_active;
 
 
   typedef pvector< PT(DisplayRegion) > DisplayRegions;
   typedef pvector< PT(DisplayRegion) > DisplayRegions;
   DisplayRegions _display_regions;
   DisplayRegions _display_regions;
 
 
-private:
-
-  GraphicsLayer(const GraphicsLayer&);
-  GraphicsLayer& operator=(const GraphicsLayer&);
-
 
 
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {
@@ -113,6 +103,7 @@ private:
 
 
   friend class GraphicsChannel;
   friend class GraphicsChannel;
   friend class GraphicsWindow;
   friend class GraphicsWindow;
+  friend class DisplayRegion;
 };
 };
 
 
 #include "graphicsLayer.I"
 #include "graphicsLayer.I"

+ 0 - 18
panda/src/display/graphicsPipe.I

@@ -16,21 +16,3 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-
-
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsPipe::get_all_pipes
-//       Access: Private, Static
-//  Description: Returns a reference to the static _all_pipes
-//               container.  This wrapper function allows us to
-//               guarantee creation of the container before we attempt
-//               to reference it.
-////////////////////////////////////////////////////////////////////
-INLINE GraphicsPipe::Pipes &GraphicsPipe::
-get_all_pipes() {
-  if (_all_pipes == NULL) {
-    _all_pipes = new Pipes;
-  }
-  return *_all_pipes;
-}

+ 61 - 268
panda/src/display/graphicsPipe.cxx

@@ -18,251 +18,93 @@
 
 
 #include "graphicsPipe.h"
 #include "graphicsPipe.h"
 #include "config_display.h"
 #include "config_display.h"
+#include "mutexHolder.h"
 
 
-#include "load_dso.h"
-#include "filename.h"
-#include "pset.h"
-
-#include <algorithm>
-
-// Static variables
-////////////////////////////////////////////////////////////////////
 TypeHandle GraphicsPipe::_type_handle;
 TypeHandle GraphicsPipe::_type_handle;
-TypeHandle GraphicsPipe::PipeSpec::_type_handle;
-
-// These static members are pointers rather than concrete objects so
-// we can guarantee order of creation at static init time.
-GraphicsPipe::PipeFactory *GraphicsPipe::_factory = NULL;
-GraphicsPipe::Pipes *GraphicsPipe::_all_pipes = NULL;
-
-GraphicsPipe::PipeSpec::~PipeSpec(void) {}
-
-TypeHandle GraphicsPipe::PipeSpec::get_class_type(void) {
-  return _type_handle;
-}
-
-void GraphicsPipe::PipeSpec::init_type(void) {
-  PipeParam::init_type();
-  register_type(_type_handle, "GraphicsPipe::PipeSpec",
-                PipeParam::get_class_type());
-}
-
-TypeHandle GraphicsPipe::PipeSpec::get_type(void) const {
-  return get_class_type();
-}
-
-TypeHandle GraphicsPipe::PipeSpec::force_init_type(void) {
-  init_type();
-  return get_class_type();
-}
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsPipe::Constructor
 //     Function: GraphicsPipe::Constructor
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-GraphicsPipe::
-GraphicsPipe(const PipeSpecifier &spec) :
-  Namable(spec.get_name())
-{
-  // Add ourself to the global list of pipes.
-  get_all_pipes().push_back(this);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsPipe::Default Constructor
-//       Access: Private
+//       Access: Protected
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsPipe::
 GraphicsPipe::
 GraphicsPipe() {
 GraphicsPipe() {
-  display_cat.error()
-    << "GraphicsPipes should not be called with default constructor" << endl;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsPipe::Copy Constructor
 //     Function: GraphicsPipe::Copy Constructor
 //       Access: Private
 //       Access: Private
-//  Description:
+//  Description: Don't try to copy GraphicsPipes.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsPipe::
 GraphicsPipe::
-GraphicsPipe(const GraphicsPipe&) {
-  display_cat.error()
-    << "GraphicsPipes should not be copied" << endl;
+GraphicsPipe(const GraphicsPipe &) {
+  nassertv(false);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsPipe::Copy Assignment Operator
 //     Function: GraphicsPipe::Copy Assignment Operator
 //       Access: Private
 //       Access: Private
-//  Description:
+//  Description: Don't try to copy GraphicsPipes.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-GraphicsPipe &GraphicsPipe::
-operator=(const GraphicsPipe&) {
-  display_cat.error()
-  << "GraphicsPipes should not be assigned" << endl;
-  return *this;
+void GraphicsPipe::
+operator = (const GraphicsPipe &) {
+  nassertv(false);
 }
 }
 
 
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsPipe::Destructor
 //     Function: GraphicsPipe::Destructor
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsPipe::
 GraphicsPipe::
 ~GraphicsPipe() {
 ~GraphicsPipe() {
-  // We don't have to destruct our child windows explicitly, since
-  // they are all reference-counted and will go away when their
-  // pointers do.  However, we do need to zero out their pointers to
-  // us.
-  Windows::const_iterator wi;
+  // On destruction, we need to clean up our references to all of the
+  // windows.
+  Windows::iterator wi;
   for (wi = _windows.begin(); wi != _windows.end(); ++wi) {
   for (wi = _windows.begin(); wi != _windows.end(); ++wi) {
-    (*wi)->_pipe = NULL;
-  }
-
-  // Remove ourself from the global list.
-  Pipes &all_pipes = get_all_pipes();
-  Pipes::iterator pi =
-    find(all_pipes.begin(), all_pipes.end(), this);
-  if (pi != all_pipes.end()) {
-    all_pipes.erase(pi);
-  }
-}
-
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsPipe::make_window
-//       Access: Public
-//  Description: Creates and returns a new window on the pipe.  The
-//               window will automatically be added to the pipe's
-//               reference-countling list of windows; it must later be
-//               explicitly removed to destroy it (you should not
-//               attempt to delete it).
-////////////////////////////////////////////////////////////////////
-GraphicsWindow *GraphicsPipe::
-make_window() {
-  FactoryParams params;
-  params.add_param(new GraphicsWindow::WindowPipe(this));
-
-  GraphicsWindow *win = GraphicsWindow::get_factory().
-    make_instance(get_window_type(), params);
-  nassertr(win != (GraphicsWindow *)NULL, NULL);
-
-  add_window(win);
-  return win;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsPipe::make_window
-//       Access: Public
-//  Description: Creates and returns a new window on the pipe.  The
-//               window will automatically be added to the pipe's
-//               reference-countling list of windows; it must later be
-//               explicitly removed to destroy it (you should not
-//               attempt to delete it).
-////////////////////////////////////////////////////////////////////
-GraphicsWindow *GraphicsPipe::
-make_window(const GraphicsWindow::Properties &props) {
-  FactoryParams params;
-  params.add_param(new GraphicsWindow::WindowPipe(this));
-  params.add_param(new GraphicsWindow::WindowProps(props));
-
-  GraphicsWindow *win = GraphicsWindow::get_factory().
-    make_instance(get_window_type(), params);
-  nassertr(win != (GraphicsWindow *)NULL, NULL);
-
-  add_window(win);
-  return win;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsPipe::remove_window
-//       Access: Public
-//  Description: Deletes a previously-created window by removing it
-//               from the reference-counting list of windows owned by
-//               the pipe.  Note that the window will not actually be
-//               deleted until all pointers to it (for instance, on
-//               mouse objects, etc.) are cleared.
-////////////////////////////////////////////////////////////////////
-void GraphicsPipe::
-remove_window(GraphicsWindow *window) {
-  // For whatever reason, VC++ considers == ambiguous unless we
-  // compare it to a PT(GraphicsWindow) instead of a GraphicsWindow*.
-  PT(GraphicsWindow) ptwin = window;
-  Windows::iterator wi =
-    find(_windows.begin(), _windows.end(), ptwin);
-  if (wi != _windows.end()) {
-    _windows.erase(wi);
+    GraphicsWindow *window = (*wi);
+    window->_pipe = NULL;
   }
   }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsPipe::get_num_windows
 //     Function: GraphicsPipe::get_num_windows
-//       Access: Public
+//       Access: Published
 //  Description: Returns the number of windows that have been created
 //  Description: Returns the number of windows that have been created
 //               on this pipe.
 //               on this pipe.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 int GraphicsPipe::
 int GraphicsPipe::
 get_num_windows() const {
 get_num_windows() const {
-  return _windows.size();
+  int result;
+  {
+    MutexHolder holder(_lock);
+    result = _windows.size();
+  }
+  return result;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsPipe::get_window
 //     Function: GraphicsPipe::get_window
-//       Access: Public
-//  Description: Returns the nth window associated with this pipe.  n
-//               must be between 0 and get_num_windows().
+//       Access: Published
+//  Description: Returns the nth window that has been created
+//               on this pipe.  It is possible for this to return NULL
+//               due to a window being removed in another thread.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-GraphicsWindow *GraphicsPipe::
+PT(GraphicsWindow) GraphicsPipe::
 get_window(int n) const {
 get_window(int n) const {
-  nassertr(n >= 0 && n < get_num_windows(), NULL);
-  return _windows[n];
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsPipe::get_num_pipes
-//       Access: Public, Static
-//  Description: Returns the total number of pipes in the universe.
-////////////////////////////////////////////////////////////////////
-int GraphicsPipe::
-get_num_pipes() {
-  return get_all_pipes().size();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsPipe::get_pipe
-//       Access: Public, Static
-//  Description: Returns the nth pipe in the universe.  n must be
-//               between 0 and get_num_pipes().
-////////////////////////////////////////////////////////////////////
-GraphicsPipe *GraphicsPipe::
-get_pipe(int n) {
-  nassertr(n >= 0 && n < get_num_pipes(), NULL);
-  return get_all_pipes()[n];
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsPipe::get_glx_display
-//       Access: Public, Virtual
-//  Description: Returns the glxDisplay information associated with
-//               this pipe, if any.  This allows us to define several
-//               kinds of GraphicsPipe objects that manage some
-//               glx-specific stuff, without having them all inherit
-//               from a common glx base class.  This allows the
-//               glxGraphicsWindow to ask questions about the
-//               glx-specific stuff without knowing what kind of
-//               glxGraphicsPipe it has.  Non-glx pipes will simply
-//               return NULL for this function.
-////////////////////////////////////////////////////////////////////
-glxDisplay *GraphicsPipe::
-get_glx_display() {
-  return (glxDisplay *)NULL;
+  PT(GraphicsWindow) result;
+  {
+    MutexHolder holder(_lock);
+    if (n >= 0 && n < (int)_windows.size()) {
+      result = _windows[n];
+    }
+  }
+  return result;
 }
 }
 
 
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsPipe::get_num_hw_channels
 //     Function: GraphicsPipe::get_num_hw_channels
-//       Access: Protected, Virtual
+//       Access: Public, Virtual
 //  Description: Returns the number of hardware channels available for
 //  Description: Returns the number of hardware channels available for
 //               pipes of this type.  See get_hw_channel().
 //               pipes of this type.  See get_hw_channel().
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -271,7 +113,6 @@ get_num_hw_channels() {
   return 0;
   return 0;
 }
 }
 
 
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsPipe::get_hw_channel
 //     Function: GraphicsPipe::get_hw_channel
 //       Access: Public, Virtual
 //       Access: Public, Virtual
@@ -287,92 +128,44 @@ get_num_hw_channels() {
 //               always return NULL.
 //               always return NULL.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 HardwareChannel *GraphicsPipe::
 HardwareChannel *GraphicsPipe::
-get_hw_channel(GraphicsWindow*, int) {
+get_hw_channel(GraphicsWindow *, int) {
   return (HardwareChannel*)0L;
   return (HardwareChannel*)0L;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsPipe::add_window
 //     Function: GraphicsPipe::add_window
 //       Access: Protected
 //       Access: Protected
-//  Description: Adds a newly-created window to the set of windows
-//               owned by the pipe.  This function is intended to be
-//               called from a derived class' make_window() function.
+//  Description: This is intended to be called by the derived
+//               make_window() function to add the newly-created
+//               window to the list of windows owned by this pipe.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsPipe::
 void GraphicsPipe::
-add_window(GraphicsWindow *win) {
-  _windows.push_back(win);
-}
-
-void GraphicsPipe::read_priorities(void) {
-  PipeFactory &factory = get_factory();
-  if (factory.get_num_preferred() == 0) {
-    Config::ConfigTable::Symbol::iterator i;
-    for (i = preferred_pipe_begin(); i != preferred_pipe_end(); ++i) {
-      ConfigString type_name = (*i).Val();
-      TypeHandle type = TypeRegistry::ptr()->find_type(type_name);
-      if (type == TypeHandle::none()) {
-        display_cat.warning()
-          << "Unknown type requested for pipe preference: " << type_name
-          << "\n";
-      } else {
-        display_cat.debug()
-          << "Specifying type " << type << " for pipe preference.\n";
-        factory.add_preferred(type);
-      }
-    }
-  }
+add_window(GraphicsWindow *window) {
+  nassertv(window->_pipe == this);
+  MutexHolder holder(_lock);
+  _windows.push_back(window);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsPipe::get_factory
-//       Access: Public, Static
-//  Description: Returns the factory object that can be used to
-//               register new kinds of GraphicsPipe objects that may
-//               be created.
+//     Function: GraphicsPipe::remove_window
+//       Access: Protected
+//  Description: This is intended to be called by the GraphicsEngine
+//               when a window is to be removed.  It returns true if
+//               the window is removed, or false if it was not found.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-GraphicsPipe::PipeFactory &GraphicsPipe::
-get_factory() {
-  if (_factory == (PipeFactory *)NULL) {
-    _factory = new PipeFactory;
-  }
-  return (*_factory);
-}
-
-void GraphicsPipe::resolve_modules(void) {
-  Config::ConfigTable::Symbol::iterator i;
-
-  // Build up a set of the modules we've already loaded as we go, so
-  // we don't attempt to load a given module more than once.
-  pset<string> already_loaded;
-
-  for (i=pipe_modules_begin(); i!=pipe_modules_end(); ++i) {
-    string name = (*i).Val();
-    if (already_loaded.insert(name).second) {
-      Filename dlname = Filename::dso_filename("lib" + name + ".so");
-      display_cat.info()
-        << "loading display module: " << dlname.to_os_specific() << endl;
-      void *tmp = load_dso(dlname);
-      if (tmp == (void*)0L) {
-        display_cat.info()
-          << "Unable to load: " << load_dso_error() << endl;
-      }
-    }
-  }
-  for (i=gsg_modules_begin(); i!=gsg_modules_end(); ++i) {
-    string name = (*i).Val();
-    if (already_loaded.insert(name).second) {
-      Filename dlname = Filename::dso_filename("lib" + name + ".so");
-      display_cat.info()
-        << "loading GSG module: " << dlname.to_os_specific() << endl;
-      void *tmp = load_dso(dlname);
-      if (tmp == (void*)0L) {
-        display_cat.info()
-          << "Unable to load: " << load_dso_error() << endl;
-      }
+bool GraphicsPipe::
+remove_window(GraphicsWindow *window) {
+  bool removed = false;
+  {
+    MutexHolder holder(_lock);
+    PT(GraphicsWindow) ptwin = window;
+    window->_pipe = NULL;
+    Windows::iterator wi = find(_windows.begin(), _windows.end(), ptwin);
+    if (wi != _windows.end()) {
+      _windows.erase(wi);
+      removed = true;
     }
     }
   }
   }
 
 
-  read_priorities();
-  GraphicsWindow::read_priorities();
-  GraphicsPipe::read_priorities();
+  return removed;
 }
 }

+ 36 - 90
panda/src/display/graphicsPipe.h

@@ -15,114 +15,64 @@
 // [email protected] .
 // [email protected] .
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
+
 #ifndef GRAPHICSPIPE_H
 #ifndef GRAPHICSPIPE_H
 #define GRAPHICSPIPE_H
 #define GRAPHICSPIPE_H
-//
-////////////////////////////////////////////////////////////////////
-// Includes
-////////////////////////////////////////////////////////////////////
-#include <pandabase.h>
 
 
-#include "graphicsWindow.h"
-#include "hardwareChannel.h"
-#include "pipeSpec.h"
+#include "pandabase.h"
 
 
-#include <typedReferenceCount.h>
-#include <namable.h>
-#include <factory.h>
-#include <factoryParam.h>
-
-#include <string>
+#include "typedReferenceCount.h"
+#include "pointerTo.h"
+#include "mutex.h"
 #include "pvector.h"
 #include "pvector.h"
 
 
-////////////////////////////////////////////////////////////////////
-// Defines
-////////////////////////////////////////////////////////////////////
-class GraphicsPipe;
-class glxDisplay;
+class HardwareChannel;
+class GraphicsWindow;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : GraphicsPipe
 //       Class : GraphicsPipe
-// Description :
+// Description : An object to create GraphicsWindows that share a
+//               particular 3-D API.  Normally, there will only be one
+//               GraphicsPipe in an application, although it is
+//               possible to have multiple of these at once if there
+//               are multiple different API's available in the same
+//               machine.
+//
+//               Often, the GraphicsPipe corresponds to a physical
+//               output device, hence the term "pipe", but this is not
+//               necessarily the case.
+//
+//               The GraphicsPipe is used by the GraphicsEngine object
+//               to create and destroy windows; it keeps ownership of
+//               the windows it creates.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDA GraphicsPipe : public TypedReferenceCount, public Namable {
+class EXPCL_PANDA GraphicsPipe : public TypedReferenceCount {
+protected:
+  GraphicsPipe();
+private:
+  GraphicsPipe(const GraphicsPipe &copy);
+  void operator = (const GraphicsPipe &copy);
+
 PUBLISHED:
 PUBLISHED:
-  GraphicsPipe(const PipeSpecifier &spec);
   virtual ~GraphicsPipe();
   virtual ~GraphicsPipe();
 
 
-  GraphicsWindow *make_window();
-  GraphicsWindow *make_window(const GraphicsWindow::Properties&);
-
-  void remove_window(GraphicsWindow *window);
-
-  virtual TypeHandle get_window_type() const=0;
-
-  // Functions for obtaining the set of windows associated with this
-  // pipe, and the set of all GraphicsPipes in the world.
-
   int get_num_windows() const;
   int get_num_windows() const;
-  GraphicsWindow *get_window(int n) const;
-
-  static int get_num_pipes();
-  static GraphicsPipe *get_pipe(int n);
+  PT(GraphicsWindow) get_window(int n) const;
 
 
 public:
 public:
-  // This function's interface must be defined here even though we
-  // know nothing about glx displays at this point.
-  virtual glxDisplay *get_glx_display();
-
-protected:
   virtual int get_num_hw_channels();
   virtual int get_num_hw_channels();
-  virtual HardwareChannel *get_hw_channel(GraphicsWindow *, int);
-
-  void add_window(GraphicsWindow *win);
-
-public:
-  // Factory stuff
-  typedef Factory<GraphicsPipe> PipeFactory;
-  typedef FactoryParam PipeParam;
-
-  // Make a factory parameter type for the pipe specifier
-  class EXPCL_PANDA PipeSpec : public PipeParam {
-  public:
-    INLINE PipeSpec(void) : PipeParam() {}
-    INLINE PipeSpec(PipeSpecifier& p) : PipeParam(), _p(p) {}
-    virtual ~PipeSpec(void);
-    INLINE const PipeSpecifier &get_specifier(void) { return _p; }
-  public:
-    static TypeHandle get_class_type(void);
-    static void init_type(void);
-    virtual TypeHandle get_type(void) const;
-    virtual TypeHandle force_init_type(void);
-  private:
-    PipeSpecifier _p;
-
-    static TypeHandle _type_handle;
-  };
-
-  static PipeFactory &get_factory();
-  static void resolve_modules(void);
-
-private:
-  static void read_priorities(void);
+  virtual HardwareChannel *get_hw_channel(GraphicsWindow *window, int index);
 
 
 protected:
 protected:
+  virtual PT(GraphicsWindow) make_window()=0;
 
 
-  GraphicsPipe();
-  GraphicsPipe(const GraphicsPipe &copy);
-  GraphicsPipe &operator = (const GraphicsPipe &copy);
+  void add_window(GraphicsWindow *window);
+  bool remove_window(GraphicsWindow *window);
 
 
-private:
-  // Some private type declarations.  These must be declared here so
-  // we can declare the public iterator types, below.
   typedef pvector< PT(GraphicsWindow) > Windows;
   typedef pvector< PT(GraphicsWindow) > Windows;
-  typedef pvector<GraphicsPipe *> Pipes;
-
   Windows _windows;
   Windows _windows;
+  Mutex _lock;
 
 
-  static PipeFactory *_factory;
-  static Pipes *_all_pipes;
-  INLINE static Pipes &get_all_pipes();
 
 
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {
@@ -130,10 +80,8 @@ public:
   }
   }
   static void init_type() {
   static void init_type() {
     TypedReferenceCount::init_type();
     TypedReferenceCount::init_type();
-    Namable::init_type();
     register_type(_type_handle, "GraphicsPipe",
     register_type(_type_handle, "GraphicsPipe",
-                  TypedReferenceCount::get_class_type(),
-                  Namable::get_class_type());
+                  TypedReferenceCount::get_class_type());
   }
   }
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {
     return get_class_type();
     return get_class_type();
@@ -142,9 +90,7 @@ public:
 
 
 private:
 private:
   static TypeHandle _type_handle;
   static TypeHandle _type_handle;
-
-  // this is so it can call get_hw_channel
-  friend class GraphicsWindow;
+  friend class GraphicsEngine;
 };
 };
 
 
 #include "graphicsPipe.I"
 #include "graphicsPipe.I"

+ 57 - 0
panda/src/display/graphicsPipeSelection.I

@@ -0,0 +1,57 @@
+// Filename: graphicsPipeSelection.I
+// Created by:  drose (15Aug02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsPipeSelection::resolve_modules
+//       Access: Published
+//  Description: Conditionally calls do_resolve_modules(), if it has
+//               not been called before.
+////////////////////////////////////////////////////////////////////
+INLINE void GraphicsPipeSelection::
+resolve_modules() const {
+  if (!_resolved_modules) {
+    ((GraphicsPipeSelection *)this)->do_resolve_modules();
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsPipeSelection::get_global_ptr
+//       Access: Published, Static
+//  Description: Returns a pointer to the one global
+//               GraphicsPipeSelection object.
+////////////////////////////////////////////////////////////////////
+INLINE GraphicsPipeSelection *GraphicsPipeSelection::
+get_global_ptr() {
+  if (_global_ptr == (GraphicsPipeSelection *)NULL) {
+    _global_ptr = new GraphicsPipeSelection;
+  }
+  return _global_ptr;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsPipeSelection::PipeType::Constructor
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+INLINE GraphicsPipeSelection::PipeType::
+PipeType(TypeHandle type, PipeConstructorFunc *constructor) :
+  _type(type),
+  _constructor(constructor)
+{
+}

+ 251 - 0
panda/src/display/graphicsPipeSelection.cxx

@@ -0,0 +1,251 @@
+// Filename: graphicsPipeSelection.cxx
+// Created by:  drose (15Aug02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "graphicsPipeSelection.h"
+#include "mutexHolder.h"
+#include "string_utils.h"
+#include "filename.h"
+#include "load_dso.h"
+#include "config_display.h"
+
+GraphicsPipeSelection *GraphicsPipeSelection::_global_ptr = NULL;
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsPipeSelection::Constructor
+//       Access: Protected
+//  Description:
+////////////////////////////////////////////////////////////////////
+GraphicsPipeSelection::
+GraphicsPipeSelection() {
+  _resolved_modules = false;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsPipeSelection::Destructor
+//       Access: Protected
+//  Description:
+////////////////////////////////////////////////////////////////////
+GraphicsPipeSelection::
+~GraphicsPipeSelection() {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsPipeSelection::get_num_pipe_types
+//       Access: Published
+//  Description: Returns the number of different types of
+//               GraphicsPipes that are available to create through
+//               this interface.
+////////////////////////////////////////////////////////////////////
+int GraphicsPipeSelection::
+get_num_pipe_types() const {
+  resolve_modules();
+
+  int result;
+  {
+    MutexHolder holder(_lock);
+    result = _pipe_types.size();
+  }
+  return result;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsPipeSelection::get_pipe_type
+//       Access: Published
+//  Description: Returns the nth type of GraphicsPipe available
+//               through this interface.
+////////////////////////////////////////////////////////////////////
+TypeHandle GraphicsPipeSelection::
+get_pipe_type(int n) const {
+  resolve_modules();
+
+  TypeHandle result;
+  {
+    MutexHolder holder(_lock);
+    if (n >= 0 && n < (int)_pipe_types.size()) {
+      result = _pipe_types[n]._type;
+    }
+  }
+  return result;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsPipeSelection::make_pipe
+//       Access: Published
+//  Description: Creates a new GraphicsPipe of the indicated type (or
+//               a type more specific than the indicated type, if
+//               necessary) and returns it.  Returns NULL if the type
+//               cannot be matched.
+////////////////////////////////////////////////////////////////////
+PT(GraphicsPipe) GraphicsPipeSelection::
+make_pipe(TypeHandle type) {
+  resolve_modules();
+
+  MutexHolder holder(_lock);
+  PipeTypes::const_iterator ti;
+
+  // First, look for an exact match of the requested type.
+  for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
+    const PipeType &ptype = (*ti);
+    if (ptype._type == type) {
+      // Here's an exact match.
+      PT(GraphicsPipe) pipe = (*ptype._constructor)();
+      if (pipe != (GraphicsPipe *)NULL) {
+        return pipe;
+      }
+    }
+  }
+
+  // Now look for a more-specific type.
+  for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
+    const PipeType &ptype = (*ti);
+    if (ptype._type.is_derived_from(type)) {
+      // Here's an approximate match.
+      PT(GraphicsPipe) pipe = (*ptype._constructor)();
+      if (pipe != (GraphicsPipe *)NULL) {
+        return pipe;
+      }
+    }
+  }
+
+  // Couldn't find a matching pipe type.
+  return NULL;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsPipeSelection::make_default_pipe
+//       Access: Published
+//  Description: Creates a new GraphicsPipe of some arbitrary type.
+//               The user may specify a preference using the Configrc
+//               file; otherwise, one will be chosen arbitrarily.
+////////////////////////////////////////////////////////////////////
+PT(GraphicsPipe) GraphicsPipeSelection::
+make_default_pipe() {
+  resolve_modules();
+
+  MutexHolder holder(_lock);
+  PipeTypes::const_iterator ti;
+
+  // First, look for an exact match of the requested type (excepting
+  // case and hyphen/underscore).
+  for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
+    const PipeType &ptype = (*ti);
+    if (cmp_nocase_uh(ptype._type.get_name(), preferred_pipe) == 0) {
+      // Here's an exact match.
+      PT(GraphicsPipe) pipe = (*ptype._constructor)();
+      if (pipe != (GraphicsPipe *)NULL) {
+        return pipe;
+      }
+    }
+  }
+
+  // No match; look for a substring match.
+  string preferred_name = downcase(preferred_pipe);
+  for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
+    const PipeType &ptype = (*ti);
+    string ptype_name = downcase(ptype._type.get_name());
+    if (ptype_name.find(preferred_name) != string::npos) {
+      // Here's a substring match.
+      PT(GraphicsPipe) pipe = (*ptype._constructor)();
+      if (pipe != (GraphicsPipe *)NULL) {
+        return pipe;
+      }
+    }
+  }
+
+  // Couldn't find a matching pipe type; choose one arbitrarily. 
+  for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
+    const PipeType &ptype = (*ti);
+    PT(GraphicsPipe) pipe = (*ptype._constructor)();
+    if (pipe != (GraphicsPipe *)NULL) {
+      return pipe;
+    }
+  }
+
+  // Nothing.  Probably the list was empty.
+  return NULL;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsPipeSelection::add_pipe_type
+//       Access: Public
+//  Description: Adds a new kind of GraphicsPipe to the list of
+//               available pipes for creation.  Normally, this is
+//               called at static init type by the various shared
+//               libraries as they are linked in.  Returns true on
+//               success, false on failure.
+////////////////////////////////////////////////////////////////////
+bool GraphicsPipeSelection::
+add_pipe_type(TypeHandle type, PipeConstructorFunc *func) {
+  if (!type.is_derived_from(GraphicsPipe::get_class_type())) {
+    display_cat.warning()
+      << "Attempt to register " << type << " as a GraphicsPipe type.\n";
+    return false;
+  }
+  
+  // First, make sure we don't already have a GraphicsPipe of this
+  // type.
+  MutexHolder holder(_lock);
+  PipeTypes::const_iterator ti;
+  for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
+    const PipeType &ptype = (*ti);
+    if (ptype._type == type) {
+      display_cat.warning()
+        << "Attempt to register GraphicsPipe type " << type
+        << " more than once.\n";
+      return false;
+    }
+  }
+
+  // Ok, now add a new entry.
+  _pipe_types.push_back(PipeType(type, func));
+
+  return true;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsPipeSelection::do_resolve_modules
+//       Access: Private
+//  Description: Loads the shared objects listed in the load-display
+//               Configrc variable, which should make all of the
+//               dynamic GraphicsPipes available.
+////////////////////////////////////////////////////////////////////
+void GraphicsPipeSelection::
+do_resolve_modules() {
+  Config::ConfigTable::Symbol::iterator ci;
+
+  // Build up a set of the modules we've already loaded as we go, so
+  // we don't attempt to load a given module more than once.
+  pset<string> already_loaded;
+
+  for (ci = display_modules_begin(); ci != display_modules_end(); ++ci) {
+    string name = (*ci).Val();
+    if (already_loaded.insert(name).second) {
+      Filename dlname = Filename::dso_filename("lib" + name + ".so");
+      display_cat.info()
+        << "loading display module: " << dlname.to_os_specific() << endl;
+      void *tmp = load_dso(dlname);
+      if (tmp == (void *)NULL) {
+        display_cat.info()
+          << "Unable to load: " << load_dso_error() << endl;
+      }
+    }
+  }
+
+  _resolved_modules = true;
+}
+

+ 86 - 0
panda/src/display/graphicsPipeSelection.h

@@ -0,0 +1,86 @@
+// Filename: graphicsPipeSelection.h
+// Created by:  drose (15Aug02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef GRAPHICSPIPESELECTION_H
+#define GRAPHICSPIPESELECTION_H
+
+#include "pandabase.h"
+
+#include "graphicsPipe.h"
+#include "pointerTo.h"
+#include "typeHandle.h"
+#include "mutex.h"
+
+class HardwareChannel;
+class GraphicsWindow;
+
+////////////////////////////////////////////////////////////////////
+//       Class : GraphicsPipeSelection
+// Description : This maintains a list of GraphicsPipes by type that
+//               are available for creation.  Normally there is one
+//               default interactive GraphicsPipe, and possibly other
+//               types available as well.
+//
+//               This is used to manage creation of a GraphicsPipe
+//               when you don't particularly care what kind of pipe
+//               you create; you just want to render to the screen.
+//               If your application does have a preference, you can
+//               of course invoke the appropriate GraphicsPipe
+//               constructor yourself.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDA GraphicsPipeSelection {
+protected:
+  GraphicsPipeSelection();
+  ~GraphicsPipeSelection();
+
+PUBLISHED:
+  int get_num_pipe_types() const;
+  TypeHandle get_pipe_type(int n) const;
+
+  PT(GraphicsPipe) make_pipe(TypeHandle type);
+  PT(GraphicsPipe) make_default_pipe();
+
+  INLINE void resolve_modules() const;
+
+  INLINE static GraphicsPipeSelection *get_global_ptr();
+
+public:
+  typedef PT(GraphicsPipe) PipeConstructorFunc();
+  bool add_pipe_type(TypeHandle type, PipeConstructorFunc *func);
+
+private:
+  void do_resolve_modules();
+
+  class PipeType {
+  public:
+    INLINE PipeType(TypeHandle type, PipeConstructorFunc *constructor);
+    TypeHandle _type;
+    PipeConstructorFunc *_constructor;
+  };
+  typedef pvector<PipeType> PipeTypes;
+  PipeTypes _pipe_types;
+  bool _resolved_modules;
+  Mutex _lock;
+
+  static GraphicsPipeSelection *_global_ptr;
+};  
+
+#include "graphicsPipeSelection.I"
+
+#endif
+

+ 55 - 29
panda/src/display/graphicsStateGuardian.cxx

@@ -417,8 +417,14 @@ prepare_lens() {
 //  Description: Called before each frame is rendered, to allow the
 //  Description: Called before each frame is rendered, to allow the
 //               GSG a chance to do any internal cleanup before
 //               GSG a chance to do any internal cleanup before
 //               beginning the frame.
 //               beginning the frame.
+//
+//               The return value is true if successful (in which case
+//               the frame will be drawn and end_frame() will be
+//               called later), or false if unsuccessful (in which
+//               case nothing will be drawn and end_frame() will not
+//               be called).
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void GraphicsStateGuardian::
+bool GraphicsStateGuardian::
 begin_frame() {
 begin_frame() {
   // Undo any lighting we had enabled last frame, to force the lights
   // Undo any lighting we had enabled last frame, to force the lights
   // to be reissued, in case their parameters or positions have
   // to be reissued, in case their parameters or positions have
@@ -466,6 +472,40 @@ begin_frame() {
   // measurably expensive.
   // measurably expensive.
   modify_state(get_untextured_state());
   modify_state(get_untextured_state());
 #endif
 #endif
+  return true;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsStateGuardian::begin_scene
+//       Access: Public, Virtual
+//  Description: Called between begin_frame() and end_frame() to mark
+//               the beginning of drawing commands for a "scene"
+//               (usually a particular DisplayRegion) within a frame.
+//               All 3-D drawing commands, except the clear operation,
+//               must be enclosed within begin_scene() .. end_scene().
+//
+//               The return value is true if successful (in which case
+//               the scene will be drawn and end_scene() will be
+//               called later), or false if unsuccessful (in which
+//               case nothing will be drawn and end_scene() will not
+//               be called).
+////////////////////////////////////////////////////////////////////
+bool GraphicsStateGuardian::
+begin_scene() {
+  return true;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsStateGuardian::end_scene
+//       Access: Public, Virtual
+//  Description: Called between begin_frame() and end_frame() to mark
+//               the end of drawing commands for a "scene" (usually a
+//               particular DisplayRegion) within a frame.  All 3-D
+//               drawing commands, except the clear operation, must be
+//               enclosed within begin_scene() .. end_scene().
+////////////////////////////////////////////////////////////////////
+void GraphicsStateGuardian::
+end_scene() {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -1338,6 +1378,16 @@ unmark_prepared_geom_node(GeomNodeContext *gnc) {
   return removed;
   return removed;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsStateGuardian::free_pointers
+//       Access: Protected, Virtual
+//  Description: Frees some memory that was explicitly allocated
+//               within the glgsg.
+////////////////////////////////////////////////////////////////////
+void GraphicsStateGuardian::
+free_pointers() {
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsStateGuardian::close_gsg
 //     Function: GraphicsStateGuardian::close_gsg
 //       Access: Protected, Virtual
 //       Access: Protected, Virtual
@@ -1348,6 +1398,10 @@ unmark_prepared_geom_node(GeomNodeContext *gnc) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsStateGuardian::
 void GraphicsStateGuardian::
 close_gsg() {
 close_gsg() {
+  free_pointers();
+  release_all_textures();
+  release_all_geoms();
+
   _win = (GraphicsWindow *)NULL;
   _win = (GraphicsWindow *)NULL;
 }
 }
 
 
@@ -1535,31 +1589,3 @@ get_factory() {
   }
   }
   return (*_factory);
   return (*_factory);
 }
 }
-
-void GraphicsStateGuardian::
-read_priorities(void) {
-  GsgFactory &factory = get_factory();
-  if (factory.get_num_preferred() == 0) {
-    Config::ConfigTable::Symbol::iterator i;
-    for (i = preferred_gsg_begin(); i != preferred_gsg_end(); ++i) {
-      ConfigString type_name = (*i).Val();
-      TypeHandle type = TypeRegistry::ptr()->find_type(type_name);
-      if (type == TypeHandle::none()) {
-        gsg_cat.warning()
-          << "Unknown type requested for GSG preference: " << type_name
-          << "\n";
-      } else {
-        gsg_cat.debug()
-          << "Specifying type " << type << " for GSG preference.\n";
-        factory.add_preferred(type);
-      }
-    }
-  }
-}
-
-void GraphicsStateGuardian::start_rendering(void) {
-}
-
-void GraphicsStateGuardian::finish_rendering(void) {
-}
-

+ 4 - 5
panda/src/display/graphicsStateGuardian.h

@@ -101,12 +101,11 @@ public:
 
 
   INLINE void enable_normals(bool val) { _normals_enabled = val; }
   INLINE void enable_normals(bool val) { _normals_enabled = val; }
 
 
-  virtual void begin_frame();
+  virtual bool begin_frame();
+  virtual bool begin_scene();
+  virtual void end_scene();
   virtual void end_frame();
   virtual void end_frame();
 
 
-  virtual void start_rendering(void);
-  virtual void finish_rendering(void);
-
   // These functions will be queried by the GeomIssuer to determine if
   // These functions will be queried by the GeomIssuer to determine if
   // it should issue normals, texcoords, and/or colors, based on the
   // it should issue normals, texcoords, and/or colors, based on the
   // GSG's current state.
   // GSG's current state.
@@ -190,6 +189,7 @@ protected:
   bool mark_prepared_geom_node(GeomNodeContext *gnc);
   bool mark_prepared_geom_node(GeomNodeContext *gnc);
   bool unmark_prepared_geom_node(GeomNodeContext *gnc);
   bool unmark_prepared_geom_node(GeomNodeContext *gnc);
 
 
+  virtual void free_pointers();
   virtual void close_gsg();
   virtual void close_gsg();
 
 
 #ifdef DO_PSTATS
 #ifdef DO_PSTATS
@@ -353,7 +353,6 @@ public:
   static GsgFactory &get_factory();
   static GsgFactory &get_factory();
 
 
 private:
 private:
-  static void read_priorities(void);
   static GsgFactory *_factory;
   static GsgFactory *_factory;
 
 
 public:
 public:

+ 26 - 423
panda/src/display/graphicsWindow.I

@@ -16,190 +16,44 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#include <notify.h>
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::Copy Constructor
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE GraphicsWindow::Properties::
-Properties(const Properties &copy) {
-  (*this) = copy;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::Copy Assignment Operator
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::Properties::
-operator = (const Properties &copy) {
-  ClearableRegion::operator = (copy);
-  _xorg = copy._xorg;
-  _yorg = copy._yorg;
-  _xsize = copy._xsize;
-  _ysize = copy._ysize;
-  _title = copy._title;
-  _border = copy._border;
-  _fullscreen = copy._fullscreen;
-  _mask = copy._mask;
-  _want_depth_bits = copy._want_depth_bits;
-  _want_color_bits = copy._want_color_bits;
-  _bCursorIsVisible = copy._bCursorIsVisible;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::Destructor
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE GraphicsWindow::Properties::
-~Properties() {
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::set_origin
-//       Access: Published
-//  Description: Specifies the origin on the screen (in pixels,
-//               relative to the top-left corner) at which the window
-//               should appear.  This is the origin of the top-left
-//               corner of the useful part of the window, not
-//               including decorations.
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::Properties::
-set_origin(int xorg, int yorg) {
-  _xorg = xorg;
-  _yorg = yorg;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::set_size
-//       Access: Published
-//  Description: Specifies the requested size of the window, in
-//               pixels.  This is the size of the useful part of the
-//               window, not including decorations.
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::Properties::
-set_size(int xsize, int ysize) {
-  _xsize = xsize;
-  _ysize = ysize;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::set_title
-//       Access: Published
-//  Description: Specifies the title that should be assigned to the
-//               window.
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::Properties::
-set_title(const string &title) {
-  _title = title;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::set_border
-//       Access: Published
-//  Description: Specifies whether the window should be created with a
-//               border (true, the default) or not (false).
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::Properties::
-set_border(bool border) {
-  _border = border;
-}
-
-/*
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::set_cursor_visible
-//       Access: Published
-//  Description: Specifies if mouse cursor is visible
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::Properties::
-set_cursor_visible(bool IsVisible) {
-  _bCursorIsVisible=IsVisible;   // note: gsg should override to implement
-}
-*/
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::set_mask
-//       Access: Published
-//  Description: Specifies the set of graphics properties that are
-//               required for the context associated with the window.
-//               This should be the union of the appropriate bits
-//               defined in WindowModeType.
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::Properties::
-set_mask(uint mask) {
-  _mask = mask;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::set_bit_depth
-//       Access: Published
-//  Description: Specifies the minimum number of bits that are
-//               required for the depth buffer and color buffer,
-//               respectively.
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::Properties::
-set_bit_depth(int want_depth_bits, int want_color_bits) {
-  _want_depth_bits = want_depth_bits;
-  _want_color_bits = want_color_bits;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_properties
-//       Access: Published
-//  Description: Returns the full Properties structure that describes
-//               the window.
-////////////////////////////////////////////////////////////////////
-INLINE const GraphicsWindow::Properties &GraphicsWindow::
-get_properties() const {
-  return _props;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_width
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE int GraphicsWindow::
-get_width() const {
-  return (_props._xsize);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_height
+//     Function: GraphicsWindow::is_closed
 //       Access: Published
 //       Access: Published
-//  Description:
+//  Description: Returns true if the window has not yet been opened,
+//               or has been fully closed, false if it is open.  The
+//               window is not opened immediately after
+//               GraphicsEngine::make_window() is called; nor is it
+//               closed immediately after
+//               GraphicsEngine::remove_window() is called.  Either
+//               operation may take a frame or two.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE int GraphicsWindow::
-get_height() const {
-  return (_props._ysize);
+INLINE bool GraphicsWindow::
+is_closed() const {
+  return !_properties.get_open();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_xorg
+//     Function: GraphicsWindow::is_active
 //       Access: Published
 //       Access: Published
-//  Description:
+//  Description: Returns true if the window is ready to be rendered
+//               into, false otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE int GraphicsWindow::
-get_xorg() const {
-  return (_props._xorg);
+INLINE bool GraphicsWindow::
+is_active() const {
+  // Make this smarter?
+  return _properties.get_open() && !_properties.get_minimized();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_yorg
+//     Function: GraphicsWindow::is_fullscreen
 //       Access: Published
 //       Access: Published
-//  Description:
+//  Description: Returns true if the window has been opened as a
+//               fullscreen window, false otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE int GraphicsWindow::
-get_yorg() const {
-  return (_props._yorg);
-}
-
 INLINE bool GraphicsWindow::
 INLINE bool GraphicsWindow::
 is_fullscreen() const {
 is_fullscreen() const {
-  return (_props._fullscreen);
+  return _properties.get_fullscreen();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -209,13 +63,13 @@ is_fullscreen() const {
 //               There is a one-to-one association between windows and
 //               There is a one-to-one association between windows and
 //               GSG's.
 //               GSG's.
 //
 //
-//               It is invalid to call this if the window has been
-//               closed; that is, if is_closed() returns true.  In
-//               this case the GSG has been closed as well.
+//               This may return NULL if the graphics context has not
+//               yet been created for the window, e.g. before the
+//               first frame has rendered; or after the window has
+//               been closed.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE GraphicsStateGuardian *GraphicsWindow::
 INLINE GraphicsStateGuardian *GraphicsWindow::
 get_gsg() const {
 get_gsg() const {
-  nassertr(!is_closed(), NULL);
   return _gsg;
   return _gsg;
 }
 }
 
 
@@ -234,207 +88,6 @@ get_pipe() const {
   return _pipe;
   return _pipe;
 }
 }
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::close_window
-//       Access: Published
-//  Description: Closes the window and frees all resources associated
-//               with it, including the GSG.  The window may not be
-//               opened again.
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::
-close_window() {
-  if (!is_closed()) {
-    do_close_window();
-    release_gsg();
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::is_closed
-//       Access: Published
-//  Description: Returns true if close_window() has been called on
-//               this window, false otherwise.  If the window has been
-//               closed, most of its interface is no longer valid.
-////////////////////////////////////////////////////////////////////
-INLINE bool GraphicsWindow::
-is_closed() const {
-
-  return (_gsg == (GraphicsStateGuardian *)NULL);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::set_frame_number
-//       Access: Published
-//  Description: Sets the current frame number of the window.  This
-//               affects the frame numbers written for %f in a RIB or
-//               image filename template.  The frame number is
-//               initially zero, and it increments at each call to
-//               end_frame().
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::
-set_frame_number(const int f) {
-  _frame_number = f;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_frame_number
-//       Access: Published
-//  Description: Returns the current frame number of the window.  See
-//               set_frame_number().
-////////////////////////////////////////////////////////////////////
-INLINE int GraphicsWindow::
-get_frame_number() const {
-  return _frame_number;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::set_draw_callback
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::
-set_draw_callback(Callback *c) {
-  _draw_callback = c;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::set_idle_callback
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::
-set_idle_callback(Callback *c) {
-  _idle_callback = c;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::call_draw_callback
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::
-call_draw_callback(bool force_redraw) {
-  if (_draw_callback) {
-    _draw_callback->draw(force_redraw);
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::call_idle_callback
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::
-call_idle_callback() {
-  if (_idle_callback) {
-    _idle_callback->idle();
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_num_input_devices
-//       Access: Published
-//  Description: Returns the number of separate input devices
-//               associated with the window.  Typically, a window will
-//               have exactly one input device: the keyboard/mouse
-//               pair.  However, some windows may have no input
-//               devices, and others may add additional devices, for
-//               instance for a joystick.
-////////////////////////////////////////////////////////////////////
-INLINE int GraphicsWindow::
-get_num_input_devices() const {
-  return _input_devices.size();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_input_device_name
-//       Access: Published
-//  Description: Returns the name of the nth input device.
-////////////////////////////////////////////////////////////////////
-INLINE string GraphicsWindow::
-get_input_device_name(int device) const {
-  nassertr(device >= 0 && device < (int)_input_devices.size(), "");
-  return _input_devices[device].get_name();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::has_pointer
-//       Access: Published
-//  Description: Returns true if the nth input device has a
-//               screen-space pointer (for instance, a mouse), false
-//               otherwise.
-////////////////////////////////////////////////////////////////////
-INLINE bool GraphicsWindow::
-has_pointer(int device) const {
-  nassertr(device >= 0 && device < (int)_input_devices.size(), false);
-  return _input_devices[device].has_pointer();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::has_keyboard
-//       Access: Published
-//  Description: Returns true if the nth input device has a keyboard,
-//               false otherwise.
-////////////////////////////////////////////////////////////////////
-INLINE bool GraphicsWindow::
-has_keyboard(int device) const {
-  nassertr(device >= 0 && device < (int)_input_devices.size(), false);
-  return _input_devices[device].has_keyboard();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_mouse_data
-//       Access: Published
-//  Description: Returns the MouseData associated with the nth input
-//               device.
-////////////////////////////////////////////////////////////////////
-INLINE const MouseData &GraphicsWindow::
-get_mouse_data(int device) const {
-  nassertr(device >= 0 && device < (int)_input_devices.size(),
-           *(new MouseData));
-  return _input_devices[device].get_mouse_data();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::has_button_event
-//       Access: Published
-//  Description: Returns true if the indicated device has a pending
-//               button event (a mouse button or keyboard button
-//               down/up), false otherwise.  If this returns true, the
-//               particular event may be extracted via
-//               get_button_event().
-////////////////////////////////////////////////////////////////////
-INLINE bool GraphicsWindow::
-has_button_event(int device) const {
-  nassertr(device >= 0 && device < (int)_input_devices.size(), false);
-  return _input_devices[device].has_button_event();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_button_event
-//       Access: Published
-//  Description: Assuming a previous call to has_button_event()
-//               returned true, this returns the pending button event.
-////////////////////////////////////////////////////////////////////
-INLINE ButtonEvent GraphicsWindow::
-get_button_event(int device) {
-  nassertr(has_button_event(device), ButtonEvent());
-  return _input_devices[device].get_button_event();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_window_active
-//       Access: Public
-//  Description: Returns true if the window is currently active and
-//               ready to be rendered into, or false otherwise.  This
-//               state is normally updated only by the GSG, or by the
-//               window itself.
-////////////////////////////////////////////////////////////////////
-INLINE bool GraphicsWindow::
-get_window_active() const {
-  return _window_active;
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::win_display_regions_changed
 //     Function: GraphicsWindow::win_display_regions_changed
 //       Access: Public
 //       Access: Public
@@ -448,56 +101,6 @@ win_display_regions_changed() {
   _display_regions_stale = true;
   _display_regions_stale = true;
 }
 }
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::set_sync
-//       Access: Public
-//  Description: Sets flag for whether the buffer swap is done 
-//               implicitely at the end of each frame, or done
-//               explicitely for the purpose of synchronization.
-////////////////////////////////////////////////////////////////////
-INLINE void GraphicsWindow::
-set_sync(const bool b) {
-  _is_synced = b;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_sync
-//       Access: Public
-//  Description: Returns whether buffer swap is done explicitely by
-//               call to swap() method.
-////////////////////////////////////////////////////////////////////
-INLINE bool GraphicsWindow::
-get_sync() const {
-  return _is_synced;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_num_display_regions
-//       Access: Published
-//  Description: Returns the number of active DisplayRegions that have
-//               been created within the various layers and channels
-//               of the window.
-////////////////////////////////////////////////////////////////////
-INLINE int GraphicsWindow::
-get_num_display_regions() const {
-  determine_display_regions();
-  return _display_regions.size();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_display_region
-//       Access: Published
-//  Description: Returns the nth active DisplayRegion of those that
-//               have been created within the various layers and
-//               channels of the window.
-////////////////////////////////////////////////////////////////////
-INLINE DisplayRegion *GraphicsWindow::
-get_display_region(int n) const {
-  determine_display_regions();
-  nassertr(n >= 0 && n < (int)_display_regions.size(), NULL);
-  return _display_regions[n];
-}
-
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::determine_display_regions
 //     Function: GraphicsWindow::determine_display_regions

+ 639 - 410
panda/src/display/graphicsWindow.cxx

@@ -19,188 +19,83 @@
 #include "graphicsWindow.h"
 #include "graphicsWindow.h"
 #include "graphicsPipe.h"
 #include "graphicsPipe.h"
 #include "config_display.h"
 #include "config_display.h"
-
-#include <mouseButton.h>
-#include <keyboardButton.h>
+#include "mouseButton.h"
+#include "keyboardButton.h"
+#include "mutexHolder.h"
+#include "hardwareChannel.h"
+#include "throw_event.h"
 
 
 #include "pmap.h"
 #include "pmap.h"
 
 
-////////////////////////////////////////////////////////////////////
-// Static variables
-////////////////////////////////////////////////////////////////////
 TypeHandle GraphicsWindow::_type_handle;
 TypeHandle GraphicsWindow::_type_handle;
-TypeHandle GraphicsWindow::WindowProps::_type_handle;
-TypeHandle GraphicsWindow::WindowPipe::_type_handle;
-
-GraphicsWindow::WindowFactory *GraphicsWindow::_factory = NULL;
-
-#ifndef CPPPARSER
-// We must compile these lines, even if DO_PSTATS is not defined,
-// because the symbols for them are declared in the header file.
-// Otherwise they will be undefined symbols at link time.  However,
-// there's no runtime overhead to speak of for declaring these, so
-// there's no harm in compiling them all the time.
-PStatCollector GraphicsWindow::_app_pcollector("App");
-PStatCollector GraphicsWindow::_show_code_pcollector("App:Show code");
-PStatCollector GraphicsWindow::_swap_pcollector("Swap buffers");
-PStatCollector GraphicsWindow::_clear_pcollector("Draw:Clear");
-PStatCollector GraphicsWindow::_show_fps_pcollector("Draw:Show fps");
-PStatCollector GraphicsWindow::_make_current_pcollector("Draw:Make current");
-#endif
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Properties::Constructor
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-GraphicsWindow::Properties::
-Properties() {
-  _xorg = 0;
-  _yorg = 0;
-  _xsize = 512;
-  _ysize = 512;
-  _title = "Panda";
-  _border = true;
-  _fullscreen = false;
-  _mask = W_RGBA | W_DOUBLE | W_DEPTH;
-  _want_depth_bits = 1;
-  _want_color_bits = 1;
-  _bCursorIsVisible=true;
-
-  // By default, windows are set up to clear color and depth.
-  set_clear_color_active(true);
-  set_clear_depth_active(true);
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Callback::draw
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-void GraphicsWindow::Callback::
-draw(bool) {
-  display_cat.error()
-    << "Callback::draw() - no class defined for this" << endl;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::Callback::idle
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-void GraphicsWindow::Callback::
-idle() {
-  display_cat.error()
-    << "Callback::idle() - no class defined for this" << endl;
-}
-
-GraphicsWindow::WindowProps::~WindowProps(void) {}
-
-TypeHandle GraphicsWindow::WindowProps::get_class_type(void) {
-  return _type_handle;
-}
-
-void GraphicsWindow::WindowProps::init_type(void) {
-  WindowParam::init_type();
-  register_type(_type_handle, "GraphicsWindow::WindowProps",
-                WindowParam::get_class_type());
-}
-
-TypeHandle GraphicsWindow::WindowProps::get_type(void) const {
-  return get_class_type();
-}
-
-TypeHandle GraphicsWindow::WindowProps::force_init_type(void) {
-  init_type();
-  return get_class_type();
-}
-
-GraphicsWindow::WindowPipe::~WindowPipe(void) {}
-
-TypeHandle GraphicsWindow::WindowPipe::get_class_type(void) {
-  return _type_handle;
-}
-
-void GraphicsWindow::WindowPipe::init_type(void) {
-  WindowParam::init_type();
-  register_type(_type_handle, "GraphicsWindow::WindowPipe",
-                WindowParam::get_class_type());
-}
-
-TypeHandle GraphicsWindow::WindowPipe::get_type(void) const {
-  return get_class_type();
-}
-
-TypeHandle GraphicsWindow::WindowPipe::force_init_type(void) {
-  init_type();
-  return get_class_type();
-}
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::Constructor
 //     Function: GraphicsWindow::Constructor
-//       Access: Public
-//  Description:
+//       Access: Protected
+//  Description: Normally, the GraphicsWindow constructor is not
+//               called directly; these are created instead via the
+//               GraphicsEngine::make_window() function.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsWindow::
 GraphicsWindow::
-GraphicsWindow(GraphicsPipe *pipe,
-               const GraphicsWindow::Properties &props) : 
-  Configurable(),
-  ClearableRegion(props)
-{
+GraphicsWindow(GraphicsPipe *pipe) {
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
   MemoryUsage::update_type(this, this);
   MemoryUsage::update_type(this, this);
 #endif
 #endif
   _pipe = pipe;
   _pipe = pipe;
-  _props = props;
 
 
-  _draw_callback = NULL;
-  _idle_callback = NULL;
-  _frame_number = 0;
-  _is_synced = false;
-  _window_active = true;
+  // Some default properties for windows unless specified otherwise.
+  // Other properties (size, title, etc.) must be explicitly
+  // specified.
+  _properties.set_open(false);
+  _properties.set_undecorated(false);
+  _properties.set_fullscreen(false);
+  _properties.set_minimized(false);
+  _properties.set_cursor_hidden(false);
+  _properties.set_depth_bits(1);
+  _properties.set_color_bits(1);
+  _properties.set_framebuffer_mode(WindowProperties::FM_rgba | 
+                                   WindowProperties::FM_double_buffer | 
+                                   WindowProperties::FM_depth);
   _display_regions_stale = false;
   _display_regions_stale = false;
+  _window_event = "window-event";
+
+  // By default, windows are set up to clear color and depth.
+  set_clear_color_active(true);
+  set_clear_depth_active(true);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::Copy Constructor
 //     Function: GraphicsWindow::Copy Constructor
-//       Access: Public
+//       Access: Private
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsWindow::
 GraphicsWindow::
-GraphicsWindow(const GraphicsWindow&) {
-  display_cat.error()
-    << "GraphicsWindows should not be copied" << endl;
+GraphicsWindow(const GraphicsWindow &) {
+  nassertv(false);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::Copy Assignment Operator
 //     Function: GraphicsWindow::Copy Assignment Operator
-//       Access: Public
+//       Access: Private
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-GraphicsWindow& GraphicsWindow::
-operator=(const GraphicsWindow&) {
-  display_cat.error()
-  << "GraphicsWindows should not be assigned" << endl;
-  return *this;
+void GraphicsWindow::
+operator = (const GraphicsWindow &) {
+  nassertv(false);
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::Destructor
 //     Function: GraphicsWindow::Destructor
-//       Access: Public, Virtual
+//       Access: Published, Virtual
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsWindow::
 GraphicsWindow::
 ~GraphicsWindow() {
 ~GraphicsWindow() {
-  // First, call close_window().  This tells our GSG to let go of its
-  // pointer to us, and also eventually calls do_close_window().
-  // However, do_close_window() is a virtual function that might be
-  // extended in a derived class, but we don't have any derived
-  // virtual functions by the time the destructor is called.
-  
-  // Therefore, if a derived class has redefined do_close_window(), it
-  // should also call close_window() in its own destructor.
-  close_window();
+  // The window should be closed by the time we destruct.
+  nassertv(!_properties.get_open());
 
 
+  // And we shouldn't have a GraphicsPipe pointer anymore.
+  nassertv(_pipe == (GraphicsPipe *)NULL);
 
 
   // We don't have to destruct our child channels explicitly, since
   // We don't have to destruct our child channels explicitly, since
   // they are all reference-counted and will go away when their
   // they are all reference-counted and will go away when their
@@ -210,11 +105,92 @@ GraphicsWindow::
   for (ci = _channels.begin(); ci != _channels.end(); ++ci) {
   for (ci = _channels.begin(); ci != _channels.end(); ++ci) {
     (*ci)->_window = NULL;
     (*ci)->_window = NULL;
   }
   }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::get_properties
+//       Access: Published
+//  Description: Returns the current properties of the window.
+////////////////////////////////////////////////////////////////////
+WindowProperties GraphicsWindow::
+get_properties() const {
+  WindowProperties result;
+  {
+    MutexHolder holder(_lock);
+    result = _properties;
+  }
+  return result;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::get_requested_properties
+//       Access: Published
+//  Description: Returns the properties of the window that are
+//               currently requested.  These properties will be
+//               applied to the window (if valid) at the next
+//               execution of process_events().
+////////////////////////////////////////////////////////////////////
+WindowProperties GraphicsWindow::
+get_requested_properties() const {
+  WindowProperties result;
+  {
+    MutexHolder holder(_lock);
+    result = _requested_properties;
+  }
+  return result;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::request_properties
+//       Access: Published
+//  Description: Requests a property change on the window.  For
+//               example, use this method to request a window change
+//               size or minimize or something.
+//
+//               The change is not made immediately; rather, the
+//               request is saved and will be applied the next time
+//               the window task is run (probably at the next frame).
+////////////////////////////////////////////////////////////////////
+void GraphicsWindow::
+request_properties(const WindowProperties &requested_properties) {
+  MutexHolder holder(_lock);
+  _requested_properties.add_properties(requested_properties);
+}
 
 
-  // We don't need to remove ourself from the pipe's list of windows.
-  // We must have already been removed, or we wouldn't be destructing!
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::set_window_event
+//       Access: Published
+//  Description: Changes the name of the event that is generated when
+//               this window is modified externally, e.g. to be
+//               resized or closed by the user.
+//
+//               By default, all windows have the same window event
+//               unless they are explicitly changed.  When the event
+//               is generated, it includes one parameter: the window
+//               itself.
+////////////////////////////////////////////////////////////////////
+void GraphicsWindow::
+set_window_event(const string &window_event) {
+  MutexHolder holder(_lock);
+  _window_event = window_event;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::get_window_event
+//       Access: Published
+//  Description: Returns the name of the event that is generated when
+//               this window is modified externally, e.g. to be
+//               resized or closed by the user.  See set_window_event().
+////////////////////////////////////////////////////////////////////
+string GraphicsWindow::
+get_window_event() const {
+  string result;
+  MutexHolder holder(_lock);
+  result = _window_event;
+  return result;
+}
+
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::get_channel
 //     Function: GraphicsWindow::get_channel
 //       Access: Public
 //       Access: Public
@@ -234,6 +210,7 @@ GraphicsWindow::
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsChannel *GraphicsWindow::
 GraphicsChannel *GraphicsWindow::
 get_channel(int index) {
 get_channel(int index) {
+  MutexHolder holder(_lock);
   nassertr(index >= 0, NULL);
   nassertr(index >= 0, NULL);
 
 
   if (index < (int)_channels.size()) {
   if (index < (int)_channels.size()) {
@@ -250,14 +227,16 @@ get_channel(int index) {
     chan = new GraphicsChannel(this);
     chan = new GraphicsChannel(this);
   } else {
   } else {
     // Any other channel is some hardware-specific channel.
     // Any other channel is some hardware-specific channel.
-    nassertr(_pipe != NULL, NULL);
-    chan = _pipe->get_hw_channel(this, index);
-    if (chan == NULL) {
-      display_cat.error()
-        << "GraphicsWindow::get_channel() - got a NULL channel" << endl;
-    } else {
-      if (chan->get_window() != this) {
-        chan = NULL;
+    GraphicsPipe *pipe = _pipe;
+    if (pipe != (GraphicsPipe *)NULL) {
+      chan = _pipe->get_hw_channel(this, index);
+      if (chan == NULL) {
+        display_cat.error()
+          << "GraphicsWindow::get_channel() - got a NULL channel" << endl;
+      } else {
+        if (chan->get_window() != this) {
+          chan = NULL;
+        }
       }
       }
     }
     }
   }
   }
@@ -279,6 +258,7 @@ get_channel(int index) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsWindow::
 void GraphicsWindow::
 remove_channel(int index) {
 remove_channel(int index) {
+  MutexHolder holder(_lock);
   if (index >= 0 && index < (int)_channels.size()) {
   if (index >= 0 && index < (int)_channels.size()) {
     _channels[index].clear();
     _channels[index].clear();
   }
   }
@@ -297,7 +277,12 @@ remove_channel(int index) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 int GraphicsWindow::
 int GraphicsWindow::
 get_max_channel_index() const {
 get_max_channel_index() const {
-  return _channels.size();
+  int result;
+  {
+    MutexHolder holder(_lock);
+    result = _channels.size();
+  }
+  return result;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -312,178 +297,275 @@ get_max_channel_index() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool GraphicsWindow::
 bool GraphicsWindow::
 is_channel_defined(int index) const {
 is_channel_defined(int index) const {
-  if (index < 0 || index >= (int)_channels.size()) {
-    return false;
+  bool result;
+  {
+    MutexHolder holder(_lock);
+    if (index < 0 || index >= (int)_channels.size()) {
+      result = false;
+    } else {
+      result = (_channels[index] != (GraphicsChannel *)NULL);
+    }
   }
   }
-  return (_channels[index] != (GraphicsChannel *)NULL);
+  return result;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::declare_channel
-//       Access: Protected
-//  Description: An internal function to add the indicated
-//               newly-created channel to the list at the indicated
-//               channel number.
+//     Function: GraphicsWindow::get_num_display_regions
+//       Access: Published
+//  Description: Returns the number of active DisplayRegions that have
+//               been created within the various layers and channels
+//               of the window.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void GraphicsWindow::
-declare_channel(int index, GraphicsChannel *chan) {
-  nassertv(index >= 0);
-  if (index >= (int)_channels.size()) {
-    _channels.reserve(index);
-    while (index >= (int)_channels.size()) {
-      _channels.push_back(NULL);
-    }
+int GraphicsWindow::
+get_num_display_regions() const {
+  determine_display_regions();
+  int result;
+  {
+    MutexHolder holder(_lock);
+    result = _display_regions.size();
   }
   }
+  return result;
+}
 
 
-  nassertv(index < (int)_channels.size());
-  _channels[index] = chan;
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::get_display_region
+//       Access: Published
+//  Description: Returns the nth active DisplayRegion of those that
+//               have been created within the various layers and
+//               channels of the window.  This may return NULL if n is
+//               out of bounds; particularly likely if the number of
+//               display regions has changed since the last call to
+//               get_num_display_regions().
+////////////////////////////////////////////////////////////////////
+DisplayRegion *GraphicsWindow::
+get_display_region(int n) const {
+  determine_display_regions();
+  DisplayRegion *result;
+  {
+    MutexHolder holder(_lock);
+    if (n >= 0 && n < (int)_display_regions.size()) {
+      result = _display_regions[n];
+    } else {
+      result = NULL;
+    }
+  }
+  return result;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::do_determine_display_regions
-//       Access: Private
-//  Description: Recomputes the list of active DisplayRegions within
-//               the window.
+//     Function: GraphicsWindow::get_num_input_devices
+//       Access: Published
+//  Description: Returns the number of separate input devices
+//               associated with the window.  Typically, a window will
+//               have exactly one input device: the keyboard/mouse
+//               pair.  However, some windows may have no input
+//               devices, and others may add additional devices, for
+//               instance for a joystick.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void GraphicsWindow::
-do_determine_display_regions() {
-  _display_regions.clear();
-  Channels::const_iterator ci;
-  for (ci = _channels.begin(); ci != _channels.end(); ++ci) {
-    GraphicsChannel *chan = (*ci);
-    if (chan->is_active()) {
-      GraphicsChannel::GraphicsLayers::const_iterator li;
-      for (li = chan->_layers.begin(); li != chan->_layers.end(); ++li) {
-        GraphicsLayer *layer = (*li);
-        if (layer->is_active()) {
-          GraphicsLayer::DisplayRegions::const_iterator dri;
-          for (dri = layer->_display_regions.begin(); 
-               dri != layer->_display_regions.end(); 
-               ++dri) {
-            DisplayRegion *dr = (*dri);
-            if (dr->is_active()) {
-              _display_regions.push_back(dr);
-            }
-          }
-        }
-      }
-    }
+int GraphicsWindow::
+get_num_input_devices() const {
+  int result;
+  {
+    MutexHolder holder(_input_lock);
+    result = _input_devices.size();
   }
   }
+  return result;
+}
 
 
-  _display_regions_stale = false;
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::get_input_device_name
+//       Access: Published
+//  Description: Returns the name of the nth input device.
+////////////////////////////////////////////////////////////////////
+string GraphicsWindow::
+get_input_device_name(int device) const {
+  string result;
+  {
+    MutexHolder holder(_input_lock);
+    nassertr(device >= 0 && device < (int)_input_devices.size(), "");
+    result = _input_devices[device].get_name();
+  }
+  return result;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::resized
-//       Access: Public, Virtual
-//  Description: Called whenever the window gets the resize event.
+//     Function: GraphicsWindow::has_pointer
+//       Access: Published
+//  Description: Returns true if the nth input device has a
+//               screen-space pointer (for instance, a mouse), false
+//               otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void GraphicsWindow::
-resized(const unsigned int x, const unsigned int y) {
-  Channels::iterator ci;
-  for (ci = _channels.begin(); ci != _channels.end(); ++ci) {
-    GraphicsChannel *chan = (*ci);
-    chan->window_resized(x, y);
+bool GraphicsWindow::
+has_pointer(int device) const {
+  bool result;
+  {
+    MutexHolder holder(_input_lock);
+    nassertr(device >= 0 && device < (int)_input_devices.size(), false);
+    result = _input_devices[device].has_pointer();
   }
   }
-  _props._xsize = x;
-  _props._ysize = y;
+  return result;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::make_scratch_display_region
-//       Access: Public
-//  Description: Allocates and returns a temporary DisplayRegion that
-//               may be used to render offscreen into.  This
-//               DisplayRegion is not associated with any layer.
-//
-//               To allocate a normal DisplayRegion for rendering, use
-//               the interface provided in GraphicsLayer.
+//     Function: GraphicsWindow::has_keyboard
+//       Access: Published
+//  Description: Returns true if the nth input device has a keyboard,
+//               false otherwise.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-PT(DisplayRegion) GraphicsWindow::
-make_scratch_display_region(int xsize, int ysize) const {
-  if (xsize > _props._xsize) {
-    display_cat.error()
-      << "GraphicsWindow::make_scratch_display_region() - x size is larger "
-      << "than window x size" << endl;
-    xsize = _props._xsize;
-  }
-  if (ysize > _props._ysize) {
-    display_cat.error()
-      << "GraphicsWindow::make_scratch_display_region() - y size is larger "
-      << "than window y size" << endl;
-    ysize = _props._ysize;
+bool GraphicsWindow::
+has_keyboard(int device) const {
+  bool result;
+  {
+    MutexHolder holder(_input_lock);
+    nassertr(device >= 0 && device < (int)_input_devices.size(), false);
+    result = _input_devices[device].has_keyboard();
   }
   }
-
-  PT(DisplayRegion) region = new DisplayRegion(xsize, ysize);
-  region->copy_clear_settings(*this);
-  return region;
+  return result;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::make_current
-//       Access: Public, Virtual
-//  Description: Makes the window's graphics context the currently
-//               active context that will be next rendered into by the
-//               GSG, if this makes sense for the particular type of
-//               GraphicsWindow.
-////////////////////////////////////////////////////////////////////
-void GraphicsWindow::
-make_current(void) {
+//     Function: GraphicsWindow::get_mouse_data
+//       Access: Public
+//  Description: Returns the MouseData associated with the nth input
+//               device.
+////////////////////////////////////////////////////////////////////
+MouseData GraphicsWindow::
+get_mouse_data(int device) const {
+  MouseData result;
+  {
+    MutexHolder holder(_input_lock);
+    nassertr(device >= 0 && device < (int)_input_devices.size(), MouseData());
+    result = _input_devices[device].get_mouse_data();
+  }
+  return result;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::unmake_current
-//       Access: Public, Virtual
-//  Description:
+//     Function: GraphicsWindow::has_button_event
+//       Access: Public
+//  Description: Returns true if the indicated device has a pending
+//               button event (a mouse button or keyboard button
+//               down/up), false otherwise.  If this returns true, the
+//               particular event may be extracted via
+//               get_button_event().
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void GraphicsWindow::
-unmake_current(void) {
+bool GraphicsWindow::
+has_button_event(int device) const {
+  bool result;
+  {
+    MutexHolder holder(_input_lock);
+    nassertr(device >= 0 && device < (int)_input_devices.size(), false);
+    result = _input_devices[device].has_button_event();
+  }
+  return result;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::flag_redisplay
-//       Access: Public, Virtual
-//  Description:
-////////////////////////////////////////////////////////////////////
-void GraphicsWindow::
-flag_redisplay() {
+//     Function: GraphicsWindow::get_button_event
+//       Access: Public
+//  Description: Assuming a previous call to has_button_event()
+//               returned true, this returns the pending button event.
+////////////////////////////////////////////////////////////////////
+ButtonEvent GraphicsWindow::
+get_button_event(int device) {
+  ButtonEvent result;
+  {
+    MutexHolder holder(_input_lock);
+    nassertr(device >= 0 && device < (int)_input_devices.size(), ButtonEvent());
+    nassertr(_input_devices[device].has_button_event(), ButtonEvent());
+    result = _input_devices[device].get_button_event();
+  }
+  return result;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::register_draw_function
+//     Function: GraphicsWindow::verify_window_sizes
 //       Access: Public, Virtual
 //       Access: Public, Virtual
-//  Description:
+//  Description: Determines which of the indicated window sizes are
+//               supported by available hardware (e.g. in fullscreen
+//               mode).
+//
+//               On entry, dimen is an array containing contiguous x,y
+//               pairs specifying possible display sizes; it is
+//               numsizes*2 words long.  The function will zero out
+//               any invalid x,y size pairs.  The return value is the
+//               number of valid sizes that were found.
+//
+//               Note this doesn't guarantee a resize attempt will
+//               work; you still need to check the return value.
+//
+//               (It might be better to implement some sort of query
+//               interface that returns an array of supported sizes,
+//               but this way is somewhat simpler and will do the job
+//               on most cards, assuming they handle the std sizes the
+//               app knows about.)
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void GraphicsWindow::
-register_draw_function(GraphicsWindow::vfn f) {
-  _draw_function = f;
+int GraphicsWindow::
+verify_window_sizes(int numsizes, int *dimen) {
+  return numsizes;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::register_idle_function
-//       Access: Public, Virtual
-//  Description:
+//     Function: GraphicsWindow::make_scratch_display_region
+//       Access: Public
+//  Description: Allocates and returns a temporary DisplayRegion that
+//               may be used to render offscreen into.  This
+//               DisplayRegion is not associated with any layer.
+//
+//               To allocate a normal DisplayRegion for rendering, use
+//               the interface provided in GraphicsLayer.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void GraphicsWindow::
-register_idle_function(GraphicsWindow::vfn f) {
-  _idle_function = f;
-}
+PT(DisplayRegion) GraphicsWindow::
+make_scratch_display_region(int x_size, int y_size) const {
+#ifndef NDEBUG
+  {
+    MutexHolder holder(_lock);
+    if (x_size > _properties.get_x_size() || 
+        y_size > _properties.get_y_size()) {
+      display_cat.error()
+        << "make_scratch_display_region(): requested region of size " 
+        << x_size << ", " << y_size << " is larger than window of size "
+        << _properties.get_x_size() << ", " << _properties.get_y_size()
+        << ".\n";
+      x_size = min(x_size, _properties.get_x_size());
+      y_size = min(y_size, _properties.get_y_size());
+    }
+  }
+#endif
 
 
+  PT(DisplayRegion) region = new DisplayRegion(x_size, y_size);
+  region->copy_clear_settings(*this);
+  return region;
+}
+ 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::begin_frame
 //     Function: GraphicsWindow::begin_frame
 //       Access: Public, Virtual
 //       Access: Public, Virtual
-//  Description: This function will be called by the GSG before
-//               beginning processing for a given frame.  It should do
-//               whatever setup is required.
+//  Description: This function will be called within the draw thread
+//               before beginning rendering for a given frame.  It
+//               should do whatever setup is required, and return true
+//               if the frame should be rendered, or false if it
+//               should be skipped.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-void GraphicsWindow::
-begin_frame(bool bStartRendering) {
-  _gsg->begin_frame();
+bool GraphicsWindow::
+begin_frame() {
+  if (_gsg == (GraphicsStateGuardian *)NULL) {
+    MutexHolder holder(_lock);
+    // Oops, we don't have a GSG yet.
+    if (!_properties.get_open()) {
+      return false;
+    }
+    make_gsg();
+    if (_gsg == (GraphicsStateGuardian *)NULL) {
+      // Still couldn't make the GSG for some reason.
+      return false;
+    }
+  } else {
+    // Okay, we already have a GSG, so activate it.
+    make_current();
+  }
 
 
-  // app may not want to automatically call start_rendering() if
-  // it wants to switch the rendertarget buffer first
-  if(bStartRendering)
-      _gsg->start_rendering();
+  return _gsg->begin_frame();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -493,14 +575,22 @@ begin_frame(bool bStartRendering) {
 //               according to the settings of get_color_clear_active()
 //               according to the settings of get_color_clear_active()
 //               and get_depth_clear_active() (inherited from
 //               and get_depth_clear_active() (inherited from
 //               ClearableRegion).
 //               ClearableRegion).
+//
+//               This function is called only within the draw thread.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsWindow::
 void GraphicsWindow::
 clear() {
 clear() {
   if (is_any_clear_active()) {
   if (is_any_clear_active()) {
     nassertv(_gsg != (GraphicsStateGuardian *)NULL);
     nassertv(_gsg != (GraphicsStateGuardian *)NULL);
 
 
+    int x_size, y_size;
+    {
+      MutexHolder holder(_lock);
+      x_size = _properties.get_x_size();
+      y_size = _properties.get_y_size();
+    }
     PT(DisplayRegion) win_dr =
     PT(DisplayRegion) win_dr =
-      make_scratch_display_region(get_width(), get_height());
+      make_scratch_display_region(x_size, y_size);
     DisplayRegionStack old_dr = _gsg->push_display_region(win_dr);
     DisplayRegionStack old_dr = _gsg->push_display_region(win_dr);
     _gsg->clear(this);
     _gsg->clear(this);
     _gsg->pop_display_region(old_dr);
     _gsg->pop_display_region(old_dr);
@@ -510,197 +600,336 @@ clear() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::end_frame
 //     Function: GraphicsWindow::end_frame
 //       Access: Public, Virtual
 //       Access: Public, Virtual
-//  Description: This function will be called by the GSG after
-//               processing is completed for a given frame.  It should
-//               do whatever finalization is required.
+//  Description: This function will be called within the draw thread
+//               after rendering is completed for a given frame.  It
+//               should do whatever finalization is required.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsWindow::
 void GraphicsWindow::
-end_frame(void) {
-  // finish_rendering not called here since gsg's own end_frame 
-  // will usually want to finish_rendering() itself, 
-  // then swap double buffers, then call GraphicsStateGuardian::end_frame
-
+end_frame() {
+  nassertv(_gsg != (GraphicsStateGuardian *)NULL);
   _gsg->end_frame();
   _gsg->end_frame();
-  _frame_number++;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::process_events
+//     Function: GraphicsWindow::make_gsg
 //       Access: Public, Virtual
 //       Access: Public, Virtual
-//  Description: Do whatever processing is necessary to ensure that
-//               the window responds to user events.
+//  Description: Creates a new GSG for the window and stores it in the
+//               _gsg pointer.  This should only be called from within
+//               the draw thread.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsWindow::
 void GraphicsWindow::
-process_events() {
+make_gsg() {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::deactivate_window
+//     Function: GraphicsWindow::release_gsg
 //       Access: Public, Virtual
 //       Access: Public, Virtual
-//  Description: Indicates the window should stop rendering
-//               temporarily, and does whatever else is associated
-//               with that.  This is normally called only by the
-//               GraphicsWindow itself, or by the GSG.
+//  Description: Releases the current GSG pointer, if it is currently
+//               held, and resets the GSG to NULL.  This should only
+//               be called from within the draw thread.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsWindow::
 void GraphicsWindow::
-deactivate_window() {
-  _window_active = false;
+release_gsg() {
+  if (_gsg != (GraphicsStateGuardian *)NULL) {
+    _gsg->close_gsg();
+    _gsg.clear();
+  }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::reactivate_window
+//     Function: GraphicsWindow::make_current
 //       Access: Public, Virtual
 //       Access: Public, Virtual
-//  Description: Restores the normal window rendering behavior after a
-//               previous call to deactivate_window().
+//  Description: This function will be called within the draw thread
+//               during begin_frame() to ensure the graphics context
+//               is ready for drawing.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsWindow::
 void GraphicsWindow::
-reactivate_window() {
-  _window_active = true;
+make_current() {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::make_gsg
-//       Access: Protected
-//  Description: Creates a new GSG for the window and stores it in the
-//               _gsg pointer.
+//     Function: GraphicsWindow::begin_flip
+//       Access: Public, Virtual
+//  Description: This function will be called within the draw thread
+//               after end_frame() has been called on all windows, to
+//               initiate the exchange of the front and back buffers.
+//
+//               This should instruct the window to prepare for the
+//               flip at the next video sync, but it should not wait.
+//
+//               We have the two separate functions, begin_flip() and
+//               end_flip(), to make it easier to flip all of the
+//               windows at the same time.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsWindow::
 void GraphicsWindow::
-make_gsg() {
-  FactoryParams params;
-  params.add_param(new GraphicsStateGuardian::GsgWindow(this));
-
-  _gsg = GraphicsStateGuardian::get_factory().
-    make_instance(get_gsg_type(), params);
-
-  nassertv(_gsg != (GraphicsStateGuardian *)NULL);
+begin_flip() {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::release_gsg
-//       Access: Protected
-//  Description: Releases the current GSG pointer, if it is currently
-//               held.  This invalidates the window and marks it
-//               closed; it should not be called unless the code to
-//               close the window is also called.
+//     Function: GraphicsWindow::end_flip
+//       Access: Public, Virtual
+//  Description: This function will be called within the draw thread
+//               after begin_flip() has been called on all windows, to
+//               finish the exchange of the front and back buffers.
+//
+//               This should cause the window to wait for the flip, if
+//               necessary.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsWindow::
 void GraphicsWindow::
-release_gsg() {
-  if (_gsg != (GraphicsStateGuardian *)NULL) {
-    // First, we save the GSG pointer and then NULL it out.  That way,
-    // if the GSG happens to call close_window() while it is closing
-    // itself, it won't be recursive (because we'll already be marked
-    // closed).
-    PT(GraphicsStateGuardian) gsg = _gsg;
-    _gsg.clear();
-
-    // Now we tell the GSG it's time to sleep.
-    gsg->close_gsg();
-  }
+end_flip() {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::do_close_window
-//       Access: Protected, Virtual
-//  Description: An internal function to release whatever system
-//               resources are held by the window and actually close
-//               it.  This is called by close_window().  
+//     Function: GraphicsWindow::process_events
+//       Access: Public, Virtual
+//  Description: Do whatever processing is necessary to ensure that
+//               the window responds to user events.  Also, honor any
+//               requests recently made via request_properties().
 //
 //
-//               If a derived class redefines this function, it should
-//               also arrange to call close_window() (or its
-//               equivalent) from its own destructor, since we cannot
-//               call a virtual function from this destructor.
+//               This function is called only within the window
+//               thread.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsWindow::
 void GraphicsWindow::
-do_close_window() {
-  display_cat.info()
-    << "Closing " << get_type() << "\n";
+process_events() {
+  if (_requested_properties.is_any_specified()) {
+    // We don't bother to grab the mutex until after we have already
+    // checked whether any properties have been specified.  This is
+    // technically sloppy, but it ought to be o.k. since it's just a
+    // bitmask after all.
+    WindowProperties properties;
+    {
+      MutexHolder holder(_lock);
+      properties = _requested_properties;
+      _requested_properties = WindowProperties();
+    }
+    set_properties_now(properties);
+    if (properties.is_any_specified()) {
+      display_cat.info()
+        << "Unable to set window properties: " << properties << "\n";
+    }
+  }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::get_factory
-//       Access: Public, Static
-//  Description: Returns the factory object that can be used to
-//               register new kinds of GraphicsWindow objects that may
-//               be created.
+//     Function: GraphicsWindow::set_properties_now
+//       Access: Public, Virtual
+//  Description: Applies the requested set of properties to the
+//               window, if possible, for instance to request a change
+//               in size or minimization status.
+//
+//               The window properties are applied immediately, rather
+//               than waiting until the next frame.  This implies that
+//               this method may *only* be called from within the
+//               window thread.
+//
+//               The properties that have been applied are cleared
+//               from the structure by this function; so on return,
+//               whatever remains in the properties structure are
+//               those that were unchanged for some reason (probably
+//               because the underlying interface does not support
+//               changing that property on an open window).
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-GraphicsWindow::WindowFactory &GraphicsWindow::
-get_factory() {
-  if (_factory == (WindowFactory *)NULL) {
-    _factory = new WindowFactory;
+void GraphicsWindow::
+set_properties_now(WindowProperties &properties) {
+  if (properties.has_open() && 
+      properties.get_open() != _properties.get_open()) {
+    // Open or close a new window.  In this case we can get all of the
+    // properties at once.
+    _properties.add_properties(properties);
+    properties.clear();
+
+    if (_properties.get_open()) {
+      if (!open_window()) {
+        _properties.set_open(false);
+      }
+
+    } else {
+      // We can't close the window if its GSG hasn't been released
+      // yet.
+      nassertv(_gsg == (GraphicsStateGuardian *)NULL);
+      close_window();
+    }
+    return;
   }
   }
-  return (*_factory);
-}
-
-void GraphicsWindow::read_priorities(void) {
-  WindowFactory &factory = get_factory();
-  if (factory.get_num_preferred() == 0) {
-    Config::ConfigTable::Symbol::iterator i;
-    for (i = preferred_window_begin(); i != preferred_window_end(); ++i) {
-      ConfigString type_name = (*i).Val();
-      TypeHandle type = TypeRegistry::ptr()->find_type(type_name);
-      if (type == TypeHandle::none()) {
-        display_cat.warning()
-          << "Unknown type requested for window preference: " << type_name
-          << "\n";
-      } else {
-        display_cat.debug()
-          << "Specifying type " << type << " for window preference.\n";
-        factory.add_preferred(type);
+
+  if (!_properties.get_open()) {
+    // The window is not currently open; we can set properties at
+    // will.
+    _properties.add_properties(properties);
+    properties.clear();
+    return;
+  }
+
+  // The window is already open; we are limited to what we can change
+  // on the fly.
+
+  if (properties.has_size() || properties.has_origin()) {
+    // Consider changing the window's size and/or position.
+    WindowProperties reshape_props;
+    if (properties.has_size()) {
+      reshape_props.set_size(properties.get_x_size(), properties.get_y_size());
+    } else {
+      reshape_props.set_size(_properties.get_x_size(), _properties.get_y_size());
+    }
+    if (properties.has_origin() && !is_fullscreen()) {
+      reshape_props.set_origin(properties.get_x_origin(), properties.get_y_origin());
+    } else {
+      reshape_props.set_origin(_properties.get_x_origin(), _properties.get_y_origin());
+    }
+    
+    if (reshape_props.get_x_size() != _properties.get_x_size() ||
+        reshape_props.get_y_size() != _properties.get_y_size() ||
+        reshape_props.get_x_origin() != _properties.get_x_origin() ||
+        reshape_props.get_y_origin() != _properties.get_y_origin()) {
+      if (do_reshape_request(reshape_props.get_x_origin(),
+                             reshape_props.get_y_origin(),
+                             reshape_props.get_x_size(),
+                             reshape_props.get_y_size())) {
+        system_changed_size(reshape_props.get_x_size(), 
+                            reshape_props.get_y_size());
+        _properties.add_properties(reshape_props);
+        properties.clear_size();
+        properties.clear_origin();
       }
       }
     }
     }
   }
   }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::swap
-//       Access: Public
-//  Description: Swaps buffers explicitely as synchronization 
-//               mechanism. 
+//     Function: GraphicsWindow::close_window
+//       Access: Protected, Virtual
+//  Description: Closes the window right now.  Called from the window
+//               thread.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GraphicsWindow::
 void GraphicsWindow::
-swap() {
-  display_cat.warning() << "swap() unimplemented by " << get_type() << endl;
+close_window() {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: GraphicsWindow::resize
-//       Access: Public
-//  Description: Resizes the window to the given size.
-//               Should try to preserve current window bitdepths,
-//               if possible.  If it is not possible to resize window to
-//               the given size, return false and maintain current
-//               window size.
+//     Function: GraphicsWindow::open_window
+//       Access: Protected, Virtual
+//  Description: Opens the window right now.  Called from the window
+//               thread.  Returns true if the window is successfully
+//               opened, or false if there was a problem.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool GraphicsWindow::
 bool GraphicsWindow::
-resize(unsigned int xsize,unsigned int ysize) {
-  display_cat.warning() << "resize() unimplemented by " << get_type() << endl;  
+open_window() {
   return false;
   return false;
 }
 }
 
 
-unsigned int GraphicsWindow::
-verify_window_sizes(unsigned int numsizes,unsigned int *dimen) {
-  // see if window sizes are supported (i.e. in fullscrn mode)
-  // dimen is an array containing contiguous x,y pairs specifying
-  // possible display sizes, it is numsizes*2 long.  fn will zero
-  // out any invalid x,y size pairs.  return value is number of valid 
-  // sizes that were found.
-  // 
-  // note: it might be better to implement some sort of query
-  //       interface that returns an array of supported sizes,
-  //       but this way is somewhat simpler and will do the job 
-  //       on most cards, assuming they handle the std sizes the app
-  //       knows about.
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::open_window
+//       Access: Protected, Virtual
+//  Description: Called from the window thread in response to a request
+//               from within the code (via request_properties()) to
+//               change the size and/or position of the window.
+//               Returns true if the window is successfully changed,
+//               or false if there was a problem.
+////////////////////////////////////////////////////////////////////
+bool GraphicsWindow::
+do_reshape_request(int x_origin, int y_origin, int x_size, int y_size) {
+  return false;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::system_changed_properties
+//       Access: Protected
+//  Description: Should be called (from within the window thread) when
+//               process_events() detects an external change in some
+//               important window property; for instance, when the
+//               user resizes the window.
+////////////////////////////////////////////////////////////////////
+void GraphicsWindow::
+system_changed_properties(const WindowProperties &properties) {
+  MutexHolder holder(_lock);
+
+  if (properties.has_size()) {
+    system_changed_size(properties.get_x_size(), properties.get_y_size());
+  }
 
 
-  // Also note this doesnt guarantee resize() will work, you still need to check its return value.
+  WindowProperties old_properties = _properties;
+  _properties.add_properties(properties);
+  if (_properties != old_properties) {
+    throw_event(_window_event, this);
+  }
+}
 
 
-  display_cat.warning() << "verify_window_sizes() unimplemented by " << get_type() << endl; 
-  return numsizes;
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::system_changed_size
+//       Access: Protected
+//  Description: An internal function to update all the channels with
+//               the new size of the window.  This should always be
+//               called before changing the _size members of the
+//               _properties structure.
+////////////////////////////////////////////////////////////////////
+void GraphicsWindow::
+system_changed_size(int x_size, int y_size) {
+  if (x_size != _properties.get_x_size() || 
+      y_size != _properties.get_y_size()) {
+    Channels::iterator ci;
+    for (ci = _channels.begin(); ci != _channels.end(); ++ci) {
+      GraphicsChannel *chan = (*ci);
+      chan->window_resized(x_size, y_size);
+    }
+  }
 }
 }
 
 
-int GraphicsWindow::
-get_depth_bitwidth(void) {
-    display_cat.warning() << "get_depth_bitwidth() unimplemented by " << get_type() << endl; 
-    return -1;
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::declare_channel
+//       Access: Protected
+//  Description: An internal function to add the indicated
+//               newly-created channel to the list at the indicated
+//               channel number.
+//
+//               The caller must grab and hold _lock before making
+//               this call.
+////////////////////////////////////////////////////////////////////
+void GraphicsWindow::
+declare_channel(int index, GraphicsChannel *chan) {
+  nassertv(index >= 0);
+  if (index >= (int)_channels.size()) {
+    _channels.reserve(index);
+    while (index >= (int)_channels.size()) {
+      _channels.push_back(NULL);
+    }
+  }
+
+  nassertv(index < (int)_channels.size());
+  _channels[index] = chan;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::do_determine_display_regions
+//       Access: Private
+//  Description: Recomputes the list of active DisplayRegions within
+//               the window.
+////////////////////////////////////////////////////////////////////
+void GraphicsWindow::
+do_determine_display_regions() {
+  MutexHolder holder(_lock);
+  _display_regions_stale = false;
+  _display_regions.clear();
+  Channels::const_iterator ci;
+  for (ci = _channels.begin(); ci != _channels.end(); ++ci) {
+    GraphicsChannel *chan = (*ci);
+    if (chan->is_active()) {
+      GraphicsChannel::GraphicsLayers::const_iterator li;
+      for (li = chan->_layers.begin(); li != chan->_layers.end(); ++li) {
+        GraphicsLayer *layer = (*li);
+        if (layer->is_active()) {
+          GraphicsLayer::DisplayRegions::const_iterator dri;
+          for (dri = layer->_display_regions.begin(); 
+               dri != layer->_display_regions.end(); 
+               ++dri) {
+            DisplayRegion *dr = (*dri);
+            if (dr->is_active()) {
+              _display_regions.push_back(dr);
+            }
+          }
+        }
+      }
+    }
+  }
 }
 }
 
 
 void GraphicsWindow::
 void GraphicsWindow::

+ 93 - 232
panda/src/display/graphicsWindow.h

@@ -21,243 +21,153 @@
 #include "pandabase.h"
 #include "pandabase.h"
 
 
 #include "graphicsWindowInputDevice.h"
 #include "graphicsWindowInputDevice.h"
+#include "windowProperties.h"
 #include "graphicsChannel.h"
 #include "graphicsChannel.h"
+#include "graphicsPipe.h"
 #include "displayRegion.h"
 #include "displayRegion.h"
 #include "graphicsStateGuardian.h"
 #include "graphicsStateGuardian.h"
 #include "clearableRegion.h"
 #include "clearableRegion.h"
 
 
-#include "typedef.h"
-#include "configurable.h"
-#include "referenceCount.h"
+#include "typedReferenceCount.h"
 #include "mouseData.h"
 #include "mouseData.h"
 #include "modifierButtons.h"
 #include "modifierButtons.h"
 #include "buttonEvent.h"
 #include "buttonEvent.h"
 #include "iterator_types.h"
 #include "iterator_types.h"
-#include "factory.h"
-#include "pStatCollector.h"
+#include "notify.h"
+#include "mutex.h"
 
 
 #include "pvector.h"
 #include "pvector.h"
 #include "pdeque.h"
 #include "pdeque.h"
 
 
-////////////////////////////////////////////////////////////////////
-// Defines
-////////////////////////////////////////////////////////////////////
-enum WindowModeType
-{
-    W_RGBA =                            0,
-    W_RGB =                             0,
-    W_INDEX =                           1,
-    W_SINGLE =                          0,
-    W_DOUBLE =                          2,
-    W_ACCUM =                           4,
-    W_ALPHA =                           8,
-    W_DEPTH =                           16,
-    W_STENCIL =                         32,
-    W_MULTISAMPLE =                     128,
-    W_STEREO =                          256,
-    W_LUMINANCE =                       512
-};
-
 class GraphicsPipe;
 class GraphicsPipe;
 class GraphicsWindow;
 class GraphicsWindow;
 class CullHandler;
 class CullHandler;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : GraphicsWindow
 //       Class : GraphicsWindow
-// Description :
+// Description : An output medium for receiving the results of
+//               rendering.  Typically this is a window on the
+//               computer desktop, but it may also be the entire
+//               desktop or console screen (i.e. a fullscreen window),
+//               or a window on another machine, or even a disk file.
+//
+//               The GraphicsWindow class handles all of the details
+//               about creating a window and its framebuffer, and
+//               managing the properties associated with the windowing
+//               system, such as position and size and keyboard/mouse
+//               input.  The actual rendering, and anything associated
+//               with the graphics context itself, is managed by the
+//               window's GraphicsStateGuardian.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDA GraphicsWindow : public Configurable, public ReferenceCount, public ClearableRegion {
-PUBLISHED:
-  class EXPCL_PANDA Properties : public ClearableRegion {
-  PUBLISHED:
-    Properties();
-    INLINE Properties(const Properties &copy);
-    INLINE void operator = (const Properties &copy);
-    INLINE ~Properties();
-
-    // all these methods essentially do nothing since they do not get passed down to the gsg
-    // and maybe should be removed or commented out until they do, since
-    // they modify parameters that usually require re-creation of the window
-    // except for set_size(), which is superseded by resize(), which actually works.
-
-    INLINE void set_origin(int xorg, int yorg);
-    INLINE void set_size(int xsize, int ysize);
-    INLINE void set_title(const string &title);
-    INLINE void set_border(bool border);
-    INLINE void set_mask(uint mask);
-    INLINE void set_bit_depth(int want_depth_bits, int want_color_bits);
-
-  public:
-    int _xorg;
-    int _yorg;
-    int _xsize;
-    int _ysize;
-    string _title;
-    bool _border;
-    bool _fullscreen;
-    bool _bCursorIsVisible;
-    uint _mask;
-    int _want_depth_bits;
-    int _want_color_bits;
-  };
-
-public:
-  class EXPCL_PANDA Callback {
-  public:
-    virtual void draw(bool);
-    virtual void idle();
-  };
-  typedef void (*vfn)();
-  typedef void (*vfnii)(int, int);
+class EXPCL_PANDA GraphicsWindow : public TypedReferenceCount, public ClearableRegion {
+protected:
+  GraphicsWindow(GraphicsPipe *pipe);
 
 
-public:
+private:
+  GraphicsWindow(const GraphicsWindow &copy);
+  void operator = (const GraphicsWindow &copy);
 
 
-  GraphicsWindow(GraphicsPipe *pipe, const Properties &props = Properties());
+PUBLISHED:
   virtual ~GraphicsWindow();
   virtual ~GraphicsWindow();
 
 
-  INLINE const Properties& get_properties() const;
-
-  virtual void get_framebuffer_format(PixelBuffer::Type &fb_type, PixelBuffer::Format &fb_format);
-
-PUBLISHED:
-  INLINE int get_width() const;
-  INLINE int get_height() const;
-  INLINE int get_xorg() const;
-  INLINE int get_yorg() const;
+  WindowProperties get_properties() const;
+  WindowProperties get_requested_properties() const;
+  void request_properties(const WindowProperties &requested_properties);
+  INLINE bool is_closed() const;
+  INLINE bool is_active() const;
   INLINE bool is_fullscreen() const;
   INLINE bool is_fullscreen() const;
 
 
-  // # of z bits/pixel.  purpose is to adjust camera near plane if have fewer z bits
-  virtual int get_depth_bitwidth(void);  
+  void set_window_event(const string &window_event);
+  string get_window_event() const;
 
 
   INLINE GraphicsStateGuardian *get_gsg() const;
   INLINE GraphicsStateGuardian *get_gsg() const;
   INLINE GraphicsPipe *get_pipe() const;
   INLINE GraphicsPipe *get_pipe() const;
 
 
-  INLINE void close_window();
-  INLINE bool is_closed() const;
-
-  INLINE void set_frame_number(const int);
-  INLINE int get_frame_number() const;
-
-  INLINE void set_sync(const bool);
-  INLINE bool get_sync() const;
-
-  // since this requires gsg modification, dont worry about implementing it yet
-  // since init control is good enough
-  // virtual void set_cursor_visible(bool bIsVisible);  // should be overridden by gsg to implement
-
-  // resize the window to the given size
-  virtual bool resize(unsigned int xsize,unsigned int ysize);  
-
-  virtual void swap();
-
-public:
-  virtual void resized(const unsigned int, const unsigned int);
-
-  // see if window sizes are supported (i.e. in fullscrn mode)
-  // 
-  // note: it might be better to implement some sort of query
-  //       interface that returns an array of supported sizes,
-  //       but this way is somewhat simpler and will do the job 
-  //       on most cards, assuming they handle the std sizes the app
-  //       knows about.
-  virtual unsigned int verify_window_sizes(unsigned int numsizes,unsigned int *dimen);
-
-  INLINE virtual void set_draw_callback(Callback *c);
-  INLINE virtual void set_idle_callback(Callback *c);
+  GraphicsChannel *get_channel(int index);
+  void remove_channel(int index);
 
 
-  INLINE void call_draw_callback(bool force_redraw);
-  INLINE void call_idle_callback();
+  int get_max_channel_index() const;
+  bool is_channel_defined(int index) const;
 
 
-  PT(DisplayRegion) make_scratch_display_region(int xsize,
-                                                int ysize) const;
+  int get_num_display_regions() const;
+  DisplayRegion *get_display_region(int n) const;
 
 
-  virtual TypeHandle get_gsg_type() const=0;
+  // Mouse and keyboard routines
+  int get_num_input_devices() const;
+  string get_input_device_name(int device) const;
+  bool has_pointer(int device) const;
+  bool has_keyboard(int device) const;
 
 
 public:
 public:
-  // context setting
-  virtual void make_current();
-  virtual void unmake_current();
+  // No need to publish these.
+  MouseData get_mouse_data(int device) const;
+  bool has_button_event(int device) const;
+  ButtonEvent get_button_event(int device);
 
 
-PUBLISHED:
-  // Mouse and keyboard routines
-  INLINE int get_num_input_devices() const;
-  INLINE string get_input_device_name(int device) const;
-  INLINE bool has_pointer(int device) const;
-  INLINE bool has_keyboard(int device) const;
+  virtual void get_framebuffer_format(PixelBuffer::Type &fb_type, PixelBuffer::Format &fb_format);
 
 
 public:
 public:
-  INLINE const MouseData &get_mouse_data(int device) const;
-  INLINE bool has_button_event(int device) const;
-  INLINE ButtonEvent get_button_event(int device);
+  virtual int verify_window_sizes(int numsizes, int *dimen);
+  PT(DisplayRegion) make_scratch_display_region(int x_size, int y_size) const;
 
 
-PUBLISHED:
-  // GUI glue methods
-  virtual void flag_redisplay();
-  virtual void register_draw_function(GraphicsWindow::vfn);
-  virtual void register_idle_function(GraphicsWindow::vfn);
+  INLINE void win_display_regions_changed();
 
 
 public:
 public:
-  virtual void begin_frame(bool bStartRendering = true);
+  // It is an error to call any of the following methods from any
+  // thread other than the draw thread.  These methods are normally
+  // called by the GraphicsEngine.
+  virtual bool begin_frame();
   void clear();
   void clear();
   virtual void end_frame();
   virtual void end_frame();
 
 
-  virtual void process_events();
+  virtual void make_gsg();
+  virtual void release_gsg();
 
 
-  INLINE bool get_window_active() const;
-  virtual void deactivate_window();
-  virtual void reactivate_window();
+  // This method is called in the draw thread prior to issuing any
+  // drawing commands for the window.
+  virtual void make_current();
 
 
-  INLINE void win_display_regions_changed();
+  // These methods will be called within the app (main) thread.
+  virtual void begin_flip();
+  virtual void end_flip();
 
 
-  // Statistics
-  static PStatCollector _app_pcollector;
-  static PStatCollector _show_code_pcollector;
-  static PStatCollector _swap_pcollector;  // dxgsg needs access so this is public
-  static PStatCollector _clear_pcollector;
-  static PStatCollector _show_fps_pcollector;
-  static PStatCollector _make_current_pcollector;
+  // It is an error to call any of the following methods from any
+  // thread other than the window thread.  These methods are normally
+  // called by the GraphicsEngine.
+  virtual void process_events();
+  virtual void set_properties_now(WindowProperties &properties);
 
 
 protected:
 protected:
-  void make_gsg();
-  void release_gsg();
-  virtual void do_close_window();
+  virtual void close_window();
+  virtual bool open_window();
+  virtual bool do_reshape_request(int x_origin, int y_origin,
+                                  int x_size, int y_size);
+
+  void declare_channel(int index, GraphicsChannel *chan);
 
 
+  // It is an error to call any of the following methods from any
+  // thread other than the window thread.
+  void system_changed_properties(const WindowProperties &properties);
+  void system_changed_size(int x_size, int y_size);
+  
+protected:
   typedef vector_GraphicsWindowInputDevice InputDevices;
   typedef vector_GraphicsWindowInputDevice InputDevices;
   InputDevices _input_devices;
   InputDevices _input_devices;
+  Mutex _input_lock;
 
 
   PT(GraphicsStateGuardian) _gsg;
   PT(GraphicsStateGuardian) _gsg;
-  Properties _props;
-
   GraphicsPipe *_pipe;
   GraphicsPipe *_pipe;
-  vfn _draw_function;
-  vfn _idle_function;
-  vfnii _resize_function;
-  int _frame_number;
-
-  bool _is_synced;
-  bool _window_active;
-
-protected:
-
-  Callback *_draw_callback;
-  Callback *_idle_callback;
-
-PUBLISHED:
-  virtual GraphicsChannel *get_channel(int index);
-  void remove_channel(int index);
 
 
-  int get_max_channel_index() const;
-  bool is_channel_defined(int index) const;
-
-  INLINE int get_num_display_regions() const;
-  INLINE DisplayRegion *get_display_region(int n) const;
+private:
+  INLINE void determine_display_regions() const;
+  void do_determine_display_regions();
 
 
 protected:
 protected:
-  void declare_channel(int index, GraphicsChannel *chan);
+  WindowProperties _properties;
 
 
 private:
 private:
-  INLINE void determine_display_regions() const;
-  void do_determine_display_regions();
+  Mutex _lock; 
+  // protects _channels, _display_regions, and _requested_properties.
 
 
   typedef pvector< PT(GraphicsChannel) > Channels;
   typedef pvector< PT(GraphicsChannel) > Channels;
   Channels _channels;
   Channels _channels;
@@ -266,67 +176,17 @@ private:
   DisplayRegions _display_regions;
   DisplayRegions _display_regions;
   bool _display_regions_stale;
   bool _display_regions_stale;
 
 
-public:
-
-  // factory stuff
-  typedef Factory<GraphicsWindow> WindowFactory;
-  typedef FactoryParam WindowParam;
-
-  // make a factory parameter type for the window properties
-  class EXPCL_PANDA WindowProps : public FactoryParam {
-  public:
-    INLINE WindowProps(void) : WindowParam() {}
-    INLINE WindowProps(const Properties& p) : WindowParam(), _p(p) {}
-    virtual ~WindowProps(void);
-    INLINE Properties get_properties(void) { return _p; }
-  public:
-    static TypeHandle get_class_type(void);
-    static void init_type(void);
-    virtual TypeHandle get_type(void) const;
-    virtual TypeHandle force_init_type(void);
-  private:
-    Properties _p;
-    static TypeHandle _type_handle;
-  };
-  // make a factory parameter type for the GraphicsPipe*
-  class EXPCL_PANDA WindowPipe : public FactoryParam {
-  public:
-    INLINE WindowPipe(GraphicsPipe* p) : WindowParam(), _p(p) {}
-    virtual ~WindowPipe(void);
-    INLINE GraphicsPipe* get_pipe(void) { return _p; }
-  public:
-    static TypeHandle get_class_type(void);
-    static void init_type(void);
-    virtual TypeHandle get_type(void) const;
-    virtual TypeHandle force_init_type(void);
-  private:
-    GraphicsPipe* _p;
-    static TypeHandle _type_handle;
-
-    INLINE WindowPipe(void) : WindowParam() {}
-  };
-
-  static WindowFactory &get_factory();
-
-private:
-
-  static void read_priorities(void);
-
-  GraphicsWindow(const GraphicsWindow&);
-  GraphicsWindow &operator=(const GraphicsWindow&);
-
-  static WindowFactory *_factory;
-
+  WindowProperties _requested_properties;
+  string _window_event;
+  
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {
     return _type_handle;
     return _type_handle;
   }
   }
   static void init_type() {
   static void init_type() {
-    Configurable::init_type();
-    ReferenceCount::init_type();
+    TypedReferenceCount::init_type();
     register_type(_type_handle, "GraphicsWindow",
     register_type(_type_handle, "GraphicsWindow",
-                  Configurable::get_class_type(),
-                  ReferenceCount::get_class_type());
+                  TypedReferenceCount::get_class_type());
   }
   }
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {
     return get_class_type();
     return get_class_type();
@@ -337,6 +197,7 @@ private:
   static TypeHandle _type_handle;
   static TypeHandle _type_handle;
 
 
   friend class GraphicsPipe;
   friend class GraphicsPipe;
+  friend class GraphicsEngine;
 };
 };
 
 
 #include "graphicsWindow.I"
 #include "graphicsWindow.I"

+ 3 - 3
panda/src/display/graphicsWindowInputDevice.cxx

@@ -18,15 +18,15 @@
 
 
 
 
 #include "graphicsWindowInputDevice.h"
 #include "graphicsWindowInputDevice.h"
-#include <mouseButton.h>
-#include <keyboardButton.h>
+#include "mouseButton.h"
+#include "keyboardButton.h"
 
 
 #define EXPCL EXPCL_PANDA
 #define EXPCL EXPCL_PANDA
 #define EXPTP EXPTP_PANDA
 #define EXPTP EXPTP_PANDA
 #define TYPE GraphicsWindowInputDevice
 #define TYPE GraphicsWindowInputDevice
 #define NAME vector_GraphicsWindowInputDevice
 #define NAME vector_GraphicsWindowInputDevice
 
 
-#include <vector_src.cxx>
+#include "vector_src.cxx"
 
 
 // Tell GCC that we'll take care of the instantiation explicitly here.
 // Tell GCC that we'll take care of the instantiation explicitly here.
 #ifdef __GNUC__
 #ifdef __GNUC__

+ 3 - 3
panda/src/display/graphicsWindowInputDevice.h

@@ -19,10 +19,10 @@
 #ifndef GRAPHICSWINDOWINPUTDEVICE_H
 #ifndef GRAPHICSWINDOWINPUTDEVICE_H
 #define GRAPHICSWINDOWINPUTDEVICE_H
 #define GRAPHICSWINDOWINPUTDEVICE_H
 
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 
-#include <buttonEvent.h>
-#include <mouseData.h>
+#include "buttonEvent.h"
+#include "mouseData.h"
 
 
 #include "pdeque.h"
 #include "pdeque.h"
 #include "pvector.h"
 #include "pvector.h"

+ 0 - 73
panda/src/display/interactiveGraphicsPipe.cxx

@@ -1,73 +0,0 @@
-// Filename: interactiveGraphicsPipe.cxx
-// Created by:  cary (10Mar99)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://www.panda3d.org/license.txt .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-
-#include "interactiveGraphicsPipe.h"
-#include "config_display.h"
-
-////////////////////////////////////////////////////////////////////
-// Static variables
-////////////////////////////////////////////////////////////////////
-TypeHandle InteractiveGraphicsPipe::_type_handle;
-
-InteractiveGraphicsPipe::
-InteractiveGraphicsPipe(const PipeSpecifier& spec) :
-  GraphicsPipe(spec) 
-{
-}
-
-
-InteractiveGraphicsPipe::
-~InteractiveGraphicsPipe() {
-}
-
-TypeHandle InteractiveGraphicsPipe::
-get_class_type(void) {
-  return _type_handle;
-}
-
-void InteractiveGraphicsPipe::
-init_type(void) {
-  GraphicsPipe::init_type();
-  register_type(_type_handle, "InteractiveGraphicsPipe",
-                GraphicsPipe::get_class_type());
-}
-
-TypeHandle InteractiveGraphicsPipe::
-get_type(void) const {
-  return get_class_type();
-}
-
-InteractiveGraphicsPipe::
-InteractiveGraphicsPipe(void) {
-  display_cat.error()
-    << "InteractiveGraphicsPipe should not be created with default constructor" << endl;
-}
-
-InteractiveGraphicsPipe::
-InteractiveGraphicsPipe(const InteractiveGraphicsPipe&) {
-  display_cat.error()
-    << "InteractiveGraphicsPipes should not be copied" << endl;
-}
-
-InteractiveGraphicsPipe &InteractiveGraphicsPipe::
-operator=(const InteractiveGraphicsPipe&) {
-  display_cat.error()
-  << "InteractiveGraphicsPipes should not be assigned" << endl;
-  return *this;
-}

+ 0 - 51
panda/src/display/interactiveGraphicsPipe.h

@@ -1,51 +0,0 @@
-// Filename: interactiveGraphicsPipe.h
-// Created by:  cary (10Mar99)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://www.panda3d.org/license.txt .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-#ifndef __INTERACTIVEGRAPHICSPIPE_H__
-#define __INTERACTIVEGRAPHICSPIPE_H__
-
-#include <pandabase.h>
-
-#include "graphicsPipe.h"
-
-class EXPCL_PANDA InteractiveGraphicsPipe : public GraphicsPipe {
-PUBLISHED:
-  InteractiveGraphicsPipe( const PipeSpecifier& );
-  virtual ~InteractiveGraphicsPipe(void);
-
-public:
-
-  static TypeHandle get_class_type(void);
-  static void init_type(void);
-  virtual TypeHandle get_type(void) const;
-  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
-
-  static TypeHandle _type_handle;
-
-protected:
-
-  InteractiveGraphicsPipe(void);
-  InteractiveGraphicsPipe(const InteractiveGraphicsPipe&);
-  InteractiveGraphicsPipe& operator=(const InteractiveGraphicsPipe&);
-};
-
-#include "interactiveGraphicsPipe.I"
-
-#endif /* __INTERACTIVEGRAPHICSPIPE_H__ */

+ 0 - 61
panda/src/display/noninteractiveGraphicsPipe.cxx

@@ -1,61 +0,0 @@
-// Filename: noninteractiveGraphicsPipe.cxx
-// Created by:  cary (10Mar99)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://www.panda3d.org/license.txt .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-
-#include "noninteractiveGraphicsPipe.h"
-#include "config_display.h"
-
-////////////////////////////////////////////////////////////////////
-// Static variables
-////////////////////////////////////////////////////////////////////
-TypeHandle NoninteractiveGraphicsPipe::_type_handle;
-
-NoninteractiveGraphicsPipe::NoninteractiveGraphicsPipe(const PipeSpecifier& spec)
-  : GraphicsPipe(spec) {}
-
-NoninteractiveGraphicsPipe::~NoninteractiveGraphicsPipe(void) {}
-
-NoninteractiveGraphicsPipe::NoninteractiveGraphicsPipe(void) {
-  display_cat.error()
-    << "NoninteractiveGraphicsPipe should not be created with default constructor" << endl;
-}
-
-NoninteractiveGraphicsPipe::NoninteractiveGraphicsPipe(const NoninteractiveGraphicsPipe&) {
-  display_cat.error()
-    << "NoninteractiveGraphicsPipes should not be copied" << endl;
-}
-
-NoninteractiveGraphicsPipe& NoninteractiveGraphicsPipe::operator=(const NoninteractiveGraphicsPipe&) {
-  display_cat.error()
-  << "NoninteractiveGraphicsPipes should not be assigned" << endl;
-  return *this;
-}
-
-TypeHandle NoninteractiveGraphicsPipe::get_class_type(void) {
-  return _type_handle;
-}
-
-void NoninteractiveGraphicsPipe::init_type(void) {
-  GraphicsPipe::init_type();
-  register_type(_type_handle, "NoninteractiveGraphicsPipe",
-                GraphicsPipe::get_class_type());
-}
-
-TypeHandle NoninteractiveGraphicsPipe::get_type(void) const {
-  return get_class_type();
-}

+ 0 - 52
panda/src/display/noninteractiveGraphicsPipe.h

@@ -1,52 +0,0 @@
-// Filename: noninteractiveGraphicsPipe.h
-// Created by:  cary (10Mar99)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://www.panda3d.org/license.txt .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-#ifndef __NONINTERACTIVEGRAPHICSPIPE_H__
-#define __NONINTERACTIVEGRAPHICSPIPE_H__
-
-#include <pandabase.h>
-
-#include "graphicsPipe.h"
-
-class EXPCL_PANDA NoninteractiveGraphicsPipe : public GraphicsPipe {
-public:
-
-  NoninteractiveGraphicsPipe( const PipeSpecifier& );
-  virtual ~NoninteractiveGraphicsPipe(void) = 0;
-
-public:
-
-  static TypeHandle get_class_type(void);
-  static void init_type(void);
-  virtual TypeHandle get_type(void) const;
-  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
-
-  static TypeHandle _type_handle;
-
-protected:
-
-  NoninteractiveGraphicsPipe(void);
-  NoninteractiveGraphicsPipe(const NoninteractiveGraphicsPipe&);
-  NoninteractiveGraphicsPipe& operator=(const NoninteractiveGraphicsPipe&);
-};
-
-#include "noninteractiveGraphicsPipe.I"
-
-#endif /* __NONINTERACTIVEGRAPHICSPIPE_H__ */

+ 0 - 78
panda/src/display/pipeSpec.I

@@ -1,78 +0,0 @@
-// Filename: pipeSpec.I
-// Created by:  frang (07Mar99)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://www.panda3d.org/license.txt .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-INLINE void PipeSpecifier::set_name(const std::string& name) {
-  _name = name;
-}
-
-INLINE std::string PipeSpecifier::get_name(void) const {
-  return _name;
-}
-
-INLINE void PipeSpecifier::unset_machine(void) {
-  if (!_is_file) {
-    _is_file = true;
-    _machine = "";
-    _is_remote = false;
-  }
-}
-
-INLINE void PipeSpecifier::unset_file(void) {
-  if (_is_file) {
-    _is_file = false;
-    _filename = "";
-  }
-}
-
-INLINE void PipeSpecifier::set_machine_name(const std::string& name) {
-  _machine = name;
-  if (_machine.empty())
-    _is_remote = false;
-  else
-    _is_remote = true;
-  unset_file();
-}
-
-INLINE std::string PipeSpecifier::get_machine_name(void) const {
-  return _machine;
-}
-
-INLINE void PipeSpecifier::set_file_name(const std::string& name) {
-  _filename = name;
-  unset_machine();
-}
-
-INLINE std::string PipeSpecifier::get_file_name(void) const {
-  return _filename;
-}
-
-INLINE void PipeSpecifier::set_pipe_number(const int p) {
-  _pipe_number = p;
-}
-
-INLINE int PipeSpecifier::get_pipe_number(void) const {
-  return _pipe_number;
-}
-
-INLINE bool PipeSpecifier::is_file(void) const {
-  return _is_file;
-}
-
-INLINE bool PipeSpecifier::is_remote(void) const {
-  return _is_remote;
-}

+ 0 - 55
panda/src/display/pipeSpec.cxx

@@ -1,55 +0,0 @@
-// Filename: pipeSpec.cxx
-// Created by:  frang (07Mar99)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://www.panda3d.org/license.txt .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-
-#include "config_display.h"
-
-#include "pipeSpec.h"
-
-PipeSpecifier::PipeSpecifier(void)
-  : _machine(pipe_spec_machine),
-    _filename(pipe_spec_filename),
-    _pipe_number(pipe_spec_pipe_number),
-    _is_file(pipe_spec_is_file),
-    _is_remote(pipe_spec_is_remote) {}
-
-PipeSpecifier::PipeSpecifier(const PipeSpecifier& c)
-  : _name(c._name), _machine(c._machine), _filename(c._filename),
-    _pipe_number(c._pipe_number), _is_file(c._is_file),
-    _is_remote(c._is_remote) {}
-
-PipeSpecifier::~PipeSpecifier(void) {}
-
-std::string PipeSpecifier::get_X_specifier(void) const {
-  std::string ret;
-
-  if (!_is_file) {
-    if (_machine.empty()) {
-      if (getenv("DISPLAY")) {
-        ret = getenv("DISPLAY");
-      }
-    }
-
-    if (ret.empty()) {
-      ostringstream ss;
-      ss << _machine << ":" << ((_pipe_number<0)?0:_pipe_number) << ".0";
-      ret = ss.str();
-    }
-  }
-  return ret;
-}

+ 0 - 60
panda/src/display/pipeSpec.h

@@ -1,60 +0,0 @@
-// Filename: pipeSpec.h
-// Created by:  frang (07Mar99)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://www.panda3d.org/license.txt .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-#ifndef __PIPESPEC_H__
-#define __PIPESPEC_H__
-
-#include <pandabase.h>
-
-#include <string>
-
-class EXPCL_PANDA PipeSpecifier {
-PUBLISHED:
-  PipeSpecifier(void);
-  PipeSpecifier(const PipeSpecifier&);
-  ~PipeSpecifier(void);
-
-  INLINE void set_name(const std::string&);
-  INLINE std::string get_name(void) const;
-  INLINE void set_machine_name(const std::string&);
-  INLINE std::string get_machine_name(void) const;
-  INLINE void set_file_name(const std::string&);
-  INLINE std::string get_file_name(void) const;
-  INLINE void set_pipe_number(const int);
-  INLINE int get_pipe_number(void) const;
-
-  INLINE bool is_file(void) const;
-  INLINE bool is_remote(void) const;
-
-  std::string get_X_specifier(void) const;
-
-private:
-  std::string _name;
-  std::string _machine;
-  std::string _filename;
-  int         _pipe_number;
-  bool        _is_file;
-  bool        _is_remote;
-
-  INLINE void unset_machine(void);
-  INLINE void unset_file(void);
-};
-
-#include "pipeSpec.I"
-
-#endif /* __PIPESPEC_H__ */

+ 1 - 0
panda/src/display/renderBuffer.h

@@ -19,6 +19,7 @@
 #ifndef RENDERBUFFER_H
 #ifndef RENDERBUFFER_H
 #define RENDERBUFFER_H
 #define RENDERBUFFER_H
 
 
+#include "pandabase.h"
 
 
 class GraphicsStateGuardian;
 class GraphicsStateGuardian;
 
 

+ 664 - 0
panda/src/display/windowProperties.I

@@ -0,0 +1,664 @@
+// Filename: windowProperties.I
+// Created by:  drose (13Aug02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::Copy Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE WindowProperties::
+WindowProperties(const WindowProperties &copy) {
+  (*this) = copy;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE WindowProperties::
+~WindowProperties() {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::operator !=
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+operator != (const WindowProperties &other) const {
+  return !operator == (other);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::is_any_specified
+//       Access: Published
+//  Description: Returns true if any properties have been specified,
+//               false otherwise.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+is_any_specified() const {
+  return (_specified != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_origin
+//       Access: Published
+//  Description: Specifies the origin on the screen (in pixels,
+//               relative to the top-left corner) at which the window
+//               should appear.  This is the origin of the top-left
+//               corner of the useful part of the window, not
+//               including decorations.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_origin(int x_origin, int y_origin) {
+  _x_origin = x_origin;
+  _y_origin = y_origin;
+  _specified |= S_origin;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_x_origin
+//       Access: Published
+//  Description: Returns the x coordinate of the window's top-left
+//               corner, not including decorations.
+////////////////////////////////////////////////////////////////////
+INLINE int WindowProperties::
+get_x_origin() const {
+  nassertr(has_origin(), 0);
+  return _x_origin;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_y_origin
+//       Access: Published
+//  Description: Returns the y coordinate of the window's top-left
+//               corner, not including decorations.
+////////////////////////////////////////////////////////////////////
+INLINE int WindowProperties::
+get_y_origin() const {
+  nassertr(has_origin(), 0);
+  return _y_origin;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_origin
+//       Access: Published
+//  Description: Returns true if the window origin has been specified,
+//               false otherwise.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_origin() const {
+  return ((_specified & S_origin) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_origin
+//       Access: Published
+//  Description: Removes the origin specification from the properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_origin() {
+  _specified &= ~S_origin;
+  _x_origin = 0;
+  _y_origin = 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_size
+//       Access: Published
+//  Description: Specifies the requested size of the window, in
+//               pixels.  This is the size of the useful part of the
+//               window, not including decorations.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_size(int x_size, int y_size) {
+  _x_size = x_size;
+  _y_size = y_size;
+  _specified |= S_size;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_x_size
+//       Access: Published
+//  Description: Returns size in pixels in the x dimension of the
+//               useful part of the window, not including decorations.
+//               That is, this is the window's width.
+////////////////////////////////////////////////////////////////////
+INLINE int WindowProperties::
+get_x_size() const {
+  nassertr(has_size(), 0);
+  return _x_size;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_y_size
+//       Access: Published
+//  Description: Returns size in pixels in the y dimension of the
+//               useful part of the window, not including decorations.
+//               That is, this is the window's height.
+////////////////////////////////////////////////////////////////////
+INLINE int WindowProperties::
+get_y_size() const {
+  nassertr(has_size(), 0);
+  return _y_size;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_size
+//       Access: Published
+//  Description: Returns true if the window size has been specified,
+//               false otherwise.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_size() const {
+  return ((_specified & S_size) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_size
+//       Access: Published
+//  Description: Removes the size specification from the properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_size() {
+  _specified &= ~S_size;
+  _x_size = 0;
+  _y_size = 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_title
+//       Access: Published
+//  Description: Specifies the title that should be assigned to the
+//               window.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_title(const string &title) {
+  _title = title;
+  _specified |= S_title;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_title
+//       Access: Published
+//  Description: Returns the window's title.
+////////////////////////////////////////////////////////////////////
+INLINE const string &WindowProperties::
+get_title() const {
+  nassertr(has_title(), _title);
+  return _title;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_title
+//       Access: Published
+//  Description: Returns true if the window title has been specified,
+//               false otherwise.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_title() const {
+  return ((_specified & S_title) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_title
+//       Access: Published
+//  Description: Removes the title specification from the properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_title() {
+  _specified &= ~S_title;
+  _title = string();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_undecorated
+//       Access: Published
+//  Description: Specifies whether the window should be created with a
+//               visible title and border (false, the default) or not
+//               (true).
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_undecorated(bool undecorated) {
+  if (undecorated) {
+    _flags |= F_undecorated;
+  } else {
+    _flags &= ~F_undecorated;
+  }
+  _specified |= S_undecorated;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_undecorated
+//       Access: Published
+//  Description: Returns true if the window has no border.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+get_undecorated() const {
+  return (_flags & F_undecorated) != 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_undecorated
+//       Access: Published
+//  Description: Returns true if set_undecorated() has been specified.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_undecorated() const {
+  return ((_specified & S_undecorated) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_undecorated
+//       Access: Published
+//  Description: Removes the undecorated specification from the properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_undecorated() {
+  _specified &= ~S_undecorated;
+  _flags &= ~F_undecorated;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_fullscreen
+//       Access: Published
+//  Description: Specifies whether the window should be opened in
+//               fullscreen mode (true) or normal windowed mode
+//               (false, the default).
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_fullscreen(bool fullscreen) {
+  if (fullscreen) {
+    _flags |= F_fullscreen;
+  } else {
+    _flags &= ~F_fullscreen;
+  }
+  _specified |= S_fullscreen;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_fullscreen
+//       Access: Published
+//  Description: Returns true if the window is in fullscreen mode.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+get_fullscreen() const {
+  return (_flags & F_fullscreen) != 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_fullscreen
+//       Access: Published
+//  Description: Returns true if set_fullscreen() has been specified.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_fullscreen() const {
+  return ((_specified & S_fullscreen) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_fullscreen
+//       Access: Published
+//  Description: Removes the fullscreen specification from the properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_fullscreen() {
+  _specified &= ~S_fullscreen;
+  _flags &= ~F_fullscreen;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_foreground
+//       Access: Published
+//  Description: Specifies whether the window should be opened in
+//               the foreground (true), or left in the background
+//               (false).
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_foreground(bool foreground) {
+  if (foreground) {
+    _flags |= F_foreground;
+  } else {
+    _flags &= ~F_foreground;
+  }
+  _specified |= S_foreground;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_foreground
+//       Access: Published
+//  Description: Returns true if the window is in the foreground.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+get_foreground() const {
+  return (_flags & F_foreground) != 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_foreground
+//       Access: Published
+//  Description: Returns true if set_foreground() has been specified.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_foreground() const {
+  return ((_specified & S_foreground) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_foreground
+//       Access: Published
+//  Description: Removes the foreground specification from the properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_foreground() {
+  _specified &= ~S_foreground;
+  _flags &= ~F_foreground;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_minimized
+//       Access: Published
+//  Description: Specifies whether the window should be created
+//               minimized (true), or normal (false).
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_minimized(bool minimized) {
+  if (minimized) {
+    _flags |= F_minimized;
+  } else {
+    _flags &= ~F_minimized;
+  }
+  _specified |= S_minimized;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_minimized
+//       Access: Published
+//  Description: Returns true if the window is minimized.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+get_minimized() const {
+  return (_flags & F_minimized) != 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_minimized
+//       Access: Published
+//  Description: Returns true if set_minimized() has been specified.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_minimized() const {
+  return ((_specified & S_minimized) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_minimized
+//       Access: Published
+//  Description: Removes the minimized specification from the properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_minimized() {
+  _specified &= ~S_minimized;
+  _flags &= ~F_minimized;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_open
+//       Access: Published
+//  Description: Specifies whether the window should be open.  It is
+//               legal to create a GraphicsWindow in the closed state,
+//               and later request it to open by changing this flag.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_open(bool open) {
+  if (open) {
+    _flags |= F_open;
+  } else {
+    _flags &= ~F_open;
+  }
+  _specified |= S_open;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_open
+//       Access: Published
+//  Description: Returns true if the window is open.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+get_open() const {
+  return (_flags & F_open) != 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_open
+//       Access: Published
+//  Description: Returns true if set_open() has been specified.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_open() const {
+  return ((_specified & S_open) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_open
+//       Access: Published
+//  Description: Removes the open specification from the properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_open() {
+  _specified &= ~S_open;
+  _flags &= ~F_open;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_cursor_hidden
+//       Access: Published
+//  Description: Specifies whether the mouse cursor should be visible.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_cursor_hidden(bool cursor_hidden) {
+  if (cursor_hidden) {
+    _flags |= F_cursor_hidden;
+  } else {
+    _flags &= ~F_cursor_hidden;
+  }
+  _specified |= S_cursor_hidden;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_cursor_hidden
+//       Access: Published
+//  Description: Returns true if the mouse cursor is invisible.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+get_cursor_hidden() const {
+  return (_flags & F_cursor_hidden) != 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_cursor_hidden
+//       Access: Published
+//  Description: Returns true if set_cursor_hidden() has been specified.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_cursor_hidden() const {
+  return ((_specified & S_cursor_hidden) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_cursor_hidden
+//       Access: Published
+//  Description: Removes the cursor_hidden specification from the properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_cursor_hidden() {
+  _specified &= ~S_cursor_hidden;
+  _flags &= ~F_cursor_hidden;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_framebuffer_mode
+//       Access: Published
+//  Description: Specifies the set of graphics properties that are
+//               required for the context associated with the window.
+//               This should be the union of the appropriate bits
+//               defined in FramebufferMode.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_framebuffer_mode(int framebuffer_mode) {
+  _framebuffer_mode = framebuffer_mode;
+  _specified |= S_framebuffer_mode;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_framebuffer_mode
+//       Access: Published
+//  Description: Returns the set of graphics properties that are
+//               in effect for the window.  This will be the union of
+//               the corresponding bits from FramebufferMode.
+////////////////////////////////////////////////////////////////////
+INLINE int WindowProperties::
+get_framebuffer_mode() const {
+  nassertr(has_framebuffer_mode(), false);
+  return _framebuffer_mode;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_framebuffer_mode
+//       Access: Published
+//  Description: Returns true if the framebuffer mode has been
+//               specified, false otherwise.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_framebuffer_mode() const {
+  return ((_specified & S_framebuffer_mode) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_framebuffer_mode
+//       Access: Published
+//  Description: Removes the framebuffer_mode specification from the
+//               properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_framebuffer_mode() {
+  _specified &= ~S_framebuffer_mode;
+  _framebuffer_mode = 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_depth_bits
+//       Access: Published
+//  Description: Specifies the minimum number of bits that are
+//               required for the depth buffer.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_depth_bits(int depth_bits) {
+  _depth_bits = depth_bits;
+  _specified |= S_depth_bits;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_depth_bits
+//       Access: Published
+//  Description: Returns the number of bits specified for the depth
+//               buffer.
+////////////////////////////////////////////////////////////////////
+INLINE int WindowProperties::
+get_depth_bits() const {
+  return _depth_bits;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_depth_bits
+//       Access: Published
+//  Description: Returns true if the number of bits for the depth
+//               buffer has been specified, false otherwise.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_depth_bits() const {
+  return ((_specified & S_depth_bits) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_depth_bits
+//       Access: Published
+//  Description: Removes the depth_bits specification from the
+//               properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_depth_bits() {
+  _specified &= ~S_depth_bits;
+  _depth_bits = 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::set_color_bits
+//       Access: Published
+//  Description: Specifies the minimum number of bits that are
+//               required for all three channels of the color buffer.
+//               That is, this is the per-channel color requirement
+//               times three.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+set_color_bits(int color_bits) {
+  _color_bits = color_bits;
+  _specified |= S_color_bits;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::get_color_bits
+//       Access: Published
+//  Description: Returns the number of bits specified for the color
+//               buffer.
+////////////////////////////////////////////////////////////////////
+INLINE int WindowProperties::
+get_color_bits() const {
+  return _color_bits;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::has_color_bits
+//       Access: Published
+//  Description: Returns true if the number of bits for the color
+//               buffer has been specified, false otherwise.
+////////////////////////////////////////////////////////////////////
+INLINE bool WindowProperties::
+has_color_bits() const {
+  return ((_specified & S_color_bits) != 0);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear_color_bits
+//       Access: Published
+//  Description: Removes the color_bits specification from the
+//               properties.
+////////////////////////////////////////////////////////////////////
+INLINE void WindowProperties::
+clear_color_bits() {
+  _specified &= ~S_color_bits;
+  _color_bits = 0;
+}
+
+INLINE ostream &
+operator << (ostream &out, const WindowProperties &properties) {
+  properties.output(out);
+  return out;
+}

+ 220 - 0
panda/src/display/windowProperties.cxx

@@ -0,0 +1,220 @@
+// Filename: windowProperties.cxx
+// Created by:  drose (13Aug02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "windowProperties.h"
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::Constructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+WindowProperties::
+WindowProperties() {
+  clear();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::Copy Assignment Operator
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+void WindowProperties::
+operator = (const WindowProperties &copy) {
+  _specified = copy._specified;
+  _x_origin = copy._x_origin;
+  _y_origin = copy._y_origin;
+  _x_size = copy._x_size;
+  _y_size = copy._y_size;
+  _title = copy._title;
+  _flags = copy._flags;
+  _framebuffer_mode = copy._framebuffer_mode;
+  _depth_bits = copy._depth_bits;
+  _color_bits = copy._color_bits;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::operator == 
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+bool WindowProperties::
+operator == (const WindowProperties &other) const {
+  return (_specified == other._specified &&
+          _flags == other._flags &&
+          _x_origin == other._x_origin &&
+          _y_origin == other._y_origin &&
+          _x_size == other._x_size &&
+          _y_size == other._y_size &&
+          _title == other._title &&
+          _framebuffer_mode == other._framebuffer_mode &&
+          _depth_bits == other._depth_bits &&
+          _color_bits == other._color_bits);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::clear
+//       Access: Published
+//  Description: Unsets all properties that have been specified so
+//               far, and resets the WindowProperties structure to its
+//               initial empty state.
+////////////////////////////////////////////////////////////////////
+void WindowProperties::
+clear() {
+  _specified = 0;
+  _x_origin = 0;
+  _y_origin = 0;
+  _x_size = 0;
+  _y_size = 0;
+  _title = string();
+  _flags = 0;
+  _framebuffer_mode = 0;
+  _depth_bits = 0;
+  _color_bits = 0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::add_properties
+//       Access: Published
+//  Description: Sets any properties that are explicitly specified in
+//               other on this object.  Leaves other properties
+//               unchanged.
+////////////////////////////////////////////////////////////////////
+void WindowProperties::
+add_properties(const WindowProperties &other) {
+  if (other.has_origin()) {
+    set_origin(other.get_x_origin(), other.get_y_origin());
+  }
+  if (other.has_size()) {
+    set_size(other.get_x_size(), other.get_y_size());
+  }
+  if (other.has_title()) {
+    set_title(other.get_title());
+  }
+  if (other.has_undecorated()) {
+    set_undecorated(other.get_undecorated());
+  }
+  if (other.has_fullscreen()) {
+    set_fullscreen(other.get_fullscreen());
+  }
+  if (other.has_foreground()) {
+    set_foreground(other.get_foreground());
+  }
+  if (other.has_minimized()) {
+    set_minimized(other.get_minimized());
+  }
+  if (other.has_open()) {
+    set_open(other.get_open());
+  }
+  if (other.has_cursor_hidden()) {
+    set_cursor_hidden(other.get_cursor_hidden());
+  }
+  if (other.has_framebuffer_mode()) {
+    set_framebuffer_mode(other.get_framebuffer_mode());
+  }
+  if (other.has_depth_bits()) {
+    set_depth_bits(other.get_depth_bits());
+  }
+  if (other.has_color_bits()) {
+    set_color_bits(other.get_color_bits());
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: WindowProperties::output
+//       Access: Published
+//  Description: Sets any properties that are explicitly specified in
+//               other on this object.  Leaves other properties
+//               unchanged.
+////////////////////////////////////////////////////////////////////
+void WindowProperties::
+output(ostream &out) const {
+  if (has_origin()) {
+    out << "origin=(" << get_x_origin() << ", " << get_y_origin() << ") ";
+  }
+  if (has_size()) {
+    out << "size=(" << get_x_size() << ", " << get_y_size() << ") ";
+  }
+  if (has_title()) {
+    out << "title=\"" << get_title() << "\"" << " ";
+  }
+  if (has_undecorated()) {
+    out << (get_undecorated() ? "undecorated " : "!undecorated ");
+  }
+  if (has_fullscreen()) {
+    out << (get_fullscreen() ? "fullscreen " : "!fullscreen ");
+  }
+  if (has_foreground()) {
+    out << (get_foreground() ? "foreground " : "!foreground ");
+  }
+  if (has_minimized()) {
+    out << (get_minimized() ? "minimized " : "!minimized ");
+  }
+  if (has_open()) {
+    out << (get_open() ? "open " : "!open ");
+  }
+  if (has_cursor_hidden()) {
+    out << (get_cursor_hidden() ? "cursor_hidden " : "!cursor_hidden ");
+  }
+  if (has_framebuffer_mode()) {
+    out << "framebuffer_mode=";
+    int framebuffer_mode = get_framebuffer_mode();
+    if ((framebuffer_mode & FM_index) != 0) {
+      out << "FM_index";
+    } else {
+      out << "FM_rgb";
+    }
+
+    if ((framebuffer_mode & FM_triple_buffer) != 0) {
+      out << "|FM_triple_buffer";
+    } else if ((framebuffer_mode & FM_double_buffer) != 0) {
+      out << "|FM_double_buffer";
+    } else {
+      out << "|FM_single_buffer";
+    }
+
+    if ((framebuffer_mode & FM_accum) != 0) {
+      out << "|FM_accum";
+    }
+    if ((framebuffer_mode & FM_alpha) != 0) {
+      out << "|FM_alpha";
+    }
+    if ((framebuffer_mode & FM_depth) != 0) {
+      out << "|FM_depth";
+    }
+    if ((framebuffer_mode & FM_stencil) != 0) {
+      out << "|FM_stencil";
+    }
+    if ((framebuffer_mode & FM_multisample) != 0) {
+      out << "|FM_multisample";
+    }
+    if ((framebuffer_mode & FM_stereo) != 0) {
+      out << "|FM_stereo";
+    }
+    if ((framebuffer_mode & FM_luminance) != 0) {
+      out << "|FM_luminance";
+    }
+    out << " ";
+  }
+  if (has_depth_bits()) {
+    out << "depth_bits=" << get_depth_bits() << " ";
+  }
+  if (has_color_bits()) {
+    out << "color_bits=" << get_color_bits() << " ";
+  }
+}

+ 173 - 0
panda/src/display/windowProperties.h

@@ -0,0 +1,173 @@
+// Filename: windowProperties.h
+// Created by:  drose (13Aug02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef WINDOWPROPERTIES_H
+#define WINDOWPROPERTIES_H
+
+#include "pandabase.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : WindowProperties
+// Description : A container for the various kinds of properties we
+//               might ask to have on a graphics window before we open
+//               it.  This also serves to hold the current properties
+//               for a window after it has been opened.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDA WindowProperties {
+PUBLISHED:
+  WindowProperties();
+  INLINE WindowProperties(const WindowProperties &copy);
+  void operator = (const WindowProperties &copy);
+  INLINE ~WindowProperties();
+
+  bool operator == (const WindowProperties &other) const;
+  INLINE bool operator != (const WindowProperties &other) const;
+
+  enum FramebufferMode {
+    FM_rgba =          0x0000,
+    FM_rgb =           0x0000,
+    FM_index =         0x0001,
+    FM_single_buffer = 0x0000,
+    FM_double_buffer = 0x0002,
+    FM_triple_buffer = 0x0004,
+    FM_accum =         0x0008,
+    FM_alpha =         0x0010,
+    FM_depth =         0x0020,
+    FM_stencil =       0x0040,
+    FM_multisample =   0x0080,
+    FM_stereo =        0x0100,
+    FM_luminance =     0x0200,
+  };
+
+  void clear();
+  INLINE bool is_any_specified() const;
+  
+  INLINE void set_origin(int x_origin, int y_origin);
+  INLINE int get_x_origin() const;
+  INLINE int get_y_origin() const;
+  INLINE bool has_origin() const;
+  INLINE void clear_origin();
+
+  INLINE void set_size(int x_size, int y_size);
+  INLINE int get_x_size() const;
+  INLINE int get_y_size() const;
+  INLINE bool has_size() const;
+  INLINE void clear_size();
+
+  INLINE void set_title(const string &title);
+  INLINE const string &get_title() const;
+  INLINE bool has_title() const;
+  INLINE void clear_title();
+
+  INLINE void set_undecorated(bool undecorated);
+  INLINE bool get_undecorated() const;
+  INLINE bool has_undecorated() const;
+  INLINE void clear_undecorated();
+
+  INLINE void set_fullscreen(bool fullscreen);
+  INLINE bool get_fullscreen() const;
+  INLINE bool has_fullscreen() const;
+  INLINE void clear_fullscreen();
+
+  INLINE void set_foreground(bool foreground);
+  INLINE bool get_foreground() const;
+  INLINE bool has_foreground() const;
+  INLINE void clear_foreground();
+
+  INLINE void set_minimized(bool minimized);
+  INLINE bool get_minimized() const;
+  INLINE bool has_minimized() const;
+  INLINE void clear_minimized();
+
+  INLINE void set_open(bool open);
+  INLINE bool get_open() const;
+  INLINE bool has_open() const;
+  INLINE void clear_open();
+
+  INLINE void set_cursor_hidden(bool cursor_hidden);
+  INLINE bool get_cursor_hidden() const;
+  INLINE bool has_cursor_hidden() const;
+  INLINE void clear_cursor_hidden();
+
+  INLINE void set_framebuffer_mode(int framebuffer_mode);
+  INLINE int get_framebuffer_mode() const;
+  INLINE bool has_framebuffer_mode() const;
+  INLINE void clear_framebuffer_mode();
+
+  INLINE void set_depth_bits(int depth_bits);
+  INLINE int get_depth_bits() const;
+  INLINE bool has_depth_bits() const;
+  INLINE void clear_depth_bits();
+
+  INLINE void set_color_bits(int color_bits);
+  INLINE int get_color_bits() const;
+  INLINE bool has_color_bits() const;
+  INLINE void clear_color_bits();
+
+  void add_properties(const WindowProperties &other);
+
+  void output(ostream &out) const;
+  
+private:
+  // This bitmask indicates which of the parameters in the properties
+  // structure have been filled in by the user, and which remain
+  // unspecified.
+  enum Specified {
+    S_origin           = 0x0001,
+    S_size             = 0x0002,
+    S_title            = 0x0004,
+    S_undecorated      = 0x0008,
+    S_fullscreen       = 0x0010,
+    S_foreground       = 0x0020,
+    S_minimized        = 0x0040,
+    S_open             = 0x0080,
+    S_cursor_hidden    = 0x0100,
+    S_framebuffer_mode = 0x0200,
+    S_depth_bits       = 0x0400,
+    S_color_bits       = 0x0800,
+  };
+
+  // This bitmask represents the true/false settings for various
+  // boolean flags (assuming the corresponding S_* bit has been set,
+  // above).
+  enum Flags {
+    F_undecorated    = S_undecorated,
+    F_fullscreen     = S_fullscreen,
+    F_foreground     = S_foreground,
+    F_minimized      = S_minimized,
+    F_open           = S_open,
+    F_cursor_hidden  = S_cursor_hidden,
+  };
+
+  int _specified;
+  int _x_origin;
+  int _y_origin;
+  int _x_size;
+  int _y_size;
+  string _title;
+  int _flags;
+  int _framebuffer_mode;
+  int _depth_bits;
+  int _color_bits;
+};
+
+INLINE ostream &operator << (ostream &out, const WindowProperties &properties);
+
+#include "windowProperties.I"
+
+#endif

+ 1 - 1
panda/src/distort/nonlinearImager.cxx

@@ -601,7 +601,7 @@ render_screen(GraphicsEngine *engine, NonlinearImager::Screen &screen) {
   PT(DisplayRegion) scratch_region =
   PT(DisplayRegion) scratch_region =
     _gsg->get_window()->make_scratch_display_region(screen._tex_width, screen._tex_height);
     _gsg->get_window()->make_scratch_display_region(screen._tex_width, screen._tex_height);
   scratch_region->set_camera(screen._source_camera);
   scratch_region->set_camera(screen._source_camera);
-  engine->render_subframe(_gsg, scratch_region);
+  engine->render_subframe(_gsg, scratch_region, true);
 
 
   // Copy the results of the render from the frame buffer into the
   // Copy the results of the render from the frame buffer into the
   // screen's texture.
   // screen's texture.

+ 0 - 29
panda/src/dxgsg/Sources.pp

@@ -1,29 +0,0 @@
-#define BUILD_DIRECTORY $[HAVE_DX]
-
-#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
-                   dtoolutil:c dtoolbase:c dtool:m
-#define USE_PACKAGES dx
-
-#begin lib_target
-
-  #define TARGET dxgsg
-  #define LOCAL_LIBS \
-    gsgmisc gsgbase gobj display \
-    putil linmath mathutil pnmimage event
-    
-  #define COMBINED_SOURCES $[TARGET]_composite1.cxx     
-
-  // need to install these due to external projects that link directly with libpandadx (bartop)  
-  #define INSTALL_HEADERS \
-    config_dxgsg.h dxGraphicsStateGuardian.I dxGraphicsStateGuardian.h \
-    dxTextureContext.h dxGeomNodeContext.h dxGeomNodeContext.I dxgsgbase.h
-
-  // build dxGraphicsStateGuardian separately since its so big
-  
-  #define SOURCES \
-    dxGraphicsStateGuardian.cxx dxSavedFrameBuffer.I dxSavedFrameBuffer.h $[INSTALL_HEADERS]
-    
-  #define INCLUDED_SOURCES \
-    config_dxgsg.cxx dxSavedFrameBuffer.cxx dxTextureContext.cxx dxGeomNodeContext.cxx
-
-#end lib_target

+ 0 - 4
panda/src/dxgsg/dxgsg_composite1.cxx

@@ -1,4 +0,0 @@
-#include "config_dxgsg.cxx"
-#include "dxSavedFrameBuffer.cxx"
-#include "dxTextureContext.cxx"
-#include "dxGeomNodeContext.cxx"

+ 36 - 0
panda/src/dxgsg7/Sources.pp

@@ -0,0 +1,36 @@
+#define BUILD_DIRECTORY $[HAVE_DX]
+
+#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \
+                   dtoolutil:c dtoolbase:c dtool:m
+#define USE_PACKAGES dx
+
+#begin lib_target
+
+  #define TARGET dxgsg7
+  #define LOCAL_LIBS \
+    gsgmisc gsgbase gobj display windisplay \
+    putil linmath mathutil pnmimage event
+    
+  #define COMBINED_SOURCES $[TARGET]_composite1.cxx     
+
+  // need to install these due to external projects that link directly with libpandadx (bartop)  
+  #define INSTALL_HEADERS \
+    config_dxgsg7.h dxGraphicsStateGuardian7.I dxGraphicsStateGuardian7.h \
+    dxTextureContext7.h dxGeomNodeContext7.h dxGeomNodeContext7.I dxgsg7base.h
+
+  // build dxGraphicsStateGuardian separately since its so big
+  
+  #define SOURCES \
+    dxGraphicsStateGuardian7.cxx dxSavedFrameBuffer7.I dxSavedFrameBuffer7.h \
+    wdxGraphicsPipe7.I wdxGraphicsPipe7.h \
+    wdxGraphicsWindow7.I wdxGraphicsWindow7.h \
+    $[INSTALL_HEADERS]
+    
+  #define INCLUDED_SOURCES \
+    config_dxgsg7.cxx \
+    dxgsg7base.cxx \
+    dxSavedFrameBuffer7.cxx dxTextureContext7.cxx \
+    dxGeomNodeContext7.cxx \
+    wdxGraphicsPipe7.cxx wdxGraphicsWindow7.cxx
+
+#end lib_target

+ 51 - 44
panda/src/dxgsg/config_dxgsg.cxx → panda/src/dxgsg7/config_dxgsg7.cxx

@@ -16,41 +16,45 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#include "config_dxgsg.h"
-#include "dxGraphicsStateGuardian.h"
-#include "dxSavedFrameBuffer.h"
-#include "dxTextureContext.h"
+#include "config_dxgsg7.h"
+#include "dxGraphicsStateGuardian7.h"
+#include "dxSavedFrameBuffer7.h"
+#include "dxTextureContext7.h"
+#include "wdxGraphicsPipe7.h"
+#include "wdxGraphicsWindow7.h"
+#include "graphicsPipeSelection.h"
 
 
-#include <dconfig.h>
+#include "dconfig.h"
 
 
-Configure(config_dxgsg);
-NotifyCategoryDef(dxgsg, ":display:gsg");
+Configure(config_dxgsg7);
+NotifyCategoryDef(dxgsg7, ":display:gsg");
+NotifyCategoryDef(wdxdisplay7, "windisplay");
 
 
 // Configure this variable true to cause the DXGSG to show each
 // Configure this variable true to cause the DXGSG to show each
 // transform space it renders by drawing a little unit axis.  This
 // transform space it renders by drawing a little unit axis.  This
 // cannot be enabled when the player is compiled in NDEBUG mode.
 // cannot be enabled when the player is compiled in NDEBUG mode.
-bool dx_show_transforms = config_dxgsg.GetBool("dx-show-transforms", false);
+bool dx_show_transforms = config_dxgsg7.GetBool("dx-show-transforms", false);
 
 
 //  Configure this to TRUE if you want DirectX to control the entire screen,
 //  Configure this to TRUE if you want DirectX to control the entire screen,
 //  If false, it will just blit into a window.
 //  If false, it will just blit into a window.
-bool dx_full_screen = config_dxgsg.GetBool("dx-full-screen", false);
+bool dx_full_screen = config_dxgsg7.GetBool("dx-full-screen", false);
 
 
 //  Configure this true to force the rendering to sync to the video
 //  Configure this true to force the rendering to sync to the video
 //  refresh, or false to let your frame rate go as high as it can,
 //  refresh, or false to let your frame rate go as high as it can,
 //  irrespective of the video refresh.
 //  irrespective of the video refresh.
-bool dx_sync_video = config_dxgsg.GetBool("sync-video", true);
+bool dx_sync_video = config_dxgsg7.GetBool("sync-video", true);
 
 
 // enable this to turn on full-screen anti-aliasing, if the HW supports it
 // enable this to turn on full-screen anti-aliasing, if the HW supports it
 // this var is also used in wdxGraphicsWindows.cxx
 // this var is also used in wdxGraphicsWindows.cxx
-bool dx_full_screen_antialiasing = config_dxgsg.GetBool("dx-antialias", false);
+bool dx_full_screen_antialiasing = config_dxgsg7.GetBool("dx-antialias", false);
 
 
 // Configure this true to perform a cull traversal over the geometry
 // Configure this true to perform a cull traversal over the geometry
 // by default, false otherwise.  The cull traversal provides support
 // by default, false otherwise.  The cull traversal provides support
 // for state-sorting, z-sorting, and binning.
 // for state-sorting, z-sorting, and binning.
-bool dx_cull_traversal = config_dxgsg.GetBool("dx-cull-traversal", true);
+bool dx_cull_traversal = config_dxgsg7.GetBool("dx-cull-traversal", true);
 
 
 // if true, if card only supports per-vertex fog, it will be treated as no-HW fog capability
 // if true, if card only supports per-vertex fog, it will be treated as no-HW fog capability
-bool dx_no_vertex_fog = config_dxgsg.GetBool("dx-no-vertex-fog", false);
+bool dx_no_vertex_fog = config_dxgsg7.GetBool("dx-no-vertex-fog", false);
 
 
 // Configure this true to cause all lighting normals to automatically
 // Configure this true to cause all lighting normals to automatically
 // be normalized by the CPU before rendering.  This is
 // be normalized by the CPU before rendering.  This is
@@ -58,43 +62,43 @@ bool dx_no_vertex_fog = config_dxgsg.GetBool("dx-no-vertex-fog", false);
 // expect lighting to work correctly.  Maybe one day there will be
 // expect lighting to work correctly.  Maybe one day there will be
 // another way to set this at runtime, instead of only as a configure
 // another way to set this at runtime, instead of only as a configure
 // variable
 // variable
-bool dx_auto_normalize_lighting = config_dxgsg.GetBool("auto-normalize-lighting", false);
+bool dx_auto_normalize_lighting = config_dxgsg7.GetBool("auto-normalize-lighting", false);
 
 
-bool dx_allow_software_renderer = config_dxgsg.GetBool("dx-allow-software-renderer", false);
-bool dx_force_software_renderer = config_dxgsg.GetBool("dx-force-software-renderer", false);
-
-bool dx_show_fps_meter = config_dxgsg.GetBool("show-fps-meter", false);
-float dx_fps_meter_update_interval = max(0.5,config_dxgsg.GetFloat("fps-meter-update-interval", 1.7));
+bool dx_allow_software_renderer = config_dxgsg7.GetBool("dx-allow-software-renderer", false);
+bool dx_force_software_renderer = config_dxgsg7.GetBool("dx-force-software-renderer", false);
 
 
 #ifndef NDEBUG
 #ifndef NDEBUG
 // debugging flag
 // debugging flag
 // values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW
 // values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW
-int dx_force_backface_culling = config_dxgsg.GetInt("dx-force-backface-culling", 0);
+int dx_force_backface_culling = config_dxgsg7.GetInt("dx-force-backface-culling", 0);
 #endif
 #endif
 
 
-bool dx_mipmap_everything = config_dxgsg.GetBool("dx-mipmap-everything", false);
-bool dx_ignore_mipmaps = config_dxgsg.GetBool("dx-ignore-mipmaps", false);
+bool dx_mipmap_everything = config_dxgsg7.GetBool("dx-mipmap-everything", false);
+bool dx_ignore_mipmaps = config_dxgsg7.GetBool("dx-ignore-mipmaps", false);
 
 
 // if this is set, more accurate but more expensive fog computations are performed
 // if this is set, more accurate but more expensive fog computations are performed
-bool dx_use_rangebased_fog = config_dxgsg.GetBool("dx-use-rangebased-fog", false);
-bool dx_force_16bpptextures = config_dxgsg.GetBool("dx-force-16bpptextures", false);
-bool dx_no_dithering = config_dxgsg.GetBool("dx-no-dithering", false);
+bool dx_use_rangebased_fog = config_dxgsg7.GetBool("dx-use-rangebased-fog", false);
+bool dx_force_16bpptextures = config_dxgsg7.GetBool("dx-force-16bpptextures", false);
+bool dx_no_dithering = config_dxgsg7.GetBool("dx-no-dithering", false);
+bool dx_force_16bpp_zbuffer = config_dxgsg7.GetBool("dx-force-16bpp-zbuffer", false);
+bool dx_do_vidmemsize_check = config_dxgsg7.GetBool("do-vidmemsize-check", true);
+bool dx_preserve_fpu_state = config_dxgsg7.GetBool("dx-preserve-fpu-state", false);
 
 
 // Configure this true to try to implement decals using a
 // Configure this true to try to implement decals using a
 // DepthOffsetAttrib, false to do them with the more reliable 3-pass
 // DepthOffsetAttrib, false to do them with the more reliable 3-pass
 // rendering method instead.
 // rendering method instead.
-bool dx_depth_offset_decals = config_dxgsg.GetBool("depth-offset-decals", false);
+bool dx_depth_offset_decals = config_dxgsg7.GetBool("depth-offset-decals", false);
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
-float dx_global_miplevel_bias = config_dxgsg.GetFloat("dx-global-miplevel-bias", 0.0);
-bool dx_debug_view_mipmaps = config_dxgsg.GetBool("dx-debug-view-mipmaps", false);
-bool dx_force_anisotropic_filtering = config_dxgsg.GetBool("dx-force-anisotropic-filtering", false);
-//int dx_print_texstats = config_dxgsg.GetBool("dx-print-texstats", 0);
+float dx_global_miplevel_bias = config_dxgsg7.GetFloat("dx-global-miplevel-bias", 0.0);
+bool dx_debug_view_mipmaps = config_dxgsg7.GetBool("dx-debug-view-mipmaps", false);
+bool dx_force_anisotropic_filtering = config_dxgsg7.GetBool("dx-force-anisotropic-filtering", false);
+//int dx_print_texstats = config_dxgsg7.GetBool("dx-print-texstats", 0);
 #endif
 #endif
 
 
 // set 'retained-mode #t' and this to have prepare_geom concatenate all tristrips within a geom 
 // set 'retained-mode #t' and this to have prepare_geom concatenate all tristrips within a geom 
 // together using degenerate tris
 // together using degenerate tris
-const bool link_tristrips = config_dxgsg.GetBool("link-tristrips", false);
+const bool link_tristrips = config_dxgsg7.GetBool("link-tristrips", false);
 
 
 // note:  offset currently disabled since it wasnt working properly
 // note:  offset currently disabled since it wasnt working properly
 DXDecalType dx_decal_type = GDT_blend;
 DXDecalType dx_decal_type = GDT_blend;
@@ -108,16 +112,16 @@ parse_decal_type(const string &type) {
   } else if (type == "offset") {
   } else if (type == "offset") {
     return GDT_offset;
     return GDT_offset;
   }
   }
-  dxgsg_cat.error() << "Invalid dx-decal-type: " << type << "\n";
+  dxgsg7_cat.error() << "Invalid dx-decal-type: " << type << "\n";
   return GDT_blend;
   return GDT_blend;
 }
 }
 
 
-ConfigureFn(config_dxgsg) {
-  init_libdxgsg();
+ConfigureFn(config_dxgsg7) {
+  init_libdxgsg7();
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: init_libdxgsg
+//     Function: init_libdxgsg7
 //  Description: Initializes the library.  This must be called at
 //  Description: Initializes the library.  This must be called at
 //               least once before any of the functions or classes in
 //               least once before any of the functions or classes in
 //               this library can be used.  Normally it will be
 //               this library can be used.  Normally it will be
@@ -125,24 +129,27 @@ ConfigureFn(config_dxgsg) {
 //               called explicitly, but special cases exist.
 //               called explicitly, but special cases exist.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void
 void
-init_libdxgsg() {
+init_libdxgsg7() {
   static bool initialized = false;
   static bool initialized = false;
   if (initialized) {
   if (initialized) {
     return;
     return;
   }
   }
   initialized = true;
   initialized = true;
 
 
-  string decal_type = config_dxgsg.GetString("dx-decal-type", "");
+  string decal_type = config_dxgsg7.GetString("dx-decal-type", "");
   if (!decal_type.empty()) {
   if (!decal_type.empty()) {
     dx_decal_type = parse_decal_type(decal_type);
     dx_decal_type = parse_decal_type(decal_type);
   }
   }
 
 
-  DXGraphicsStateGuardian::init_type();
-  DXSavedFrameBuffer::init_type();
-  DXTextureContext::init_type();
-  DXGeomNodeContext::init_type();
+  DXGraphicsStateGuardian7::init_type();
+  DXSavedFrameBuffer7::init_type();
+  DXTextureContext7::init_type();
+  DXGeomNodeContext7::init_type();
+
+  wdxGraphicsPipe7::init_type();
+  wdxGraphicsWindow7::init_type();
 
 
-  GraphicsStateGuardian::get_factory().register_factory
-    (DXGraphicsStateGuardian::get_class_type(),
-     DXGraphicsStateGuardian::make_DXGraphicsStateGuardian);
+  GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
+  selection->add_pipe_type(wdxGraphicsPipe7::get_class_type(),
+                           wdxGraphicsPipe7::pipe_constructor);
 }
 }

+ 9 - 7
panda/src/dxgsg/config_dxgsg.h → panda/src/dxgsg7/config_dxgsg7.h

@@ -1,4 +1,4 @@
-// Filename: config_dxgsg.h
+// Filename: config_dxgsg7.h
 // Created by:  drose (06Oct99)
 // Created by:  drose (06Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,21 +16,20 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#ifndef CONFIG_DXGSG_H
-#define CONFIG_DXGSG_H
+#ifndef CONFIG_DXGSG7_H
+#define CONFIG_DXGSG7_H
 
 
 #include <pandabase.h>
 #include <pandabase.h>
 #include <notifyCategoryProxy.h>
 #include <notifyCategoryProxy.h>
 
 
-NotifyCategoryDecl(dxgsg, EXPCL_PANDADX, EXPTP_PANDADX);
+NotifyCategoryDecl(dxgsg7, EXPCL_PANDADX, EXPTP_PANDADX);
+NotifyCategoryDecl(wdxdisplay7, EXPCL_PANDADX, EXPTP_PANDADX);
 
 
 extern bool dx_full_screen;
 extern bool dx_full_screen;
 extern bool dx_sync_video;
 extern bool dx_sync_video;
 extern bool dx_cull_traversal;
 extern bool dx_cull_traversal;
-extern bool dx_show_fps_meter;
 extern bool dx_no_vertex_fog;
 extern bool dx_no_vertex_fog;
 extern bool dx_full_screen_antialiasing;
 extern bool dx_full_screen_antialiasing;
-extern float dx_fps_meter_update_interval;
 extern bool dx_auto_normalize_lighting;
 extern bool dx_auto_normalize_lighting;
 extern bool dx_use_rangebased_fog;
 extern bool dx_use_rangebased_fog;
 extern bool dx_allow_software_renderer;
 extern bool dx_allow_software_renderer;
@@ -43,6 +42,9 @@ extern bool dx_mipmap_everything;
 extern bool dx_show_transforms;
 extern bool dx_show_transforms;
 extern bool dx_force_16bpptextures;
 extern bool dx_force_16bpptextures;
 extern bool dx_no_dithering;
 extern bool dx_no_dithering;
+extern bool dx_force_16bpp_zbuffer;
+extern bool dx_do_vidmemsize_check;
+extern bool dx_preserve_fpu_state;
 
 
 extern bool dx_depth_offset_decals;
 extern bool dx_depth_offset_decals;
 
 
@@ -64,6 +66,6 @@ enum DXDecalType {
 };
 };
 extern DXDecalType dx_decal_type;
 extern DXDecalType dx_decal_type;
 
 
-extern EXPCL_PANDADX void init_libdxgsg();
+extern EXPCL_PANDADX void init_libdxgsg7();
 
 
 #endif
 #endif

+ 4 - 4
panda/src/dxgsg/dxGeomNodeContext.I → panda/src/dxgsg7/dxGeomNodeContext7.I

@@ -1,4 +1,4 @@
-// Filename: dxGeomNodeContext.I
+// Filename: dxGeomNodeContext7.I
 // Created by:  drose (12Jun01)
 // Created by:  drose (12Jun01)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -18,12 +18,12 @@
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: dxGeomNodeContext::Constructor
+//     Function: DXGeomNodeContext7::Constructor
 //       Access: Public                                 
 //       Access: Public                                 
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE DXGeomNodeContext::
-DXGeomNodeContext(GeomNode *node) : GeomNodeContext(node)
+INLINE DXGeomNodeContext7::
+DXGeomNodeContext7(GeomNode *node) : GeomNodeContext(node)
 {
 {
   _num_verts = 0;
   _num_verts = 0;
   _pVB = NULL;
   _pVB = NULL;

+ 4 - 4
panda/src/dxgsg/dxGeomNodeContext.cxx → panda/src/dxgsg7/dxGeomNodeContext7.cxx

@@ -1,4 +1,4 @@
-// Filename: dxGeomNodeContext.cxx
+// Filename: dxGeomNodeContext7.cxx
 // Created by:  drose (12Jun01)
 // Created by:  drose (12Jun01)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,11 +16,11 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#include "dxGeomNodeContext.h"
+#include "DXGeomNodeContext7.h"
 
 
-TypeHandle DXGeomNodeContext::_type_handle;
+TypeHandle DXGeomNodeContext7::_type_handle;
 
 
-DXGeomNodeContext::~DXGeomNodeContext()
+DXGeomNodeContext7::~DXGeomNodeContext7()
 {
 {
    if(_pXformed_VB!=NULL)
    if(_pXformed_VB!=NULL)
        _pXformed_VB->Release();
        _pXformed_VB->Release();

+ 10 - 10
panda/src/dxgsg/dxGeomNodeContext.h → panda/src/dxgsg7/dxGeomNodeContext7.h

@@ -1,4 +1,4 @@
-// Filename: dxGeomNodeContext.h
+// Filename: dxGeomNodeContext7.h
 // Created by:  drose (12Jun01)
 // Created by:  drose (12Jun01)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,10 +16,10 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#ifndef DXGEOMNODECONTEXT_H
-#define DXGEOMNODECONTEXT_H
+#ifndef DXGEOMNODECONTEXT7_H
+#define DXGEOMNODECONTEXT7_H
 
 
-#include "dxgsgbase.h"
+#include "dxgsg7base.h"
 
 
 #include "geomNodeContext.h"
 #include "geomNodeContext.h"
 #include "geomNode.h"
 #include "geomNode.h"
@@ -31,13 +31,13 @@ typedef struct {
 } DPInfo;
 } DPInfo;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//       Class : DXGeomNodeContext
+//       Class : DXGeomNodeContext7
 // Description :
 // Description :
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDADX DXGeomNodeContext : public GeomNodeContext {
+class EXPCL_PANDADX DXGeomNodeContext7 : public GeomNodeContext {
 public:
 public:
-  INLINE DXGeomNodeContext(GeomNode *node);
-  ~DXGeomNodeContext();
+  INLINE DXGeomNodeContext7(GeomNode *node);
+  ~DXGeomNodeContext7();
 
 
   // A list of the dynamic Geoms within the GeomNode; these aren't
   // A list of the dynamic Geoms within the GeomNode; these aren't
   // part of the above display list and must be drawn separately
   // part of the above display list and must be drawn separately
@@ -66,7 +66,7 @@ public:
   }
   }
   static void init_type() {
   static void init_type() {
     GeomNodeContext::init_type();
     GeomNodeContext::init_type();
-    register_type(_type_handle, "DXGeomNodeContext",
+    register_type(_type_handle, "DXGeomNodeContext7",
                   GeomNodeContext::get_class_type());
                   GeomNodeContext::get_class_type());
   }
   }
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {
@@ -78,7 +78,7 @@ private:
   static TypeHandle _type_handle;
   static TypeHandle _type_handle;
 };
 };
 
 
-#include "dxGeomNodeContext.I"
+#include "dxGeomNodeContext7.I"
 
 
 #endif
 #endif
 
 

+ 75 - 71
panda/src/dxgsg/dxGraphicsStateGuardian.I → panda/src/dxgsg7/dxGraphicsStateGuardian7.I

@@ -1,4 +1,4 @@
-// Filename: dxGraphicsStateGuardian.I
+// Filename: dxGraphicsStateGuardian7.I
 // Created by:  mike (02Feb99)
 // Created by:  mike (02Feb99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,22 +16,22 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#include "config_dxgsg.h"
+#include "config_dxgsg7.h"
 #include <graphicsWindow.h>
 #include <graphicsWindow.h>
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_line_smooth
+//     Function: DXGraphicsStateGuardian7::enable_line_smooth
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_line_smooth(bool val) {
 enable_line_smooth(bool val) {
   if(_line_smooth_enabled != val) {
   if(_line_smooth_enabled != val) {
     _line_smooth_enabled = val;
     _line_smooth_enabled = val;
   #ifdef NDEBUG
   #ifdef NDEBUG
     {
     {
         if(val && (scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
         if(val && (scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
-           dxgsg_cat.error() << "no HW support for line smoothing!!\n";
+           dxgsg7_cat.error() << "no HW support for line smoothing!!\n";
     }
     }
   #endif
   #endif
 
 
@@ -40,18 +40,18 @@ enable_line_smooth(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_dither
+//     Function: DXGraphicsStateGuardian7::enable_dither
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_dither(bool val) {
 enable_dither(bool val) {
   if (_dither_enabled != val) {
   if (_dither_enabled != val) {
 
 
   #ifdef _DEBUG
   #ifdef _DEBUG
     {
     {
         if(val && !(scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER))
         if(val && !(scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER))
-           dxgsg_cat.error() << "no HW support for color dithering!!\n";
+           dxgsg7_cat.error() << "no HW support for color dithering!!\n";
         return;
         return;
     }
     }
   #endif
   #endif
@@ -62,11 +62,11 @@ enable_dither(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_stencil_test
+//     Function: DXGraphicsStateGuardian7::enable_stencil_test
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_stencil_test(bool val) {
 enable_stencil_test(bool val) {
   if (_stencil_test_enabled != val) {
   if (_stencil_test_enabled != val) {
     _stencil_test_enabled = val;
     _stencil_test_enabled = val;
@@ -75,11 +75,11 @@ enable_stencil_test(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_color_material
+//     Function: DXGraphicsStateGuardian7::enable_color_material
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_color_material(bool val) {
 enable_color_material(bool val) {
   if (_color_material_enabled != val) {
   if (_color_material_enabled != val) {
     _color_material_enabled = val;
     _color_material_enabled = val;
@@ -87,11 +87,11 @@ enable_color_material(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_blend
+//     Function: DXGraphicsStateGuardian7::enable_blend
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_blend(bool val) {
 enable_blend(bool val) {
   if (_blend_enabled != val) {
   if (_blend_enabled != val) {
     _blend_enabled = val;
     _blend_enabled = val;
@@ -100,11 +100,11 @@ enable_blend(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_blend
+//     Function: DXGraphicsStateGuardian7::enable_blend
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 set_shademode(D3DSHADEMODE val) {
 set_shademode(D3DSHADEMODE val) {
   if (_CurShadeMode != val) {
   if (_CurShadeMode != val) {
     _CurShadeMode = val;
     _CurShadeMode = val;
@@ -112,7 +112,7 @@ set_shademode(D3DSHADEMODE val) {
   }
   }
 }
 }
 
 
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_primitive_clipping(bool val) {
 enable_primitive_clipping(bool val) {
   if (_clipping_enabled != val) {
   if (_clipping_enabled != val) {
     _clipping_enabled = val;
     _clipping_enabled = val;
@@ -121,11 +121,11 @@ enable_primitive_clipping(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_fog
+//     Function: DXGraphicsStateGuardian7::enable_fog
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_fog(bool val) {
 enable_fog(bool val) {
   if ((_fog_enabled != val) && (_doFogType!=None)) {
   if ((_fog_enabled != val) && (_doFogType!=None)) {
     _fog_enabled = val;
     _fog_enabled = val;
@@ -134,11 +134,11 @@ enable_fog(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_alpha_test
+//     Function: DXGraphicsStateGuardian7::enable_alpha_test
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_alpha_test(bool val )
 enable_alpha_test(bool val )
 {
 {
   if (_alpha_test_enabled != val) {
   if (_alpha_test_enabled != val) {
@@ -148,17 +148,17 @@ enable_alpha_test(bool val )
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::call_dxLightModelAmbient
+//     Function: DXGraphicsStateGuardian7::call_dxLightModelAmbient
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 call_dxLightModelAmbient( const Colorf& color)
 call_dxLightModelAmbient( const Colorf& color)
 {
 {
   if (_lmodel_ambient != color) {
   if (_lmodel_ambient != color) {
     _lmodel_ambient = color;
     _lmodel_ambient = color;
 #ifdef GSG_VERBOSE
 #ifdef GSG_VERBOSE
-    dxgsg_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
+    dxgsg7_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
 #endif
 #endif
     scrn.pD3DDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
     scrn.pD3DDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
                 D3DRGBA(color[0], color[1], color[2], color[3]));
                 D3DRGBA(color[0], color[1], color[2], color[3]));
@@ -166,43 +166,47 @@ call_dxLightModelAmbient( const Colorf& color)
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::call_dxAlphaFunc
+//     Function: DXGraphicsStateGuardian7::call_dxAlphaFunc
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
 call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
   if (_alpha_func != func) {
   if (_alpha_func != func) {
     _alpha_func = func;
     _alpha_func = func;
 #ifdef GSG_VERBOSE
 #ifdef GSG_VERBOSE
-    dxgsg_cat.debug() << "dxAlphaFunc(";
+    dxgsg7_cat.debug() << "dxAlphaFunc(";
     switch (func) {
     switch (func) {
     case D3DCMP_NEVER:
     case D3DCMP_NEVER:
-      dxgsg_cat.debug(false) << "D3DCMP_NEVER";
+      dxgsg7_cat.debug(false) << "D3DCMP_NEVER";
       break;
       break;
     case D3DCMP_LESS:
     case D3DCMP_LESS:
-      dxgsg_cat.debug(false) << "D3DCMP_LESS";
+      dxgsg7_cat.debug(false) << "D3DCMP_LESS";
       break;
       break;
     case D3DCMP_EQUAL:
     case D3DCMP_EQUAL:
-      dxgsg_cat.debug(false) << "D3DCMP_EQUAL";
+      dxgsg7_cat.debug(false) << "D3DCMP_EQUAL";
       break;
       break;
+#ifdef D3DCMP_LEQUAL
     case D3DCMP_LEQUAL:
     case D3DCMP_LEQUAL:
-      dxgsg_cat.debug(false) << "D3DCMP_LEQUAL";
+      dxgsg7_cat.debug(false) << "D3DCMP_LEQUAL";
       break;
       break;
+#endif
     case D3DCMP_GREATER:
     case D3DCMP_GREATER:
-      dxgsg_cat.debug(false) << "D3DCMP_GREATER";
+      dxgsg7_cat.debug(false) << "D3DCMP_GREATER";
       break;
       break;
     case D3DCMP_NOTEQUAL:
     case D3DCMP_NOTEQUAL:
-      dxgsg_cat.debug(false) << "D3DCMP_NOTEQUAL";
+      dxgsg7_cat.debug(false) << "D3DCMP_NOTEQUAL";
       break;
       break;
+#ifdef D3DCMP_GEQUAL
     case D3DCMP_GEQUAL:
     case D3DCMP_GEQUAL:
-      dxgsg_cat.debug(false) << "D3DCMP_GEQUAL";
+      dxgsg7_cat.debug(false) << "D3DCMP_GEQUAL";
       break;
       break;
+#endif
     case D3DCMP_ALWAYS:
     case D3DCMP_ALWAYS:
-      dxgsg_cat.debug(false) << "D3DCMP_ALWAYS";
+      dxgsg7_cat.debug(false) << "D3DCMP_ALWAYS";
       break;
       break;
     }
     }
-    dxgsg_cat.debug() << " , " << reference_alpha << ")" << endl;
+    dxgsg7_cat.debug() << " , " << reference_alpha << ")" << endl;
 #endif
 #endif
     scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, func);
     scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, func);
   }
   }
@@ -213,7 +217,7 @@ call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
   }
   }
 }
 }
 
 
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
 call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
 {
 {
   if (_blend_source_func != sfunc)
   if (_blend_source_func != sfunc)
@@ -221,41 +225,41 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
     _blend_source_func = sfunc;
     _blend_source_func = sfunc;
     scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, sfunc);
     scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, sfunc);
 #ifdef GSG_VERBOSE
 #ifdef GSG_VERBOSE
-    dxgsg_cat.debug() << "dxSrcBlendFunc(";
+    dxgsg7_cat.debug() << "dxSrcBlendFunc(";
     switch (sfunc)
     switch (sfunc)
         {
         {
         case D3DBLEND_ZERO:
         case D3DBLEND_ZERO:
-          dxgsg_cat.debug(false) << "ZERO, ";
+          dxgsg7_cat.debug(false) << "ZERO, ";
           break;
           break;
         case D3DBLEND_ONE:
         case D3DBLEND_ONE:
-          dxgsg_cat.debug(false) << "ONE, ";
+          dxgsg7_cat.debug(false) << "ONE, ";
           break;
           break;
         case D3DBLEND_DESTCOLOR:
         case D3DBLEND_DESTCOLOR:
-          dxgsg_cat.debug(false) << "DESTCOLOR, ";
+          dxgsg7_cat.debug(false) << "DESTCOLOR, ";
           break;
           break;
         case D3DBLEND_INVDESTCOLOR:
         case D3DBLEND_INVDESTCOLOR:
-          dxgsg_cat.debug(false) << "INVDESTCOLOR, ";
+          dxgsg7_cat.debug(false) << "INVDESTCOLOR, ";
           break;
           break;
         case D3DBLEND_SRCALPHA:
         case D3DBLEND_SRCALPHA:
-          dxgsg_cat.debug(false) << "SRCALPHA, ";
+          dxgsg7_cat.debug(false) << "SRCALPHA, ";
           break;
           break;
         case D3DBLEND_INVSRCALPHA:
         case D3DBLEND_INVSRCALPHA:
-          dxgsg_cat.debug(false) << "INVSRCALPHA, ";
+          dxgsg7_cat.debug(false) << "INVSRCALPHA, ";
           break;
           break;
         case D3DBLEND_DESTALPHA:
         case D3DBLEND_DESTALPHA:
-          dxgsg_cat.debug(false) << "DESTALPHA, ";
+          dxgsg7_cat.debug(false) << "DESTALPHA, ";
           break;
           break;
         case D3DBLEND_INVDESTALPHA:
         case D3DBLEND_INVDESTALPHA:
-          dxgsg_cat.debug(false) << "INVDESTALPHA, ";
+          dxgsg7_cat.debug(false) << "INVDESTALPHA, ";
           break;
           break;
         case D3DBLEND_SRCALPHASAT:
         case D3DBLEND_SRCALPHASAT:
-          dxgsg_cat.debug(false) << "SRCALPHASAT, ";
+          dxgsg7_cat.debug(false) << "SRCALPHASAT, ";
           break;
           break;
         default:
         default:
-          dxgsg_cat.debug(false) << "unknown, ";
+          dxgsg7_cat.debug(false) << "unknown, ";
           break;
           break;
         }
         }
-    dxgsg_cat.debug(false) << endl;
+    dxgsg7_cat.debug(false) << endl;
 #endif
 #endif
     }
     }
   if ( _blend_dest_func != dfunc)
   if ( _blend_dest_func != dfunc)
@@ -263,43 +267,43 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
     _blend_dest_func = dfunc;
     _blend_dest_func = dfunc;
     scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, dfunc);
     scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, dfunc);
 #ifdef GSG_VERBOSE
 #ifdef GSG_VERBOSE
-    dxgsg_cat.debug() << "dxDstBlendFunc(";
+    dxgsg7_cat.debug() << "dxDstBlendFunc(";
     switch (dfunc)
     switch (dfunc)
         {
         {
         case D3DBLEND_ZERO:
         case D3DBLEND_ZERO:
-          dxgsg_cat.debug(false) << "ZERO, ";
+          dxgsg7_cat.debug(false) << "ZERO, ";
           break;
           break;
         case D3DBLEND_ONE:
         case D3DBLEND_ONE:
-          dxgsg_cat.debug(false) << "ONE, ";
+          dxgsg7_cat.debug(false) << "ONE, ";
           break;
           break;
         case D3DBLEND_DESTCOLOR:
         case D3DBLEND_DESTCOLOR:
-          dxgsg_cat.debug(false) << "DESTCOLOR, ";
+          dxgsg7_cat.debug(false) << "DESTCOLOR, ";
           break;
           break;
         case D3DBLEND_INVDESTCOLOR:
         case D3DBLEND_INVDESTCOLOR:
-          dxgsg_cat.debug(false) << "INVDESTCOLOR, ";
+          dxgsg7_cat.debug(false) << "INVDESTCOLOR, ";
           break;
           break;
         case D3DBLEND_SRCALPHA:
         case D3DBLEND_SRCALPHA:
-          dxgsg_cat.debug(false) << "SRCALPHA, ";
+          dxgsg7_cat.debug(false) << "SRCALPHA, ";
           break;
           break;
         case D3DBLEND_INVSRCALPHA:
         case D3DBLEND_INVSRCALPHA:
-          dxgsg_cat.debug(false) << "INVSRCALPHA, ";
+          dxgsg7_cat.debug(false) << "INVSRCALPHA, ";
           break;
           break;
         case D3DBLEND_DESTALPHA:
         case D3DBLEND_DESTALPHA:
-          dxgsg_cat.debug(false) << "DESTALPHA, ";
+          dxgsg7_cat.debug(false) << "DESTALPHA, ";
           break;
           break;
         case D3DBLEND_INVDESTALPHA:
         case D3DBLEND_INVDESTALPHA:
-          dxgsg_cat.debug(false) << "INVDESTALPHA, ";
+          dxgsg7_cat.debug(false) << "INVDESTALPHA, ";
           break;
           break;
         case D3DBLEND_SRCALPHASAT:
         case D3DBLEND_SRCALPHASAT:
-          dxgsg_cat.debug(false) << "SRCALPHASAT, ";
+          dxgsg7_cat.debug(false) << "SRCALPHASAT, ";
           break;
           break;
         }
         }
-    dxgsg_cat.debug(false) << endl;
+    dxgsg7_cat.debug(false) << endl;
 #endif
 #endif
     }
     }
 }
 }
 
 
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_zwritemask(bool val) {
 enable_zwritemask(bool val) {
     if (_depth_write_enabled != val) {
     if (_depth_write_enabled != val) {
         _depth_write_enabled = val;
         _depth_write_enabled = val;
@@ -310,24 +314,24 @@ enable_zwritemask(bool val) {
 /**  unimplemented
 /**  unimplemented
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_multisample
+//     Function: DXGraphicsStateGuardian7::enable_multisample
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_multisample(bool val) {
 enable_multisample(bool val) {
   _multisample_enabled = val;
   _multisample_enabled = val;
   #ifdef NDEBUG
   #ifdef NDEBUG
-    dxgsg_cat.error() << "dx multisample unimplemented!!\n";
+    dxgsg7_cat.error() << "dx multisample unimplemented!!\n";
   #endif
   #endif
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_multisample_alpha_one
+//     Function: DXGraphicsStateGuardian7::enable_multisample_alpha_one
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_multisample_alpha_one(bool val) {
 enable_multisample_alpha_one(bool val) {
   if (_multisample_alpha_one_enabled != val) {
   if (_multisample_alpha_one_enabled != val) {
     _multisample_alpha_one_enabled = val;
     _multisample_alpha_one_enabled = val;
@@ -335,11 +339,11 @@ enable_multisample_alpha_one(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_multisample_alpha_mask
+//     Function: DXGraphicsStateGuardian7::enable_multisample_alpha_mask
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_multisample_alpha_mask(bool val) {
 enable_multisample_alpha_mask(bool val) {
   if (_multisample_alpha_mask_enabled != val) {
   if (_multisample_alpha_mask_enabled != val) {
     _multisample_alpha_mask_enabled = val;
     _multisample_alpha_mask_enabled = val;
@@ -347,16 +351,16 @@ enable_multisample_alpha_mask(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_point_smooth
+//     Function: DXGraphicsStateGuardian7::enable_point_smooth
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian7::
 enable_point_smooth(bool val) {
 enable_point_smooth(bool val) {
   // _point_smooth_enabled = val;
   // _point_smooth_enabled = val;
 
 
   #ifdef NDEBUG
   #ifdef NDEBUG
-    dxgsg_cat.error() << "dx point smoothing unimplemented!!\n";
+    dxgsg7_cat.error() << "dx point smoothing unimplemented!!\n";
   #endif
   #endif
 }
 }
 */
 */

File diff suppressed because it is too large
+ 158 - 383
panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx


+ 23 - 37
panda/src/dxgsg/dxGraphicsStateGuardian.h → panda/src/dxgsg7/dxGraphicsStateGuardian7.h

@@ -1,4 +1,4 @@
-// Filename: dxGraphicsStateGuardian.h
+// Filename: dxGraphicsStateGuardian7.h
 // Created by:  mike (02Feb99)
 // Created by:  mike (02Feb99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,12 +16,14 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#ifndef DXGRAPHICSSTATEGUARDIAN_H
-#define DXGRAPHICSSTATEGUARDIAN_H
+#ifndef DXGRAPHICSSTATEGUARDIAN7_H
+#define DXGRAPHICSSTATEGUARDIAN7_H
 
 
-#include "dxgsgbase.h"
-#include "dxGeomNodeContext.h"
-#include "dxTextureContext.h"
+//#define GSG_VERBOSE 1
+
+#include "dxgsg7base.h"
+#include "dxGeomNodeContext7.h"
+#include "dxTextureContext7.h"
 
 
 #include "graphicsStateGuardian.h"
 #include "graphicsStateGuardian.h"
 #include "geomprimitives.h"
 #include "geomprimitives.h"
@@ -51,20 +53,20 @@ extern void dbgPrintVidMem(LPDIRECTDRAW7 pDD, LPDDSCAPS2 lpddsCaps,const char *p
 #endif
 #endif
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//   Class : DXGraphicsStateGuardian
+//   Class : DXGraphicsStateGuardian7
 // Description : A GraphicsStateGuardian specialized for rendering
 // Description : A GraphicsStateGuardian specialized for rendering
 //               into DX.  There should be no DX calls
 //               into DX.  There should be no DX calls
 //               outside of this object.
 //               outside of this object.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDADX DXGraphicsStateGuardian : public GraphicsStateGuardian {
-  friend class wdxGraphicsWindow;
-  friend class wdxGraphicsPipe;
-  friend class wdxGraphicsWindowGroup;
-  friend class DXTextureContext;
+class EXPCL_PANDADX DXGraphicsStateGuardian7 : public GraphicsStateGuardian {
+  friend class wdxGraphicsWindow7;
+  friend class wdxGraphicsPipe7;
+  friend class wdxGraphicsWindow7Group;
+  friend class DXTextureContext7;
 
 
 public:
 public:
-  DXGraphicsStateGuardian(GraphicsWindow *win);
-  ~DXGraphicsStateGuardian();
+  DXGraphicsStateGuardian7(GraphicsWindow *win);
+  ~DXGraphicsStateGuardian7();
 
 
   virtual void reset();
   virtual void reset();
 
 
@@ -126,12 +128,11 @@ public:
   virtual void bind_light(DirectionalLight *light, int light_id);
   virtual void bind_light(DirectionalLight *light, int light_id);
   virtual void bind_light(Spotlight *light, int light_id);
   virtual void bind_light(Spotlight *light, int light_id);
 
 
-  // default gsg begin_frame() used
+  virtual bool begin_frame();
+  virtual bool begin_scene();
+  virtual void end_scene();
   virtual void end_frame();
   virtual void end_frame();
 
 
-  virtual void start_rendering();
-  virtual void finish_rendering();
-
   virtual bool wants_normals(void) const;
   virtual bool wants_normals(void) const;
   virtual bool wants_texcoords(void) const;
   virtual bool wants_texcoords(void) const;
 
 
@@ -180,10 +181,8 @@ protected:
   bool                  _dx_ready;
   bool                  _dx_ready;
   HRESULT               _last_testcooplevel_result;
   HRESULT               _last_testcooplevel_result;
 
 
-  bool                  _bShowFPSMeter;
-
   HDC               _front_hdc;
   HDC               _front_hdc;
-  DXTextureContext  *_pCurTexContext;
+  DXTextureContext7  *_pCurTexContext;
 
 
   bool              _bTransformIssued;  // decaling needs to tell when a transform has been issued
   bool              _bTransformIssued;  // decaling needs to tell when a transform has been issued
   D3DMATRIX         _SavedTransform;   
   D3DMATRIX         _SavedTransform;   
@@ -243,7 +242,7 @@ protected:
   D3DSHADEMODE _CurShadeMode;
   D3DSHADEMODE _CurShadeMode;
 
 
   bool _bDrawPrimDoSetupVertexBuffer;       // if true, draw methods just copy vertex data into pCurrentGeomContext
   bool _bDrawPrimDoSetupVertexBuffer;       // if true, draw methods just copy vertex data into pCurrentGeomContext
-  DXGeomNodeContext *_pCurrentGeomContext;  // used in vertex buffer setup
+  DXGeomNodeContext7 *_pCurrentGeomContext;  // used in vertex buffer setup
 
 
   // iterators for primitives
   // iterators for primitives
   Geom::VertexIterator vi;
   Geom::VertexIterator vi;
@@ -322,19 +321,6 @@ protected:
 
 
   bool _overlay_windows_supported;
   bool _overlay_windows_supported;
 
 
-  // vars for frames/sec meter
-  DWORD _start_time;
-  DWORD _start_frame_count;
-  DWORD _cur_frame_count;
-  float _current_fps;
-  DWORD *_fpsmeter_verts;
-  DWORD _fpsmeter_fvfflags;
-  LPDIRECTDRAWSURFACE7 _fpsmeter_font_surf;
-  float _fps_u_usedwidth,_fps_v_usedheight;  // fraction of fps font texture actually used
-  DWORD _fps_vertexsize;   // size of verts used to render fps meter
-  void  SetFPSMeterPosition(RECT &view_rect);
-  void  FillFPSMeterTexture(void);
-
 public:
 public:
   static GraphicsStateGuardian*
   static GraphicsStateGuardian*
   make_DXGraphicsStateGuardian(const FactoryParams &params);
   make_DXGraphicsStateGuardian(const FactoryParams &params);
@@ -353,7 +339,7 @@ public:
   void adjust_view_rect(int x, int y);
   void adjust_view_rect(int x, int y);
   INLINE void SetDXReady(bool stat)  {  _dx_ready = stat; }
   INLINE void SetDXReady(bool stat)  {  _dx_ready = stat; }
   INLINE bool GetDXReady(void)  { return _dx_ready;}
   INLINE bool GetDXReady(void)  { return _dx_ready;}
-  void DXGraphicsStateGuardian::SetTextureBlendMode(TextureApplyAttrib::Mode TexBlendMode,bool bJustEnable);
+  void DXGraphicsStateGuardian7::SetTextureBlendMode(TextureApplyAttrib::Mode TexBlendMode,bool bJustEnable);
 
 
   void  dx_cleanup(bool bRestoreDisplayMode,bool bAtExitFnCalled);
   void  dx_cleanup(bool bRestoreDisplayMode,bool bAtExitFnCalled);
 
 
@@ -383,7 +369,7 @@ private:
   static TypeHandle _type_handle;
   static TypeHandle _type_handle;
 };
 };
 
 
-#include "dxGraphicsStateGuardian.I"
+#include "dxGraphicsStateGuardian7.I"
 
 
 #endif
 #endif
 
 

+ 7 - 7
panda/src/dxgsg/dxSavedFrameBuffer.I → panda/src/dxgsg7/dxSavedFrameBuffer7.I

@@ -1,4 +1,4 @@
-// Filename: dxSavedFrameBuffer.I
+// Filename: dxSavedFrameBuffer7.I
 // Created by:  drose (06Oct99)
 // Created by:  drose (06Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -18,22 +18,22 @@
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXSavedFrameBuffer::Constructor
+//     Function: DXSavedFrameBuffer7::Constructor
 //       Access: Public
 //       Access: Public
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE DXSavedFrameBuffer::
-DXSavedFrameBuffer(const RenderBuffer &buffer, CPT(DisplayRegion) dr) :
+INLINE DXSavedFrameBuffer7::
+DXSavedFrameBuffer7(const RenderBuffer &buffer, CPT(DisplayRegion) dr) :
   SavedFrameBuffer(buffer, dr)
   SavedFrameBuffer(buffer, dr)
 {
 {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXSavedFrameBuffer::Destructor
+//     Function: DXSavedFrameBuffer7::Destructor
 //       Access: Public
 //       Access: Public
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE DXSavedFrameBuffer::
-~DXSavedFrameBuffer() {
+INLINE DXSavedFrameBuffer7::
+~DXSavedFrameBuffer7() {
 }
 }
 
 

+ 3 - 3
panda/src/dxgsg/dxSavedFrameBuffer.cxx → panda/src/dxgsg7/dxSavedFrameBuffer7.cxx

@@ -1,4 +1,4 @@
-// Filename: dxSavedFrameBuffer.cxx
+// Filename: dxSavedFrameBuffer7.cxx
 // Created by:  drose (06Oct99)
 // Created by:  drose (06Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,6 +16,6 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#include "dxSavedFrameBuffer.h"
+#include "dxSavedFrameBuffer7.h"
 
 
-TypeHandle DXSavedFrameBuffer::_type_handle;
+TypeHandle DXSavedFrameBuffer7::_type_handle;

+ 9 - 9
panda/src/dxgsg/dxSavedFrameBuffer.h → panda/src/dxgsg7/dxSavedFrameBuffer7.h

@@ -1,4 +1,4 @@
-// Filename: dxSavedFrameBuffer.h
+// Filename: dxSavedFrameBuffer7.h
 // Created by:  drose (06Oct99)
 // Created by:  drose (06Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,8 +16,8 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#ifndef DXSAVEDFRAMEBUFFER_H
-#define DXSAVEDFRAMEBUFFER_H
+#ifndef DXSAVEDFRAMEBUFFER7_H
+#define DXSAVEDFRAMEBUFFER7_H
 
 
 #include <pandabase.h>
 #include <pandabase.h>
 
 
@@ -28,14 +28,14 @@
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//   Class : DXSavedFrameBuffer
+//   Class : DXSavedFrameBuffer7
 // Description :
 // Description :
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDADX DXSavedFrameBuffer : public SavedFrameBuffer {
+class EXPCL_PANDADX DXSavedFrameBuffer7 : public SavedFrameBuffer {
 public:
 public:
-  INLINE DXSavedFrameBuffer(const RenderBuffer &buffer,
+  INLINE DXSavedFrameBuffer7(const RenderBuffer &buffer,
                 CPT(DisplayRegion) dr);
                 CPT(DisplayRegion) dr);
-  INLINE ~DXSavedFrameBuffer();
+  INLINE ~DXSavedFrameBuffer7();
 
 
   PT(Texture) _back_rgba;
   PT(Texture) _back_rgba;
   PT(PixelBuffer) _depth;
   PT(PixelBuffer) _depth;
@@ -46,7 +46,7 @@ public:
   }
   }
   static void init_type() {
   static void init_type() {
     SavedFrameBuffer::init_type();
     SavedFrameBuffer::init_type();
-    register_type(_type_handle, "DXSavedFrameBuffer",
+    register_type(_type_handle, "DXSavedFrameBuffer7",
           SavedFrameBuffer::get_class_type());
           SavedFrameBuffer::get_class_type());
   }
   }
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {
@@ -58,7 +58,7 @@ private:
   static TypeHandle _type_handle;
   static TypeHandle _type_handle;
 };
 };
 
 
-#include "dxSavedFrameBuffer.I"
+#include "dxSavedFrameBuffer7.I"
 
 
 #endif
 #endif
 
 

+ 57 - 57
panda/src/dxgsg/dxTextureContext.cxx → panda/src/dxgsg7/dxTextureContext7.cxx

@@ -1,4 +1,4 @@
-// Filename: dxTextureContext.cxx
+// Filename: dxTextureContext7.cxx
 // Created by:  drose (07Oct99)
 // Created by:  drose (07Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -18,9 +18,9 @@
 
 
 #include <assert.h>
 #include <assert.h>
 #include <time.h>
 #include <time.h>
-#include "dxTextureContext.h"
-#include "config_dxgsg.h"
-#include "dxGraphicsStateGuardian.h"
+#include "dxTextureContext7.h"
+#include "config_dxgsg7.h"
+#include "dxGraphicsStateGuardian7.h"
 #include "pnmImage.h"
 #include "pnmImage.h"
 
 
 static const DWORD g_LowByteMask = 0x000000FF;
 static const DWORD g_LowByteMask = 0x000000FF;
@@ -64,14 +64,14 @@ char *PandaFilterNameStrs[] = {"FT_nearest","FT_linear","FT_nearest_mipmap_neare
     "FT_nearest_mipmap_linear", "FT_linear_mipmap_linear"
     "FT_nearest_mipmap_linear", "FT_linear_mipmap_linear"
 };
 };
 
 
-TypeHandle DXTextureContext::_type_handle;
+TypeHandle DXTextureContext7::_type_handle;
 
 
 #define SWAPDWORDS(X,Y)  { DWORD temp=X;  X=Y; Y=temp; }
 #define SWAPDWORDS(X,Y)  { DWORD temp=X;  X=Y; Y=temp; }
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
 static void DebugPrintPixFmt(DDPIXELFORMAT* pddpf) {
 static void DebugPrintPixFmt(DDPIXELFORMAT* pddpf) {
     static int iddpfnum=0;
     static int iddpfnum=0;
-    ostream *dbgout = &dxgsg_cat.debug();
+    ostream *dbgout = &dxgsg7_cat.debug();
 
 
     *dbgout << "DDPF[" << iddpfnum << "]: RGBBitCount:" << pddpf->dwRGBBitCount
     *dbgout << "DDPF[" << iddpfnum << "]: RGBBitCount:" << pddpf->dwRGBBitCount
     << " Flags:"  << (void *)pddpf->dwFlags ;
     << " Flags:"  << (void *)pddpf->dwFlags ;
@@ -148,7 +148,7 @@ enum Format {
 */
 */
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXTextureContext::get_bits_per_pixel
+//     Function: DXTextureContext7::get_bits_per_pixel
 //       Access: Protected
 //       Access: Protected
 //  Description: Maps from the PixelBuffer's Format symbols
 //  Description: Maps from the PixelBuffer's Format symbols
 //               to bpp.  returns # of alpha bits
 //               to bpp.  returns # of alpha bits
@@ -156,7 +156,7 @@ enum Format {
 //                     not the stored format, which is indicated by pixelbuffer type
 //                     not the stored format, which is indicated by pixelbuffer type
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-unsigned int DXTextureContext::
+unsigned int DXTextureContext7::
 get_bits_per_pixel(PixelBuffer::Format format, int *alphbits) {
 get_bits_per_pixel(PixelBuffer::Format format, int *alphbits) {
     *alphbits = 0;      // assume no alpha bits
     *alphbits = 0;      // assume no alpha bits
     switch(format) {
     switch(format) {
@@ -209,12 +209,12 @@ HRESULT ConvertPixBuftoDDSurf(ConversionType ConvNeeded,BYTE *pbuf,LPDIRECTDRAWS
     DX_DECLARE_CLEAN(DDSURFACEDESC2, ddsd);
     DX_DECLARE_CLEAN(DDSURFACEDESC2, ddsd);
 
 
     if(IsBadWritePtr(pDDSurf,sizeof(DWORD))) {
     if(IsBadWritePtr(pDDSurf,sizeof(DWORD))) {
-        dxgsg_cat.error() << "ConvertPixBuftoDDSurf failed: bad pDDSurf ptr value (" << ((void*)pDDSurf) << ")\n";
+        dxgsg7_cat.error() << "ConvertPixBuftoDDSurf failed: bad pDDSurf ptr value (" << ((void*)pDDSurf) << ")\n";
         exit(1);
         exit(1);
     }
     }
 
 
     if(FAILED( hr = pDDSurf->Lock( NULL, &ddsd,  DDLOCK_NOSYSLOCK | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL ))) {
     if(FAILED( hr = pDDSurf->Lock( NULL, &ddsd,  DDLOCK_NOSYSLOCK | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL ))) {
-        dxgsg_cat.error() << "CreateTexture failed: _surface->Lock() failed on texture! hr = " << ConvD3DErrorToString(hr) << "\n";
+        dxgsg7_cat.error() << "CreateTexture failed: _surface->Lock() failed on texture! hr = " << ConvD3DErrorToString(hr) << "\n";
         return hr;
         return hr;
     }
     }
 
 
@@ -662,7 +662,7 @@ HRESULT ConvertPixBuftoDDSurf(ConversionType ConvNeeded,BYTE *pbuf,LPDIRECTDRAWS
             }
             }
 
 
         default:
         default:
-            dxgsg_cat.error() << "CreateTexture failed! unhandled texture conversion type: "<< ConvNeeded <<" \n";
+            dxgsg7_cat.error() << "CreateTexture failed! unhandled texture conversion type: "<< ConvNeeded <<" \n";
             pDDSurf->Unlock(NULL);
             pDDSurf->Unlock(NULL);
             return E_INVALIDARG;
             return E_INVALIDARG;
     }
     }
@@ -686,12 +686,12 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
     BYTE *pbuf=pixbuf->_image.p();
     BYTE *pbuf=pixbuf->_image.p();
 
 
     if(IsBadWritePtr(pDDSurf,sizeof(DWORD))) {
     if(IsBadWritePtr(pDDSurf,sizeof(DWORD))) {
-        dxgsg_cat.error() << "ConvertDDSurftoPixBuf failed: bad pDDSurf ptr value (" << ((void*)pDDSurf) << ")\n";
+        dxgsg7_cat.error() << "ConvertDDSurftoPixBuf failed: bad pDDSurf ptr value (" << ((void*)pDDSurf) << ")\n";
         exit(1);
         exit(1);
     }
     }
 
 
     if(FAILED( hr = pDDSurf->Lock( NULL, &ddsd,  DDLOCK_NOSYSLOCK | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL ))) {
     if(FAILED( hr = pDDSurf->Lock( NULL, &ddsd,  DDLOCK_NOSYSLOCK | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL ))) {
-        dxgsg_cat.error() << "ConvertDDSurftoPixBuf Lock() failed! hr = " << ConvD3DErrorToString(hr) << "\n";
+        dxgsg7_cat.error() << "ConvertDDSurftoPixBuf Lock() failed! hr = " << ConvD3DErrorToString(hr) << "\n";
         return hr;
         return hr;
     }
     }
 
 
@@ -705,7 +705,7 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
     if(FAILED(hr) && !((hr == DDERR_NOCLIPPERATTACHED) && dx_full_screen)) {
     if(FAILED(hr) && !((hr == DDERR_NOCLIPPERATTACHED) && dx_full_screen)) {
-        dxgsg_cat.error() << "ConvertDDSurftoPixBuf GetClipper failed! hr = " << ConvD3DErrorToString(hr) << "\n";
+        dxgsg7_cat.error() << "ConvertDDSurftoPixBuf GetClipper failed! hr = " << ConvD3DErrorToString(hr) << "\n";
         return hr;
         return hr;
     }
     }
 #endif
 #endif
@@ -714,7 +714,7 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
         HWND hWin;
         HWND hWin;
 
 
         if(FAILED(hr = pDDClipper->GetHWnd(&hWin))) {
         if(FAILED(hr = pDDClipper->GetHWnd(&hWin))) {
-            dxgsg_cat.error() << "ConvertDDSurftoPixBuf GetHwnd failed! hr = " << ConvD3DErrorToString(hr) << "\n";
+            dxgsg7_cat.error() << "ConvertDDSurftoPixBuf GetHwnd failed! hr = " << ConvD3DErrorToString(hr) << "\n";
             return hr;
             return hr;
         }
         }
 
 
@@ -737,7 +737,7 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
     if(!((dwCopyWidth==pixbuf->get_xsize()) && (dwCopyHeight<=(DWORD)pixbuf->get_ysize()))) {
     if(!((dwCopyWidth==pixbuf->get_xsize()) && (dwCopyHeight<=(DWORD)pixbuf->get_ysize()))) {
         pDDSurf->Unlock(NULL);
         pDDSurf->Unlock(NULL);
         assert(0);
         assert(0);
-        dxgsg_cat.error() << "ConvertDDSurftoPixBuf, PixBuf incorrect size to hold display surface!\n";
+        dxgsg7_cat.error() << "ConvertDDSurftoPixBuf, PixBuf incorrect size to hold display surface!\n";
         return E_FAIL;
         return E_FAIL;
     }
     }
 
 
@@ -751,8 +751,8 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
 
 
     // writes out last line in DDSurf first in PixelBuf, so Y line order precedes inversely
     // writes out last line in DDSurf first in PixelBuf, so Y line order precedes inversely
 
 
-    if(dxgsg_cat.is_debug())
-        dxgsg_cat.debug() << "ConvertDDSurftoPixBuf converting " << ddsd.ddpfPixelFormat.dwRGBBitCount << "bpp DDSurf to " 
+    if(dxgsg7_cat.is_debug())
+        dxgsg7_cat.debug() << "ConvertDDSurftoPixBuf converting " << ddsd.ddpfPixelFormat.dwRGBBitCount << "bpp DDSurf to " 
                           <<  dwNumComponents << "-channel panda PixelBuffer\n";
                           <<  dwNumComponents << "-channel panda PixelBuffer\n";
 
 
 
 
@@ -1003,7 +1003,7 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
 //       gets the attributes of the texture from the bitmap, creates the
 //       gets the attributes of the texture from the bitmap, creates the
 //       texture, and then copies the bitmap into the texture.
 //       texture, and then copies the bitmap into the texture.
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, 
+LPDIRECTDRAWSURFACE7 DXTextureContext7::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, 
 #ifdef USE_TEXFMTVEC
 #ifdef USE_TEXFMTVEC
                                         DDPixelFormatVec &TexFmts,LPD3DDEVICEDESC7 pD3DDevDesc)
                                         DDPixelFormatVec &TexFmts,LPD3DDEVICEDESC7 pD3DDevDesc)
 #else
 #else
@@ -1045,7 +1045,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
     assert(pixbuf_type==PixelBuffer::T_unsigned_byte);   // cant handle anything else now
     assert(pixbuf_type==PixelBuffer::T_unsigned_byte);   // cant handle anything else now
 
 
     if((pixbuf_type != PixelBuffer::T_unsigned_byte) || (pbuf->get_component_width()!=1)) {
     if((pixbuf_type != PixelBuffer::T_unsigned_byte) || (pbuf->get_component_width()!=1)) {
-        dxgsg_cat.error() << "CreateTexture failed, havent handled non 8-bit channel pixelbuffer types yet! \n";
+        dxgsg7_cat.error() << "CreateTexture failed, havent handled non 8-bit channel pixelbuffer types yet! \n";
         return NULL;
         return NULL;
     }
     }
 
 
@@ -1099,7 +1099,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
     ddsd.dwHeight        = dwOrigHeight;
     ddsd.dwHeight        = dwOrigHeight;
 
 
     if(!ISPOW2(ddsd.dwWidth) || !ISPOW2(ddsd.dwHeight)) {
     if(!ISPOW2(ddsd.dwWidth) || !ISPOW2(ddsd.dwHeight)) {
-        dxgsg_cat.error() << "ERROR: texture dimensions are not a power of 2 for " << _tex->get_name() << "!!!!! \n";
+        dxgsg7_cat.error() << "ERROR: texture dimensions are not a power of 2 for " << _tex->get_name() << "!!!!! \n";
         #ifdef _DEBUG
         #ifdef _DEBUG
           exit(1);  // want to catch badtexsize errors
           exit(1);  // want to catch badtexsize errors
         #else
         #else
@@ -1112,7 +1112,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
 
 
     if((dwOrigWidth>pD3DDevDesc->dwMaxTextureWidth)||(dwOrigHeight>pD3DDevDesc->dwMaxTextureHeight)) {
     if((dwOrigWidth>pD3DDevDesc->dwMaxTextureWidth)||(dwOrigHeight>pD3DDevDesc->dwMaxTextureHeight)) {
         #ifdef _DEBUG
         #ifdef _DEBUG
-           dxgsg_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << pD3DDevDesc->dwMaxTextureWidth << "," << pD3DDevDesc->dwMaxTextureHeight << ") !!\n"
+           dxgsg7_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << pD3DDevDesc->dwMaxTextureWidth << "," << pD3DDevDesc->dwMaxTextureHeight << ") !!\n"
            << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<<  pD3DDevDesc->dwMaxTextureWidth << "," << pD3DDevDesc->dwMaxTextureHeight << ") !\n";
            << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<<  pD3DDevDesc->dwMaxTextureWidth << "," << pD3DDevDesc->dwMaxTextureHeight << ") !\n";
         #endif
         #endif
 
 
@@ -1134,7 +1134,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
         bShrinkOriginal=true;
         bShrinkOriginal=true;
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
-        dxgsg_cat.debug() << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< ddsd.dwWidth<<"," << ddsd.dwHeight << ") to meet HW square texture reqmt\n";
+        dxgsg7_cat.debug() << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< ddsd.dwWidth<<"," << ddsd.dwHeight << ") to meet HW square texture reqmt\n";
 #endif
 #endif
     }
     }
 
 
@@ -1157,7 +1157,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
 // easier to use dxcapsviewer instead of this
 // easier to use dxcapsviewer instead of this
     { static BOOL bPrinted=FALSE;
     { static BOOL bPrinted=FALSE;
         if(!bPrinted) {
         if(!bPrinted) {
-            dxgsg_cat.debug() << "Gfx card supported TexFmts:\n";
+            dxgsg7_cat.debug() << "Gfx card supported TexFmts:\n";
             for(i=0;i<cNumTexPixFmts;i++) {
             for(i=0;i<cNumTexPixFmts;i++) {
                 DebugPrintPixFmt(&pTexPixFmts[i]);
                 DebugPrintPixFmt(&pTexPixFmts[i]);
             }
             }
@@ -1174,8 +1174,8 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
 
 
     szErrorMsg = "CreateTexture failed: couldn't find compatible Tex DDPIXELFORMAT!\n";
     szErrorMsg = "CreateTexture failed: couldn't find compatible Tex DDPIXELFORMAT!\n";
 
 
-    if(dxgsg_cat.is_spam())
-        dxgsg_cat.spam() << "CreateTexture handling bitdepth: " << bpp << " alphabits: " << cNumAlphaBits << "\n";
+    if(dxgsg7_cat.is_spam())
+        dxgsg7_cat.spam() << "CreateTexture handling bitdepth: " << bpp << " alphabits: " << cNumAlphaBits << "\n";
 
 
     // Mark formats I dont want to deal with
     // Mark formats I dont want to deal with
     for(i=0,pCurPixFmt=pTexPixFmts;i<cNumTexPixFmts;i++,pCurPixFmt++) {
     for(i=0,pCurPixFmt=pTexPixFmts;i<cNumTexPixFmts;i++,pCurPixFmt++) {
@@ -1483,7 +1483,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
 
 
     // if we've gotten here, haven't found a match
     // if we've gotten here, haven't found a match
 
 
-    dxgsg_cat.error() << szErrorMsg << ";  requested tex bitdepth: " << bpp << "\n";
+    dxgsg7_cat.error() << szErrorMsg << ";  requested tex bitdepth: " << bpp << "\n";
     goto error_exit;
     goto error_exit;
 
 
     ///////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////
@@ -1541,7 +1541,7 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
         if(dx_mipmap_everything) {  // debug toggle, ok to leave in since its just a creation cost
         if(dx_mipmap_everything) {  // debug toggle, ok to leave in since its just a creation cost
            _bHasMipMaps=TRUE;
            _bHasMipMaps=TRUE;
            if(ft != Texture::FT_linear_mipmap_linear) {
            if(ft != Texture::FT_linear_mipmap_linear) {
-               dxgsg_cat.spam() << "Forcing mipmap filtering on DX texture [" << _tex->get_name() << "]\n";
+               dxgsg7_cat.spam() << "Forcing mipmap filtering on DX texture [" << _tex->get_name() << "]\n";
            }
            }
            ft = Texture::FT_linear_mipmap_linear;
            ft = Texture::FT_linear_mipmap_linear;
            _tex->set_minfilter(ft);
            _tex->set_minfilter(ft);
@@ -1594,14 +1594,14 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
     }
     }
     _tex->set_anisotropic_degree(aniso_degree);
     _tex->set_anisotropic_degree(aniso_degree);
 #ifdef _DEBUG
 #ifdef _DEBUG
-    dxgsg_cat.spam() << "CreateTexture: setting aniso degree for "<< _tex->get_name() << " to: " << aniso_degree << endl;
+    dxgsg7_cat.spam() << "CreateTexture: setting aniso degree for "<< _tex->get_name() << " to: " << aniso_degree << endl;
 #endif
 #endif
 
 
     if(_bHasMipMaps) {
     if(_bHasMipMaps) {
        // We dont specify mipmapcount, so CreateSurface will auto-create surfs
        // We dont specify mipmapcount, so CreateSurface will auto-create surfs
        // for all mipmaps down to 1x1 (if driver supports deep-mipmaps, otherwise Nx1)
        // for all mipmaps down to 1x1 (if driver supports deep-mipmaps, otherwise Nx1)
         ddsd.ddsCaps.dwCaps |= (DDSCAPS_MIPMAP | DDSCAPS_COMPLEX);
         ddsd.ddsCaps.dwCaps |= (DDSCAPS_MIPMAP | DDSCAPS_COMPLEX);
-        dxgsg_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
+        dxgsg7_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
     }
     }
 
 
     if(pD3DDevDesc->dwDevCaps & D3DDEVCAPS_SEPARATETEXTUREMEMORIES) {
     if(pD3DDevDesc->dwDevCaps & D3DDEVCAPS_SEPARATETEXTUREMEMORIES) {
@@ -1615,13 +1615,13 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
 
 
     // Create a new surface for the texture
     // Create a new surface for the texture
     if(FAILED( hr = pDD->CreateSurface( &ddsd, &_surface, NULL ) )) {
     if(FAILED( hr = pDD->CreateSurface( &ddsd, &_surface, NULL ) )) {
-        dxgsg_cat.error() << "CreateTexture failed: pDD->CreateSurface() failed!  hr = " << ConvD3DErrorToString(hr) << "\n";
+        dxgsg7_cat.error() << "CreateTexture failed: pDD->CreateSurface() failed!  hr = " << ConvD3DErrorToString(hr) << "\n";
         goto error_exit;
         goto error_exit;
     }
     }
 
 
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
-    dxgsg_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converted " << ConvNameStrs[ConvNeeded] << " \n";
+    dxgsg7_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converted " << ConvNameStrs[ConvNeeded] << " \n";
 #endif
 #endif
 
 
     _PixBufConversionType=ConvNeeded;
     _PixBufConversionType=ConvNeeded;
@@ -1652,12 +1652,12 @@ LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevic
     return NULL;
     return NULL;
 }
 }
 
 
-HRESULT DXTextureContext::
+HRESULT DXTextureContext7::
 FillDDSurfTexturePixels(void) {
 FillDDSurfTexturePixels(void) {
     
     
     PixelBuffer *pbuf = _texture->get_ram_image();
     PixelBuffer *pbuf = _texture->get_ram_image();
     if (pbuf == (PixelBuffer *)NULL) {
     if (pbuf == (PixelBuffer *)NULL) {
-      dxgsg_cat.fatal() << "CreateTexture: get_ram_image() failed\n";
+      dxgsg7_cat.fatal() << "CreateTexture: get_ram_image() failed\n";
       // The texture doesn't have an image to load.
       // The texture doesn't have an image to load.
       return E_FAIL;
       return E_FAIL;
     }
     }
@@ -1762,7 +1762,7 @@ FillDDSurfTexturePixels(void) {
 
 
             hr = pCurDDSurf->GetAttachedSurface(&ddsCaps, &pMipLevel_DDSurf);
             hr = pCurDDSurf->GetAttachedSurface(&ddsCaps, &pMipLevel_DDSurf);
             if(FAILED(hr)) {
             if(FAILED(hr)) {
-                dxgsg_cat.error() << "CreateTexture failed creating mipmaps: GetAttachedSurf hr = " << ConvD3DErrorToString(hr) << "\n";
+                dxgsg7_cat.error() << "CreateTexture failed creating mipmaps: GetAttachedSurf hr = " << ConvD3DErrorToString(hr) << "\n";
                 delete [] pMipMapPixBufSpace;
                 delete [] pMipMapPixBufSpace;
                 pCurDDSurf->Release();
                 pCurDDSurf->Release();
                 return hr;
                 return hr;
@@ -1790,7 +1790,7 @@ FillDDSurfTexturePixels(void) {
         if(dx_debug_view_mipmaps) {
         if(dx_debug_view_mipmaps) {
 #if 0
 #if 0
             if(!(ddcaps.dwCaps & DDCAPS_BLTSTRETCH)) {
             if(!(ddcaps.dwCaps & DDCAPS_BLTSTRETCH)) {
-                dxgsg_cat.error() << "CreateTexture failed debug-viewing mipmaps, BLT stretching not supported!  ( we need to do SW stretch) \n";
+                dxgsg7_cat.error() << "CreateTexture failed debug-viewing mipmaps, BLT stretching not supported!  ( we need to do SW stretch) \n";
                 return hr;
                 return hr;
             }
             }
 #endif
 #endif
@@ -1817,14 +1817,14 @@ FillDDSurfTexturePixels(void) {
 
 
                 hr = pTexturePrev->GetDC(&hTexDC);
                 hr = pTexturePrev->GetDC(&hTexDC);
                 if(FAILED(hr)) {
                 if(FAILED(hr)) {
-                    dxgsg_cat.error() << "GetDC failed hr = " << ConvD3DErrorToString(hr) << "\n";
+                    dxgsg7_cat.error() << "GetDC failed hr = " << ConvD3DErrorToString(hr) << "\n";
                     break;
                     break;
                 }
                 }
 
 
                 BOOL res;
                 BOOL res;
-                        // res = BitBlt(_dxgsg->_hdc,0,0,ddsd.dwWidth,ddsd.dwHeight, TexDC,0,0,SRCCOPY);
+                        // res = BitBlt(_dxgsg7->_hdc,0,0,ddsd.dwWidth,ddsd.dwHeight, TexDC,0,0,SRCCOPY);
                         // loader inverts y, so use StretchBlt to re-invert it
                         // loader inverts y, so use StretchBlt to re-invert it
-                        // res = StretchBlt(_dxgsg->hdc,0,ddsd_cur.dwHeight+cury,ddsd_cur.dwWidth,-ddsd_cur.dwHeight, TexDC,0,0,ddsd_cur.dwWidth,ddsd_cur.dwHeight,SRCCOPY);
+                        // res = StretchBlt(_dxgsg7->hdc,0,ddsd_cur.dwHeight+cury,ddsd_cur.dwWidth,-ddsd_cur.dwHeight, TexDC,0,0,ddsd_cur.dwWidth,ddsd_cur.dwHeight,SRCCOPY);
 #if 0
 #if 0
                 if(cNumAlphaBits>0) {
                 if(cNumAlphaBits>0) {
                     BLENDFUNCTION  bf;
                     BLENDFUNCTION  bf;
@@ -1833,7 +1833,7 @@ FillDDSurfTexturePixels(void) {
                     res = AlphaBlend(hScreenDC,curx,cury,ddsd_cur.dwWidth,ddsd_cur.dwHeight, TexDC,0,0,ddsd_cur.dwWidth,ddsd_cur.dwHeight,bf);
                     res = AlphaBlend(hScreenDC,curx,cury,ddsd_cur.dwWidth,ddsd_cur.dwHeight, TexDC,0,0,ddsd_cur.dwWidth,ddsd_cur.dwHeight,bf);
                     if(!res) {
                     if(!res) {
                         PrintLastError(msg);
                         PrintLastError(msg);
-                        dxgsg_cat.error() << "AlphaBlend BLT failed: "<<msg<<"\n";
+                        dxgsg7_cat.error() << "AlphaBlend BLT failed: "<<msg<<"\n";
                     }
                     }
 
 
                 } else
                 } else
@@ -1842,7 +1842,7 @@ FillDDSurfTexturePixels(void) {
                     res = StretchBlt(hScreenDC,curx,ddsd_cur.dwHeight+cury,ddsd_cur.dwWidth,-((int)ddsd_cur.dwHeight), hTexDC,0,0,ddsd_cur.dwWidth,ddsd_cur.dwHeight,SRCCOPY);
                     res = StretchBlt(hScreenDC,curx,ddsd_cur.dwHeight+cury,ddsd_cur.dwWidth,-((int)ddsd_cur.dwHeight), hTexDC,0,0,ddsd_cur.dwWidth,ddsd_cur.dwHeight,SRCCOPY);
                     if(!res) {
                     if(!res) {
                         PrintLastError(msg);
                         PrintLastError(msg);
-                        dxgsg_cat.error() << "StretchBLT failed: "<<msg<<"\n";
+                        dxgsg7_cat.error() << "StretchBLT failed: "<<msg<<"\n";
 
 
                     }
                     }
                 }
                 }
@@ -1859,7 +1859,7 @@ FillDDSurfTexturePixels(void) {
                 hr = pTexturePrev->ReleaseDC(hTexDC);
                 hr = pTexturePrev->ReleaseDC(hTexDC);
 
 
                 if(FAILED(hr)) {
                 if(FAILED(hr)) {
-                    dxgsg_cat.error() << "tex ReleaseDC failed for mip "<<i<<" hr = " << ConvD3DErrorToString(hr) << "\n";
+                    dxgsg7_cat.error() << "tex ReleaseDC failed for mip "<<i<<" hr = " << ConvD3DErrorToString(hr) << "\n";
                     break;
                     break;
                 }
                 }
 
 
@@ -1874,7 +1874,7 @@ FillDDSurfTexturePixels(void) {
                 ddsCaps.dwCaps2 = DDSCAPS2_MIPMAPSUBLEVEL;
                 ddsCaps.dwCaps2 = DDSCAPS2_MIPMAPSUBLEVEL;
                 hr = pTexturePrev->GetAttachedSurface(&ddsCaps, &pTextureCurrent);
                 hr = pTexturePrev->GetAttachedSurface(&ddsCaps, &pTextureCurrent);
                 if(FAILED(hr)) {
                 if(FAILED(hr)) {
-                    dxgsg_cat.error() << " failed displaying mipmaps: GetAttachedSurf hr = " << ConvD3DErrorToString(hr) << "\n";
+                    dxgsg7_cat.error() << " failed displaying mipmaps: GetAttachedSurf hr = " << ConvD3DErrorToString(hr) << "\n";
                 }
                 }
                         // done with the previous texture
                         // done with the previous texture
                 pTexturePrev->Release();
                 pTexturePrev->Release();
@@ -1891,9 +1891,9 @@ FillDDSurfTexturePixels(void) {
             int val=MsgWaitForMultipleObjects(1,hArr,TRUE,INFINITE,QS_KEY);
             int val=MsgWaitForMultipleObjects(1,hArr,TRUE,INFINITE,QS_KEY);
             if(val==-1) {
             if(val==-1) {
                 PrintLastError(msg);
                 PrintLastError(msg);
-                dxgsg_cat.error() << " MsgWaitForMultipleObjects returns " << val << "  " <<msg << endl;
+                dxgsg7_cat.error() << " MsgWaitForMultipleObjects returns " << val << "  " <<msg << endl;
             } else {
             } else {
-                dxgsg_cat.error() << " MsgWaitForMultipleObjects returns " << val << endl;
+                dxgsg7_cat.error() << " MsgWaitForMultipleObjects returns " << val << endl;
             }
             }
         }
         }
 #endif
 #endif
@@ -1907,10 +1907,10 @@ FillDDSurfTexturePixels(void) {
 // Name: DeleteTexture()
 // Name: DeleteTexture()
 // Desc: Release the surface used to store the texture
 // Desc: Release the surface used to store the texture
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-void DXTextureContext::
+void DXTextureContext7::
 DeleteTexture( ) {
 DeleteTexture( ) {
-    if(dxgsg_cat.is_spam()) {
-        dxgsg_cat.spam() << "Deleting DX texture for " << _tex->get_name() << "\n";
+    if(dxgsg7_cat.is_spam()) {
+        dxgsg7_cat.spam() << "Deleting DX texture for " << _tex->get_name() << "\n";
     }
     }
 
 
     ULONG refcnt;
     ULONG refcnt;
@@ -1922,26 +1922,26 @@ DeleteTexture( ) {
         pDD->Release();
         pDD->Release();
 
 
         PRINTREFCNT(pDD,"before DeleteTex, IDDraw7");
         PRINTREFCNT(pDD,"before DeleteTex, IDDraw7");
-        RELEASE(_surface,dxgsg,"texture",false);
+        RELEASE(_surface,dxgsg7,"texture",false);
         PRINTREFCNT(pDD,"after DeleteTex, IDDraw7");
         PRINTREFCNT(pDD,"after DeleteTex, IDDraw7");
     }
     }
 #else
 #else
-    RELEASE(_surface,dxgsg,"texture",false);
+    RELEASE(_surface,dxgsg7,"texture",false);
 #endif
 #endif
 }
 }
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXTextureContext::Constructor
+//     Function: DXTextureContext7::Constructor
 //       Access: Public
 //       Access: Public
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-DXTextureContext::
-DXTextureContext(Texture *tex) :
+DXTextureContext7::
+DXTextureContext7(Texture *tex) :
 TextureContext(tex) {
 TextureContext(tex) {
 //#ifdef NDEBUG
 //#ifdef NDEBUG
-    if(dxgsg_cat.is_spam()) {
-       dxgsg_cat.spam() << "Creating DX texture [" << tex->get_name() << "], minfilter(" << PandaFilterNameStrs[tex->get_minfilter()] << "), magfilter("<<PandaFilterNameStrs[tex->get_magfilter()] << "), anisodeg(" << tex->get_anisotropic_degree() << ")\n";
+    if(dxgsg7_cat.is_spam()) {
+       dxgsg7_cat.spam() << "Creating DX texture [" << tex->get_name() << "], minfilter(" << PandaFilterNameStrs[tex->get_minfilter()] << "), magfilter("<<PandaFilterNameStrs[tex->get_magfilter()] << "), anisodeg(" << tex->get_anisotropic_degree() << ")\n";
     }
     }
 //#endif
 //#endif
     _surface = NULL;
     _surface = NULL;
@@ -1949,8 +1949,8 @@ TextureContext(tex) {
     _tex = tex;
     _tex = tex;
 }
 }
 
 
-DXTextureContext::
-~DXTextureContext() {
+DXTextureContext7::
+~DXTextureContext7() {
     DeleteTexture();
     DeleteTexture();
     TextureContext::~TextureContext();
     TextureContext::~TextureContext();
     _tex = NULL;
     _tex = NULL;

+ 11 - 11
panda/src/dxgsg/dxTextureContext.h → panda/src/dxgsg7/dxTextureContext7.h

@@ -1,4 +1,4 @@
-// Filename: dxTextureContext.h
+// Filename: dxTextureContext7.h
 // Created by:  drose (07Oct99)
 // Created by:  drose (07Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,25 +16,25 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#ifndef DXTEXTURECONTEXT_H
-#define DXTEXTURECONTEXT_H
+#ifndef DXTEXTURECONTEXT7_H
+#define DXTEXTURECONTEXT7_H
 
 
-#include "dxgsgbase.h"
+#include "dxgsg7base.h"
 
 
 #include <texture.h>
 #include <texture.h>
 #include <textureContext.h>
 #include <textureContext.h>
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//   Class : DXTextureContext
+//   Class : DXTextureContext7
 // Description :
 // Description :
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDADX DXTextureContext : public TextureContext {
-  friend class DXGraphicsStateGuardian;
-  friend class wdxGraphicsWindow;
+class EXPCL_PANDADX DXTextureContext7 : public TextureContext {
+  friend class DXGraphicsStateGuardian7;
+  friend class wdxGraphicsWindow7;
 
 
 public:
 public:
-  DXTextureContext(Texture *tex);
-  ~DXTextureContext();
+  DXTextureContext7(Texture *tex);
+  ~DXTextureContext7();
 
 
   LPDIRECTDRAWSURFACE7  _surface;
   LPDIRECTDRAWSURFACE7  _surface;
   Texture *_tex;            // ptr to parent, primarily for access to namestr
   Texture *_tex;            // ptr to parent, primarily for access to namestr
@@ -63,7 +63,7 @@ public:
   }
   }
   static void init_type() {
   static void init_type() {
     TextureContext::init_type();
     TextureContext::init_type();
-    register_type(_type_handle, "DXTextureContext",
+    register_type(_type_handle, "DXTextureContext7",
           TextureContext::get_class_type());
           TextureContext::get_class_type());
   }
   }
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {

+ 7 - 0
panda/src/dxgsg7/dxgsg7_composite1.cxx

@@ -0,0 +1,7 @@
+#include "config_dxgsg7.cxx"
+#include "dxgsg7base.cxx"
+#include "dxSavedFrameBuffer7.cxx"
+#include "dxTextureContext7.cxx"
+#include "dxGeomNodeContext7.cxx"
+#include "wdxGraphicsPipe7.cxx"
+#include "wdxGraphicsWindow7.cxx"

+ 1516 - 0
panda/src/dxgsg7/dxgsg7base.cxx

@@ -0,0 +1,1516 @@
+// Filename: dxgsg7base.cxx
+// Created by:  drose (02Jan03)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "dxgsg7base.h"
+
+#include <dxfile.h>
+
+const char *
+ConvD3DErrorToString(HRESULT error) {
+  switch (error) {
+  case E_FAIL:
+    return "Unspecified error E_FAIL";
+    
+  case DD_OK:
+    return "No error.";
+  case D3DERR_BADMAJORVERSION      : // (700)
+    return "D3DERR_BADMAJORVERSION";
+  case D3DERR_BADMINORVERSION      : // (701)
+    return "D3DERR_BADMINORVERSION";
+  case D3DERR_INVALID_DEVICE   : // (705)
+    return "D3DERR_INVALID_DEVICE";
+  case D3DERR_INITFAILED       : // (706)
+    return "D3DERR_INITFAILED";
+  case D3DERR_DEVICEAGGREGATED : // (707)
+    return "D3DERR_DEVICEAGGREGATED";
+  case D3DERR_EXECUTE_CREATE_FAILED    : // (710)
+    return "D3DERR_EXECUTE_CREATE_FAILED";
+  case D3DERR_EXECUTE_DESTROY_FAILED   : // (711)
+    return "D3DERR_EXECUTE_DESTROY_FAILED";
+  case D3DERR_EXECUTE_LOCK_FAILED  : // (712)
+    return "D3DERR_EXECUTE_LOCK_FAILED";
+  case D3DERR_EXECUTE_UNLOCK_FAILED    : // (713)
+    return "D3DERR_EXECUTE_UNLOCK_FAILED";
+  case D3DERR_EXECUTE_LOCKED       : // (714)
+    return "D3DERR_EXECUTE_LOCKED";
+  case D3DERR_EXECUTE_NOT_LOCKED   : // (715)
+    return "D3DERR_EXECUTE_NOT_LOCKED";
+  case D3DERR_EXECUTE_FAILED       : // (716)
+    return "D3DERR_EXECUTE_FAILED";
+  case D3DERR_EXECUTE_CLIPPED_FAILED   : // (717)
+    return "D3DERR_EXECUTE_CLIPPED_FAILED";
+  case D3DERR_TEXTURE_NO_SUPPORT   : // (720)
+    return "D3DERR_TEXTURE_NO_SUPPORT";
+  case D3DERR_TEXTURE_CREATE_FAILED    : // (721)
+    return "D3DERR_TEXTURE_CREATE_FAILED";
+  case D3DERR_TEXTURE_DESTROY_FAILED   : // (722)
+    return "D3DERR_TEXTURE_DESTROY_FAILED";
+  case D3DERR_TEXTURE_LOCK_FAILED  : // (723)
+    return "D3DERR_TEXTURE_LOCK_FAILED";
+  case D3DERR_TEXTURE_UNLOCK_FAILED    : // (724)
+    return "D3DERR_TEXTURE_UNLOCK_FAILED";
+  case D3DERR_TEXTURE_LOAD_FAILED  : // (725)
+    return "D3DERR_TEXTURE_LOAD_FAILED";
+  case D3DERR_TEXTURE_SWAP_FAILED  : // (726)
+    return "D3DERR_TEXTURE_SWAP_FAILED";
+  case D3DERR_TEXTURE_LOCKED       : // (727)
+    return "D3DERR_TEXTURE_LOCKED";
+  case D3DERR_TEXTURE_NOT_LOCKED   : // (728)
+    return "D3DERR_TEXTURE_NOT_LOCKED";
+  case D3DERR_TEXTURE_GETSURF_FAILED   : // (729)
+    return "D3DERR_TEXTURE_GETSURF_FAILED";
+  case D3DERR_MATRIX_CREATE_FAILED : // (730)
+    return "D3DERR_MATRIX_CREATE_FAILED";
+  case D3DERR_MATRIX_DESTROY_FAILED    : // (731)
+    return "D3DERR_MATRIX_DESTROY_FAILED";
+  case D3DERR_MATRIX_SETDATA_FAILED    : // (732)
+    return "D3DERR_MATRIX_SETDATA_FAILED";
+  case D3DERR_MATRIX_GETDATA_FAILED    : // (733)
+    return "D3DERR_MATRIX_GETDATA_FAILED";
+  case D3DERR_SETVIEWPORTDATA_FAILED   : // (734)
+    return "D3DERR_SETVIEWPORTDATA_FAILED";
+  case D3DERR_INVALIDCURRENTVIEWPORT   : // (735)
+    return "D3DERR_INVALIDCURRENTVIEWPORT";
+  case D3DERR_INVALIDPRIMITIVETYPE     : // (736)
+    return "D3DERR_INVALIDPRIMITIVETYPE";
+  case D3DERR_INVALIDVERTEXTYPE        : // (737)
+    return "D3DERR_INVALIDVERTEXTYPE";
+  case D3DERR_TEXTURE_BADSIZE          : // (738)
+    return "D3DERR_TEXTURE_BADSIZE";
+  case D3DERR_INVALIDRAMPTEXTURE       : // (739)
+    return "D3DERR_INVALIDRAMPTEXTURE";
+  case D3DERR_MATERIAL_CREATE_FAILED   : // (740)
+    return "D3DERR_MATERIAL_CREATE_FAILED";
+  case D3DERR_MATERIAL_DESTROY_FAILED  : // (741)
+    return "D3DERR_MATERIAL_DESTROY_FAILED";
+  case D3DERR_MATERIAL_SETDATA_FAILED  : // (742)
+    return "D3DERR_MATERIAL_SETDATA_FAILED";
+  case D3DERR_MATERIAL_GETDATA_FAILED  : // (743)
+    return "D3DERR_MATERIAL_GETDATA_FAILED";
+  case D3DERR_INVALIDPALETTE           : // (744)
+    return "D3DERR_INVALIDPALETTE";
+  case D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY : // (745)
+    return "D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY";
+  case D3DERR_ZBUFF_NEEDS_VIDEOMEMORY  : // (746)
+    return "D3DERR_ZBUFF_NEEDS_VIDEOMEMORY";
+  case D3DERR_SURFACENOTINVIDMEM       : // (747)
+    return "D3DERR_SURFACENOTINVIDMEM";
+  case D3DERR_LIGHT_SET_FAILED     : // (750)
+    return "D3DERR_LIGHT_SET_FAILED";
+  case D3DERR_LIGHTHASVIEWPORT     : // (751)
+    return "D3DERR_LIGHTHASVIEWPORT";
+  case D3DERR_LIGHTNOTINTHISVIEWPORT           : // (752)
+    return "D3DERR_LIGHTNOTINTHISVIEWPORT";
+  case D3DERR_SCENE_IN_SCENE       : // (760)
+    return "D3DERR_SCENE_IN_SCENE";
+  case D3DERR_SCENE_NOT_IN_SCENE   : // (761)
+    return "D3DERR_SCENE_NOT_IN_SCENE";
+  case D3DERR_SCENE_BEGIN_FAILED   : // (762)
+    return "D3DERR_SCENE_BEGIN_FAILED";
+  case D3DERR_SCENE_END_FAILED     : // (763)
+    return "D3DERR_SCENE_END_FAILED";
+  case D3DERR_INBEGIN                  : // (770)
+    return "D3DERR_INBEGIN";
+  case D3DERR_NOTINBEGIN               : // (771)
+    return "D3DERR_NOTINBEGIN";
+  case D3DERR_NOVIEWPORTS              : // (772)
+    return "D3DERR_NOVIEWPORTS";
+  case D3DERR_VIEWPORTDATANOTSET       : // (773)
+    return "D3DERR_VIEWPORTDATANOTSET";
+  case D3DERR_VIEWPORTHASNODEVICE      : // (774)
+    return "D3DERR_VIEWPORTHASNODEVICE";
+  case D3DERR_NOCURRENTVIEWPORT        : // (775)
+    return "D3DERR_NOCURRENTVIEWPORT";
+  case D3DERR_INVALIDVERTEXFORMAT              : // (2048)
+    return "D3DERR_INVALIDVERTEXFORMAT";
+  case D3DERR_COLORKEYATTACHED                 : // (2050)
+    return "D3DERR_COLORKEYATTACHED";
+  case D3DERR_VERTEXBUFFEROPTIMIZED            : // (2060)
+    return "D3DERR_VERTEXBUFFEROPTIMIZED";
+  case D3DERR_VBUF_CREATE_FAILED               : // (2061)
+    return "D3DERR_VBUF_CREATE_FAILED";
+  case D3DERR_VERTEXBUFFERLOCKED               : // (2062)
+    return "D3DERR_VERTEXBUFFERLOCKED";
+  case D3DERR_ZBUFFER_NOTPRESENT               : // (2070)
+    return "D3DERR_ZBUFFER_NOTPRESENT";
+  case D3DERR_STENCILBUFFER_NOTPRESENT         : // (2071)
+    return "D3DERR_STENCILBUFFER_NOTPRESENT";
+  case D3DERR_WRONGTEXTUREFORMAT               : // (2072)
+    return "D3DERR_WRONGTEXTUREFORMAT";
+  case D3DERR_UNSUPPORTEDCOLOROPERATION        : // (2073)
+    return "D3DERR_UNSUPPORTEDCOLOROPERATION";
+  case D3DERR_UNSUPPORTEDCOLORARG              : // (2074)
+    return "D3DERR_UNSUPPORTEDCOLORARG";
+  case D3DERR_UNSUPPORTEDALPHAOPERATION        : // (2075)
+    return "D3DERR_UNSUPPORTEDALPHAOPERATION";
+  case D3DERR_UNSUPPORTEDALPHAARG              : // (2076)
+    return "D3DERR_UNSUPPORTEDALPHAARG";
+  case D3DERR_TOOMANYOPERATIONS                : // (2077)
+    return "D3DERR_TOOMANYOPERATIONS";
+  case D3DERR_CONFLICTINGTEXTUREFILTER         : // (2078)
+    return "D3DERR_CONFLICTINGTEXTUREFILTER";
+  case D3DERR_UNSUPPORTEDFACTORVALUE           : // (2079)
+    return "D3DERR_UNSUPPORTEDFACTORVALUE";
+  case D3DERR_CONFLICTINGRENDERSTATE           : // (2081)
+    return "D3DERR_CONFLICTINGRENDERSTATE";
+  case D3DERR_UNSUPPORTEDTEXTUREFILTER         : // (2082)
+    return "D3DERR_UNSUPPORTEDTEXTUREFILTER";
+  case D3DERR_TOOMANYPRIMITIVES                : // (2083)
+    return "D3DERR_TOOMANYPRIMITIVES";
+  case D3DERR_INVALIDMATRIX                    : // (2084)
+    return "D3DERR_INVALIDMATRIX";
+  case D3DERR_TOOMANYVERTICES                  : // (2085)
+    return "D3DERR_TOOMANYVERTICES";
+  case D3DERR_CONFLICTINGTEXTUREPALETTE        : // (2086)
+    return "D3DERR_CONFLICTINGTEXTUREPALETTE";
+    //#if DX7
+  case D3DERR_VERTEXBUFFERUNLOCKFAILED         : // (2063)
+    return "D3DERR_VERTEXBUFFERUNLOCKFAILED";
+  case D3DERR_INVALIDSTATEBLOCK        : // (2100)
+    return "D3DERR_INVALIDSTATEBLOCK";
+  case D3DERR_INBEGINSTATEBLOCK        : // (2101)
+    return "D3DERR_INBEGINSTATEBLOCK";
+  case D3DERR_NOTINBEGINSTATEBLOCK     : // (2102)
+    return "D3DERR_NOTINBEGINSTATEBLOCK";
+    //case D3DERR_INOVERLAYSTATEBLOCK      : // (2103)
+    //  return "D3DERR_INOVERLAYSTATEBLOCK";
+  case DDERR_NOSTEREOHARDWARE       : // ( 181 )
+    return "DDERR_NOSTEREOHARDWARE      ";
+  case DDERR_NOSURFACELEFT              : // ( 182 )
+    return "DDERR_NOSURFACELEFT             ";
+  case DDERR_DDSCAPSCOMPLEXREQUIRED            : // ( 542 )
+    return "DDERR_DDSCAPSCOMPLEXREQUIRED";
+  case DDERR_NOTONMIPMAPSUBLEVEL               : // ( 603 )
+    return "DDERR_NOTONMIPMAPSUBLEVEL";
+  case DDERR_TESTFINISHED                      : // ( 692 )
+    return "DDERR_TESTFINISHED";
+  case DDERR_NEWMODE                           : // ( 693 )
+    return "DDERR_NEWMODE";
+    //#endif
+    //case D3DERR_COMMAND_UNPARSED              : // (3000)
+    /// return "case";//D3DERR_COMMAND_UNPARSED              : // (3000)
+
+  case DDERR_ALREADYINITIALIZED     : // ( 5 )
+    return "DDERR_ALREADYINITIALIZED        ";
+  case DDERR_CANNOTATTACHSURFACE        : // ( 10 )
+    return "DDERR_CANNOTATTACHSURFACE       ";
+  case DDERR_CANNOTDETACHSURFACE        : // ( 20 )
+    return "DDERR_CANNOTDETACHSURFACE       ";
+  case DDERR_CURRENTLYNOTAVAIL          : // ( 40 )
+    return "DDERR_CURRENTLYNOTAVAIL         ";
+  case DDERR_EXCEPTION              : // ( 55 )
+    return "DDERR_EXCEPTION             ";
+  case DDERR_HEIGHTALIGN            : // ( 90 )
+    return "DDERR_HEIGHTALIGN           ";
+  case DDERR_INCOMPATIBLEPRIMARY        : // ( 95 )
+    return "DDERR_INCOMPATIBLEPRIMARY       ";
+  case DDERR_INVALIDCAPS            : // ( 100 )
+    return "DDERR_INVALIDCAPS           ";
+  case DDERR_INVALIDCLIPLIST            : // ( 110 )
+    return "DDERR_INVALIDCLIPLIST           ";
+  case DDERR_INVALIDMODE            : // ( 120 )
+    return "DDERR_INVALIDMODE           ";
+  case DDERR_INVALIDOBJECT          : // ( 130 )
+    return "DDERR_INVALIDOBJECT         ";
+  case DDERR_INVALIDPIXELFORMAT     : // ( 145 )
+    return "DDERR_INVALIDPIXELFORMAT        ";
+  case DDERR_INVALIDRECT            : // ( 150 )
+    return "DDERR_INVALIDRECT           ";
+  case DDERR_LOCKEDSURFACES         : // ( 160 )
+    return "DDERR_LOCKEDSURFACES            ";
+  case DDERR_NO3D               : // ( 170 )
+    return "DDERR_NO3D              ";
+  case DDERR_NOALPHAHW              : // ( 180 )
+    return "DDERR_NOALPHAHW             ";
+  case DDERR_NOCLIPLIST         : // ( 205 )
+    return "DDERR_NOCLIPLIST            ";
+  case DDERR_NOCOLORCONVHW          : // ( 210 )
+    return "DDERR_NOCOLORCONVHW         ";
+  case DDERR_NOCOOPERATIVELEVELSET      : // ( 212 )
+    return "DDERR_NOCOOPERATIVELEVELSET     ";
+  case DDERR_NOCOLORKEY         : // ( 215 )
+    return "DDERR_NOCOLORKEY            ";
+  case DDERR_NOCOLORKEYHW           : // ( 220 )
+    return "DDERR_NOCOLORKEYHW          ";
+  case DDERR_NODIRECTDRAWSUPPORT        : // ( 222 )
+    return "DDERR_NODIRECTDRAWSUPPORT       ";
+  case DDERR_NOEXCLUSIVEMODE            : // ( 225 )
+    return "DDERR_NOEXCLUSIVEMODE           ";
+  case DDERR_NOFLIPHW               : // ( 230 )
+    return "DDERR_NOFLIPHW              ";
+  case DDERR_NOGDI              : // ( 240 )
+    return "DDERR_NOGDI             ";
+  case DDERR_NOMIRRORHW         : // ( 250 )
+    return "DDERR_NOMIRRORHW            ";
+  case DDERR_NOTFOUND               : // ( 255 )
+    return "DDERR_NOTFOUND              ";
+  case DDERR_NOOVERLAYHW            : // ( 260 )
+    return "DDERR_NOOVERLAYHW           ";
+  case DDERR_OVERLAPPINGRECTS           : // ( 270 )
+    return "DDERR_OVERLAPPINGRECTS          ";
+  case DDERR_NORASTEROPHW           : // ( 280 )
+    return "DDERR_NORASTEROPHW          ";
+  case DDERR_NOROTATIONHW           : // ( 290 )
+    return "DDERR_NOROTATIONHW          ";
+  case DDERR_NOSTRETCHHW            : // ( 310 )
+    return "DDERR_NOSTRETCHHW           ";
+  case DDERR_NOT4BITCOLOR           : // ( 316 )
+    return "DDERR_NOT4BITCOLOR          ";
+  case DDERR_NOT4BITCOLORINDEX          : // ( 317 )
+    return "DDERR_NOT4BITCOLORINDEX         ";
+  case DDERR_NOT8BITCOLOR           : // ( 320 )
+    return "DDERR_NOT8BITCOLOR          ";
+  case DDERR_NOTEXTUREHW            : // ( 330 )
+    return "DDERR_NOTEXTUREHW           ";
+  case DDERR_NOVSYNCHW              : // ( 335 )
+    return "DDERR_NOVSYNCHW             ";
+  case DDERR_NOZBUFFERHW            : // ( 340 )
+    return "DDERR_NOZBUFFERHW           ";
+  case DDERR_NOZOVERLAYHW           : // ( 350 )
+    return "DDERR_NOZOVERLAYHW          ";
+  case DDERR_OUTOFCAPS              : // ( 360 )
+    return "DDERR_OUTOFCAPS             ";
+  case DDERR_OUTOFVIDEOMEMORY           : // ( 380 )
+    return "DDERR_OUTOFVIDEOMEMORY          ";
+  case DDERR_OVERLAYCANTCLIP            : // ( 382 )
+    return "DDERR_OVERLAYCANTCLIP           ";
+  case DDERR_OVERLAYCOLORKEYONLYONEACTIVE   : // ( 384 )
+    return "DDERR_OVERLAYCOLORKEYONLYONEACTIVE  ";
+  case DDERR_PALETTEBUSY            : // ( 387 )
+    return "DDERR_PALETTEBUSY           ";
+  case DDERR_COLORKEYNOTSET         : // ( 400 )
+    return "DDERR_COLORKEYNOTSET            ";
+  case DDERR_SURFACEALREADYATTACHED     : // ( 410 )
+    return "DDERR_SURFACEALREADYATTACHED        ";
+  case DDERR_SURFACEALREADYDEPENDENT        : // ( 420 )
+    return "DDERR_SURFACEALREADYDEPENDENT       ";
+  case DDERR_SURFACEBUSY            : // ( 430 )
+    return "DDERR_SURFACEBUSY           ";
+  case DDERR_CANTLOCKSURFACE                   : // ( 435 )
+    return "DDERR_CANTLOCKSURFACE";
+  case DDERR_SURFACEISOBSCURED          : // ( 440 )
+    return "DDERR_SURFACEISOBSCURED         ";
+  case DDERR_SURFACELOST            : // ( 450 )
+    return "DDERR_SURFACELOST           ";
+  case DDERR_SURFACENOTATTACHED     : // ( 460 )
+    return "DDERR_SURFACENOTATTACHED        ";
+  case DDERR_TOOBIGHEIGHT           : // ( 470 )
+    return "DDERR_TOOBIGHEIGHT          ";
+  case DDERR_TOOBIGSIZE         : // ( 480 )
+    return "DDERR_TOOBIGSIZE            ";
+  case DDERR_TOOBIGWIDTH            : // ( 490 )
+    return "DDERR_TOOBIGWIDTH           ";
+  case DDERR_UNSUPPORTEDFORMAT          : // ( 510 )
+    return "DDERR_UNSUPPORTEDFORMAT         ";
+  case DDERR_UNSUPPORTEDMASK            : // ( 520 )
+    return "DDERR_UNSUPPORTEDMASK           ";
+  case DDERR_INVALIDSTREAM                     : // ( 521 )
+    return "DDERR_INVALIDSTREAM";
+  case DDERR_VERTICALBLANKINPROGRESS        : // ( 537 )
+    return "DDERR_VERTICALBLANKINPROGRESS       ";
+  case DDERR_WASSTILLDRAWING            : // ( 540 )
+    return "DDERR_WASSTILLDRAWING           ";
+  case DDERR_XALIGN             : // ( 560 )
+    return "DDERR_XALIGN                ";
+  case DDERR_INVALIDDIRECTDRAWGUID      : // ( 561 )
+    return "DDERR_INVALIDDIRECTDRAWGUID     ";
+  case DDERR_DIRECTDRAWALREADYCREATED       : // ( 562 )
+    return "DDERR_DIRECTDRAWALREADYCREATED      ";
+  case DDERR_NODIRECTDRAWHW         : // ( 563 )
+    return "DDERR_NODIRECTDRAWHW            ";
+  case DDERR_PRIMARYSURFACEALREADYEXISTS    : // ( 564 )
+    return "DDERR_PRIMARYSURFACEALREADYEXISTS   ";
+  case DDERR_NOEMULATION            : // ( 565 )
+    return "DDERR_NOEMULATION           ";
+  case DDERR_REGIONTOOSMALL         : // ( 566 )
+    return "DDERR_REGIONTOOSMALL            ";
+  case DDERR_CLIPPERISUSINGHWND     : // ( 567 )
+    return "DDERR_CLIPPERISUSINGHWND        ";
+  case DDERR_NOCLIPPERATTACHED          : // ( 568 )
+    return "DDERR_NOCLIPPERATTACHED         ";
+  case DDERR_NOHWND             : // ( 569 )
+    return "DDERR_NOHWND                ";
+  case DDERR_HWNDSUBCLASSED         : // ( 570 )
+    return "DDERR_HWNDSUBCLASSED            ";
+  case DDERR_HWNDALREADYSET         : // ( 571 )
+    return "DDERR_HWNDALREADYSET            ";
+  case DDERR_NOPALETTEATTACHED          : // ( 572 )
+    return "DDERR_NOPALETTEATTACHED         ";
+  case DDERR_NOPALETTEHW            : // ( 573 )
+    return "DDERR_NOPALETTEHW           ";
+  case DDERR_BLTFASTCANTCLIP            : // ( 574 )
+    return "DDERR_BLTFASTCANTCLIP           ";
+  case DDERR_NOBLTHW                : // ( 575 )
+    return "DDERR_NOBLTHW               ";
+  case DDERR_NODDROPSHW         : // ( 576 )
+    return "DDERR_NODDROPSHW            ";
+  case DDERR_OVERLAYNOTVISIBLE          : // ( 577 )
+    return "DDERR_OVERLAYNOTVISIBLE         ";
+  case DDERR_NOOVERLAYDEST          : // ( 578 )
+    return "DDERR_NOOVERLAYDEST         ";
+  case DDERR_INVALIDPOSITION            : // ( 579 )
+    return "DDERR_INVALIDPOSITION           ";
+  case DDERR_NOTAOVERLAYSURFACE     : // ( 580 )
+    return "DDERR_NOTAOVERLAYSURFACE        ";
+  case DDERR_EXCLUSIVEMODEALREADYSET        : // ( 581 )
+    return "DDERR_EXCLUSIVEMODEALREADYSET       ";
+  case DDERR_NOTFLIPPABLE           : // ( 582 )
+    return "DDERR_NOTFLIPPABLE          ";
+  case DDERR_CANTDUPLICATE          : // ( 583 )
+    return "DDERR_CANTDUPLICATE         ";
+  case DDERR_NOTLOCKED              : // ( 584 )
+    return "DDERR_NOTLOCKED             ";
+  case DDERR_CANTCREATEDC           : // ( 585 )
+    return "DDERR_CANTCREATEDC          ";
+  case DDERR_NODC               : // ( 586 )
+    return "DDERR_NODC              ";
+  case DDERR_WRONGMODE              : // ( 587 )
+    return "DDERR_WRONGMODE             ";
+  case DDERR_IMPLICITLYCREATED          : // ( 588 )
+    return "DDERR_IMPLICITLYCREATED         ";
+  case DDERR_NOTPALETTIZED          : // ( 589 )
+    return "DDERR_NOTPALETTIZED         ";
+  case DDERR_UNSUPPORTEDMODE            : // ( 590 )
+    return "DDERR_UNSUPPORTEDMODE           ";
+  case DDERR_NOMIPMAPHW         : // ( 591 )
+    return "DDERR_NOMIPMAPHW            ";
+  case DDERR_INVALIDSURFACETYPE                : // ( 592 )
+    return "DDERR_INVALIDSURFACETYPE";
+  case DDERR_NOOPTIMIZEHW                      : // ( 600 )
+    return "DDERR_NOOPTIMIZEHW";
+  case DDERR_NOTLOADED                         : // ( 601 )
+    return "DDERR_NOTLOADED";
+  case DDERR_NOFOCUSWINDOW                     : // ( 602 )
+    return "DDERR_NOFOCUSWINDOW";
+  case DDERR_DCALREADYCREATED           : // ( 620 )
+    return "DDERR_DCALREADYCREATED          ";
+  case DDERR_NONONLOCALVIDMEM                  : // ( 630 )
+    return "DDERR_NONONLOCALVIDMEM";
+  case DDERR_CANTPAGELOCK           : // ( 640 )
+    return "DDERR_CANTPAGELOCK          ";
+  case DDERR_CANTPAGEUNLOCK         : // ( 660 )
+    return "DDERR_CANTPAGEUNLOCK            ";
+  case DDERR_NOTPAGELOCKED          : // ( 680 )
+    return "DDERR_NOTPAGELOCKED         ";
+  case DDERR_MOREDATA                   : // ( 690 )
+    return "DDERR_MOREDATA                  ";
+  case DDERR_EXPIRED                           : // ( 691 )
+    return "DDERR_EXPIRED";
+  case DDERR_VIDEONOTACTIVE             : // ( 695 )
+    return "DDERR_VIDEONOTACTIVE            ";
+  case DDERR_DEVICEDOESNTOWNSURFACE         : // ( 699 )
+    return "DDERR_DEVICEDOESNTOWNSURFACE        ";
+  case DXFILEERR_BADOBJECT                 : // (850)
+    return "DXFILEERR_BADOBJECT";
+  case DXFILEERR_BADVALUE                  : // (851)
+    return "DXFILEERR_BADVALUE";
+  case DXFILEERR_BADTYPE                   : // (852)
+    return "DXFILEERR_BADTYPE";
+  case DXFILEERR_BADSTREAMHANDLE           : // (853)
+    return "DXFILEERR_BADSTREAMHANDLE";
+  case DXFILEERR_BADALLOC                  : // (854)
+    return "DXFILEERR_BADALLOC";
+  case DXFILEERR_NOTFOUND                  : // (855)
+    return "DXFILEERR_NOTFOUND";
+  case DXFILEERR_NOTDONEYET                : // (856)
+    return "DXFILEERR_NOTDONEYET";
+  case DXFILEERR_FILENOTFOUND              : // (857)
+    return "DXFILEERR_FILENOTFOUND";
+  case DXFILEERR_RESOURCENOTFOUND          : // (858)
+    return "DXFILEERR_RESOURCENOTFOUND";
+  case DXFILEERR_URLNOTFOUND               : // (859)
+    return "DXFILEERR_URLNOTFOUND";
+  case DXFILEERR_BADRESOURCE               : // (860)
+    return "DXFILEERR_BADRESOURCE";
+  case DXFILEERR_BADFILETYPE               : // (861)
+    return "DXFILEERR_BADFILETYPE";
+  case DXFILEERR_BADFILEVERSION            : // (862)
+    return "DXFILEERR_BADFILEVERSION";
+  case DXFILEERR_BADFILEFLOATSIZE          : // (863)
+    return "DXFILEERR_BADFILEFLOATSIZE";
+  case DXFILEERR_BADFILECOMPRESSIONTYPE    : // (864)
+    return "DXFILEERR_BADFILECOMPRESSIONTYPE";
+  case DXFILEERR_BADFILE                   : // (865)
+    return "DXFILEERR_BADFILE";
+  case DXFILEERR_PARSEERROR                : // (866)
+    return "DXFILEERR_PARSEERROR";
+  case DXFILEERR_NOTEMPLATE                : // (867)
+    return "DXFILEERR_NOTEMPLATE";
+  case DXFILEERR_BADARRAYSIZE              : // (868)
+    return "DXFILEERR_BADARRAYSIZE";
+  case DXFILEERR_BADDATAREFERENCE          : // (869)
+    return "DXFILEERR_BADDATAREFERENCE";
+  case DXFILEERR_INTERNALERROR             : // (870)
+    return "DXFILEERR_INTERNALERROR";
+  case DXFILEERR_NOMOREOBJECTS             : // (871)
+    return "DXFILEERR_NOMOREOBJECTS";
+  case DXFILEERR_BADINTRINSICS             : // (872)
+    return "DXFILEERR_BADINTRINSICS";
+  case DXFILEERR_NOMORESTREAMHANDLES       : // (873)
+    return "DXFILEERR_NOMORESTREAMHANDLES";
+  case DXFILEERR_NOMOREDATA                : // (874)
+    return "DXFILEERR_NOMOREDATA";
+  case DXFILEERR_BADCACHEFILE              : // (875)
+    return "DXFILEERR_BADCACHEFILE";
+  case DXFILEERR_NOINTERNET                : // (876)
+    return "DXFILEERR_NOINTERNET";
+
+  case E_UNEXPECTED                     :
+    return "E_UNEXPECTED                     ";
+  case E_NOTIMPL                        :
+    return "E_NOTIMPL                        ";
+  case E_OUTOFMEMORY                    :
+    return "E_OUTOFMEMORY                    ";
+  case E_INVALIDARG                     :
+    return "E_INVALIDARG or DDERR_INVALIDPARAMS";
+  case E_NOINTERFACE                    :
+    return "E_NOINTERFACE                    ";
+  case E_POINTER                        :
+    return "E_POINTER                        ";
+  case E_HANDLE                         :
+    return "E_HANDLE                         ";
+  case E_ABORT                          :
+    return "E_ABORT                          ";
+    //    case E_FAIL                           :
+    //    return "E_FAIL                           ";
+  case E_ACCESSDENIED                   :
+    return "E_ACCESSDENIED                   ";
+  case E_PENDING                        :
+    return "E_PENDING                        ";
+  case CO_E_INIT_TLS                    :
+    return "CO_E_INIT_TLS                    ";
+  case CO_E_INIT_SHARED_ALLOCATOR       :
+    return "CO_E_INIT_SHARED_ALLOCATOR       ";
+  case CO_E_INIT_MEMORY_ALLOCATOR       :
+    return "CO_E_INIT_MEMORY_ALLOCATOR       ";
+  case CO_E_INIT_CLASS_CACHE            :
+    return "CO_E_INIT_CLASS_CACHE            ";
+  case CO_E_INIT_RPC_CHANNEL            :
+    return "CO_E_INIT_RPC_CHANNEL            ";
+  case CO_E_INIT_TLS_SET_CHANNEL_CONTROL :
+    return "CO_E_INIT_TLS_SET_CHANNEL_CONTROL ";
+  case CO_E_INIT_TLS_CHANNEL_CONTROL    :
+    return "CO_E_INIT_TLS_CHANNEL_CONTROL    ";
+  case CO_E_INIT_UNACCEPTED_USER_ALLOCATOR :
+    return "CO_E_INIT_UNACCEPTED_USER_ALLOCATOR ";
+  case CO_E_INIT_SCM_MUTEX_EXISTS       :
+    return "CO_E_INIT_SCM_MUTEX_EXISTS       ";
+  case CO_E_INIT_SCM_FILE_MAPPING_EXISTS :
+    return "CO_E_INIT_SCM_FILE_MAPPING_EXISTS ";
+  case CO_E_INIT_SCM_MAP_VIEW_OF_FILE   :
+    return "CO_E_INIT_SCM_MAP_VIEW_OF_FILE   ";
+  case CO_E_INIT_SCM_EXEC_FAILURE       :
+    return "CO_E_INIT_SCM_EXEC_FAILURE       ";
+  case CO_E_INIT_ONLY_SINGLE_THREADED   :
+    return "CO_E_INIT_ONLY_SINGLE_THREADED   ";
+  case CO_E_CANT_REMOTE                 :
+    return "CO_E_CANT_REMOTE                 ";
+  case CO_E_BAD_SERVER_NAME             :
+    return "CO_E_BAD_SERVER_NAME             ";
+  case CO_E_WRONG_SERVER_IDENTITY       :
+    return "CO_E_WRONG_SERVER_IDENTITY       ";
+  case CO_E_OLE1DDE_DISABLED            :
+    return "CO_E_OLE1DDE_DISABLED            ";
+  case CO_E_RUNAS_SYNTAX                :
+    return "CO_E_RUNAS_SYNTAX                ";
+  case CO_E_CREATEPROCESS_FAILURE       :
+    return "CO_E_CREATEPROCESS_FAILURE       ";
+  case CO_E_RUNAS_CREATEPROCESS_FAILURE :
+    return "CO_E_RUNAS_CREATEPROCESS_FAILURE ";
+  case CO_E_RUNAS_LOGON_FAILURE         :
+    return "CO_E_RUNAS_LOGON_FAILURE         ";
+  case CO_E_LAUNCH_PERMSSION_DENIED     :
+    return "CO_E_LAUNCH_PERMSSION_DENIED     ";
+  case CO_E_START_SERVICE_FAILURE       :
+    return "CO_E_START_SERVICE_FAILURE       ";
+  case CO_E_REMOTE_COMMUNICATION_FAILURE :
+    return "CO_E_REMOTE_COMMUNICATION_FAILURE ";
+  case CO_E_SERVER_START_TIMEOUT        :
+    return "CO_E_SERVER_START_TIMEOUT        ";
+  case CO_E_CLSREG_INCONSISTENT         :
+    return "CO_E_CLSREG_INCONSISTENT         ";
+  case CO_E_IIDREG_INCONSISTENT         :
+    return "CO_E_IIDREG_INCONSISTENT         ";
+  case CO_E_NOT_SUPPORTED               :
+    return "CO_E_NOT_SUPPORTED               ";
+  case CO_E_RELOAD_DLL                  :
+    return "CO_E_RELOAD_DLL                  ";
+  case CO_E_MSI_ERROR                   :
+    return "CO_E_MSI_ERROR                   ";
+  case OLE_E_OLEVERB                    :
+    return "OLE_E_OLEVERB                    ";
+  case OLE_E_ADVF                       :
+    return "OLE_E_ADVF                       ";
+  case OLE_E_ENUM_NOMORE                :
+    return "OLE_E_ENUM_NOMORE                ";
+  case OLE_E_ADVISENOTSUPPORTED         :
+    return "OLE_E_ADVISENOTSUPPORTED         ";
+  case OLE_E_NOCONNECTION               :
+    return "OLE_E_NOCONNECTION               ";
+  case OLE_E_NOTRUNNING                 :
+    return "OLE_E_NOTRUNNING                 ";
+  case OLE_E_NOCACHE                    :
+    return "OLE_E_NOCACHE                    ";
+  case OLE_E_BLANK                      :
+    return "OLE_E_BLANK                      ";
+  case OLE_E_CLASSDIFF                  :
+    return "OLE_E_CLASSDIFF                  ";
+  case OLE_E_CANT_GETMONIKER            :
+    return "OLE_E_CANT_GETMONIKER            ";
+  case OLE_E_CANT_BINDTOSOURCE          :
+    return "OLE_E_CANT_BINDTOSOURCE          ";
+  case OLE_E_STATIC                     :
+    return "OLE_E_STATIC                     ";
+  case OLE_E_PROMPTSAVECANCELLED        :
+    return "OLE_E_PROMPTSAVECANCELLED        ";
+  case OLE_E_INVALIDRECT                :
+    return "OLE_E_INVALIDRECT                ";
+  case OLE_E_WRONGCOMPOBJ               :
+    return "OLE_E_WRONGCOMPOBJ               ";
+  case OLE_E_INVALIDHWND                :
+    return "OLE_E_INVALIDHWND                ";
+  case OLE_E_NOT_INPLACEACTIVE          :
+    return "OLE_E_NOT_INPLACEACTIVE          ";
+  case OLE_E_CANTCONVERT                :
+    return "OLE_E_CANTCONVERT                ";
+  case OLE_E_NOSTORAGE                  :
+    return "OLE_E_NOSTORAGE                  ";
+  case DV_E_FORMATETC                   :
+    return "DV_E_FORMATETC                   ";
+  case DV_E_DVTARGETDEVICE              :
+    return "DV_E_DVTARGETDEVICE              ";
+  case DV_E_STGMEDIUM                   :
+    return "DV_E_STGMEDIUM                   ";
+  case DV_E_STATDATA                    :
+    return "DV_E_STATDATA                    ";
+  case DV_E_LINDEX                      :
+    return "DV_E_LINDEX                      ";
+  case DV_E_TYMED                       :
+    return "DV_E_TYMED                       ";
+  case DV_E_CLIPFORMAT                  :
+    return "DV_E_CLIPFORMAT                  ";
+  case DV_E_DVASPECT                    :
+    return "DV_E_DVASPECT                    ";
+  case DV_E_DVTARGETDEVICE_SIZE         :
+    return "DV_E_DVTARGETDEVICE_SIZE         ";
+  case DV_E_NOIVIEWOBJECT               :
+    return "DV_E_NOIVIEWOBJECT               ";
+  case DRAGDROP_E_NOTREGISTERED         :
+    return "DRAGDROP_E_NOTREGISTERED         ";
+  case DRAGDROP_E_ALREADYREGISTERED     :
+    return "DRAGDROP_E_ALREADYREGISTERED     ";
+  case DRAGDROP_E_INVALIDHWND           :
+    return "DRAGDROP_E_INVALIDHWND           ";
+  case CLASS_E_NOAGGREGATION            :
+    return "CLASS_E_NOAGGREGATION            ";
+  case CLASS_E_CLASSNOTAVAILABLE        :
+    return "CLASS_E_CLASSNOTAVAILABLE        ";
+  case CLASS_E_NOTLICENSED              :
+    return "CLASS_E_NOTLICENSED              ";
+  case VIEW_E_DRAW                      :
+    return "VIEW_E_DRAW                      ";
+  case REGDB_E_READREGDB                :
+    return "REGDB_E_READREGDB                ";
+  case REGDB_E_WRITEREGDB               :
+    return "REGDB_E_WRITEREGDB               ";
+  case REGDB_E_KEYMISSING               :
+    return "REGDB_E_KEYMISSING               ";
+  case REGDB_E_INVALIDVALUE             :
+    return "REGDB_E_INVALIDVALUE             ";
+  case REGDB_E_CLASSNOTREG              :
+    return "REGDB_E_CLASSNOTREG              ";
+  case REGDB_E_IIDNOTREG                :
+    return "REGDB_E_IIDNOTREG                ";
+  case CAT_E_CATIDNOEXIST               :
+    return "CAT_E_CATIDNOEXIST               ";
+  case CAT_E_NODESCRIPTION              :
+    return "CAT_E_NODESCRIPTION              ";
+  case CS_E_PACKAGE_NOTFOUND            :
+    return "CS_E_PACKAGE_NOTFOUND            ";
+  case CS_E_NOT_DELETABLE               :
+    return "CS_E_NOT_DELETABLE               ";
+  case CS_E_CLASS_NOTFOUND              :
+    return "CS_E_CLASS_NOTFOUND              ";
+  case CS_E_INVALID_VERSION             :
+    return "CS_E_INVALID_VERSION             ";
+  case CS_E_NO_CLASSSTORE               :
+    return "CS_E_NO_CLASSSTORE               ";
+  case CACHE_E_NOCACHE_UPDATED          :
+    return "CACHE_E_NOCACHE_UPDATED          ";
+  case OLEOBJ_E_NOVERBS                 :
+    return "OLEOBJ_E_NOVERBS                 ";
+  case OLEOBJ_E_INVALIDVERB             :
+    return "OLEOBJ_E_INVALIDVERB             ";
+  case INPLACE_E_NOTUNDOABLE            :
+    return "INPLACE_E_NOTUNDOABLE            ";
+  case INPLACE_E_NOTOOLSPACE            :
+    return "INPLACE_E_NOTOOLSPACE            ";
+  case CONVERT10_E_OLESTREAM_GET        :
+    return "CONVERT10_E_OLESTREAM_GET        ";
+  case CONVERT10_E_OLESTREAM_PUT        :
+    return "CONVERT10_E_OLESTREAM_PUT        ";
+  case CONVERT10_E_OLESTREAM_FMT        :
+    return "CONVERT10_E_OLESTREAM_FMT        ";
+  case CONVERT10_E_OLESTREAM_BITMAP_TO_DIB :
+    return "CONVERT10_E_OLESTREAM_BITMAP_TO_DIB ";
+  case CONVERT10_E_STG_FMT              :
+    return "CONVERT10_E_STG_FMT              ";
+  case CONVERT10_E_STG_NO_STD_STREAM    :
+    return "CONVERT10_E_STG_NO_STD_STREAM    ";
+  case CONVERT10_E_STG_DIB_TO_BITMAP    :
+    return "CONVERT10_E_STG_DIB_TO_BITMAP    ";
+  case CLIPBRD_E_CANT_OPEN              :
+    return "CLIPBRD_E_CANT_OPEN              ";
+  case CLIPBRD_E_CANT_EMPTY             :
+    return "CLIPBRD_E_CANT_EMPTY             ";
+  case CLIPBRD_E_CANT_SET               :
+    return "CLIPBRD_E_CANT_SET               ";
+  case CLIPBRD_E_BAD_DATA               :
+    return "CLIPBRD_E_BAD_DATA               ";
+  case CLIPBRD_E_CANT_CLOSE             :
+    return "CLIPBRD_E_CANT_CLOSE             ";
+  case MK_E_CONNECTMANUALLY             :
+    return "MK_E_CONNECTMANUALLY             ";
+  case MK_E_EXCEEDEDDEADLINE            :
+    return "MK_E_EXCEEDEDDEADLINE            ";
+  case MK_E_NEEDGENERIC                 :
+    return "MK_E_NEEDGENERIC                 ";
+  case MK_E_UNAVAILABLE                 :
+    return "MK_E_UNAVAILABLE                 ";
+  case MK_E_SYNTAX                      :
+    return "MK_E_SYNTAX                      ";
+  case MK_E_NOOBJECT                    :
+    return "MK_E_NOOBJECT                    ";
+  case MK_E_INVALIDEXTENSION            :
+    return "MK_E_INVALIDEXTENSION            ";
+  case MK_E_INTERMEDIATEINTERFACENOTSUPPORTED :
+    return "MK_E_INTERMEDIATEINTERFACENOTSUPPORTED ";
+  case MK_E_NOTBINDABLE                 :
+    return "MK_E_NOTBINDABLE                 ";
+  case MK_E_NOTBOUND                    :
+    return "MK_E_NOTBOUND                    ";
+  case MK_E_CANTOPENFILE                :
+    return "MK_E_CANTOPENFILE                ";
+  case MK_E_MUSTBOTHERUSER              :
+    return "MK_E_MUSTBOTHERUSER              ";
+  case MK_E_NOINVERSE                   :
+    return "MK_E_NOINVERSE                   ";
+  case MK_E_NOSTORAGE                   :
+    return "MK_E_NOSTORAGE                   ";
+  case MK_E_NOPREFIX                    :
+    return "MK_E_NOPREFIX                    ";
+  case MK_E_ENUMERATION_FAILED          :
+    return "MK_E_ENUMERATION_FAILED          ";
+  case CO_E_NOTINITIALIZED              :
+    return "CO_E_NOTINITIALIZED              ";
+  case CO_E_ALREADYINITIALIZED          :
+    return "CO_E_ALREADYINITIALIZED          ";
+  case CO_E_CANTDETERMINECLASS          :
+    return "CO_E_CANTDETERMINECLASS          ";
+  case CO_E_CLASSSTRING                 :
+    return "CO_E_CLASSSTRING                 ";
+  case CO_E_IIDSTRING                   :
+    return "CO_E_IIDSTRING                   ";
+  case CO_E_APPNOTFOUND                 :
+    return "CO_E_APPNOTFOUND                 ";
+  case CO_E_APPSINGLEUSE                :
+    return "CO_E_APPSINGLEUSE                ";
+  case CO_E_ERRORINAPP                  :
+    return "CO_E_ERRORINAPP                  ";
+  case CO_E_DLLNOTFOUND                 :
+    return "CO_E_DLLNOTFOUND                 ";
+  case CO_E_ERRORINDLL                  :
+    return "CO_E_ERRORINDLL                  ";
+  case CO_E_WRONGOSFORAPP               :
+    return "CO_E_WRONGOSFORAPP               ";
+  case CO_E_OBJNOTREG                   :
+    return "CO_E_OBJNOTREG                   ";
+  case CO_E_OBJISREG                    :
+    return "CO_E_OBJISREG                    ";
+  case CO_E_OBJNOTCONNECTED             :
+    return "CO_E_OBJNOTCONNECTED             ";
+  case CO_E_APPDIDNTREG                 :
+    return "CO_E_APPDIDNTREG                 ";
+  case CO_E_RELEASED                    :
+    return "CO_E_RELEASED                    ";
+  case CO_E_FAILEDTOIMPERSONATE         :
+    return "CO_E_FAILEDTOIMPERSONATE         ";
+  case CO_E_FAILEDTOGETSECCTX           :
+    return "CO_E_FAILEDTOGETSECCTX           ";
+  case CO_E_FAILEDTOOPENTHREADTOKEN     :
+    return "CO_E_FAILEDTOOPENTHREADTOKEN     ";
+  case CO_E_FAILEDTOGETTOKENINFO        :
+    return "CO_E_FAILEDTOGETTOKENINFO        ";
+  case CO_E_TRUSTEEDOESNTMATCHCLIENT    :
+    return "CO_E_TRUSTEEDOESNTMATCHCLIENT    ";
+  case CO_E_FAILEDTOQUERYCLIENTBLANKET  :
+    return "CO_E_FAILEDTOQUERYCLIENTBLANKET  ";
+  case CO_E_FAILEDTOSETDACL             :
+    return "CO_E_FAILEDTOSETDACL             ";
+  case CO_E_ACCESSCHECKFAILED           :
+    return "CO_E_ACCESSCHECKFAILED           ";
+  case CO_E_NETACCESSAPIFAILED          :
+    return "CO_E_NETACCESSAPIFAILED          ";
+  case CO_E_WRONGTRUSTEENAMESYNTAX      :
+    return "CO_E_WRONGTRUSTEENAMESYNTAX      ";
+  case CO_E_INVALIDSID                  :
+    return "CO_E_INVALIDSID                  ";
+  case CO_E_CONVERSIONFAILED            :
+    return "CO_E_CONVERSIONFAILED            ";
+  case CO_E_NOMATCHINGSIDFOUND          :
+    return "CO_E_NOMATCHINGSIDFOUND          ";
+  case CO_E_LOOKUPACCSIDFAILED          :
+    return "CO_E_LOOKUPACCSIDFAILED          ";
+  case CO_E_NOMATCHINGNAMEFOUND         :
+    return "CO_E_NOMATCHINGNAMEFOUND         ";
+  case CO_E_LOOKUPACCNAMEFAILED         :
+    return "CO_E_LOOKUPACCNAMEFAILED         ";
+  case CO_E_SETSERLHNDLFAILED           :
+    return "CO_E_SETSERLHNDLFAILED           ";
+  case CO_E_FAILEDTOGETWINDIR           :
+    return "CO_E_FAILEDTOGETWINDIR           ";
+  case CO_E_PATHTOOLONG                 :
+    return "CO_E_PATHTOOLONG                 ";
+  case CO_E_FAILEDTOGENUUID             :
+    return "CO_E_FAILEDTOGENUUID             ";
+  case CO_E_FAILEDTOCREATEFILE          :
+    return "CO_E_FAILEDTOCREATEFILE          ";
+  case CO_E_FAILEDTOCLOSEHANDLE         :
+    return "CO_E_FAILEDTOCLOSEHANDLE         ";
+  case CO_E_EXCEEDSYSACLLIMIT           :
+    return "CO_E_EXCEEDSYSACLLIMIT           ";
+  case CO_E_ACESINWRONGORDER            :
+    return "CO_E_ACESINWRONGORDER            ";
+  case CO_E_INCOMPATIBLESTREAMVERSION   :
+    return "CO_E_INCOMPATIBLESTREAMVERSION   ";
+  case CO_E_FAILEDTOOPENPROCESSTOKEN    :
+    return "CO_E_FAILEDTOOPENPROCESSTOKEN    ";
+  case CO_E_DECODEFAILED                :
+    return "CO_E_DECODEFAILED                ";
+  case CO_E_ACNOTINITIALIZED            :
+    return "CO_E_ACNOTINITIALIZED            ";
+  case OLE_S_USEREG                     :
+    return "OLE_S_USEREG                     ";
+  case OLE_S_STATIC                     :
+    return "OLE_S_STATIC                     ";
+  case OLE_S_MAC_CLIPFORMAT             :
+    return "OLE_S_MAC_CLIPFORMAT             ";
+  case DRAGDROP_S_DROP                  :
+    return "DRAGDROP_S_DROP                  ";
+  case DRAGDROP_S_CANCEL                :
+    return "DRAGDROP_S_CANCEL                ";
+  case DRAGDROP_S_USEDEFAULTCURSORS     :
+    return "DRAGDROP_S_USEDEFAULTCURSORS     ";
+  case DATA_S_SAMEFORMATETC             :
+    return "DATA_S_SAMEFORMATETC             ";
+  case VIEW_S_ALREADY_FROZEN            :
+    return "VIEW_S_ALREADY_FROZEN            ";
+  case CACHE_S_FORMATETC_NOTSUPPORTED   :
+    return "CACHE_S_FORMATETC_NOTSUPPORTED   ";
+  case CACHE_S_SAMECACHE                :
+    return "CACHE_S_SAMECACHE                ";
+  case CACHE_S_SOMECACHES_NOTUPDATED    :
+    return "CACHE_S_SOMECACHES_NOTUPDATED    ";
+  case OLEOBJ_S_INVALIDVERB             :
+    return "OLEOBJ_S_INVALIDVERB             ";
+  case OLEOBJ_S_CANNOT_DOVERB_NOW       :
+    return "OLEOBJ_S_CANNOT_DOVERB_NOW       ";
+  case OLEOBJ_S_INVALIDHWND             :
+    return "OLEOBJ_S_INVALIDHWND             ";
+  case INPLACE_S_TRUNCATED              :
+    return "INPLACE_S_TRUNCATED              ";
+  case CONVERT10_S_NO_PRESENTATION      :
+    return "CONVERT10_S_NO_PRESENTATION      ";
+  case MK_S_REDUCED_TO_SELF             :
+    return "MK_S_REDUCED_TO_SELF             ";
+  case MK_S_ME                          :
+    return "MK_S_ME                          ";
+  case MK_S_HIM                         :
+    return "MK_S_HIM                         ";
+  case MK_S_US                          :
+    return "MK_S_US                          ";
+  case MK_S_MONIKERALREADYREGISTERED    :
+    return "MK_S_MONIKERALREADYREGISTERED    ";
+  case CO_E_CLASS_CREATE_FAILED         :
+    return "CO_E_CLASS_CREATE_FAILED         ";
+  case CO_E_SCM_ERROR                   :
+    return "CO_E_SCM_ERROR                   ";
+  case CO_E_SCM_RPC_FAILURE             :
+    return "CO_E_SCM_RPC_FAILURE             ";
+  case CO_E_BAD_PATH                    :
+    return "CO_E_BAD_PATH                    ";
+  case CO_E_SERVER_EXEC_FAILURE         :
+    return "CO_E_SERVER_EXEC_FAILURE         ";
+  case CO_E_OBJSRV_RPC_FAILURE          :
+    return "CO_E_OBJSRV_RPC_FAILURE          ";
+  case MK_E_NO_NORMALIZED               :
+    return "MK_E_NO_NORMALIZED               ";
+  case CO_E_SERVER_STOPPING             :
+    return "CO_E_SERVER_STOPPING             ";
+  case MEM_E_INVALID_ROOT               :
+    return "MEM_E_INVALID_ROOT               ";
+  case MEM_E_INVALID_LINK               :
+    return "MEM_E_INVALID_LINK               ";
+  case MEM_E_INVALID_SIZE               :
+    return "MEM_E_INVALID_SIZE               ";
+  case CO_S_NOTALLINTERFACES            :
+    return "CO_S_NOTALLINTERFACES            ";
+  case DISP_E_UNKNOWNINTERFACE          :
+    return "DISP_E_UNKNOWNINTERFACE          ";
+  case DISP_E_MEMBERNOTFOUND            :
+    return "DISP_E_MEMBERNOTFOUND            ";
+  case DISP_E_PARAMNOTFOUND             :
+    return "DISP_E_PARAMNOTFOUND             ";
+  case DISP_E_TYPEMISMATCH              :
+    return "DISP_E_TYPEMISMATCH              ";
+  case DISP_E_UNKNOWNNAME               :
+    return "DISP_E_UNKNOWNNAME               ";
+  case DISP_E_NONAMEDARGS               :
+    return "DISP_E_NONAMEDARGS               ";
+  case DISP_E_BADVARTYPE                :
+    return "DISP_E_BADVARTYPE                ";
+  case DISP_E_EXCEPTION                 :
+    return "DISP_E_EXCEPTION                 ";
+  case DISP_E_OVERFLOW                  :
+    return "DISP_E_OVERFLOW                  ";
+  case DISP_E_BADINDEX                  :
+    return "DISP_E_BADINDEX                  ";
+  case DISP_E_UNKNOWNLCID               :
+    return "DISP_E_UNKNOWNLCID               ";
+  case DISP_E_ARRAYISLOCKED             :
+    return "DISP_E_ARRAYISLOCKED             ";
+  case DISP_E_BADPARAMCOUNT             :
+    return "DISP_E_BADPARAMCOUNT             ";
+  case DISP_E_PARAMNOTOPTIONAL          :
+    return "DISP_E_PARAMNOTOPTIONAL          ";
+  case DISP_E_BADCALLEE                 :
+    return "DISP_E_BADCALLEE                 ";
+  case DISP_E_NOTACOLLECTION            :
+    return "DISP_E_NOTACOLLECTION            ";
+  case DISP_E_DIVBYZERO                 :
+    return "DISP_E_DIVBYZERO                 ";
+  case TYPE_E_BUFFERTOOSMALL            :
+    return "TYPE_E_BUFFERTOOSMALL            ";
+  case TYPE_E_FIELDNOTFOUND             :
+    return "TYPE_E_FIELDNOTFOUND             ";
+  case TYPE_E_INVDATAREAD               :
+    return "TYPE_E_INVDATAREAD               ";
+  case TYPE_E_UNSUPFORMAT               :
+    return "TYPE_E_UNSUPFORMAT               ";
+  case TYPE_E_REGISTRYACCESS            :
+    return "TYPE_E_REGISTRYACCESS            ";
+  case TYPE_E_LIBNOTREGISTERED          :
+    return "TYPE_E_LIBNOTREGISTERED          ";
+  case TYPE_E_UNDEFINEDTYPE             :
+    return "TYPE_E_UNDEFINEDTYPE             ";
+  case TYPE_E_QUALIFIEDNAMEDISALLOWED   :
+    return "TYPE_E_QUALIFIEDNAMEDISALLOWED   ";
+  case TYPE_E_INVALIDSTATE              :
+    return "TYPE_E_INVALIDSTATE              ";
+  case TYPE_E_WRONGTYPEKIND             :
+    return "TYPE_E_WRONGTYPEKIND             ";
+  case TYPE_E_ELEMENTNOTFOUND           :
+    return "TYPE_E_ELEMENTNOTFOUND           ";
+  case TYPE_E_AMBIGUOUSNAME             :
+    return "TYPE_E_AMBIGUOUSNAME             ";
+  case TYPE_E_NAMECONFLICT              :
+    return "TYPE_E_NAMECONFLICT              ";
+  case TYPE_E_UNKNOWNLCID               :
+    return "TYPE_E_UNKNOWNLCID               ";
+  case TYPE_E_DLLFUNCTIONNOTFOUND       :
+    return "TYPE_E_DLLFUNCTIONNOTFOUND       ";
+  case TYPE_E_BADMODULEKIND             :
+    return "TYPE_E_BADMODULEKIND             ";
+  case TYPE_E_SIZETOOBIG                :
+    return "TYPE_E_SIZETOOBIG                ";
+  case TYPE_E_DUPLICATEID               :
+    return "TYPE_E_DUPLICATEID               ";
+  case TYPE_E_INVALIDID                 :
+    return "TYPE_E_INVALIDID                 ";
+  case TYPE_E_TYPEMISMATCH              :
+    return "TYPE_E_TYPEMISMATCH              ";
+  case TYPE_E_OUTOFBOUNDS               :
+    return "TYPE_E_OUTOFBOUNDS               ";
+  case TYPE_E_IOERROR                   :
+    return "TYPE_E_IOERROR                   ";
+  case TYPE_E_CANTCREATETMPFILE         :
+    return "TYPE_E_CANTCREATETMPFILE         ";
+  case TYPE_E_CANTLOADLIBRARY           :
+    return "TYPE_E_CANTLOADLIBRARY           ";
+  case TYPE_E_INCONSISTENTPROPFUNCS     :
+    return "TYPE_E_INCONSISTENTPROPFUNCS     ";
+  case TYPE_E_CIRCULARTYPE              :
+    return "TYPE_E_CIRCULARTYPE              ";
+  case STG_E_INVALIDFUNCTION            :
+    return "STG_E_INVALIDFUNCTION            ";
+  case STG_E_FILENOTFOUND               :
+    return "STG_E_FILENOTFOUND               ";
+  case STG_E_PATHNOTFOUND               :
+    return "STG_E_PATHNOTFOUND               ";
+  case STG_E_TOOMANYOPENFILES           :
+    return "STG_E_TOOMANYOPENFILES           ";
+  case STG_E_ACCESSDENIED               :
+    return "STG_E_ACCESSDENIED               ";
+  case STG_E_INVALIDHANDLE              :
+    return "STG_E_INVALIDHANDLE              ";
+  case STG_E_INSUFFICIENTMEMORY         :
+    return "STG_E_INSUFFICIENTMEMORY         ";
+  case STG_E_INVALIDPOINTER             :
+    return "STG_E_INVALIDPOINTER             ";
+  case STG_E_NOMOREFILES                :
+    return "STG_E_NOMOREFILES                ";
+  case STG_E_DISKISWRITEPROTECTED       :
+    return "STG_E_DISKISWRITEPROTECTED       ";
+  case STG_E_SEEKERROR                  :
+    return "STG_E_SEEKERROR                  ";
+  case STG_E_WRITEFAULT                 :
+    return "STG_E_WRITEFAULT                 ";
+  case STG_E_READFAULT                  :
+    return "STG_E_READFAULT                  ";
+  case STG_E_SHAREVIOLATION             :
+    return "STG_E_SHAREVIOLATION             ";
+  case STG_E_LOCKVIOLATION              :
+    return "STG_E_LOCKVIOLATION              ";
+  case STG_E_FILEALREADYEXISTS          :
+    return "STG_E_FILEALREADYEXISTS          ";
+  case STG_E_INVALIDPARAMETER           :
+    return "STG_E_INVALIDPARAMETER           ";
+  case STG_E_MEDIUMFULL                 :
+    return "STG_E_MEDIUMFULL                 ";
+  case STG_E_PROPSETMISMATCHED          :
+    return "STG_E_PROPSETMISMATCHED          ";
+  case STG_E_ABNORMALAPIEXIT            :
+    return "STG_E_ABNORMALAPIEXIT            ";
+  case STG_E_INVALIDHEADER              :
+    return "STG_E_INVALIDHEADER              ";
+  case STG_E_INVALIDNAME                :
+    return "STG_E_INVALIDNAME                ";
+  case STG_E_UNKNOWN                    :
+    return "STG_E_UNKNOWN                    ";
+  case STG_E_UNIMPLEMENTEDFUNCTION      :
+    return "STG_E_UNIMPLEMENTEDFUNCTION      ";
+  case STG_E_INVALIDFLAG                :
+    return "STG_E_INVALIDFLAG                ";
+  case STG_E_INUSE                      :
+    return "STG_E_INUSE                      ";
+  case STG_E_NOTCURRENT                 :
+    return "STG_E_NOTCURRENT                 ";
+  case STG_E_REVERTED                   :
+    return "STG_E_REVERTED                   ";
+  case STG_E_CANTSAVE                   :
+    return "STG_E_CANTSAVE                   ";
+  case STG_E_OLDFORMAT                  :
+    return "STG_E_OLDFORMAT                  ";
+  case STG_E_OLDDLL                     :
+    return "STG_E_OLDDLL                     ";
+  case STG_E_SHAREREQUIRED              :
+    return "STG_E_SHAREREQUIRED              ";
+  case STG_E_NOTFILEBASEDSTORAGE        :
+    return "STG_E_NOTFILEBASEDSTORAGE        ";
+  case STG_E_EXTANTMARSHALLINGS         :
+    return "STG_E_EXTANTMARSHALLINGS         ";
+  case STG_E_DOCFILECORRUPT             :
+    return "STG_E_DOCFILECORRUPT             ";
+  case STG_E_BADBASEADDRESS             :
+    return "STG_E_BADBASEADDRESS             ";
+  case STG_E_INCOMPLETE                 :
+    return "STG_E_INCOMPLETE                 ";
+  case STG_E_TERMINATED                 :
+    return "STG_E_TERMINATED                 ";
+  case STG_S_CONVERTED                  :
+    return "STG_S_CONVERTED                  ";
+  case STG_S_BLOCK                      :
+    return "STG_S_BLOCK                      ";
+  case STG_S_RETRYNOW                   :
+    return "STG_S_RETRYNOW                   ";
+  case STG_S_MONITORING                 :
+    return "STG_S_MONITORING                 ";
+  case STG_S_MULTIPLEOPENS              :
+    return "STG_S_MULTIPLEOPENS              ";
+  case STG_S_CONSOLIDATIONFAILED        :
+    return "STG_S_CONSOLIDATIONFAILED        ";
+  case STG_S_CANNOTCONSOLIDATE          :
+    return "STG_S_CANNOTCONSOLIDATE          ";
+  case RPC_E_CALL_REJECTED              :
+    return "RPC_E_CALL_REJECTED              ";
+  case RPC_E_CALL_CANCELED              :
+    return "RPC_E_CALL_CANCELED              ";
+  case RPC_E_CANTPOST_INSENDCALL        :
+    return "RPC_E_CANTPOST_INSENDCALL        ";
+  case RPC_E_CANTCALLOUT_INASYNCCALL    :
+    return "RPC_E_CANTCALLOUT_INASYNCCALL    ";
+  case RPC_E_CANTCALLOUT_INEXTERNALCALL :
+    return "RPC_E_CANTCALLOUT_INEXTERNALCALL ";
+  case RPC_E_CONNECTION_TERMINATED      :
+    return "RPC_E_CONNECTION_TERMINATED      ";
+  case RPC_E_SERVER_DIED                :
+    return "RPC_E_SERVER_DIED                ";
+  case RPC_E_CLIENT_DIED                :
+    return "RPC_E_CLIENT_DIED                ";
+  case RPC_E_INVALID_DATAPACKET         :
+    return "RPC_E_INVALID_DATAPACKET         ";
+  case RPC_E_CANTTRANSMIT_CALL          :
+    return "RPC_E_CANTTRANSMIT_CALL          ";
+  case RPC_E_CLIENT_CANTMARSHAL_DATA    :
+    return "RPC_E_CLIENT_CANTMARSHAL_DATA    ";
+  case RPC_E_CLIENT_CANTUNMARSHAL_DATA  :
+    return "RPC_E_CLIENT_CANTUNMARSHAL_DATA  ";
+  case RPC_E_SERVER_CANTMARSHAL_DATA    :
+    return "RPC_E_SERVER_CANTMARSHAL_DATA    ";
+  case RPC_E_SERVER_CANTUNMARSHAL_DATA  :
+    return "RPC_E_SERVER_CANTUNMARSHAL_DATA  ";
+  case RPC_E_INVALID_DATA               :
+    return "RPC_E_INVALID_DATA               ";
+  case RPC_E_INVALID_PARAMETER          :
+    return "RPC_E_INVALID_PARAMETER          ";
+  case RPC_E_CANTCALLOUT_AGAIN          :
+    return "RPC_E_CANTCALLOUT_AGAIN          ";
+  case RPC_E_SERVER_DIED_DNE            :
+    return "RPC_E_SERVER_DIED_DNE            ";
+  case RPC_E_SYS_CALL_FAILED            :
+    return "RPC_E_SYS_CALL_FAILED            ";
+  case RPC_E_OUT_OF_RESOURCES           :
+    return "RPC_E_OUT_OF_RESOURCES           ";
+  case RPC_E_ATTEMPTED_MULTITHREAD      :
+    return "RPC_E_ATTEMPTED_MULTITHREAD      ";
+  case RPC_E_NOT_REGISTERED             :
+    return "RPC_E_NOT_REGISTERED             ";
+  case RPC_E_FAULT                      :
+    return "RPC_E_FAULT                      ";
+  case RPC_E_SERVERFAULT                :
+    return "RPC_E_SERVERFAULT                ";
+  case RPC_E_CHANGED_MODE               :
+    return "RPC_E_CHANGED_MODE               ";
+  case RPC_E_INVALIDMETHOD              :
+    return "RPC_E_INVALIDMETHOD              ";
+  case RPC_E_DISCONNECTED               :
+    return "RPC_E_DISCONNECTED               ";
+  case RPC_E_RETRY                      :
+    return "RPC_E_RETRY                      ";
+  case RPC_E_SERVERCALL_RETRYLATER      :
+    return "RPC_E_SERVERCALL_RETRYLATER      ";
+  case RPC_E_SERVERCALL_REJECTED        :
+    return "RPC_E_SERVERCALL_REJECTED        ";
+  case RPC_E_INVALID_CALLDATA           :
+    return "RPC_E_INVALID_CALLDATA           ";
+  case RPC_E_CANTCALLOUT_ININPUTSYNCCALL :
+    return "RPC_E_CANTCALLOUT_ININPUTSYNCCALL ";
+  case RPC_E_WRONG_THREAD               :
+    return "RPC_E_WRONG_THREAD               ";
+  case RPC_E_THREAD_NOT_INIT            :
+    return "RPC_E_THREAD_NOT_INIT            ";
+  case RPC_E_VERSION_MISMATCH           :
+    return "RPC_E_VERSION_MISMATCH           ";
+  case RPC_E_INVALID_HEADER             :
+    return "RPC_E_INVALID_HEADER             ";
+  case RPC_E_INVALID_EXTENSION          :
+    return "RPC_E_INVALID_EXTENSION          ";
+  case RPC_E_INVALID_IPID               :
+    return "RPC_E_INVALID_IPID               ";
+  case RPC_E_INVALID_OBJECT             :
+    return "RPC_E_INVALID_OBJECT             ";
+  case RPC_S_CALLPENDING                :
+    return "RPC_S_CALLPENDING                ";
+  case RPC_S_WAITONTIMER                :
+    return "RPC_S_WAITONTIMER                ";
+  case RPC_E_CALL_COMPLETE              :
+    return "RPC_E_CALL_COMPLETE              ";
+  case RPC_E_UNSECURE_CALL              :
+    return "RPC_E_UNSECURE_CALL              ";
+  case RPC_E_TOO_LATE                   :
+    return "RPC_E_TOO_LATE                   ";
+  case RPC_E_NO_GOOD_SECURITY_PACKAGES  :
+    return "RPC_E_NO_GOOD_SECURITY_PACKAGES  ";
+  case RPC_E_ACCESS_DENIED              :
+    return "RPC_E_ACCESS_DENIED              ";
+  case RPC_E_REMOTE_DISABLED            :
+    return "RPC_E_REMOTE_DISABLED            ";
+  case RPC_E_INVALID_OBJREF             :
+    return "RPC_E_INVALID_OBJREF             ";
+  case RPC_E_NO_CONTEXT                 :
+    return "RPC_E_NO_CONTEXT                 ";
+  case RPC_E_TIMEOUT                    :
+    return "RPC_E_TIMEOUT                    ";
+  case RPC_E_NO_SYNC                    :
+    return "RPC_E_NO_SYNC                    ";
+  case RPC_E_UNEXPECTED                 :
+    return "RPC_E_UNEXPECTED                 ";
+  case NTE_BAD_UID                      :
+    return "NTE_BAD_UID                      ";
+  case NTE_BAD_HASH                     :
+    return "NTE_BAD_HASH                     ";
+    //case NTE_BAD_HASH                     :
+    //return "NTE_BAD_HASH                     ";
+  case NTE_BAD_KEY                      :
+    return "NTE_BAD_KEY                      ";
+  case NTE_BAD_LEN                      :
+    return "NTE_BAD_LEN                      ";
+  case NTE_BAD_DATA                     :
+    return "NTE_BAD_DATA                     ";
+  case NTE_BAD_SIGNATURE                :
+    return "NTE_BAD_SIGNATURE                ";
+  case NTE_BAD_VER                      :
+    return "NTE_BAD_VER                      ";
+  case NTE_BAD_ALGID                    :
+    return "NTE_BAD_ALGID                    ";
+  case NTE_BAD_FLAGS                    :
+    return "NTE_BAD_FLAGS                    ";
+  case NTE_BAD_TYPE                     :
+    return "NTE_BAD_TYPE                     ";
+  case NTE_BAD_KEY_STATE                :
+    return "NTE_BAD_KEY_STATE                ";
+  case NTE_BAD_HASH_STATE               :
+    return "NTE_BAD_HASH_STATE               ";
+  case NTE_NO_KEY                       :
+    return "NTE_NO_KEY                       ";
+  case NTE_NO_MEMORY                    :
+    return "NTE_NO_MEMORY                    ";
+  case NTE_EXISTS                       :
+    return "NTE_EXISTS                       ";
+  case NTE_PERM                         :
+    return "NTE_PERM                         ";
+  case NTE_NOT_FOUND                    :
+    return "NTE_NOT_FOUND                    ";
+  case NTE_DOUBLE_ENCRYPT               :
+    return "NTE_DOUBLE_ENCRYPT               ";
+  case NTE_BAD_PROVIDER                 :
+    return "NTE_BAD_PROVIDER                 ";
+  case NTE_BAD_PROV_TYPE                :
+    return "NTE_BAD_PROV_TYPE                ";
+  case NTE_BAD_PUBLIC_KEY               :
+    return "NTE_BAD_PUBLIC_KEY               ";
+  case NTE_BAD_KEYSET                   :
+    return "NTE_BAD_KEYSET                   ";
+  case NTE_PROV_TYPE_NOT_DEF            :
+    return "NTE_PROV_TYPE_NOT_DEF            ";
+  case NTE_PROV_TYPE_ENTRY_BAD          :
+    return "NTE_PROV_TYPE_ENTRY_BAD          ";
+  case NTE_KEYSET_NOT_DEF               :
+    return "NTE_KEYSET_NOT_DEF               ";
+  case NTE_KEYSET_ENTRY_BAD             :
+    return "NTE_KEYSET_ENTRY_BAD             ";
+  case NTE_PROV_TYPE_NO_MATCH           :
+    return "NTE_PROV_TYPE_NO_MATCH           ";
+  case NTE_SIGNATURE_FILE_BAD           :
+    return "NTE_SIGNATURE_FILE_BAD           ";
+  case NTE_PROVIDER_DLL_FAIL            :
+    return "NTE_PROVIDER_DLL_FAIL            ";
+  case NTE_PROV_DLL_NOT_FOUND           :
+    return "NTE_PROV_DLL_NOT_FOUND           ";
+  case NTE_BAD_KEYSET_PARAM             :
+    return "NTE_BAD_KEYSET_PARAM             ";
+  case NTE_FAIL                         :
+    return "NTE_FAIL                         ";
+  case NTE_SYS_ERR                      :
+    return "NTE_SYS_ERR                      ";
+  case CRYPT_E_MSG_ERROR                :
+    return "CRYPT_E_MSG_ERROR                ";
+  case CRYPT_E_UNKNOWN_ALGO             :
+    return "CRYPT_E_UNKNOWN_ALGO             ";
+  case CRYPT_E_OID_FORMAT               :
+    return "CRYPT_E_OID_FORMAT               ";
+  case CRYPT_E_INVALID_MSG_TYPE         :
+    return "CRYPT_E_INVALID_MSG_TYPE         ";
+  case CRYPT_E_UNEXPECTED_ENCODING      :
+    return "CRYPT_E_UNEXPECTED_ENCODING      ";
+  case CRYPT_E_AUTH_ATTR_MISSING        :
+    return "CRYPT_E_AUTH_ATTR_MISSING        ";
+  case CRYPT_E_HASH_VALUE               :
+    return "CRYPT_E_HASH_VALUE               ";
+  case CRYPT_E_INVALID_INDEX            :
+    return "CRYPT_E_INVALID_INDEX            ";
+  case CRYPT_E_ALREADY_DECRYPTED        :
+    return "CRYPT_E_ALREADY_DECRYPTED        ";
+  case CRYPT_E_NOT_DECRYPTED            :
+    return "CRYPT_E_NOT_DECRYPTED            ";
+  case CRYPT_E_RECIPIENT_NOT_FOUND      :
+    return "CRYPT_E_RECIPIENT_NOT_FOUND      ";
+  case CRYPT_E_CONTROL_TYPE             :
+    return "CRYPT_E_CONTROL_TYPE             ";
+  case CRYPT_E_ISSUER_SERIALNUMBER      :
+    return "CRYPT_E_ISSUER_SERIALNUMBER      ";
+  case CRYPT_E_SIGNER_NOT_FOUND         :
+    return "CRYPT_E_SIGNER_NOT_FOUND         ";
+  case CRYPT_E_ATTRIBUTES_MISSING       :
+    return "CRYPT_E_ATTRIBUTES_MISSING       ";
+  case CRYPT_E_STREAM_MSG_NOT_READY     :
+    return "CRYPT_E_STREAM_MSG_NOT_READY     ";
+  case CRYPT_E_STREAM_INSUFFICIENT_DATA :
+    return "CRYPT_E_STREAM_INSUFFICIENT_DATA ";
+  case CRYPT_E_BAD_LEN                  :
+    return "CRYPT_E_BAD_LEN                  ";
+  case CRYPT_E_BAD_ENCODE               :
+    return "CRYPT_E_BAD_ENCODE               ";
+  case CRYPT_E_FILE_ERROR               :
+    return "CRYPT_E_FILE_ERROR               ";
+  case CRYPT_E_NOT_FOUND                :
+    return "CRYPT_E_NOT_FOUND                ";
+  case CRYPT_E_EXISTS                   :
+    return "CRYPT_E_EXISTS                   ";
+  case CRYPT_E_NO_PROVIDER              :
+    return "CRYPT_E_NO_PROVIDER              ";
+  case CRYPT_E_SELF_SIGNED              :
+    return "CRYPT_E_SELF_SIGNED              ";
+  case CRYPT_E_DELETED_PREV             :
+    return "CRYPT_E_DELETED_PREV             ";
+  case CRYPT_E_NO_MATCH                 :
+    return "CRYPT_E_NO_MATCH                 ";
+  case CRYPT_E_UNEXPECTED_MSG_TYPE      :
+    return "CRYPT_E_UNEXPECTED_MSG_TYPE      ";
+  case CRYPT_E_NO_KEY_PROPERTY          :
+    return "CRYPT_E_NO_KEY_PROPERTY          ";
+  case CRYPT_E_NO_DECRYPT_CERT          :
+    return "CRYPT_E_NO_DECRYPT_CERT          ";
+  case CRYPT_E_BAD_MSG                  :
+    return "CRYPT_E_BAD_MSG                  ";
+  case CRYPT_E_NO_SIGNER                :
+    return "CRYPT_E_NO_SIGNER                ";
+  case CRYPT_E_PENDING_CLOSE            :
+    return "CRYPT_E_PENDING_CLOSE            ";
+  case CRYPT_E_REVOKED                  :
+    return "CRYPT_E_REVOKED                  ";
+  case CRYPT_E_NO_REVOCATION_DLL        :
+    return "CRYPT_E_NO_REVOCATION_DLL        ";
+  case CRYPT_E_NO_REVOCATION_CHECK      :
+    return "CRYPT_E_NO_REVOCATION_CHECK      ";
+  case CRYPT_E_REVOCATION_OFFLINE       :
+    return "CRYPT_E_REVOCATION_OFFLINE       ";
+  case CRYPT_E_NOT_IN_REVOCATION_DATABASE :
+    return "CRYPT_E_NOT_IN_REVOCATION_DATABASE ";
+  case CRYPT_E_INVALID_NUMERIC_STRING   :
+    return "CRYPT_E_INVALID_NUMERIC_STRING   ";
+  case CRYPT_E_INVALID_PRINTABLE_STRING :
+    return "CRYPT_E_INVALID_PRINTABLE_STRING ";
+  case CRYPT_E_INVALID_IA5_STRING       :
+    return "CRYPT_E_INVALID_IA5_STRING       ";
+  case CRYPT_E_INVALID_X500_STRING      :
+    return "CRYPT_E_INVALID_X500_STRING      ";
+  case CRYPT_E_NOT_CHAR_STRING          :
+    return "CRYPT_E_NOT_CHAR_STRING          ";
+  case CRYPT_E_FILERESIZED              :
+    return "CRYPT_E_FILERESIZED              ";
+  case CRYPT_E_SECURITY_SETTINGS        :
+    return "CRYPT_E_SECURITY_SETTINGS        ";
+  case CRYPT_E_NO_VERIFY_USAGE_DLL      :
+    return "CRYPT_E_NO_VERIFY_USAGE_DLL      ";
+  case CRYPT_E_NO_VERIFY_USAGE_CHECK    :
+    return "CRYPT_E_NO_VERIFY_USAGE_CHECK    ";
+  case CRYPT_E_VERIFY_USAGE_OFFLINE     :
+    return "CRYPT_E_VERIFY_USAGE_OFFLINE     ";
+  case CRYPT_E_NOT_IN_CTL               :
+    return "CRYPT_E_NOT_IN_CTL               ";
+  case CRYPT_E_NO_TRUSTED_SIGNER        :
+    return "CRYPT_E_NO_TRUSTED_SIGNER        ";
+  case CRYPT_E_OSS_ERROR                :
+    return "CRYPT_E_OSS_ERROR                ";
+  case CERTSRV_E_BAD_REQUESTSUBJECT     :
+    return "CERTSRV_E_BAD_REQUESTSUBJECT     ";
+  case CERTSRV_E_NO_REQUEST             :
+    return "CERTSRV_E_NO_REQUEST             ";
+  case CERTSRV_E_BAD_REQUESTSTATUS      :
+    return "CERTSRV_E_BAD_REQUESTSTATUS      ";
+  case CERTSRV_E_PROPERTY_EMPTY         :
+    return "CERTSRV_E_PROPERTY_EMPTY         ";
+    //case CERTDB_E_JET_ERROR               :
+    //return "CERTDB_E_JET_ERROR               ";
+  case TRUST_E_SYSTEM_ERROR             :
+    return "TRUST_E_SYSTEM_ERROR             ";
+  case TRUST_E_NO_SIGNER_CERT           :
+    return "TRUST_E_NO_SIGNER_CERT           ";
+  case TRUST_E_COUNTER_SIGNER           :
+    return "TRUST_E_COUNTER_SIGNER           ";
+  case TRUST_E_CERT_SIGNATURE           :
+    return "TRUST_E_CERT_SIGNATURE           ";
+  case TRUST_E_TIME_STAMP               :
+    return "TRUST_E_TIME_STAMP               ";
+  case TRUST_E_BAD_DIGEST               :
+    return "TRUST_E_BAD_DIGEST               ";
+  case TRUST_E_BASIC_CONSTRAINTS        :
+    return "TRUST_E_BASIC_CONSTRAINTS        ";
+  case TRUST_E_FINANCIAL_CRITERIA       :
+    return "TRUST_E_FINANCIAL_CRITERIA       ";
+  case TRUST_E_PROVIDER_UNKNOWN         :
+    return "TRUST_E_PROVIDER_UNKNOWN         ";
+  case TRUST_E_ACTION_UNKNOWN           :
+    return "TRUST_E_ACTION_UNKNOWN           ";
+  case TRUST_E_SUBJECT_FORM_UNKNOWN     :
+    return "TRUST_E_SUBJECT_FORM_UNKNOWN     ";
+  case TRUST_E_SUBJECT_NOT_TRUSTED      :
+    return "TRUST_E_SUBJECT_NOT_TRUSTED      ";
+  case DIGSIG_E_ENCODE                  :
+    return "DIGSIG_E_ENCODE                  ";
+  case DIGSIG_E_DECODE                  :
+    return "DIGSIG_E_DECODE                  ";
+  case DIGSIG_E_EXTENSIBILITY           :
+    return "DIGSIG_E_EXTENSIBILITY           ";
+  case DIGSIG_E_CRYPTO                  :
+    return "DIGSIG_E_CRYPTO                  ";
+  case PERSIST_E_SIZEDEFINITE           :
+    return "PERSIST_E_SIZEDEFINITE           ";
+  case PERSIST_E_SIZEINDEFINITE         :
+    return "PERSIST_E_SIZEINDEFINITE         ";
+  case PERSIST_E_NOTSELFSIZING          :
+    return "PERSIST_E_NOTSELFSIZING          ";
+  case TRUST_E_NOSIGNATURE              :
+    return "TRUST_E_NOSIGNATURE              ";
+  case CERT_E_EXPIRED                   :
+    return "CERT_E_EXPIRED                   ";
+  case CERT_E_VALIDITYPERIODNESTING     :
+    return "CERT_E_VALIDITYPERIODNESTING     ";
+  case CERT_E_ROLE                      :
+    return "CERT_E_ROLE                      ";
+  case CERT_E_PATHLENCONST              :
+    return "CERT_E_PATHLENCONST              ";
+  case CERT_E_CRITICAL                  :
+    return "CERT_E_CRITICAL                  ";
+  case CERT_E_PURPOSE                   :
+    return "CERT_E_PURPOSE                   ";
+  case CERT_E_ISSUERCHAINING            :
+    return "CERT_E_ISSUERCHAINING            ";
+  case CERT_E_MALFORMED                 :
+    return "CERT_E_MALFORMED                 ";
+  case CERT_E_UNTRUSTEDROOT             :
+    return "CERT_E_UNTRUSTEDROOT             ";
+  case CERT_E_CHAINING                  :
+    return "CERT_E_CHAINING                  ";
+  case TRUST_E_FAIL                     :
+    return "TRUST_E_FAIL                     ";
+  case CERT_E_REVOKED                   :
+    return "CERT_E_REVOKED                   ";
+  case CERT_E_UNTRUSTEDTESTROOT         :
+    return "CERT_E_UNTRUSTEDTESTROOT         ";
+  case CERT_E_REVOCATION_FAILURE        :
+    return "CERT_E_REVOCATION_FAILURE        ";
+  case CERT_E_CN_NO_MATCH               :
+    return "CERT_E_CN_NO_MATCH               ";
+  case CERT_E_WRONG_USAGE               :
+    return "CERT_E_WRONG_USAGE               ";
+  case SPAPI_E_EXPECTED_SECTION_NAME    :
+    return "SPAPI_E_EXPECTED_SECTION_NAME    ";
+  case SPAPI_E_BAD_SECTION_NAME_LINE    :
+    return "SPAPI_E_BAD_SECTION_NAME_LINE    ";
+  case SPAPI_E_SECTION_NAME_TOO_LONG    :
+    return "SPAPI_E_SECTION_NAME_TOO_LONG    ";
+  case SPAPI_E_GENERAL_SYNTAX           :
+    return "SPAPI_E_GENERAL_SYNTAX           ";
+  case SPAPI_E_WRONG_INF_STYLE          :
+    return "SPAPI_E_WRONG_INF_STYLE          ";
+  case SPAPI_E_SECTION_NOT_FOUND        :
+    return "SPAPI_E_SECTION_NOT_FOUND        ";
+  case SPAPI_E_LINE_NOT_FOUND           :
+    return "SPAPI_E_LINE_NOT_FOUND           ";
+  case SPAPI_E_NO_ASSOCIATED_CLASS      :
+    return "SPAPI_E_NO_ASSOCIATED_CLASS      ";
+  case SPAPI_E_CLASS_MISMATCH           :
+    return "SPAPI_E_CLASS_MISMATCH           ";
+  case SPAPI_E_DUPLICATE_FOUND          :
+    return "SPAPI_E_DUPLICATE_FOUND          ";
+  case SPAPI_E_NO_DRIVER_SELECTED       :
+    return "SPAPI_E_NO_DRIVER_SELECTED       ";
+  case SPAPI_E_KEY_DOES_NOT_EXIST       :
+    return "SPAPI_E_KEY_DOES_NOT_EXIST       ";
+  case SPAPI_E_INVALID_DEVINST_NAME     :
+    return "SPAPI_E_INVALID_DEVINST_NAME     ";
+  case SPAPI_E_INVALID_CLASS            :
+    return "SPAPI_E_INVALID_CLASS            ";
+  case SPAPI_E_DEVINST_ALREADY_EXISTS   :
+    return "SPAPI_E_DEVINST_ALREADY_EXISTS   ";
+  case SPAPI_E_DEVINFO_NOT_REGISTERED   :
+    return "SPAPI_E_DEVINFO_NOT_REGISTERED   ";
+  case SPAPI_E_INVALID_REG_PROPERTY     :
+    return "SPAPI_E_INVALID_REG_PROPERTY     ";
+  case SPAPI_E_NO_INF                   :
+    return "SPAPI_E_NO_INF                   ";
+  case SPAPI_E_NO_SUCH_DEVINST          :
+    return "SPAPI_E_NO_SUCH_DEVINST          ";
+  case SPAPI_E_CANT_LOAD_CLASS_ICON     :
+    return "SPAPI_E_CANT_LOAD_CLASS_ICON     ";
+  case SPAPI_E_INVALID_CLASS_INSTALLER  :
+    return "SPAPI_E_INVALID_CLASS_INSTALLER  ";
+  case SPAPI_E_DI_DO_DEFAULT            :
+    return "SPAPI_E_DI_DO_DEFAULT            ";
+  case SPAPI_E_DI_NOFILECOPY            :
+    return "SPAPI_E_DI_NOFILECOPY            ";
+  case SPAPI_E_INVALID_HWPROFILE        :
+    return "SPAPI_E_INVALID_HWPROFILE        ";
+  case SPAPI_E_NO_DEVICE_SELECTED       :
+    return "SPAPI_E_NO_DEVICE_SELECTED       ";
+  case SPAPI_E_DEVINFO_LIST_LOCKED      :
+    return "SPAPI_E_DEVINFO_LIST_LOCKED      ";
+  case SPAPI_E_DEVINFO_DATA_LOCKED      :
+    return "SPAPI_E_DEVINFO_DATA_LOCKED      ";
+  case SPAPI_E_DI_BAD_PATH              :
+    return "SPAPI_E_DI_BAD_PATH              ";
+  case SPAPI_E_NO_CLASSINSTALL_PARAMS   :
+    return "SPAPI_E_NO_CLASSINSTALL_PARAMS   ";
+  case SPAPI_E_FILEQUEUE_LOCKED         :
+    return "SPAPI_E_FILEQUEUE_LOCKED         ";
+  case SPAPI_E_BAD_SERVICE_INSTALLSECT  :
+    return "SPAPI_E_BAD_SERVICE_INSTALLSECT  ";
+  case SPAPI_E_NO_CLASS_DRIVER_LIST     :
+    return "SPAPI_E_NO_CLASS_DRIVER_LIST     ";
+  case SPAPI_E_NO_ASSOCIATED_SERVICE    :
+    return "SPAPI_E_NO_ASSOCIATED_SERVICE    ";
+  case SPAPI_E_NO_DEFAULT_DEVICE_INTERFACE :
+    return "SPAPI_E_NO_DEFAULT_DEVICE_INTERFACE ";
+  case SPAPI_E_DEVICE_INTERFACE_ACTIVE  :
+    return "SPAPI_E_DEVICE_INTERFACE_ACTIVE  ";
+  case SPAPI_E_DEVICE_INTERFACE_REMOVED :
+    return "SPAPI_E_DEVICE_INTERFACE_REMOVED ";
+  case SPAPI_E_BAD_INTERFACE_INSTALLSECT :
+    return "SPAPI_E_BAD_INTERFACE_INSTALLSECT ";
+  case SPAPI_E_NO_SUCH_INTERFACE_CLASS  :
+    return "SPAPI_E_NO_SUCH_INTERFACE_CLASS  ";
+  case SPAPI_E_INVALID_REFERENCE_STRING :
+    return "SPAPI_E_INVALID_REFERENCE_STRING ";
+  case SPAPI_E_INVALID_MACHINENAME      :
+    return "SPAPI_E_INVALID_MACHINENAME      ";
+  case SPAPI_E_REMOTE_COMM_FAILURE      :
+    return "SPAPI_E_REMOTE_COMM_FAILURE      ";
+  case SPAPI_E_MACHINE_UNAVAILABLE      :
+    return "SPAPI_E_MACHINE_UNAVAILABLE      ";
+  case SPAPI_E_NO_CONFIGMGR_SERVICES    :
+    return "SPAPI_E_NO_CONFIGMGR_SERVICES    ";
+  case SPAPI_E_INVALID_PROPPAGE_PROVIDER :
+    return "SPAPI_E_INVALID_PROPPAGE_PROVIDER ";
+  case SPAPI_E_NO_SUCH_DEVICE_INTERFACE :
+    return "SPAPI_E_NO_SUCH_DEVICE_INTERFACE ";
+  case SPAPI_E_DI_POSTPROCESSING_REQUIRED :
+    return "SPAPI_E_DI_POSTPROCESSING_REQUIRED ";
+  case SPAPI_E_INVALID_COINSTALLER      :
+    return "SPAPI_E_INVALID_COINSTALLER      ";
+  case SPAPI_E_NO_COMPAT_DRIVERS        :
+    return "SPAPI_E_NO_COMPAT_DRIVERS        ";
+  case SPAPI_E_NO_DEVICE_ICON           :
+    return "SPAPI_E_NO_DEVICE_ICON           ";
+  case SPAPI_E_INVALID_INF_LOGCONFIG    :
+    return "SPAPI_E_INVALID_INF_LOGCONFIG    ";
+  case SPAPI_E_DI_DONT_INSTALL          :
+    return "SPAPI_E_DI_DONT_INSTALL          ";
+  case SPAPI_E_INVALID_FILTER_DRIVER    :
+    return "SPAPI_E_INVALID_FILTER_DRIVER    ";
+  case SPAPI_E_ERROR_NOT_INSTALLED      :
+    return "SPAPI_E_ERROR_NOT_INSTALLED      ";
+
+  default:
+    static char buff[1000];
+    sprintf(buff, "Unrecognized error value: %08X\0", error);
+
+    return buff;
+  }
+}

+ 3 - 3
panda/src/dxgsg/dxgsgbase.h → panda/src/dxgsg7/dxgsg7base.h

@@ -1,4 +1,4 @@
-// Filename: dxTextureContext.h
+// Filename: dxTextureContext7.h
 // Created by:  drose (07Oct99)
 // Created by:  drose (07Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -86,7 +86,7 @@ typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
         MODULE##_cat.debug() << DBGSTR << " not released, ptr == NULL" << endl;  \
         MODULE##_cat.debug() << DBGSTR << " not released, ptr == NULL" << endl;  \
       } 
       } 
 
 
-#define PRINTREFCNT(OBJECT,STR)  {  (OBJECT)->AddRef();  dxgsg_cat.debug() << STR << " refcnt = " << (OBJECT)->Release() << endl; }
+#define PRINTREFCNT(OBJECT,STR)  {  (OBJECT)->AddRef();  dxgsg7_cat.debug() << STR << " refcnt = " << (OBJECT)->Release() << endl; }
 #else
 #else
 #define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)     \
 #define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero)     \
    if(((OBJECT)!=NULL)&&(!IsBadWritePtr((OBJECT),4))) { \
    if(((OBJECT)!=NULL)&&(!IsBadWritePtr((OBJECT),4))) { \
@@ -109,7 +109,7 @@ typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
 #define DO_PSTATS_STUFF(XX)
 #define DO_PSTATS_STUFF(XX)
 #endif
 #endif
 
 
-extern char * ConvD3DErrorToString(const HRESULT &error);   // defined in wdxGraphicsPipe.cxx
+const char *ConvD3DErrorToString(HRESULT error);
 
 
 typedef struct {
 typedef struct {
       LPDIRECT3DDEVICE7 pD3DDevice;
       LPDIRECT3DDEVICE7 pD3DDevice;

+ 2 - 3
panda/src/display/interactiveGraphicsPipe.I → panda/src/dxgsg7/wdxGraphicsPipe7.I

@@ -1,5 +1,5 @@
-// Filename: interactiveGraphicsPipe.I
-// Created by:  cary (10Mar99)
+// Filename: wdxGraphicsPipe7.I
+// Created by:  drose (20Dec02)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //
 //
@@ -15,4 +15,3 @@
 // [email protected] .
 // [email protected] .
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-

+ 63 - 0
panda/src/dxgsg7/wdxGraphicsPipe7.cxx

@@ -0,0 +1,63 @@
+// Filename: wdxGraphicsPipe7.cxx
+// Created by:  drose (20Dec02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "wdxGraphicsPipe7.h"
+#include "wdxGraphicsWindow7.h"
+#include "config_dxgsg7.h"
+
+TypeHandle wdxGraphicsPipe7::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsPipe7::Constructor
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+wdxGraphicsPipe7::
+wdxGraphicsPipe7() {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsPipe7::Destructor
+//       Access: Public, Virtual
+//  Description: 
+////////////////////////////////////////////////////////////////////
+wdxGraphicsPipe7::
+~wdxGraphicsPipe7() {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsPipe7::pipe_constructor
+//       Access: Public, Static
+//  Description: This function is passed to the GraphicsPipeSelection
+//               object to allow the user to make a default
+//               wdxGraphicsPipe7.
+////////////////////////////////////////////////////////////////////
+PT(GraphicsPipe) wdxGraphicsPipe7::
+pipe_constructor() {
+  return new wdxGraphicsPipe7;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsPipe7::make_window
+//       Access: Protected, Virtual
+//  Description: Creates a new window on the pipe, if possible.
+////////////////////////////////////////////////////////////////////
+PT(GraphicsWindow) wdxGraphicsPipe7::
+make_window() {
+  return new wdxGraphicsWindow7(this);
+}

+ 60 - 0
panda/src/dxgsg7/wdxGraphicsPipe7.h

@@ -0,0 +1,60 @@
+// Filename: wdxGraphicsPipe7.h
+// Created by:  drose (20Dec02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef WDXGRAPHICSPIPE7_H
+#define WDXGRAPHICSPIPE7_H
+
+#include "pandabase.h"
+#include "winGraphicsPipe.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : wdxGraphicsPipe7
+// Description : This graphics pipe represents the interface for
+//               creating DirectX graphics windows.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDADX wdxGraphicsPipe7 : public WinGraphicsPipe {
+public:
+  wdxGraphicsPipe7();
+  virtual ~wdxGraphicsPipe7();
+
+  static PT(GraphicsPipe) pipe_constructor();
+
+protected:
+  virtual PT(GraphicsWindow) make_window();
+
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    WinGraphicsPipe::init_type();
+    register_type(_type_handle, "wdxGraphicsPipe7",
+                  WinGraphicsPipe::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+};
+
+#include "wdxGraphicsPipe7.I"
+
+#endif

+ 2 - 2
panda/src/display/noninteractiveGraphicsPipe.I → panda/src/dxgsg7/wdxGraphicsWindow7.I

@@ -1,5 +1,5 @@
-// Filename: noninteractiveGraphicsPipe.I
-// Created by:  cary (10Mar99)
+// Filename: wdxGraphicsWindow7.I
+// Created by:  drose (20Dec02)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //
 //

+ 1331 - 0
panda/src/dxgsg7/wdxGraphicsWindow7.cxx

@@ -0,0 +1,1331 @@
+// Filename: wdxGraphicsWindow7.cxx
+// Created by:  drose (20Dec02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "wdxGraphicsWindow7.h"
+#include "config_dxgsg7.h"
+#include "config_windisplay.h"
+#include "wdxGraphicsPipe7.h"
+#include "dxGraphicsStateGuardian7.h"
+
+#include <wingdi.h>
+
+static DWORD
+BitDepth_2_DDBDMask(DWORD iBitDepth) {
+  switch (iBitDepth) {
+  case 16: return DDBD_16;
+  case 32: return DDBD_32;
+  case 24: return DDBD_24;
+  case 8: return DDBD_8;
+  case 1: return DDBD_1;
+  case 2: return DDBD_2;
+  case 4: return DDBD_4;
+  }
+  return 0x0;
+}
+
+#define MAX_DX_ZBUF_FMTS 20
+static int cNumZBufFmts;
+
+HRESULT CALLBACK
+EnumZBufFmtsCallback(LPDDPIXELFORMAT pddpf, VOID *param)  {
+  DDPIXELFORMAT *ZBufFmtsArr = (DDPIXELFORMAT *) param;
+  assert(cNumZBufFmts < MAX_DX_ZBUF_FMTS);
+  memcpy(&(ZBufFmtsArr[cNumZBufFmts]), pddpf, sizeof(DDPIXELFORMAT));
+  cNumZBufFmts++;
+  return DDENUMRET_OK;
+}
+
+HRESULT CALLBACK
+EnumDevicesCallback(LPSTR pDeviceDescription, LPSTR pDeviceName,
+                    LPD3DDEVICEDESC7 pD3DDeviceDesc,LPVOID pContext) {
+  D3DDEVICEDESC7 *pd3ddevs = (D3DDEVICEDESC7 *)pContext;
+#ifdef _DEBUG
+  wdxdisplay7_cat.spam()
+    << "Enumerating Device " << pDeviceName << " : " 
+    << pDeviceDescription << endl;
+#endif
+
+#define REGHALIDX 0
+#define TNLHALIDX 1
+#define SWRASTIDX 2
+  
+  if (IsEqualGUID(pD3DDeviceDesc->deviceGUID, IID_IDirect3DHALDevice)) {
+    CopyMemory(&pd3ddevs[REGHALIDX], pD3DDeviceDesc, sizeof(D3DDEVICEDESC7));
+  } else if (IsEqualGUID(pD3DDeviceDesc->deviceGUID, IID_IDirect3DTnLHalDevice)) {
+    CopyMemory(&pd3ddevs[TNLHALIDX], pD3DDeviceDesc, sizeof(D3DDEVICEDESC7));
+  } else if(IsEqualGUID(pD3DDeviceDesc->deviceGUID, IID_IDirect3DRGBDevice)) {
+    CopyMemory(&pd3ddevs[SWRASTIDX], pD3DDeviceDesc, sizeof(D3DDEVICEDESC7));
+  }
+  return DDENUMRET_OK;
+}
+
+#define MAX_DISPLAY_MODES 100  // probably dont need this much, since i already screen for width&hgt
+typedef struct {
+  DWORD maxWidth,maxHeight;
+  DWORD supportedBitDepths;    // uses DDBD_* flags
+  LPDDSURFACEDESC2 pDDSD_Arr;
+  DWORD cNumSurfDescs;
+} DisplayModeInfo;
+
+HRESULT WINAPI
+EnumDisplayModesCallBack(LPDDSURFACEDESC2 lpDDSurfaceDesc,LPVOID lpContext) {
+  DisplayModeInfo *pDMI = (DisplayModeInfo *) lpContext;
+  
+  // ddsd_search should assure this is true
+  assert((lpDDSurfaceDesc->dwWidth == pDMI->maxWidth) && (lpDDSurfaceDesc->dwHeight == pDMI->maxHeight));
+  
+  // ignore refresh rates under 60Hz (and special values of 0 & 1)
+  if ((lpDDSurfaceDesc->dwRefreshRate > 1) && 
+      (lpDDSurfaceDesc->dwRefreshRate < 60)) {
+    return DDENUMRET_OK;
+  }
+  
+  assert(pDMI->cNumSurfDescs < MAX_DISPLAY_MODES);
+  memcpy(&(pDMI->pDDSD_Arr[pDMI->cNumSurfDescs]), lpDDSurfaceDesc, sizeof(DDSURFACEDESC2));
+  pDMI->cNumSurfDescs++;
+  pDMI->supportedBitDepths |= BitDepth_2_DDBDMask(lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount);
+  
+  return DDENUMRET_OK;
+}
+
+// imperfect method to ID NVid? could also scan desc str, but that isnt fullproof either
+#define IS_NVIDIA(DDDEVICEID) ((DDDEVICEID.dwVendorId==0x10DE) || (DDDEVICEID.dwVendorId==0x12D2))
+#define IS_ATI(DDDEVICEID) (DDDEVICEID.dwVendorId==0x1002) 
+#define IS_MATROX(DDDEVICEID) (DDDEVICEID.dwVendorId==0x102B)
+
+HINSTANCE wdxGraphicsWindow7::_hDDrawDLL = NULL;
+LPDIRECTDRAWCREATEEX wdxGraphicsWindow7::_pDDCreateEx = NULL;
+
+TypeHandle wdxGraphicsWindow7::_type_handle;
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+wdxGraphicsWindow7::
+wdxGraphicsWindow7(GraphicsPipe *pipe) :
+  WinGraphicsWindow(pipe) 
+{
+  _dxgsg = (DXGraphicsStateGuardian7 *)NULL;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::Destructor
+//       Access: Public, Virtual
+//  Description:
+////////////////////////////////////////////////////////////////////
+wdxGraphicsWindow7::
+~wdxGraphicsWindow7() {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::make_gsg
+//       Access: Public, Virtual
+//  Description: Creates a new GSG for the window and stores it in the
+//               _gsg pointer.  This should only be called from within
+//               the draw thread.
+////////////////////////////////////////////////////////////////////
+void wdxGraphicsWindow7::
+make_gsg() {
+  nassertv(_gsg == (GraphicsStateGuardian *)NULL);
+  _dxgsg = new DXGraphicsStateGuardian7(this);
+  _gsg = _dxgsg;
+  // Tell the associated dxGSG about the window handle.
+  _dxgsg->scrn.hWnd = _mwindow;
+
+  init_ddraw();
+  if (!search_for_device(0, NULL)) {
+    wdxdisplay7_cat.error()
+      << "Unable to find suitable rendering device.\n";
+    release_gsg();
+    return;
+  }
+
+  set_coop_levels_and_display_modes();
+  create_screen_buffers_and_device(_dxgsg->scrn, dx_force_16bpp_zbuffer);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::release_gsg
+//       Access: Public, Virtual
+//  Description: Releases the current GSG pointer, if it is currently
+//               held, and resets the GSG to NULL.  This should only
+//               be called from within the draw thread.
+////////////////////////////////////////////////////////////////////
+void wdxGraphicsWindow7::
+release_gsg() {
+  if (_gsg != (GraphicsStateGuardian *)NULL) {
+    GraphicsWindow::release_gsg();
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::end_flip
+//       Access: Public, Virtual
+//  Description: This function will be called within the draw thread
+//               after begin_flip() has been called on all windows, to
+//               finish the exchange of the front and back buffers.
+//
+//               This should cause the window to wait for the flip, if
+//               necessary.
+////////////////////////////////////////////////////////////////////
+void wdxGraphicsWindow7::
+end_flip() {
+  if (_dxgsg != (DXGraphicsStateGuardian7 *)NULL && is_active()) {
+    _dxgsg->show_frame();
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::fullscreen_restored
+//       Access: Protected, Virtual
+//  Description: This is a hook for derived classes to do something
+//               special, if necessary, when a fullscreen window has
+//               been restored after being minimized.  The given
+//               WindowProperties struct will be applied to this
+//               window's properties after this function returns.
+////////////////////////////////////////////////////////////////////
+void wdxGraphicsWindow7::
+fullscreen_restored(WindowProperties &properties) {
+  // For some reason, this message comes in twice, once while the
+  // fullscreen window is still minimized, and once again when it has
+  // been restored.
+
+  // In DX7, it seems to be necessary to render one frame between the
+  // two cases, so we must set the minimized property to false even in
+  // the first case.
+  properties.set_minimized(false);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::handle_reshape
+//       Access: Protected, Virtual
+//  Description: Called in the window thread when the window size or
+//               location is changed, this updates the properties
+//               structure accordingly.
+////////////////////////////////////////////////////////////////////
+void wdxGraphicsWindow7::
+handle_reshape() {
+  GdiFlush();
+  WinGraphicsWindow::handle_reshape();
+
+  if (_dxgsg!=NULL) {
+    HRESULT hr;
+
+    if (_dxgsg->scrn.pddsBack == NULL) {
+      // assume this is initial creation reshape and ignore this call
+      return;
+    }
+
+    // Clear the back/primary surface to black
+    DX_DECLARE_CLEAN(DDBLTFX, bltfx);
+    bltfx.dwDDFX |= DDBLTFX_NOTEARING;
+    hr = _dxgsg->scrn.pddsPrimary->Blt
+      (NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &bltfx);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "Blt to Black of Primary Surf failed! : result = "
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+
+    hr = _dxgsg->scrn.pDD->TestCooperativeLevel();
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.error()
+        << "TestCooperativeLevel failed : result = "
+        << ConvD3DErrorToString(hr) << endl;
+      return;
+    }
+
+    _dxgsg->RestoreAllVideoSurfaces();
+
+    set_to_temp_rendertarget();
+
+    // create the new resized rendertargets
+    RECT view_rect;
+    HWND hWnd = _dxgsg->scrn.hWnd;
+    get_client_rect_screen(hWnd, &view_rect);
+    _dxgsg->dx_setup_after_resize(view_rect, hWnd);
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::do_fullscreen_resize
+//       Access: Protected, Virtual
+//  Description: Called in the window thread to resize a fullscreen
+//               window.
+////////////////////////////////////////////////////////////////////
+bool wdxGraphicsWindow7::
+do_fullscreen_resize(int x_size, int y_size) {
+  _dxgsg->SetDXReady(false);
+
+  HRESULT hr;
+
+  DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_curmode);
+
+  hr = _dxgsg->scrn.pDD->GetDisplayMode(&ddsd_curmode);
+  if (FAILED(hr)) {
+    wdxdisplay7_cat.fatal() 
+      << "resize() - GetDisplayMode failed, result = "
+      << ConvD3DErrorToString(hr) << endl;
+    exit(1);
+  }
+
+  DX_DECLARE_CLEAN(DDSURFACEDESC2, ddsd_search);
+
+  ddsd_search.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
+  ddsd_search.dwWidth=x_size;  
+  ddsd_search.dwHeight=y_size;
+
+  // not requesting same refresh rate since changing res might not
+  // support same refresh rate
+
+  DDSURFACEDESC2 DDSD_Arr[MAX_DISPLAY_MODES];
+  DisplayModeInfo DMI;
+  ZeroMemory(&DDSD_Arr,sizeof(DDSD_Arr));
+  ZeroMemory(&DMI,sizeof(DMI));
+  DMI.maxWidth = x_size;  
+  DMI.maxHeight = y_size;
+  DMI.pDDSD_Arr = DDSD_Arr;
+
+  hr = _dxgsg->scrn.pDD->EnumDisplayModes(DDEDM_REFRESHRATES, &ddsd_search,
+                                          &DMI, EnumDisplayModesCallBack);
+  if (FAILED(hr)) {
+    wdxdisplay7_cat.fatal()
+      << "resize() - EnumDisplayModes failed, result = "
+      << ConvD3DErrorToString(hr) << endl;
+    return false;
+  }
+
+  DMI.supportedBitDepths &= _dxgsg->scrn.D3DDevDesc.dwDeviceRenderBitDepth;
+
+  DWORD dwFullScreenBitDepth;
+  DWORD requested_bpp = ddsd_curmode.ddpfPixelFormat.dwRGBBitCount;
+
+  // would like to match current bpp first.  if that is not possible,
+  // try 16bpp, then 32
+  DWORD requested_bpp_DDBD = BitDepth_2_DDBDMask(requested_bpp);
+
+  if (DMI.supportedBitDepths & requested_bpp_DDBD) {
+    dwFullScreenBitDepth = requested_bpp;
+  } else if (DMI.supportedBitDepths & DDBD_16) {
+    dwFullScreenBitDepth = 16;
+  } else if (DMI.supportedBitDepths & DDBD_32) {
+    dwFullScreenBitDepth = 32;
+  } else {
+    wdxdisplay7_cat.error()
+      << "resize failed, no fullScreen resolutions at " << x_size
+      << "x" << y_size << endl;
+    return false;
+  }
+
+  hr = _dxgsg->scrn.pDD->TestCooperativeLevel();
+  if (FAILED(hr)) {
+    wdxdisplay7_cat.error()
+      << "TestCooperativeLevel failed : result = " 
+      << ConvD3DErrorToString(hr) << endl;
+    wdxdisplay7_cat.error()
+      << "Full screen app failed to get exclusive mode on resize, exiting..\n";
+    return false;
+  }
+
+  _dxgsg->free_dxgsg_objects();
+
+   // let driver choose default refresh rate (hopefully its >=60Hz)   
+  hr = _dxgsg->scrn.pDD->SetDisplayMode(x_size, y_size, dwFullScreenBitDepth,
+                                        0L, 0L);
+  if (FAILED(hr)) {
+    wdxdisplay7_cat.error()
+      << "resize failed to reset display mode to (" 
+      << x_size << "x" << y_size << "x" 
+      << dwFullScreenBitDepth << "): result = " 
+      << ConvD3DErrorToString(hr) << endl;
+  }
+
+  if (wdxdisplay7_cat.is_debug()) {
+    DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd34); 
+    _dxgsg->scrn.pDD->GetDisplayMode(&ddsd34);
+    wdxdisplay7_cat.debug()
+      << "set displaymode to " << ddsd34.dwWidth << "x" << ddsd34.dwHeight
+      << " at "<< ddsd34.ddpfPixelFormat.dwRGBBitCount << "bpp, "
+      << ddsd34.dwRefreshRate << "Hz\n";
+  }
+
+  _dxgsg->scrn.dwRenderWidth = x_size;
+  _dxgsg->scrn.dwRenderHeight = y_size;
+
+  create_screen_buffers_and_device(_dxgsg->scrn, dx_force_16bpp_zbuffer);
+  _dxgsg->RecreateAllVideoSurfaces();
+  _dxgsg->SetDXReady(true);
+  return true;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::set_to_temp_rendertarget
+//       Access: Private
+//  Description: Constructs a temporary tiny render target for the d3d
+//               device (and sets the d3d device to use it).  This is
+//               called by handle_reshape() just before the full-sized
+//               rendertargets are constructed, in order to save video
+//               memory and thereby allow resizing of the window to
+//               work on 4MB cards.
+////////////////////////////////////////////////////////////////////
+bool wdxGraphicsWindow7::
+set_to_temp_rendertarget() {
+  LPDIRECTDRAWSURFACE7 pddsDummy = NULL, pddsDummyZ = NULL;
+  ULONG refcnt;
+  HRESULT hr;
+    
+  DX_DECLARE_CLEAN(DDSURFACEDESC2, ddsd);
+
+  _dxgsg->scrn.pddsBack->GetSurfaceDesc(&ddsd);
+  LPDIRECTDRAW7 pDD = _dxgsg->scrn.pDD;
+    
+  ddsd.dwFlags &= ~DDSD_PITCH;
+  ddsd.dwWidth = 1; 
+  ddsd.dwHeight = 1;
+  ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER);
+  
+  PRINTVIDMEM(pDD, &ddsd.ddsCaps, "dummy backbuf");
+  
+  hr = pDD->CreateSurface(&ddsd, &pddsDummy, NULL);    
+  if (FAILED(hr)) {
+    wdxdisplay7_cat.error()
+      << "Resize CreateSurface for temp backbuf failed : result = "
+      << ConvD3DErrorToString(hr) << endl;
+    return false;
+  }
+  
+  if (_dxgsg->scrn.pddsZBuf != NULL) {
+    DX_DECLARE_CLEAN(DDSURFACEDESC2, ddsdZ);
+    _dxgsg->scrn.pddsZBuf->GetSurfaceDesc(&ddsdZ);
+    ddsdZ.dwFlags &= ~DDSD_PITCH;
+    ddsdZ.dwWidth = 1;
+    ddsdZ.dwHeight = 1;
+    
+    PRINTVIDMEM(pDD,&ddsdZ.ddsCaps,"dummy zbuf");
+    
+    hr = pDD->CreateSurface(&ddsdZ, &pddsDummyZ, NULL);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.error()
+        << "Resize CreateSurface for temp zbuf failed : result = "
+        << ConvD3DErrorToString(hr) << endl;
+      return false;
+    }
+
+    hr = pddsDummy->AddAttachedSurface(pddsDummyZ);        
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.error()
+        << "Resize AddAttachedSurf for temp zbuf failed : result = "
+        << ConvD3DErrorToString(hr) << endl;
+      return false;
+    }
+  }
+
+  hr = _dxgsg->scrn.pD3DDevice->SetRenderTarget(pddsDummy, 0x0);
+  if (FAILED(hr)) {
+    wdxdisplay7_cat.error()
+      << "Resize failed to set render target to temporary surface, result = " 
+      << ConvD3DErrorToString(hr) << endl;
+    return false;
+  }
+  
+  RELEASE(pddsDummyZ, wdxdisplay7, "dummy resize zbuffer", false);
+  RELEASE(pddsDummy, wdxdisplay7, "dummy resize rendertarget buffer", false);
+
+  return true;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::create_screen_buffers_and_device
+//       Access: Private
+//  Description: Called whenever the window is resized, this recreates
+//               the necessary buffers for rendering.
+////////////////////////////////////////////////////////////////////
+void wdxGraphicsWindow7::
+create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer) {
+  DWORD dwRenderWidth=Display.dwRenderWidth;
+  DWORD dwRenderHeight=Display.dwRenderHeight;
+  LPDIRECT3D7 pD3DI=Display.pD3D;
+  LPDIRECTDRAW7 pDD=Display.pDD;
+  D3DDEVICEDESC7 *pD3DDevDesc=&Display.D3DDevDesc;
+
+  LPDIRECTDRAWSURFACE7 pPrimaryDDSurf,pBackDDSurf,pZDDSurf;
+  LPDIRECT3DDEVICE7 pD3DDevice;
+  RECT view_rect;
+  int i;
+  HRESULT hr;
+  DX_DECLARE_CLEAN(DDSURFACEDESC2, SurfaceDesc);
+
+  assert(pDD!=NULL);
+  assert(pD3DI!=NULL);
+
+  DX_DECLARE_CLEAN(DDCAPS, DDCaps);
+  pDD->GetCaps(&DDCaps, NULL);
+
+  // if window is not foreground in exclusive mode, ddraw thinks you
+  // are 'not active', so it changes your WM_ACTIVATEAPP from true to
+  // false, causing us to go into a 'wait-for WM_ACTIVATEAPP true'
+  // loop, and the event never comes so we hang in fullscreen wait.
+  SetForegroundWindow(Display.hWnd);
+
+  if (is_fullscreen()) {
+    // Setup to create the primary surface w/backbuffer
+    DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd);
+    ddsd.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT;
+    ddsd.ddsCaps.dwCaps = 
+      DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE |
+      DDSCAPS_FLIP | DDSCAPS_COMPLEX;
+    ddsd.dwBackBufferCount = 1;
+
+    if (dx_full_screen_antialiasing) {
+      // cant check that d3ddevice has this capability yet, so got to
+      // set it anyway.  hope this is OK.
+      ddsd.ddsCaps.dwCaps2 |= DDSCAPS2_HINTANTIALIASING; 
+    }
+
+    PRINTVIDMEM(pDD, &ddsd.ddsCaps, "initial primary & backbuf");
+
+    // Create the primary surface
+    hr = pDD->CreateSurface(&ddsd, &pPrimaryDDSurf, NULL);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "CreateSurface failed for primary surface: result = " 
+        << ConvD3DErrorToString(hr) << endl;
+
+      if (((hr == DDERR_OUTOFVIDEOMEMORY)||(hr == DDERR_OUTOFMEMORY)) &&
+          (Display.dwFullScreenBitDepth > 16)) {
+        // emergency fallback to 16bpp (shouldnt have to do this
+        // unless GetAvailVidMem lied) will this work for multimon?
+        // what if surfs are already created on 1st mon?
+        Display.dwFullScreenBitDepth=16;
+
+        wdxdisplay7_cat.info()
+          << "GetAvailVidMem lied, not enough VidMem for 32bpp, so trying 16bpp on device #"
+          << Display.CardIDNum << endl;
+
+        hr = pDD->SetDisplayMode(Display.dwRenderWidth, 
+                                 Display.dwRenderHeight,
+                                 Display.dwFullScreenBitDepth, 0, 0);
+        if (FAILED(hr)) {
+          wdxdisplay7_cat.fatal()
+            << "SetDisplayMode failed to set ("
+            << Display.dwRenderWidth << "x" << Display.dwRenderHeight
+            << "x" << Display.dwFullScreenBitDepth << ") on device #"
+            << Display.CardIDNum << ": result = "
+            << ConvD3DErrorToString(hr) << endl;
+          exit(1);
+        }
+        create_screen_buffers_and_device(Display, true);
+        return;
+      } else {
+        exit(1);
+      }
+    }
+
+    // Clear the primary surface to black
+    DX_DECLARE_CLEAN(DDBLTFX, bltfx);
+    bltfx.dwDDFX |= DDBLTFX_NOTEARING;
+    hr = pPrimaryDDSurf->Blt(NULL, NULL, NULL, 
+                             DDBLT_COLORFILL | DDBLT_WAIT, &bltfx);
+
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "Blt to Black of Primary Surf failed! : result = " 
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+
+    // Get the backbuffer, which was created along with the primary.
+    DDSCAPS2 ddscaps = { 
+      DDSCAPS_BACKBUFFER, 0, 0, 0
+    };
+    hr = pPrimaryDDSurf->GetAttachedSurface(&ddscaps, &pBackDDSurf);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal() 
+        << "Can't get the backbuffer: result = " 
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+
+    hr = pBackDDSurf->Blt(NULL,NULL,NULL,DDBLT_COLORFILL | DDBLT_WAIT,&bltfx);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal() 
+        << "Blt to Black of Back Surf failed! : result = "
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+
+    SetRect(&view_rect, 0, 0, dwRenderWidth, dwRenderHeight);
+    // end create full screen buffers
+
+  } else {          // CREATE WINDOWED BUFFERS
+    if (!(DDCaps.dwCaps2 & DDCAPS2_CANRENDERWINDOWED)) {
+      wdxdisplay7_cat.fatal()
+        << "the 3D HW cannot render windowed, exiting..." << endl;
+      exit(1);
+    }
+
+    hr = pDD->GetDisplayMode(&SurfaceDesc);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal() 
+        << "GetDisplayMode failed result = " 
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+    if (SurfaceDesc.ddpfPixelFormat.dwRGBBitCount <= 8) {
+      wdxdisplay7_cat.fatal()
+        << "Can't run windowed in an 8-bit or less display mode" << endl;
+      exit(1);
+    }
+
+    if (!(BitDepth_2_DDBDMask(SurfaceDesc.ddpfPixelFormat.dwRGBBitCount) & pD3DDevDesc->dwDeviceRenderBitDepth)) {
+      wdxdisplay7_cat.fatal() 
+        << "3D Device doesnt support rendering at " 
+        << SurfaceDesc.ddpfPixelFormat.dwRGBBitCount 
+        << "bpp (current desktop bitdepth)" << endl;
+      exit(1);
+    }
+
+    // Get the dimensions of the viewport and screen bounds
+    get_client_rect_screen(Display.hWnd, &view_rect);
+
+    dwRenderWidth = view_rect.right - view_rect.left;
+    dwRenderHeight = view_rect.bottom - view_rect.top;
+
+    // _properties should reflect view rectangle
+    WindowProperties properties;
+    properties.set_origin(view_rect.left, view_rect.top);
+    properties.set_size(dwRenderWidth, dwRenderHeight);
+    system_changed_properties(properties);
+
+    // Initialize the description of the primary surface
+    ZeroMemory(&SurfaceDesc, sizeof(DDSURFACEDESC2));
+    SurfaceDesc.dwSize = sizeof(DDSURFACEDESC2);
+    SurfaceDesc.dwFlags = DDSD_CAPS ;
+    SurfaceDesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+    PRINTVIDMEM(pDD, &SurfaceDesc.ddsCaps, "initial primary surface");
+
+    // Create the primary surface.  This includes all of the visible
+    // window, so no need to specify height/width
+    hr = pDD->CreateSurface(&SurfaceDesc, &pPrimaryDDSurf, NULL);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "CreateSurface failed for primary surface: result = "
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+
+    // Create a clipper object which handles all our clipping for
+    // cases when our window is partially obscured by other windows.
+    LPDIRECTDRAWCLIPPER Clipper;
+    hr = pDD->CreateClipper(0, &Clipper, NULL);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "CreateClipper failed : result = "
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+
+    // Associate the clipper with our window.  Note that, afterwards,
+    // the clipper is internally referenced by the primary surface, so
+    // it is safe to release our local reference to it.
+    Clipper->SetHWnd(0, Display.hWnd);
+    pPrimaryDDSurf->SetClipper(Clipper);
+    Clipper->Release();
+   
+    // Clear the primary surface to black
+    DX_DECLARE_CLEAN(DDBLTFX, bltfx);
+
+    hr = pPrimaryDDSurf->Blt(NULL,NULL,NULL,DDBLT_COLORFILL | DDBLT_WAIT,&bltfx);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "Blt to Black of Primary Surf failed! : result = " << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+
+    // Set up a surface description to create a backbuffer.
+    SurfaceDesc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
+    SurfaceDesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY;
+    SurfaceDesc.dwWidth = dwRenderWidth;
+    SurfaceDesc.dwHeight = dwRenderHeight;
+
+    if (dx_full_screen_antialiasing) {
+      // cant check that d3ddevice has this capability yet, so got to
+      // set it anyway.  hope this is OK.
+      SurfaceDesc.ddsCaps.dwCaps2 |= DDSCAPS2_HINTANTIALIASING; 
+    }
+
+    PRINTVIDMEM(pDD, &SurfaceDesc.ddsCaps, "initial backbuf");
+
+    // Create the backbuffer. (might want to handle failure due to
+    // running out of video memory)
+    hr = pDD->CreateSurface(&SurfaceDesc, &pBackDDSurf, NULL);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "CreateSurface failed for backbuffer : result = "
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+
+    hr = pBackDDSurf->Blt(NULL,NULL,NULL,DDBLT_COLORFILL | DDBLT_WAIT,&bltfx);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "Blt to Black of Back Surf failed! : result = "
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+  }  // end create windowed buffers
+
+  //  ========================================================
+
+  //  resized(dwRenderWidth, dwRenderHeight);  // update panda channel/display rgn info
+
+  int framebuffer_mode = get_properties().get_framebuffer_mode();
+
+#ifndef NDEBUG
+  if ((framebuffer_mode & WindowProperties::FM_depth) == 0) {
+    wdxdisplay7_cat.info()
+      << "no zbuffer requested, skipping zbuffer creation\n";
+  }
+#endif
+
+  // Check if the device supports z-bufferless hidden surface
+  // removal. If so, we don't really need a z-buffer
+  if ((!(pD3DDevDesc->dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ZBUFFERLESSHSR )) &&
+      ((framebuffer_mode & WindowProperties::FM_depth) != 0)) {
+
+    // Get z-buffer dimensions from the render target
+    DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd);
+    pBackDDSurf->GetSurfaceDesc( &ddsd );
+
+    // Setup the surface desc for the z-buffer.
+    ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
+    ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | ((_dxgsg->scrn.bIsSWRast) ?  DDSCAPS_SYSTEMMEMORY : DDSCAPS_VIDEOMEMORY);
+
+    DDPIXELFORMAT ZBufPixFmts[MAX_DX_ZBUF_FMTS];
+    cNumZBufFmts=0;
+
+    // Get an appropiate pixel format from enumeration of the
+    // formats. On the first pass, we look for a zbuffer dpeth which
+    // is equal to the frame buffer depth (as some cards unfornately
+    // require this).
+    hr = pD3DI->EnumZBufferFormats((Display.bIsTNLDevice ? IID_IDirect3DHALDevice : IID_IDirect3DTnLHalDevice),
+                                   EnumZBufFmtsCallback,
+                                   (VOID*)&ZBufPixFmts);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal() << "EnumZBufferFormats failed" << endl;
+      exit(1);
+    }
+
+#ifdef _DEBUG
+    {
+      static BOOL bPrinted=FALSE;
+      if (!bPrinted) {
+        for (i = 0; i < cNumZBufFmts; i++) {
+          DebugPrintPixFmt(&ZBufPixFmts[i]);
+        }
+        bPrinted=TRUE;
+      }
+    }
+#endif
+
+    // should we pay attn to these at some point?  
+    //int want_depth_bits = _props._want_depth_bits; 
+    //int want_color_bits = _props._want_color_bits;
+    bool bWantStencil = ((framebuffer_mode & WindowProperties::FM_stencil) != 0);
+
+    LPDDPIXELFORMAT pCurPixFmt, pz16 = NULL, pz24 = NULL, pz32 = NULL;
+    for (i = 0, pCurPixFmt = ZBufPixFmts; 
+         i < cNumZBufFmts; 
+         i++, pCurPixFmt++) {
+      if (bWantStencil == ((pCurPixFmt->dwFlags & DDPF_STENCILBUFFER)!=0)) {
+        switch (pCurPixFmt->dwRGBBitCount) {
+        case 16:
+          pz16 = pCurPixFmt;
+          break;
+        case 24:
+          pz24 = pCurPixFmt;
+          break;
+        case 32:
+          pz32 = pCurPixFmt;
+          break;
+        }
+      }
+    }
+
+    if ((pz16 == NULL) && (pz24 == NULL) && (pz32 == NULL)) {
+      if (bWantStencil) {
+        wdxdisplay7_cat.fatal()
+          << "stencil buffer requested, device has no stencil capability\n";
+      } else {
+        wdxdisplay7_cat.fatal()
+          << "failed to find adequate zbuffer capability\n";
+      }
+      exit(1);
+    }
+
+#define SET_ZBUF_DEPTH(DEPTH) { assert(pz##DEPTH != NULL); Display.depth_buffer_bitdepth=DEPTH; ddsd.ddpfPixelFormat = *pz##DEPTH;}
+        
+    if (_dxgsg->scrn.bIsSWRast) {
+      SET_ZBUF_DEPTH(16);    // need this for fast path rasterizers
+    } else {
+      if (IS_NVIDIA(Display.DXDeviceID)) {
+        DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_pri);
+        pPrimaryDDSurf->GetSurfaceDesc(&ddsd_pri);
+
+        // must pick zbuf depth to match primary surface depth for nvidia
+        if (ddsd_pri.ddpfPixelFormat.dwRGBBitCount==16) {
+          SET_ZBUF_DEPTH(16);
+        } else {
+          if (force_16bpp_zbuffer) {
+            wdxdisplay7_cat.fatal()
+              << "'dx-force-16bpp-zbuffer #t' requires a 16bpp desktop on nvidia cards\n";
+            exit(1);
+          }
+          // take the smaller of 24 or 32.  (already assured to match stencil capability)
+          if(pz24 != NULL) {
+            SET_ZBUF_DEPTH(24);
+          } else {
+            SET_ZBUF_DEPTH(32);
+          }
+        }
+      } else {
+        if (force_16bpp_zbuffer) {
+          if (pz16 == NULL) {
+            wdxdisplay7_cat.fatal()
+              << "'dx-force-16bpp-zbuffer #t', but no 16bpp zbuf fmts available on this card\n";
+            exit(1);
+          }
+
+          if(wdxdisplay7_cat.is_debug()) {
+            wdxdisplay7_cat.debug() << "forcing use of 16bpp Z-Buffer\n";
+          }
+          SET_ZBUF_DEPTH(16);
+          ddsd.ddpfPixelFormat = *pz16;
+
+        } else {
+          // pick the highest res zbuffer format avail.  Note: this is
+          // choosing to waste vid-memory and possibly perf for more
+          // accuracy, less z-fighting at long distance (std 16bpp
+          // would be smaller, maybe faster) order of preference 24:
+          // (should be enough), 32: probably means 24 of Z, then 16
+
+          if (bWantStencil && (pz32!=NULL)) {
+            // dont want to select 16/8 z/stencil over 24/8 z/stenc
+            SET_ZBUF_DEPTH(32);
+          } else {
+            if (pz24!=NULL) {
+              SET_ZBUF_DEPTH(24);
+            } else if (pz32!=NULL) {
+              SET_ZBUF_DEPTH(32);
+            } else {
+              SET_ZBUF_DEPTH(16);
+            }
+          }
+        }
+      }
+    }
+
+    PRINTVIDMEM(pDD, &ddsd.ddsCaps, "initial zbuf");
+
+#ifdef _DEBUG
+    wdxdisplay7_cat.info()
+      << "Creating " << ddsd.ddpfPixelFormat.dwRGBBitCount << "bpp zbuffer\n";
+#endif
+
+    // Create and attach a z-buffer
+    hr = pDD->CreateSurface(&ddsd, &pZDDSurf, NULL);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "CreateSurface failed for Z buffer: result = "
+        <<  ConvD3DErrorToString(hr) << endl;
+
+      if (((hr==DDERR_OUTOFVIDEOMEMORY)||(hr==DDERR_OUTOFMEMORY)) &&
+          ((Display.dwFullScreenBitDepth>16)||(ddsd.ddpfPixelFormat.dwRGBBitCount>16))) {
+        Display.dwFullScreenBitDepth=16;
+        // emergency fallback to 16bpp (shouldnt have to do this
+        // unless GetAvailVidMem lied) will this work for multimon?
+        // what if surfs are already created on 1st mon?
+
+        wdxdisplay7_cat.info()
+          << "GetAvailVidMem lied, not enough VidMem for 32bpp, so trying 16bpp on device #"
+          << Display.CardIDNum << endl;
+        
+        ULONG refcnt;
+
+        // free pri and back (maybe should just free pri since created
+        // as complex chain?)
+        RELEASE(pBackDDSurf, wdxdisplay7, "backbuffer", false);
+        RELEASE(pPrimaryDDSurf, wdxdisplay7, "primary surface", false);
+
+        hr = pDD->SetDisplayMode(Display.dwRenderWidth,
+                                 Display.dwRenderHeight,
+                                 Display.dwFullScreenBitDepth, 
+                                 0, 0);
+        if (FAILED(hr)) {
+          wdxdisplay7_cat.fatal()
+            << "SetDisplayMode failed to set (" 
+            << Display.dwRenderWidth << "x" << Display.dwRenderHeight 
+            << "x" << Display.dwFullScreenBitDepth << ") on device #"
+            << Display.CardIDNum << ": result = " 
+            << ConvD3DErrorToString(hr) << endl;
+          exit(1);
+        }
+        create_screen_buffers_and_device(Display, true);
+        return;
+
+      } else {
+        exit(1);
+      }
+    }
+
+    hr = pBackDDSurf->AddAttachedSurface(pZDDSurf);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "AddAttachedSurface failed : result = " 
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+  }
+
+  // Create the device. The device is created off of our back buffer,
+  // which becomes the render target for the newly created device.
+  hr = pD3DI->CreateDevice(pD3DDevDesc->deviceGUID, pBackDDSurf, &pD3DDevice);
+  if (hr != DD_OK) {
+    wdxdisplay7_cat.fatal() 
+      << "CreateDevice failed : result = " 
+      << ConvD3DErrorToString(hr) << endl;
+    exit(1);
+  }
+
+  // No reason to create a viewport at this point.
+  /*
+  // Create the viewport
+  WindowProperties properties = get_properties();
+  D3DVIEWPORT7 vp = { 
+    0, 0,
+    properties.get_x_size(), properties.get_y_size(),
+    0.0f, 1.0f
+  };
+  hr = pD3DDevice->SetViewport(&vp);
+  if (hr != DD_OK) {
+    wdxdisplay7_cat.fatal()
+      << "SetViewport failed : result = " << ConvD3DErrorToString(hr) << endl;
+    exit(1);
+  }
+  */
+
+  Display.pD3DDevice = pD3DDevice;
+  Display.pddsPrimary = pPrimaryDDSurf;
+  Display.pddsBack = pBackDDSurf;
+  Display.pddsZBuf = pZDDSurf;
+  Display.view_rect = view_rect;
+
+  //pDD, pPrimaryDDSurf, pBackDDSurf, pZDDSurf, pD3DI, pD3DDevice, view_rect);
+  _dxgsg->dx_init();
+
+  // do not SetDXReady() yet since caller may want to do more work
+  // before letting rendering proceed
+
+  // Oh, go ahead and call it.
+  _dxgsg->SetDXReady(true);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::search_for_device
+//       Access: Private
+//  Description: Searches for a suitable hardware device for
+//               rendering.
+////////////////////////////////////////////////////////////////////
+bool wdxGraphicsWindow7::
+search_for_device(int devnum, DXDeviceInfo *pDevinfo) {
+  DWORD dwRenderWidth = get_properties().get_x_size();
+  DWORD dwRenderHeight = get_properties().get_y_size();
+  LPDIRECTDRAW7 pDD=NULL;
+  HRESULT hr;
+
+  assert(_dxgsg != NULL);
+
+  GUID *pDDDeviceGUID;
+  if (pDevinfo == NULL) {
+    pDDDeviceGUID = NULL;
+  } else {
+    pDDDeviceGUID = &pDevinfo->guidDeviceIdentifier;
+  }
+
+  assert(_pDDCreateEx != NULL);
+
+  // Create the Direct Draw Objects
+  hr = (*(_pDDCreateEx))(pDDDeviceGUID,(void **)&pDD, 
+                         IID_IDirectDraw7, NULL);
+  if ((hr != DD_OK) || (pDD == NULL)) {
+    wdxdisplay7_cat.fatal()
+      << "DirectDrawCreateEx failed for monitor(" << devnum
+      << "): result = " << ConvD3DErrorToString(hr) << endl;
+    return false;
+  }
+
+  _dxgsg->scrn.pDD = pDD;
+
+  // GetDeviceID bug writes an extra 4 bytes, so need xtra space
+  BYTE id_arr[sizeof(DDDEVICEIDENTIFIER2) + 4];
+  pDD->GetDeviceIdentifier((DDDEVICEIDENTIFIER2 *)&id_arr, 0x0);
+
+  memcpy(&_dxgsg->scrn.DXDeviceID, id_arr, sizeof(DDDEVICEIDENTIFIER2));
+
+  if (wdxdisplay7_cat.is_info()) {
+    DDDEVICEIDENTIFIER2 *pDevID = &_dxgsg->scrn.DXDeviceID;
+    wdxdisplay7_cat.info() 
+      << "GfxCard: " << pDevID->szDescription <<  "; DriverFile: '" 
+      << pDevID->szDriver  
+      << "'; VendorID: 0x" <<  (void*)pDevID->dwVendorId 
+      << "; DeviceID: 0x" <<  (void*)pDevID->dwDeviceId 
+      << "; DriverVer: " 
+      << HIWORD(pDevID->liDriverVersion.HighPart) << "." 
+      << LOWORD(pDevID->liDriverVersion.HighPart) << "."
+      << HIWORD(pDevID->liDriverVersion.LowPart) << "." 
+      << LOWORD(pDevID->liDriverVersion.LowPart) << endl;
+  }
+
+  // Query DirectDraw for access to Direct3D
+  hr = pDD->QueryInterface(IID_IDirect3D7, (VOID**)&_dxgsg->scrn.pD3D);
+  if(hr != DD_OK) {
+    wdxdisplay7_cat.fatal()
+      << "QI for D3D failed : result = " << ConvD3DErrorToString(hr) << endl;
+    goto error_exit;
+  }
+
+  D3DDEVICEDESC7 d3ddevs[3];  // put HAL in 0, TnLHAL in 1, SW rast in 2
+
+  // just look for HAL and TnL devices right now.  I dont think
+  // we have any interest in the sw rasts at this point
+
+  ZeroMemory(d3ddevs,3*sizeof(D3DDEVICEDESC7));
+
+  hr = _dxgsg->scrn.pD3D->EnumDevices(EnumDevicesCallback, d3ddevs);
+  if(hr != DD_OK) {
+    wdxdisplay7_cat.fatal()
+      << "EnumDevices failed : result = " << ConvD3DErrorToString(hr) << endl;
+    goto error_exit;
+  }
+    
+  WORD DeviceIdx;
+
+  // select TNL if present
+  if (d3ddevs[TNLHALIDX].dwDevCaps & D3DDEVCAPS_HWRASTERIZATION) {
+    DeviceIdx = TNLHALIDX;
+  } else if (d3ddevs[REGHALIDX].dwDevCaps & D3DDEVCAPS_HWRASTERIZATION) {
+    DeviceIdx = REGHALIDX;
+  } else if (dx_allow_software_renderer || dx_force_software_renderer) {
+    DeviceIdx = SWRASTIDX;      
+  } else {
+    wdxdisplay7_cat.error()
+      << "No 3D HW present on device #" << devnum << ", skipping it... ("
+      << _dxgsg->scrn.DXDeviceID.szDescription<<")\n";
+    goto error_exit;
+  }
+
+  if (dx_force_software_renderer) {
+    DeviceIdx = SWRASTIDX; 
+  }
+    
+  memcpy(&_dxgsg->scrn.D3DDevDesc, &d3ddevs[DeviceIdx], 
+         sizeof(D3DDEVICEDESC7));
+
+  _dxgsg->scrn.bIsTNLDevice = (DeviceIdx == TNLHALIDX);
+
+  // Get Current VidMem avail.  Note this is only an estimate, when we
+  // switch to fullscreen mode from desktop, more vidmem will be
+  // available (typically 1.2 meg).  I dont want to switch to
+  // fullscreen more than once due to the annoying monitor flicker, so
+  // try to figure out optimal mode using this estimate
+  DDSCAPS2 ddsGAVMCaps;
+  DWORD dwVidMemTotal, dwVidMemFree;
+  dwVidMemTotal = dwVidMemFree = 0;
+  ZeroMemory(&ddsGAVMCaps, sizeof(DDSCAPS2));
+  ddsGAVMCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM;  // dont count AGP mem!
+  hr = pDD->GetAvailableVidMem(&ddsGAVMCaps,&dwVidMemTotal,&dwVidMemFree);
+  if (FAILED(hr)) {
+    wdxdisplay7_cat.error()
+      << "GetAvailableVidMem failed for device #" << devnum
+      << ": result = " << ConvD3DErrorToString(hr) << endl;
+    // goto skip_device;
+    exit(1);  // probably want to exit, since it may be my fault
+  }
+    
+  // after SetDisplayMode, GetAvailVidMem totalmem seems to go down by
+  // 1.2 meg (contradicting above comment and what I think would be
+  // correct behavior (shouldnt FS mode release the desktop vidmem?),
+  // so this is the true value
+  _dxgsg->scrn.MaxAvailVidMem = dwVidMemTotal;
+    
+#define LOWVIDMEMTHRESHOLD 5500000
+#define CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD 1000000     // every vidcard we deal with should have at least 1MB
+    
+  // assume buggy drivers (this means you, FireGL2) may return zero for dwVidMemTotal, so ignore value if its < CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD
+  _dxgsg->scrn.bIsLowVidMemCard = 
+    ((dwVidMemTotal>CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD) && 
+     (dwVidMemTotal< LOWVIDMEMTHRESHOLD));   
+
+  if (!dx_do_vidmemsize_check) {
+    _dxgsg->scrn.MaxAvailVidMem = 0xFFFFFFFF;
+    _dxgsg->scrn.bIsLowVidMemCard = false; 
+  }
+
+  if (DeviceIdx == SWRASTIDX) {
+    // this will force 640x480x16, is this what we want for all sw rast?
+    _dxgsg->scrn.bIsLowVidMemCard = true; 
+    _dxgsg->scrn.bIsSWRast = true; 
+    dx_force_16bpp_zbuffer = true;
+  }
+
+  if (dx_full_screen) {
+    DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_search);
+    ddsd_search.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
+    ddsd_search.dwWidth = dwRenderWidth;
+    ddsd_search.dwHeight = dwRenderHeight;
+    
+    DDSURFACEDESC2 DDSD_Arr[MAX_DISPLAY_MODES];
+    DisplayModeInfo DMI;
+    ZeroMemory(&DDSD_Arr, sizeof(DDSD_Arr));
+    ZeroMemory(&DMI, sizeof(DMI));
+    DMI.maxWidth = dwRenderWidth;
+    DMI.maxHeight = dwRenderHeight;
+    DMI.pDDSD_Arr = DDSD_Arr;
+
+    hr= pDD->EnumDisplayModes(DDEDM_REFRESHRATES, &ddsd_search,
+                              &DMI, EnumDisplayModesCallBack);        
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "EnumDisplayModes failed for device #" << devnum 
+        << " (" << _dxgsg->scrn.DXDeviceID.szDescription
+        << "), result = " << ConvD3DErrorToString(hr) << endl;
+      // goto skip_device;
+      exit(1);  // probably want to exit, since it may be my fault
+    }
+        
+    if (wdxdisplay7_cat.is_info()) {
+      wdxdisplay7_cat.info()
+        << "Before fullscreen switch: GetAvailableVidMem for device #"
+        << devnum << " returns Total: " << dwVidMemTotal/1000000.0
+        << "  Free: " << dwVidMemFree/1000000.0 << endl;
+    }
+        
+    // Now we try to figure out if we can use requested screen
+    // resolution and best rendertarget bpp and still have at least 2
+    // meg of texture vidmem
+        
+    DMI.supportedBitDepths &= _dxgsg->scrn.D3DDevDesc.dwDeviceRenderBitDepth;
+
+    DWORD dwFullScreenBitDepth;
+
+    // note: this chooses 32bpp, which may not be preferred over 16
+    // for memory & speed reasons
+    if (DMI.supportedBitDepths & DDBD_32) {
+      dwFullScreenBitDepth = 32;              // go for 32bpp if its avail
+    } else if (DMI.supportedBitDepths & DDBD_24) {
+      dwFullScreenBitDepth = 24;              // go for 24bpp if its avail
+    } else if (DMI.supportedBitDepths & DDBD_16) {
+      dwFullScreenBitDepth = 16;              // do 16bpp
+    } else {
+      wdxdisplay7_cat.fatal() 
+        << "No Supported FullScreen resolutions at " << dwRenderWidth
+        << "x" << dwRenderHeight << " for device #" << devnum 
+        << " (" << _dxgsg->scrn.DXDeviceID.szDescription
+        << "), skipping device...\n";
+      goto error_exit;
+    }
+        
+    if (_dxgsg->scrn.bIsLowVidMemCard) {
+      {
+        // hack: figuring out exactly what res to use is tricky,
+        // instead I will just use 640x480 if we have < 3 meg avail
+    
+        dwFullScreenBitDepth = 16; 
+        dwRenderWidth = 640;
+        dwRenderHeight = 480;
+        dx_force_16bpptextures = true;
+        
+        if (wdxdisplay7_cat.is_info())
+          wdxdisplay7_cat.info() 
+            << "Available VidMem (" << dwVidMemFree << ") is under "
+            << LOWVIDMEMTHRESHOLD 
+            << ", using 640x480 16bpp rendertargets to save tex vidmem.\n";
+      }
+    }
+
+    _dxgsg->scrn.dwFullScreenBitDepth = dwFullScreenBitDepth;
+  }
+    
+  _dxgsg->scrn.dwRenderWidth = dwRenderWidth;
+  _dxgsg->scrn.dwRenderHeight = dwRenderHeight;
+  if (pDevinfo) {
+    _dxgsg->scrn.hMon = pDevinfo->hMon;
+  }
+  _dxgsg->scrn.CardIDNum = devnum;  // add ID tag for dbgprint purposes
+
+  return true;
+    
+  // handle errors within this for device loop
+    
+ error_exit:
+  if (_dxgsg->scrn.pD3D != NULL)
+    _dxgsg->scrn.pD3D->Release();
+  if (_dxgsg->scrn.pDD != NULL)
+    _dxgsg->scrn.pDD->Release();
+
+  _dxgsg->scrn.pDD = NULL;
+  _dxgsg->scrn.pD3D = NULL;
+  return false;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::set_coop_levels_and_display_modes
+//       Access: Private
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void wdxGraphicsWindow7::
+set_coop_levels_and_display_modes() {
+  HRESULT hr;
+  DWORD SCL_FPUFlag;
+
+  if (dx_preserve_fpu_state) {
+    // tell d3d to preserve the fpu state across calls.  this hurts
+    // perf, but is good for dbgging
+    SCL_FPUFlag = DDSCL_FPUPRESERVE;
+
+  } else {
+    SCL_FPUFlag = DDSCL_FPUSETUP;
+  }
+
+  DXScreenData *pScrn = &_dxgsg->scrn;
+  
+  if (!is_fullscreen()) {
+    hr = pScrn->pDD->SetCooperativeLevel(_mwindow, 
+                                         SCL_FPUFlag | DDSCL_NORMAL);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "SetCooperativeLevel failed : result = "
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+    return; 
+  }
+    
+  DWORD SCL_FLAGS = SCL_FPUFlag | DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT;
+
+  // The following code would be done per window if were supporting
+  // multiple fullscreen windows on different graphics cards.  TODO:
+  // restore that functionality.
+  DWORD devnum = 0;
+  {
+    DXScreenData *pScrn = &_dxgsg->scrn;
+
+    // need to set focus/device windows for multimon
+    // focus window is primary monitor that will receive keybd input
+    // all ddraw objs need to have same focus window
+    /*
+    if(_windows.size()>1) {    
+      if(FAILED(hr = pScrn->pDD->SetCooperativeLevel(_hParentWindow, DDSCL_SETFOCUSWINDOW))) {
+        wdxdisplay7_cat.fatal() << "SetCooperativeLevel SetFocusWindow failed on device 0: result = " << ConvD3DErrorToString(hr) << endl;
+        exit(1);
+      }
+    }
+    */
+
+    // s3 savage2000 on w95 seems to set EXCLUSIVE_MODE only if you call
+    // SetCoopLevel twice.  so we do it, it really shouldnt be necessary
+    // if drivers werent buggy
+    for (int jj=0; jj<2; jj++) {
+      hr = pScrn->pDD->SetCooperativeLevel(pScrn->hWnd, SCL_FLAGS);
+      if (FAILED(hr)) {
+        wdxdisplay7_cat.fatal() 
+          << "SetCooperativeLevel failed for device #" << devnum 
+          << ": result = " << ConvD3DErrorToString(hr) << endl;
+        exit(1);
+      }
+    }
+    
+    hr = pScrn->pDD->TestCooperativeLevel();
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "TestCooperativeLevel failed: result = " << ConvD3DErrorToString(hr)
+        << endl;
+      wdxdisplay7_cat.fatal()
+        << "Full screen app failed to get exclusive mode on init, exiting..\n";
+      exit(1);
+    }
+    
+    // note: its important we call SetDisplayMode on all cards before
+    // creating surfaces on any of them let driver choose default
+    // refresh rate (hopefully its >=60Hz)
+    hr = pScrn->pDD->SetDisplayMode(pScrn->dwRenderWidth, 
+                                    pScrn->dwRenderHeight,
+                                    pScrn->dwFullScreenBitDepth, 0, 0);
+    if (FAILED(hr)) {
+      wdxdisplay7_cat.fatal()
+        << "SetDisplayMode failed to set (" << pScrn->dwRenderWidth
+        << "x" <<pScrn->dwRenderHeight << "x" << pScrn->dwFullScreenBitDepth
+        << ") on device #" << pScrn->CardIDNum << ": result = " 
+        << ConvD3DErrorToString(hr) << endl;
+      exit(1);
+    }
+    
+    if(wdxdisplay7_cat.is_debug()) {
+      DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd34); 
+      pScrn->pDD->GetDisplayMode(&ddsd34);
+      wdxdisplay7_cat.debug()
+        << "set displaymode to " << ddsd34.dwWidth << "x" << ddsd34.dwHeight
+        << " at " << ddsd34.ddpfPixelFormat.dwRGBBitCount << "bpp, " 
+        << ddsd34.dwRefreshRate<< "Hz\n";
+    }
+  }
+}
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsWindow7::init_ddraw
+//       Access: Private, Static
+//  Description: Gets the pointer to the DirectDrawCreateEx function
+//               from ddraw.dll, if it hasn't been retrieved already.
+////////////////////////////////////////////////////////////////////
+void wdxGraphicsWindow7::
+init_ddraw() {
+  if (_hDDrawDLL != NULL) {
+    return;
+  }
+
+  static const char * const ddraw_name = "ddraw.dll";
+  _hDDrawDLL = LoadLibrary(ddraw_name);
+  if(_hDDrawDLL == 0) {
+    wdxdisplay7_cat.fatal()
+      << "can't locate " << ddraw_name <<"!\n";
+    exit(1);
+  }
+
+  _pDDCreateEx = (LPDIRECTDRAWCREATEEX)GetProcAddress(_hDDrawDLL,"DirectDrawCreateEx");
+  if(_pDDCreateEx == NULL) {
+    wdxdisplay7_cat.fatal()
+      << "Panda currently requires at least DirectX 7.0!\n";
+    exit(1);
+  }
+}
+

+ 92 - 0
panda/src/dxgsg7/wdxGraphicsWindow7.h

@@ -0,0 +1,92 @@
+// Filename: wdxGraphicsWindow7.h
+// Created by:  drose (20Dec02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef WDXGRAPHICSWINDOW7_H
+#define WDXGRAPHICSWINDOW7_H
+
+#include "pandabase.h"
+#include "winGraphicsWindow.h"
+#include "pvector.h"
+
+class DXGraphicsStateGuardian7;
+
+typedef struct {
+   char    szDriver[MAX_DDDEVICEID_STRING];
+   char    szDescription[MAX_DDDEVICEID_STRING];
+   GUID    guidDeviceIdentifier;
+   HMONITOR hMon;
+} DXDeviceInfo;
+typedef pvector<DXDeviceInfo> DXDeviceInfoVec;
+
+typedef HRESULT (WINAPI * LPDIRECTDRAWCREATEEX)(GUID FAR * lpGuid, LPVOID  *lplpDD, REFIID  iid,IUnknown FAR *pUnkOuter);
+
+////////////////////////////////////////////////////////////////////
+//       Class : wdxGraphicsWindow7
+// Description : A single graphics window for rendering DirectX under
+//               Microsoft Windows.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDADX wdxGraphicsWindow7 : public WinGraphicsWindow {
+public:
+  wdxGraphicsWindow7(GraphicsPipe *pipe);
+  virtual ~wdxGraphicsWindow7();
+
+  virtual void make_gsg();
+  virtual void release_gsg();
+
+  virtual void end_flip();
+
+protected:
+  virtual void fullscreen_restored(WindowProperties &properties);
+  virtual void handle_reshape();
+  virtual bool do_fullscreen_resize(int x_size, int y_size);
+
+private:
+  bool set_to_temp_rendertarget();
+  void create_screen_buffers_and_device(DXScreenData &Display,
+                                        bool force_16bpp_zbuffer);
+  bool search_for_device(int devnum, DXDeviceInfo *pDevinfo);
+  void set_coop_levels_and_display_modes();
+
+  static void init_ddraw();
+
+  DXGraphicsStateGuardian7 *_dxgsg;
+
+  static HINSTANCE _hDDrawDLL;
+  static LPDIRECTDRAWCREATEEX _pDDCreateEx;
+
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    WinGraphicsWindow::init_type();
+    register_type(_type_handle, "wdxGraphicsWindow7",
+                  WinGraphicsWindow::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+};
+
+#include "wdxGraphicsWindow7.I"
+
+#endif

+ 10 - 3
panda/src/dxgsg8/Sources.pp

@@ -7,7 +7,7 @@
 #begin lib_target
 #begin lib_target
   #define TARGET dxgsg8
   #define TARGET dxgsg8
   #define LOCAL_LIBS \
   #define LOCAL_LIBS \
-    gsgmisc gsgbase gobj display \
+    gsgmisc gsgbase gobj display windisplay \
     putil linmath mathutil pnmimage event
     putil linmath mathutil pnmimage event
     
     
   #define COMBINED_SOURCES $[TARGET]_composite1.cxx     
   #define COMBINED_SOURCES $[TARGET]_composite1.cxx     
@@ -20,9 +20,16 @@
   // build dxGraphicsStateGuardian separately since its so big
   // build dxGraphicsStateGuardian separately since its so big
   
   
   #define SOURCES \
   #define SOURCES \
-    dxGraphicsStateGuardian8.cxx dxSavedFrameBuffer8.I dxSavedFrameBuffer8.h $[INSTALL_HEADERS]
+    dxGraphicsStateGuardian8.cxx dxSavedFrameBuffer8.I dxSavedFrameBuffer8.h \
+    wdxGraphicsPipe8.I wdxGraphicsPipe8.h \
+    wdxGraphicsWindow8.I wdxGraphicsWindow8.h \
+    $[INSTALL_HEADERS]
     
     
   #define INCLUDED_SOURCES \
   #define INCLUDED_SOURCES \
-    config_dxgsg8.cxx dxSavedFrameBuffer8.cxx dxTextureContext8.cxx dxGeomNodeContext8.cxx d3dfont8.cxx
+    config_dxgsg8.cxx \
+    dxSavedFrameBuffer8.cxx dxTextureContext8.cxx \
+    dxGeomNodeContext8.cxx \
+    d3dfont8.cxx \
+    wdxGraphicsPipe8.cxx wdxGraphicsWindow8.cxx
 
 
 #end lib_target
 #end lib_target

+ 55 - 38
panda/src/dxgsg8/config_dxgsg8.cxx

@@ -1,4 +1,4 @@
-// Filename: config_dxgsg.cxx
+// Filename: config_dxgsg8.cxx
 // Created by:  drose (06Oct99)
 // Created by:  drose (06Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -20,39 +20,43 @@
 #include "dxGraphicsStateGuardian8.h"
 #include "dxGraphicsStateGuardian8.h"
 #include "dxSavedFrameBuffer8.h"
 #include "dxSavedFrameBuffer8.h"
 #include "dxTextureContext8.h"
 #include "dxTextureContext8.h"
+#include "graphicsPipeSelection.h"
+#include "wdxGraphicsWindow8.h"
+#include "wdxGraphicsPipe8.h"
 
 
 #include <dconfig.h>
 #include <dconfig.h>
 
 
-Configure(config_dxgsg);
-NotifyCategoryDef(dxgsg, ":display:gsg");
+Configure(config_dxgsg8);
+NotifyCategoryDef(dxgsg8, ":display:gsg");
+NotifyCategoryDef(wdxdisplay8, "windisplay");
 
 
 // Configure this variable true to cause the DXGSG to show each
 // Configure this variable true to cause the DXGSG to show each
 // transform space it renders by drawing a little unit axis.  This
 // transform space it renders by drawing a little unit axis.  This
 // cannot be enabled when the player is compiled in NDEBUG mode.
 // cannot be enabled when the player is compiled in NDEBUG mode.
-bool dx_show_transforms = config_dxgsg.GetBool("dx-show-transforms", false);
+bool dx_show_transforms = config_dxgsg8.GetBool("dx-show-transforms", false);
 
 
 //  Configure this to TRUE if you want DirectX to control the entire screen,
 //  Configure this to TRUE if you want DirectX to control the entire screen,
 //  If false, it will just blit into a window.
 //  If false, it will just blit into a window.
-bool dx_full_screen = config_dxgsg.GetBool("dx-full-screen", false);
+bool dx_full_screen = config_dxgsg8.GetBool("dx-full-screen", false);
 
 
 //  Configure this true to force the rendering to sync to the video
 //  Configure this true to force the rendering to sync to the video
 //  refresh, or false to let your frame rate go as high as it can,
 //  refresh, or false to let your frame rate go as high as it can,
 //  irrespective of the video refresh.
 //  irrespective of the video refresh.
-bool dx_sync_video = config_dxgsg.GetBool("sync-video", true);
+bool dx_sync_video = config_dxgsg8.GetBool("sync-video", true);
 
 
 // Set Level of MultiSampling to be used, if HW supports it.  Valid values are 2-16.
 // Set Level of MultiSampling to be used, if HW supports it.  Valid values are 2-16.
-DWORD dx_multisample_antialiasing_level = (DWORD) config_dxgsg.GetInt("dx-multisample-antialiasing-level", 0);
+DWORD dx_multisample_antialiasing_level = (DWORD) config_dxgsg8.GetInt("dx-multisample-antialiasing-level", 0);
 
 
 // Configure this true to perform a cull traversal over the geometry
 // Configure this true to perform a cull traversal over the geometry
 // by default, false otherwise.  The cull traversal provides support
 // by default, false otherwise.  The cull traversal provides support
 // for state-sorting, z-sorting, and binning.
 // for state-sorting, z-sorting, and binning.
-bool dx_cull_traversal = config_dxgsg.GetBool("dx-cull-traversal", true);
+bool dx_cull_traversal = config_dxgsg8.GetBool("dx-cull-traversal", true);
 
 
 // if true, if card only supports per-vertex fog, it will be treated as no-HW fog capability
 // if true, if card only supports per-vertex fog, it will be treated as no-HW fog capability
-bool dx_no_vertex_fog = config_dxgsg.GetBool("dx-no-vertex-fog", false);
+bool dx_no_vertex_fog = config_dxgsg8.GetBool("dx-no-vertex-fog", false);
 
 
 // if true, overwrite cursor bitmap tip with "D3D" to distinguish it from GDI cursor 
 // if true, overwrite cursor bitmap tip with "D3D" to distinguish it from GDI cursor 
-bool dx_show_cursor_watermark = config_dxgsg.GetBool("dx-show-cursor-watermark", 
+bool dx_show_cursor_watermark = config_dxgsg8.GetBool("dx-show-cursor-watermark", 
 #ifdef _DEBUG
 #ifdef _DEBUG
     true
     true
 #else
 #else
@@ -61,7 +65,7 @@ bool dx_show_cursor_watermark = config_dxgsg.GetBool("dx-show-cursor-watermark",
     );
     );
 
 
 // if true, triangle filter will be used to generate mipmap levels instead of default box filter
 // if true, triangle filter will be used to generate mipmap levels instead of default box filter
-bool dx_use_triangle_mipgen_filter = config_dxgsg.GetBool("dx-use-triangle-mipgen-filter", false);
+bool dx_use_triangle_mipgen_filter = config_dxgsg8.GetBool("dx-use-triangle-mipgen-filter", false);
 
 
 // Configure this true to cause all lighting normals to automatically
 // Configure this true to cause all lighting normals to automatically
 // be normalized by the CPU before rendering.  This is
 // be normalized by the CPU before rendering.  This is
@@ -69,40 +73,50 @@ bool dx_use_triangle_mipgen_filter = config_dxgsg.GetBool("dx-use-triangle-mipge
 // expect lighting to work correctly.  Maybe one day there will be
 // expect lighting to work correctly.  Maybe one day there will be
 // another way to set this at runtime, instead of only as a configure
 // another way to set this at runtime, instead of only as a configure
 // variable
 // variable
-bool dx_auto_normalize_lighting = config_dxgsg.GetBool("auto-normalize-lighting", false);
+bool dx_auto_normalize_lighting = config_dxgsg8.GetBool("auto-normalize-lighting", false);
 
 
-bool dx_show_fps_meter = config_dxgsg.GetBool("show-fps-meter", false);
-float dx_fps_meter_update_interval = max(0.5,config_dxgsg.GetFloat("fps-meter-update-interval", 1.7));
+bool dx_show_fps_meter = config_dxgsg8.GetBool("show-fps-meter", false);
+float dx_fps_meter_update_interval = max(0.5,config_dxgsg8.GetFloat("fps-meter-update-interval", 1.7));
 
 
 #ifndef NDEBUG
 #ifndef NDEBUG
 // debugging flag
 // debugging flag
 // values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW
 // values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW
-int dx_force_backface_culling = config_dxgsg.GetInt("dx-force-backface-culling", 0);
+int dx_force_backface_culling = config_dxgsg8.GetInt("dx-force-backface-culling", 0);
 #endif
 #endif
 
 
-bool dx_mipmap_everything = config_dxgsg.GetBool("dx-mipmap-everything", false);
-bool dx_ignore_mipmaps = config_dxgsg.GetBool("dx-ignore-mipmaps", false);
+bool dx_mipmap_everything = config_dxgsg8.GetBool("dx-mipmap-everything", false);
+bool dx_ignore_mipmaps = config_dxgsg8.GetBool("dx-ignore-mipmaps", false);
 
 
 // if this is set, more accurate but more expensive fog computations are performed
 // if this is set, more accurate but more expensive fog computations are performed
-bool dx_use_rangebased_fog = config_dxgsg.GetBool("dx-use-rangebased-fog", false);
-bool dx_force_16bpptextures = config_dxgsg.GetBool("dx-force-16bpptextures", false);
-bool dx_no_dithering = config_dxgsg.GetBool("dx-no-dithering", false);
+bool dx_use_rangebased_fog = config_dxgsg8.GetBool("dx-use-rangebased-fog", false);
+bool dx_force_16bpptextures = config_dxgsg8.GetBool("dx-force-16bpptextures", false);
+bool dx_no_dithering = config_dxgsg8.GetBool("dx-no-dithering", false);
+bool dx_force_16bpp_zbuffer = config_dxgsg8.GetBool("dx-force-16bpp-zbuffer", false);
+bool dx_do_vidmemsize_check = config_dxgsg8.GetBool("do-vidmemsize-check", true);
+bool dx_preserve_fpu_state = config_dxgsg8.GetBool("dx-preserve-fpu-state", false);
+
+// if true, override win-width/height and use driver vidmem info to
+// pick what will be a fullscreen window size close to the best perf
+// capability of card, based on a heuristic
+bool dx_pick_best_screenres = config_dxgsg8.GetBool("pick-best-screenres", false);
+
+int dx_preferred_device_id = config_dxgsg8.GetInt("dx-preferred-device-id", -1);
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
-float dx_global_miplevel_bias = config_dxgsg.GetFloat("dx-global-miplevel-bias", 0.0);
-bool dx_debug_view_mipmaps = config_dxgsg.GetBool("dx-debug-view-mipmaps", false);
-//int dx_print_texstats = config_dxgsg.GetBool("dx-print-texstats", 0);
+float dx_global_miplevel_bias = config_dxgsg8.GetFloat("dx-global-miplevel-bias", 0.0);
+bool dx_debug_view_mipmaps = config_dxgsg8.GetBool("dx-debug-view-mipmaps", false);
+//int dx_print_texstats = config_dxgsg8.GetBool("dx-print-texstats", 0);
 #endif
 #endif
 
 
 // use dx8 or GDI mouse cursor in fullscreen mode?
 // use dx8 or GDI mouse cursor in fullscreen mode?
 // Nvidia dx8 cursor is invisible as of 28.32 drivers, so using GDI in fullscrn by default for now
 // Nvidia dx8 cursor is invisible as of 28.32 drivers, so using GDI in fullscrn by default for now
-bool dx_use_dx_cursor = config_dxgsg.GetBool("dx-use-dx-cursor", false);
+bool dx_use_dx_cursor = config_dxgsg8.GetBool("dx-use-dx-cursor", false);
 
 
-bool dx_force_anisotropic_filtering = config_dxgsg.GetBool("dx-force-anisotropic-filtering", false);
+bool dx_force_anisotropic_filtering = config_dxgsg8.GetBool("dx-force-anisotropic-filtering", false);
 
 
 // set 'retained-mode #t' and this to have prepare_geom concatenate all tristrips within a geom 
 // set 'retained-mode #t' and this to have prepare_geom concatenate all tristrips within a geom 
 // together using degenerate tris
 // together using degenerate tris
-const bool link_tristrips = config_dxgsg.GetBool("link-tristrips", false);
+const bool link_tristrips = config_dxgsg8.GetBool("link-tristrips", false);
 
 
 // note:  offset currently disabled since it wasnt working properly
 // note:  offset currently disabled since it wasnt working properly
 DXDecalType dx_decal_type = GDT_mask;
 DXDecalType dx_decal_type = GDT_mask;
@@ -116,7 +130,7 @@ string *pdx_pixelshader_filename=NULL;
 // texture file to be set globally, usually for special FX
 // texture file to be set globally, usually for special FX
 string *pdx_globaltexture_filename=NULL;
 string *pdx_globaltexture_filename=NULL;
 // tex stagenum to set the global tex to
 // tex stagenum to set the global tex to
-UINT dx_globaltexture_stagenum = (UINT) config_dxgsg.GetInt("dx-globaltexture-stagenum", 0);
+UINT dx_globaltexture_stagenum = (UINT) config_dxgsg8.GetInt("dx-globaltexture-stagenum", 0);
 
 
 static DXDecalType
 static DXDecalType
 parse_decal_type(const string &type) {
 parse_decal_type(const string &type) {
@@ -127,11 +141,11 @@ parse_decal_type(const string &type) {
   } else if (type == "offset") {
   } else if (type == "offset") {
     return GDT_offset;
     return GDT_offset;
   }
   }
-  dxgsg_cat.error() << "Invalid dx-decal-type: " << type << "\n";
+  dxgsg8_cat.error() << "Invalid dx-decal-type: " << type << "\n";
   return GDT_mask;
   return GDT_mask;
 }
 }
 
 
-ConfigureFn(config_dxgsg) {
+ConfigureFn(config_dxgsg8) {
   init_libdxgsg8();
   init_libdxgsg8();
 }
 }
 
 
@@ -139,7 +153,7 @@ void init_config_string(string *&pFname,const char *ConfigrcVarname) {
   // pFname is reference to string ptr
   // pFname is reference to string ptr
 
 
   // dont try to take the & of a soon-to-be-gone stack var string, this must be on the heap!
   // dont try to take the & of a soon-to-be-gone stack var string, this must be on the heap!
-  pFname = new string(config_dxgsg.GetString(ConfigrcVarname, ""));
+  pFname = new string(config_dxgsg8.GetString(ConfigrcVarname, ""));
   if(pFname->empty()) {
   if(pFname->empty()) {
       delete pFname;
       delete pFname;
       pFname=NULL;
       pFname=NULL;
@@ -162,7 +176,7 @@ init_libdxgsg8() {
   }
   }
   initialized = true;
   initialized = true;
 
 
-  string decal_type = config_dxgsg.GetString("dx-decal-type", "");
+  string decal_type = config_dxgsg8.GetString("dx-decal-type", "");
   if (!decal_type.empty()) {
   if (!decal_type.empty()) {
     dx_decal_type = parse_decal_type(decal_type);
     dx_decal_type = parse_decal_type(decal_type);
   }
   }
@@ -171,14 +185,17 @@ init_libdxgsg8() {
   init_config_string(pdx_pixelshader_filename,"dx-pixelshader-filename");
   init_config_string(pdx_pixelshader_filename,"dx-pixelshader-filename");
   init_config_string(pdx_globaltexture_filename,"dx-globaltexture-filename");
   init_config_string(pdx_globaltexture_filename,"dx-globaltexture-filename");
 
 
-  DXGraphicsStateGuardian::init_type();
-  DXSavedFrameBuffer::init_type();
-  DXTextureContext::init_type();
-  DXGeomNodeContext::init_type();
+  DXGraphicsStateGuardian8::init_type();
+  DXSavedFrameBuffer8::init_type();
+  DXTextureContext8::init_type();
+  DXGeomNodeContext8::init_type();
+
+  wdxGraphicsPipe8::init_type();
+  wdxGraphicsWindow8::init_type();
 
 
-  GraphicsStateGuardian::get_factory().register_factory
-    (DXGraphicsStateGuardian::get_class_type(),
-     DXGraphicsStateGuardian::make_DXGraphicsStateGuardian);
+  GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
+  selection->add_pipe_type(wdxGraphicsPipe8::get_class_type(),
+                           wdxGraphicsPipe8::pipe_constructor);
 }
 }
 
 
 const char *D3DFormatStr(D3DFORMAT fmt) {
 const char *D3DFormatStr(D3DFORMAT fmt) {

+ 9 - 3
panda/src/dxgsg8/config_dxgsg8.h

@@ -19,11 +19,12 @@
 #ifndef CONFIG_DXGSG8_H
 #ifndef CONFIG_DXGSG8_H
 #define CONFIG_DXGSG8_H
 #define CONFIG_DXGSG8_H
 
 
-#include <pandabase.h>
-#include <notifyCategoryProxy.h>
+#include "pandabase.h"
+#include "notifyCategoryProxy.h"
 #include <d3d8.h>
 #include <d3d8.h>
 
 
-NotifyCategoryDecl(dxgsg, EXPCL_PANDADX, EXPTP_PANDADX);
+NotifyCategoryDecl(dxgsg8, EXPCL_PANDADX, EXPTP_PANDADX);
+NotifyCategoryDecl(wdxdisplay8, EXPCL_PANDADX, EXPTP_PANDADX);
 
 
 extern bool dx_full_screen;
 extern bool dx_full_screen;
 extern bool dx_sync_video;
 extern bool dx_sync_video;
@@ -48,6 +49,11 @@ extern bool dx_show_transforms;
 extern bool dx_force_16bpptextures;
 extern bool dx_force_16bpptextures;
 extern bool dx_no_dithering;
 extern bool dx_no_dithering;
 extern bool dx_force_anisotropic_filtering;
 extern bool dx_force_anisotropic_filtering;
+extern bool dx_force_16bpp_zbuffer;
+extern bool dx_do_vidmemsize_check;
+extern bool dx_preserve_fpu_state;
+extern bool dx_pick_best_screenres;
+extern int dx_preferred_device_id;
 
 
 extern string *pdx_vertexshader_filename;
 extern string *pdx_vertexshader_filename;
 extern string *pdx_pixelshader_filename;
 extern string *pdx_pixelshader_filename;

+ 18 - 18
panda/src/dxgsg8/d3dfont8.cxx

@@ -123,7 +123,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice ) {
                                  CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
                                  CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
                                  VARIABLE_PITCH, m_strFontName );
                                  VARIABLE_PITCH, m_strFontName );
     if(NULL==hFont) {
     if(NULL==hFont) {
-        dxgsg_cat.error() << "CD3DFont InitDeviceObjects(): initial CreateFont failed!  GetLastError=" << GetLastError() << endl;
+        dxgsg8_cat.error() << "CD3DFont InitDeviceObjects(): initial CreateFont failed!  GetLastError=" << GetLastError() << endl;
         return E_FAIL;
         return E_FAIL;
     }
     }
 
 
@@ -194,7 +194,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice ) {
 
 
     // moved here to allow deletion of GDI objects 
     // moved here to allow deletion of GDI objects 
     if(dwTexSize == 0) {
     if(dwTexSize == 0) {
-        dxgsg_cat.error() << "CD3DFont InitDeviceObjects() error: Texture didnt fit, creation failed!\n";
+        dxgsg8_cat.error() << "CD3DFont InitDeviceObjects() error: Texture didnt fit, creation failed!\n";
         return E_FAIL;
         return E_FAIL;
     }
     }
 
 
@@ -228,7 +228,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice ) {
                            VARIABLE_PITCH, m_strFontName );
                            VARIABLE_PITCH, m_strFontName );
 
 
     if(NULL==hFont) {
     if(NULL==hFont) {
-        dxgsg_cat.error() << "CD3DFont InitDeviceObjects(): optimal CreateFont failed!  GetLastError=" << GetLastError() << endl;
+        dxgsg8_cat.error() << "CD3DFont InitDeviceObjects(): optimal CreateFont failed!  GetLastError=" << GetLastError() << endl;
         return E_FAIL;
         return E_FAIL;
     }
     }
 
 
@@ -263,7 +263,7 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice ) {
         DeleteObject( hFont );
         DeleteObject( hFont );
         DeleteDC( hDC );
         DeleteDC( hDC );
 
 
-        dxgsg_cat.error() << "CD3DFont InitDeviceObjs CreateTexture failed!" << D3DERRORSTRING(hr);
+        dxgsg8_cat.error() << "CD3DFont InitDeviceObjs CreateTexture failed!" << D3DERRORSTRING(hr);
         return hr;
         return hr;
     }; 
     }; 
 
 
@@ -341,11 +341,11 @@ HRESULT CD3DFont::RestoreDeviceObjects() {
                                                     D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0,
                                                     D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0,
                                                     D3DPOOL_DEFAULT,  // D3DUSAGE_DYNAMIC makes D3DPOOL_MANAGED impossible
                                                     D3DPOOL_DEFAULT,  // D3DUSAGE_DYNAMIC makes D3DPOOL_MANAGED impossible
                                                     &m_pVB ) )) {
                                                     &m_pVB ) )) {
-        dxgsg_cat.error() << "CD3DFont CreateVB failed!" << D3DERRORSTRING(hr);
+        dxgsg8_cat.error() << "CD3DFont CreateVB failed!" << D3DERRORSTRING(hr);
         return hr;
         return hr;
     }
     }
 
 
-    PRINT_REFCNT(dxgsg,m_pd3dDevice);
+    PRINT_REFCNT(dxgsg8,m_pd3dDevice);
 
 
     // Create the state blocks for rendering text
     // Create the state blocks for rendering text
     for(UINT which=0; which<2; which++) {
     for(UINT which=0; which<2; which++) {
@@ -403,7 +403,7 @@ HRESULT CD3DFont::RestoreDeviceObjects() {
 HRESULT CD3DFont::InvalidateDeviceObjects() {
 HRESULT CD3DFont::InvalidateDeviceObjects() {
     HRESULT hr;
     HRESULT hr;
 
 
-    PRINT_REFCNT(dxgsg,m_pd3dDevice);
+    PRINT_REFCNT(dxgsg8,m_pd3dDevice);
 
 
     if(IS_VALID_PTR(m_pd3dDevice)) {
     if(IS_VALID_PTR(m_pd3dDevice)) {
         // undo SetStreamSource before releasing VB
         // undo SetStreamSource before releasing VB
@@ -416,11 +416,11 @@ HRESULT CD3DFont::InvalidateDeviceObjects() {
             hr = m_pd3dDevice->SetStreamSource(0,NULL,0);
             hr = m_pd3dDevice->SetStreamSource(0,NULL,0);
     }
     }
 
 
-    PRINT_REFCNT(dxgsg,m_pVB);
+    PRINT_REFCNT(dxgsg8,m_pVB);
 
 
-    RELEASE(m_pVB,dxgsg,"d3dfont VB",RELEASE_ONCE);
+    RELEASE(m_pVB,dxgsg8,"d3dfont VB",RELEASE_ONCE);
 
 
-    PRINT_REFCNT(dxgsg,m_pd3dDevice);
+    PRINT_REFCNT(dxgsg8,m_pd3dDevice);
 
 
     // Delete the state blocks
     // Delete the state blocks
     if(m_pd3dDevice) {
     if(m_pd3dDevice) {
@@ -431,7 +431,7 @@ HRESULT CD3DFont::InvalidateDeviceObjects() {
             m_pd3dDevice->DeleteStateBlock( m_dwDrawTextStateBlock );
             m_pd3dDevice->DeleteStateBlock( m_dwDrawTextStateBlock );
     }
     }
 
 
-    PRINT_REFCNT(dxgsg,m_pd3dDevice);
+    PRINT_REFCNT(dxgsg8,m_pd3dDevice);
 
 
     m_dwSavedStateBlock    = NULL;
     m_dwSavedStateBlock    = NULL;
     m_dwDrawTextStateBlock = NULL;
     m_dwDrawTextStateBlock = NULL;
@@ -445,13 +445,13 @@ HRESULT CD3DFont::InvalidateDeviceObjects() {
 // Desc: Destroys all device-dependent objects
 // Desc: Destroys all device-dependent objects
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 HRESULT CD3DFont::DeleteDeviceObjects() {
 HRESULT CD3DFont::DeleteDeviceObjects() {
-    PRINT_REFCNT(dxgsg,m_pd3dDevice);
+    PRINT_REFCNT(dxgsg8,m_pd3dDevice);
 
 
     InvalidateDeviceObjects();
     InvalidateDeviceObjects();
 
 
     SAFE_RELEASE( m_pTexture );
     SAFE_RELEASE( m_pTexture );
 
 
-    PRINT_REFCNT(dxgsg,m_pd3dDevice);
+    PRINT_REFCNT(dxgsg8,m_pd3dDevice);
 
 
     m_pd3dDevice = NULL;
     m_pd3dDevice = NULL;
 
 
@@ -581,7 +581,7 @@ HRESULT CD3DFont::DeferedDraw
   FLOAT fXScale, FLOAT fYScale, DWORD dwColor, 
   FLOAT fXScale, FLOAT fYScale, DWORD dwColor, 
   TCHAR* strText, DWORD dwFlags ) {
   TCHAR* strText, DWORD dwFlags ) {
     if(m_nDeferedCalls >= MaxCalls) {
     if(m_nDeferedCalls >= MaxCalls) {
-        dxgsg_cat.error() << "CD3DFont DeferedDraw() error, MaxCalls exceeded!\n";
+        dxgsg8_cat.error() << "CD3DFont DeferedDraw() error, MaxCalls exceeded!\n";
         return E_FAIL ;
         return E_FAIL ;
     }
     }
 
 
@@ -591,7 +591,7 @@ HRESULT CD3DFont::DeferedDraw
     int nStrLen = strlen ( strText ) + 1 ; 
     int nStrLen = strlen ( strText ) + 1 ; 
     int nUsed = m_pTextBuffer - & m_pTextBuffer [ 0 ] ; 
     int nUsed = m_pTextBuffer - & m_pTextBuffer [ 0 ] ; 
     if(nUsed + nStrLen > TextBufferLength) {
     if(nUsed + nStrLen > TextBufferLength) {
-        dxgsg_cat.error() << "CD3DFont DeferedDraw() error, TextBufferLength exceeded!\n";
+        dxgsg8_cat.error() << "CD3DFont DeferedDraw() error, TextBufferLength exceeded!\n";
         return E_FAIL ;
         return E_FAIL ;
     }
     }
 
 
@@ -637,7 +637,7 @@ HRESULT CD3DFont::EndText ( void ) {
 
 
     hr = m_pd3dDevice->GetStreamSource(0,&pSavedStreamData,&SavedStreamStride);
     hr = m_pd3dDevice->GetStreamSource(0,&pSavedStreamData,&SavedStreamStride);
     if(FAILED(hr)) {
     if(FAILED(hr)) {
-        dxgsg_cat.error() << "CD3DFont EndText GetStreamSource() failed!" << D3DERRORSTRING(hr);
+        dxgsg8_cat.error() << "CD3DFont EndText GetStreamSource() failed!" << D3DERRORSTRING(hr);
         return E_FAIL;
         return E_FAIL;
     }
     }
 
 
@@ -647,7 +647,7 @@ HRESULT CD3DFont::EndText ( void ) {
     if((pSavedStreamData!=m_pVB)||(SavedStreamStride!=sizeof(FONT2DVERTEX))) {
     if((pSavedStreamData!=m_pVB)||(SavedStreamStride!=sizeof(FONT2DVERTEX))) {
         hr = m_pd3dDevice->SetStreamSource(0,m_pVB,sizeof(FONT2DVERTEX));
         hr = m_pd3dDevice->SetStreamSource(0,m_pVB,sizeof(FONT2DVERTEX));
         if(FAILED(hr)) {
         if(FAILED(hr)) {
-            dxgsg_cat.error() << "CD3DFont EndText initial SetStreamSource() failed!" << D3DERRORSTRING(hr);
+            dxgsg8_cat.error() << "CD3DFont EndText initial SetStreamSource() failed!" << D3DERRORSTRING(hr);
             return E_FAIL;
             return E_FAIL;
         }
         }
     }
     }
@@ -821,7 +821,7 @@ HRESULT CD3DFont::EndText ( void ) {
     if(IS_VALID_PTR(pSavedStreamData) && ((pSavedStreamData!=m_pVB)||(SavedStreamStride!=sizeof(FONT2DVERTEX)))) {
     if(IS_VALID_PTR(pSavedStreamData) && ((pSavedStreamData!=m_pVB)||(SavedStreamStride!=sizeof(FONT2DVERTEX)))) {
         hr = m_pd3dDevice->SetStreamSource(0,pSavedStreamData,SavedStreamStride);
         hr = m_pd3dDevice->SetStreamSource(0,pSavedStreamData,SavedStreamStride);
         if(FAILED(hr)) {
         if(FAILED(hr)) {
-            dxgsg_cat.error() << "CD3DFont EndText restore SetStreamSource() failed!" << D3DERRORSTRING(hr);
+            dxgsg8_cat.error() << "CD3DFont EndText restore SetStreamSource() failed!" << D3DERRORSTRING(hr);
             return E_FAIL;
             return E_FAIL;
         }
         }
         pSavedStreamData->Release();
         pSavedStreamData->Release();

+ 3 - 3
panda/src/dxgsg8/dxGeomNodeContext8.I

@@ -18,12 +18,12 @@
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: dxGeomNodeContext::Constructor
+//     Function: DXGeomNodeContext8::Constructor
 //       Access: Public                                 
 //       Access: Public                                 
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE DXGeomNodeContext::
-DXGeomNodeContext(GeomNode *node) : GeomNodeContext(node)
+INLINE DXGeomNodeContext8::
+DXGeomNodeContext8(GeomNode *node) : GeomNodeContext(node)
 {
 {
   _num_verts = 0;
   _num_verts = 0;
 /*
 /*

+ 2 - 2
panda/src/dxgsg8/dxGeomNodeContext8.cxx

@@ -18,9 +18,9 @@
 
 
 #include "dxGeomNodeContext8.h"
 #include "dxGeomNodeContext8.h"
 
 
-TypeHandle DXGeomNodeContext::_type_handle;
+TypeHandle DXGeomNodeContext8::_type_handle;
 
 
-DXGeomNodeContext::~DXGeomNodeContext()
+DXGeomNodeContext8::~DXGeomNodeContext8()
 {
 {
 /*
 /*
    if(_pXformed_VB!=NULL)
    if(_pXformed_VB!=NULL)

+ 8 - 8
panda/src/dxgsg8/dxGeomNodeContext8.h

@@ -1,4 +1,4 @@
-// Filename: dxGeomNodeContext.h
+// Filename: dxGeomNodeContext8.h
 // Created by:  drose (12Jun01)
 // Created by:  drose (12Jun01)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,8 +16,8 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#ifndef DXGEOMNODECONTEXT_H
-#define DXGEOMNODECONTEXT_H
+#ifndef DXGEOMNODECONTEXT8_H
+#define DXGEOMNODECONTEXT8_H
 
 
 #include "dxgsg8base.h"
 #include "dxgsg8base.h"
 
 
@@ -33,13 +33,13 @@ typedef struct {
 // empty shell unimplemented for DX8 right now
 // empty shell unimplemented for DX8 right now
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//       Class : DXGeomNodeContext
+//       Class : DXGeomNodeContext8
 // Description :
 // Description :
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDADX DXGeomNodeContext : public GeomNodeContext {
+class EXPCL_PANDADX DXGeomNodeContext8 : public GeomNodeContext {
 public:
 public:
-  INLINE DXGeomNodeContext(GeomNode *node);
-  ~DXGeomNodeContext();
+  INLINE DXGeomNodeContext8(GeomNode *node);
+  ~DXGeomNodeContext8();
 
 
   // A list of the dynamic Geoms within the GeomNode; these aren't
   // A list of the dynamic Geoms within the GeomNode; these aren't
   // part of the above display list and must be drawn separately
   // part of the above display list and must be drawn separately
@@ -71,7 +71,7 @@ public:
   }
   }
   static void init_type() {
   static void init_type() {
     GeomNodeContext::init_type();
     GeomNodeContext::init_type();
-    register_type(_type_handle, "DXGeomNodeContext",
+    register_type(_type_handle, "DXGeomNodeContext8",
                   GeomNodeContext::get_class_type());
                   GeomNodeContext::get_class_type());
   }
   }
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {

+ 81 - 77
panda/src/dxgsg8/dxGraphicsStateGuardian8.I

@@ -1,4 +1,4 @@
-// Filename: dxGraphicsStateGuardian.I
+// Filename: dxGraphicsStateGuardian8.I
 // Created by:  mike (02Feb99)
 // Created by:  mike (02Feb99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,22 +16,22 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-// for dxgsg_cat stuff
+// for dxgsg8_cat stuff
 #include "config_dxgsg8.h"
 #include "config_dxgsg8.h"
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_line_smooth
+//     Function: DXGraphicsStateGuardian8::enable_line_smooth
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_line_smooth(bool val) {
 enable_line_smooth(bool val) {
   if(_line_smooth_enabled != val) {
   if(_line_smooth_enabled != val) {
     _line_smooth_enabled = val;
     _line_smooth_enabled = val;
   #ifdef NDEBUG
   #ifdef NDEBUG
     {
     {
         if(val && (scrn.d3dcaps.RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
         if(val && (scrn.d3dcaps.RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
-           dxgsg_cat.error() << "no HW support for line smoothing!!\n";
+           dxgsg8_cat.error() << "no HW support for line smoothing!!\n";
     }
     }
   #endif
   #endif
 
 
@@ -40,18 +40,18 @@ enable_line_smooth(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_dither
+//     Function: DXGraphicsStateGuardian8::enable_dither
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_dither(bool val) {
 enable_dither(bool val) {
   if (_dither_enabled != val) {
   if (_dither_enabled != val) {
 
 
   #ifdef _DEBUG
   #ifdef _DEBUG
     {
     {
         if(val && !(scrn.d3dcaps.RasterCaps & D3DPRASTERCAPS_DITHER))
         if(val && !(scrn.d3dcaps.RasterCaps & D3DPRASTERCAPS_DITHER))
-           dxgsg_cat.error() << "no HW support for color dithering!!\n";
+           dxgsg8_cat.error() << "no HW support for color dithering!!\n";
         return;
         return;
     }
     }
   #endif
   #endif
@@ -62,11 +62,11 @@ enable_dither(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_stencil_test
+//     Function: DXGraphicsStateGuardian8::enable_stencil_test
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_stencil_test(bool val) {
 enable_stencil_test(bool val) {
   if (_stencil_test_enabled != val) {
   if (_stencil_test_enabled != val) {
     _stencil_test_enabled = val;
     _stencil_test_enabled = val;
@@ -75,11 +75,11 @@ enable_stencil_test(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_color_material
+//     Function: DXGraphicsStateGuardian8::enable_color_material
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_color_material(bool val) {
 enable_color_material(bool val) {
   if (_color_material_enabled != val) {
   if (_color_material_enabled != val) {
     _color_material_enabled = val;
     _color_material_enabled = val;
@@ -88,11 +88,11 @@ enable_color_material(bool val) {
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_blend
+//     Function: DXGraphicsStateGuardian8::enable_blend
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_blend(bool val) {
 enable_blend(bool val) {
   if (_blend_enabled != val) {
   if (_blend_enabled != val) {
     _blend_enabled = val;
     _blend_enabled = val;
@@ -101,11 +101,11 @@ enable_blend(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::set_color_writemask
+//     Function: DXGraphicsStateGuardian8::set_color_writemask
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 set_color_writemask(UINT color_writemask) {
 set_color_writemask(UINT color_writemask) {
   if (_color_writemask != color_writemask) {
   if (_color_writemask != color_writemask) {
     _color_writemask = color_writemask;
     _color_writemask = color_writemask;
@@ -121,11 +121,11 @@ set_color_writemask(UINT color_writemask) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_blend
+//     Function: DXGraphicsStateGuardian8::enable_blend
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_gouraud_shading(bool val) {
 enable_gouraud_shading(bool val) {
   if (_bGouraudShadingOn != val) {
   if (_bGouraudShadingOn != val) {
     _bGouraudShadingOn = val;
     _bGouraudShadingOn = val;
@@ -133,7 +133,7 @@ enable_gouraud_shading(bool val) {
   }
   }
 }
 }
 
 
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_primitive_clipping(bool val) {
 enable_primitive_clipping(bool val) {
   if (_clipping_enabled != val) {
   if (_clipping_enabled != val) {
     _clipping_enabled = val;
     _clipping_enabled = val;
@@ -142,11 +142,11 @@ enable_primitive_clipping(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_fog
+//     Function: DXGraphicsStateGuardian8::enable_fog
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_fog(bool val) {
 enable_fog(bool val) {
   if ((_fog_enabled != val) && (_doFogType!=None)) {
   if ((_fog_enabled != val) && (_doFogType!=None)) {
     _fog_enabled = val;
     _fog_enabled = val;
@@ -155,11 +155,11 @@ enable_fog(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::set_vertex_format
+//     Function: DXGraphicsStateGuardian8::set_vertex_format
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 set_vertex_format(DWORD NewFvfType) {
 set_vertex_format(DWORD NewFvfType) {
 #ifdef USE_VERTEX_SHADERS
 #ifdef USE_VERTEX_SHADERS
   if(_CurVertexShader!=NULL) {
   if(_CurVertexShader!=NULL) {
@@ -167,7 +167,7 @@ set_vertex_format(DWORD NewFvfType) {
     HRESULT hr = scrn.pD3DDevice->SetVertexShader(_CurVertexShader);
     HRESULT hr = scrn.pD3DDevice->SetVertexShader(_CurVertexShader);
     #ifndef NDEBUG
     #ifndef NDEBUG
     if(FAILED(hr)) {
     if(FAILED(hr)) {
-           dxgsg_cat.error() << "SetVertexShader for custom vtx shader failed" << D3DERRORSTRING(hr);
+           dxgsg8_cat.error() << "SetVertexShader for custom vtx shader failed" << D3DERRORSTRING(hr);
            exit(1);
            exit(1);
     }
     }
     #endif
     #endif
@@ -182,7 +182,7 @@ set_vertex_format(DWORD NewFvfType) {
     HRESULT hr = scrn.pD3DDevice->SetVertexShader(NewFvfType);
     HRESULT hr = scrn.pD3DDevice->SetVertexShader(NewFvfType);
  #ifndef NDEBUG
  #ifndef NDEBUG
     if(FAILED(hr)) {
     if(FAILED(hr)) {
-           dxgsg_cat.error() << "SetVertexShader(0x" << (void*)NewFvfType<<") failed" << D3DERRORSTRING(hr);
+           dxgsg8_cat.error() << "SetVertexShader(0x" << (void*)NewFvfType<<") failed" << D3DERRORSTRING(hr);
            exit(1);
            exit(1);
     }
     }
  #endif
  #endif
@@ -190,11 +190,11 @@ set_vertex_format(DWORD NewFvfType) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_alpha_test
+//     Function: DXGraphicsStateGuardian8::enable_alpha_test
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_alpha_test(bool val )
 enable_alpha_test(bool val )
 {
 {
   if (_alpha_test_enabled != val) {
   if (_alpha_test_enabled != val) {
@@ -204,17 +204,17 @@ enable_alpha_test(bool val )
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::call_dxLightModelAmbient
+//     Function: DXGraphicsStateGuardian8::call_dxLightModelAmbient
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 call_dxLightModelAmbient( const Colorf& color)
 call_dxLightModelAmbient( const Colorf& color)
 {
 {
   if (_lmodel_ambient != color) {
   if (_lmodel_ambient != color) {
     _lmodel_ambient = color;
     _lmodel_ambient = color;
 #ifdef GSG_VERBOSE
 #ifdef GSG_VERBOSE
-    dxgsg_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
+    dxgsg8_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
 #endif
 #endif
     scrn.pD3DDevice->SetRenderState( D3DRS_AMBIENT,
     scrn.pD3DDevice->SetRenderState( D3DRS_AMBIENT,
                 D3DCOLOR_COLORVALUE(color[0], color[1], color[2], color[3]));
                 D3DCOLOR_COLORVALUE(color[0], color[1], color[2], color[3]));
@@ -223,43 +223,47 @@ call_dxLightModelAmbient( const Colorf& color)
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::call_dxAlphaFunc
+//     Function: DXGraphicsStateGuardian8::call_dxAlphaFunc
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
 call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
   if (_alpha_func != func) {
   if (_alpha_func != func) {
     _alpha_func = func;
     _alpha_func = func;
 #ifdef GSG_VERBOSE
 #ifdef GSG_VERBOSE
-    dxgsg_cat.debug() << "dxAlphaFunc(";
+    dxgsg8_cat.debug() << "dxAlphaFunc(";
     switch (func) {
     switch (func) {
     case D3DCMP_NEVER:
     case D3DCMP_NEVER:
-      dxgsg_cat.debug(false) << "D3DCMP_NEVER";
+      dxgsg8_cat.debug(false) << "D3DCMP_NEVER";
       break;
       break;
     case D3DCMP_LESS:
     case D3DCMP_LESS:
-      dxgsg_cat.debug(false) << "D3DCMP_LESS";
+      dxgsg8_cat.debug(false) << "D3DCMP_LESS";
       break;
       break;
     case D3DCMP_EQUAL:
     case D3DCMP_EQUAL:
-      dxgsg_cat.debug(false) << "D3DCMP_EQUAL";
+      dxgsg8_cat.debug(false) << "D3DCMP_EQUAL";
       break;
       break;
+#ifdef D3DCMP_LEQUAL
     case D3DCMP_LEQUAL:
     case D3DCMP_LEQUAL:
-      dxgsg_cat.debug(false) << "D3DCMP_LEQUAL";
+      dxgsg8_cat.debug(false) << "D3DCMP_LEQUAL";
       break;
       break;
+#endif
     case D3DCMP_GREATER:
     case D3DCMP_GREATER:
-      dxgsg_cat.debug(false) << "D3DCMP_GREATER";
+      dxgsg8_cat.debug(false) << "D3DCMP_GREATER";
       break;
       break;
     case D3DCMP_NOTEQUAL:
     case D3DCMP_NOTEQUAL:
-      dxgsg_cat.debug(false) << "D3DCMP_NOTEQUAL";
+      dxgsg8_cat.debug(false) << "D3DCMP_NOTEQUAL";
       break;
       break;
+#ifdef D3DCMP_GEQUAL
     case D3DCMP_GEQUAL:
     case D3DCMP_GEQUAL:
-      dxgsg_cat.debug(false) << "D3DCMP_GEQUAL";
+      dxgsg8_cat.debug(false) << "D3DCMP_GEQUAL";
       break;
       break;
+#endif
     case D3DCMP_ALWAYS:
     case D3DCMP_ALWAYS:
-      dxgsg_cat.debug(false) << "D3DCMP_ALWAYS";
+      dxgsg8_cat.debug(false) << "D3DCMP_ALWAYS";
       break;
       break;
     }
     }
-    dxgsg_cat.debug() << " , " << reference_alpha << ")" << endl;
+    dxgsg8_cat.debug() << " , " << reference_alpha << ")" << endl;
 #endif
 #endif
     scrn.pD3DDevice->SetRenderState(D3DRS_ALPHAFUNC, func);
     scrn.pD3DDevice->SetRenderState(D3DRS_ALPHAFUNC, func);
   }
   }
@@ -271,7 +275,7 @@ call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
 }
 }
 
 
 
 
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
 call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
 {
 {
   if (_blend_source_func != sfunc)
   if (_blend_source_func != sfunc)
@@ -279,41 +283,41 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
     _blend_source_func = sfunc;
     _blend_source_func = sfunc;
     scrn.pD3DDevice->SetRenderState(D3DRS_SRCBLEND, sfunc);
     scrn.pD3DDevice->SetRenderState(D3DRS_SRCBLEND, sfunc);
 #ifdef GSG_VERBOSE
 #ifdef GSG_VERBOSE
-    dxgsg_cat.debug() << "dxSrcBlendFunc(";
+    dxgsg8_cat.debug() << "dxSrcBlendFunc(";
     switch (sfunc)
     switch (sfunc)
         {
         {
         case D3DBLEND_ZERO:
         case D3DBLEND_ZERO:
-          dxgsg_cat.debug(false) << "ZERO, ";
+          dxgsg8_cat.debug(false) << "ZERO, ";
           break;
           break;
         case D3DBLEND_ONE:
         case D3DBLEND_ONE:
-          dxgsg_cat.debug(false) << "ONE, ";
+          dxgsg8_cat.debug(false) << "ONE, ";
           break;
           break;
         case D3DBLEND_DESTCOLOR:
         case D3DBLEND_DESTCOLOR:
-          dxgsg_cat.debug(false) << "DESTCOLOR, ";
+          dxgsg8_cat.debug(false) << "DESTCOLOR, ";
           break;
           break;
         case D3DBLEND_INVDESTCOLOR:
         case D3DBLEND_INVDESTCOLOR:
-          dxgsg_cat.debug(false) << "INVDESTCOLOR, ";
+          dxgsg8_cat.debug(false) << "INVDESTCOLOR, ";
           break;
           break;
         case D3DBLEND_SRCALPHA:
         case D3DBLEND_SRCALPHA:
-          dxgsg_cat.debug(false) << "SRCALPHA, ";
+          dxgsg8_cat.debug(false) << "SRCALPHA, ";
           break;
           break;
         case D3DBLEND_INVSRCALPHA:
         case D3DBLEND_INVSRCALPHA:
-          dxgsg_cat.debug(false) << "INVSRCALPHA, ";
+          dxgsg8_cat.debug(false) << "INVSRCALPHA, ";
           break;
           break;
         case D3DBLEND_DESTALPHA:
         case D3DBLEND_DESTALPHA:
-          dxgsg_cat.debug(false) << "DESTALPHA, ";
+          dxgsg8_cat.debug(false) << "DESTALPHA, ";
           break;
           break;
         case D3DBLEND_INVDESTALPHA:
         case D3DBLEND_INVDESTALPHA:
-          dxgsg_cat.debug(false) << "INVDESTALPHA, ";
+          dxgsg8_cat.debug(false) << "INVDESTALPHA, ";
           break;
           break;
         case D3DBLEND_SRCALPHASAT:
         case D3DBLEND_SRCALPHASAT:
-          dxgsg_cat.debug(false) << "SRCALPHASAT, ";
+          dxgsg8_cat.debug(false) << "SRCALPHASAT, ";
           break;
           break;
         default:
         default:
-          dxgsg_cat.debug(false) << "unknown, ";
+          dxgsg8_cat.debug(false) << "unknown, ";
           break;
           break;
         }
         }
-    dxgsg_cat.debug(false) << endl;
+    dxgsg8_cat.debug(false) << endl;
 #endif
 #endif
     }
     }
   if ( _blend_dest_func != dfunc)
   if ( _blend_dest_func != dfunc)
@@ -321,43 +325,43 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
     _blend_dest_func = dfunc;
     _blend_dest_func = dfunc;
     scrn.pD3DDevice->SetRenderState(D3DRS_DESTBLEND, dfunc);
     scrn.pD3DDevice->SetRenderState(D3DRS_DESTBLEND, dfunc);
 #ifdef GSG_VERBOSE
 #ifdef GSG_VERBOSE
-    dxgsg_cat.debug() << "dxDstBlendFunc(";
+    dxgsg8_cat.debug() << "dxDstBlendFunc(";
     switch (dfunc)
     switch (dfunc)
         {
         {
         case D3DBLEND_ZERO:
         case D3DBLEND_ZERO:
-          dxgsg_cat.debug(false) << "ZERO, ";
+          dxgsg8_cat.debug(false) << "ZERO, ";
           break;
           break;
         case D3DBLEND_ONE:
         case D3DBLEND_ONE:
-          dxgsg_cat.debug(false) << "ONE, ";
+          dxgsg8_cat.debug(false) << "ONE, ";
           break;
           break;
         case D3DBLEND_DESTCOLOR:
         case D3DBLEND_DESTCOLOR:
-          dxgsg_cat.debug(false) << "DESTCOLOR, ";
+          dxgsg8_cat.debug(false) << "DESTCOLOR, ";
           break;
           break;
         case D3DBLEND_INVDESTCOLOR:
         case D3DBLEND_INVDESTCOLOR:
-          dxgsg_cat.debug(false) << "INVDESTCOLOR, ";
+          dxgsg8_cat.debug(false) << "INVDESTCOLOR, ";
           break;
           break;
         case D3DBLEND_SRCALPHA:
         case D3DBLEND_SRCALPHA:
-          dxgsg_cat.debug(false) << "SRCALPHA, ";
+          dxgsg8_cat.debug(false) << "SRCALPHA, ";
           break;
           break;
         case D3DBLEND_INVSRCALPHA:
         case D3DBLEND_INVSRCALPHA:
-          dxgsg_cat.debug(false) << "INVSRCALPHA, ";
+          dxgsg8_cat.debug(false) << "INVSRCALPHA, ";
           break;
           break;
         case D3DBLEND_DESTALPHA:
         case D3DBLEND_DESTALPHA:
-          dxgsg_cat.debug(false) << "DESTALPHA, ";
+          dxgsg8_cat.debug(false) << "DESTALPHA, ";
           break;
           break;
         case D3DBLEND_INVDESTALPHA:
         case D3DBLEND_INVDESTALPHA:
-          dxgsg_cat.debug(false) << "INVDESTALPHA, ";
+          dxgsg8_cat.debug(false) << "INVDESTALPHA, ";
           break;
           break;
         case D3DBLEND_SRCALPHASAT:
         case D3DBLEND_SRCALPHASAT:
-          dxgsg_cat.debug(false) << "SRCALPHASAT, ";
+          dxgsg8_cat.debug(false) << "SRCALPHASAT, ";
           break;
           break;
         }
         }
-    dxgsg_cat.debug(false) << endl;
+    dxgsg8_cat.debug(false) << endl;
 #endif
 #endif
     }
     }
 }
 }
 
 
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_zwritemask(bool val) {
 enable_zwritemask(bool val) {
     if (_depth_write_enabled != val) {
     if (_depth_write_enabled != val) {
         _depth_write_enabled = val;
         _depth_write_enabled = val;
@@ -368,24 +372,24 @@ enable_zwritemask(bool val) {
 /**  unimplemented
 /**  unimplemented
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_multisample
+//     Function: DXGraphicsStateGuardian8::enable_multisample
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_multisample(bool val) {
 enable_multisample(bool val) {
   _multisample_enabled = val;
   _multisample_enabled = val;
   #ifdef NDEBUG
   #ifdef NDEBUG
-    dxgsg_cat.error() << "dx multisample unimplemented!!\n";
+    dxgsg8_cat.error() << "dx multisample unimplemented!!\n";
   #endif
   #endif
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_multisample_alpha_one
+//     Function: DXGraphicsStateGuardian8::enable_multisample_alpha_one
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_multisample_alpha_one(bool val) {
 enable_multisample_alpha_one(bool val) {
   if (_multisample_alpha_one_enabled != val) {
   if (_multisample_alpha_one_enabled != val) {
     _multisample_alpha_one_enabled = val;
     _multisample_alpha_one_enabled = val;
@@ -393,11 +397,11 @@ enable_multisample_alpha_one(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_multisample_alpha_mask
+//     Function: DXGraphicsStateGuardian8::enable_multisample_alpha_mask
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_multisample_alpha_mask(bool val) {
 enable_multisample_alpha_mask(bool val) {
   if (_multisample_alpha_mask_enabled != val) {
   if (_multisample_alpha_mask_enabled != val) {
     _multisample_alpha_mask_enabled = val;
     _multisample_alpha_mask_enabled = val;
@@ -405,16 +409,16 @@ enable_multisample_alpha_mask(bool val) {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXGraphicsStateGuardian::enable_point_smooth
+//     Function: DXGraphicsStateGuardian8::enable_point_smooth
 //       Access:
 //       Access:
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE void DXGraphicsStateGuardian::
+INLINE void DXGraphicsStateGuardian8::
 enable_point_smooth(bool val) {
 enable_point_smooth(bool val) {
   // _point_smooth_enabled = val;
   // _point_smooth_enabled = val;
 
 
   #ifdef NDEBUG
   #ifdef NDEBUG
-    dxgsg_cat.error() << "dx point smoothing unimplemented!!\n";
+    dxgsg8_cat.error() << "dx point smoothing unimplemented!!\n";
   #endif
   #endif
 }
 }
 */
 */

File diff suppressed because it is too large
+ 149 - 208
panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx


+ 17 - 26
panda/src/dxgsg8/dxGraphicsStateGuardian8.h

@@ -19,7 +19,7 @@
 #ifndef DXGRAPHICSSTATEGUARDIAN_H
 #ifndef DXGRAPHICSSTATEGUARDIAN_H
 #define DXGRAPHICSSTATEGUARDIAN_H
 #define DXGRAPHICSSTATEGUARDIAN_H
 
 
-//#define GSG_VERBOSE
+//#define GSG_VERBOSE 1
 
 
 #include "dxgsg8base.h"
 #include "dxgsg8base.h"
 #include "dxGeomNodeContext8.h"
 #include "dxGeomNodeContext8.h"
@@ -58,20 +58,20 @@ extern void dbgPrintVidMem(LPDIRECTDRAW7 pDD, LPDDSCAPS2 lpddsCaps,const char *p
 #endif
 #endif
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//   Class : DXGraphicsStateGuardian
+//   Class : DXGraphicsStateGuardian8
 // Description : A GraphicsStateGuardian specialized for rendering
 // Description : A GraphicsStateGuardian specialized for rendering
 //               into DX.  There should be no DX calls
 //               into DX.  There should be no DX calls
 //               outside of this object.
 //               outside of this object.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDADX DXGraphicsStateGuardian : public GraphicsStateGuardian {
-  friend class wdxGraphicsWindow;
-  friend class wdxGraphicsPipe;
-  friend class wdxGraphicsWindowGroup;
-  friend class DXTextureContext;
+class EXPCL_PANDADX DXGraphicsStateGuardian8 : public GraphicsStateGuardian {
+  friend class wdxGraphicsWindow8;
+  friend class wdxGraphicsPipe8;
+  friend class wdxGraphicsWindowGroup8;
+  friend class DXTextureContext8;
 
 
 public:
 public:
-  DXGraphicsStateGuardian(GraphicsWindow *win);
-  ~DXGraphicsStateGuardian();
+  DXGraphicsStateGuardian8(GraphicsWindow *win);
+  ~DXGraphicsStateGuardian8();
 
 
   virtual void reset();
   virtual void reset();
 
 
@@ -134,12 +134,11 @@ public:
   virtual void bind_light(DirectionalLight *light, int light_id);
   virtual void bind_light(DirectionalLight *light, int light_id);
   virtual void bind_light(Spotlight *light, int light_id);
   virtual void bind_light(Spotlight *light, int light_id);
 
 
-  // default gsg begin_frame() used
+  virtual bool begin_frame();
+  virtual bool begin_scene();
+  virtual void end_scene();
   virtual void end_frame();
   virtual void end_frame();
 
 
-  virtual void start_rendering();
-  virtual void finish_rendering();
-
   virtual bool wants_normals(void) const;
   virtual bool wants_normals(void) const;
   virtual bool wants_texcoords(void) const;
   virtual bool wants_texcoords(void) const;
 
 
@@ -179,8 +178,7 @@ protected:
 
 
   bool                  _bDXisReady;
   bool                  _bDXisReady;
   HRESULT               _last_testcooplevel_result;
   HRESULT               _last_testcooplevel_result;
-  bool                  _bShowFPSMeter;
-  DXTextureContext  *_pCurTexContext;
+  DXTextureContext8  *_pCurTexContext;
 
 
   bool              _bTransformIssued;  // decaling needs to tell when a transform has been issued
   bool              _bTransformIssued;  // decaling needs to tell when a transform has been issued
   D3DMATRIX         _SavedTransform;
   D3DMATRIX         _SavedTransform;
@@ -246,7 +244,7 @@ protected:
   bool _bGouraudShadingOn;
   bool _bGouraudShadingOn;
   UINT _color_writemask;
   UINT _color_writemask;
   bool _bDrawPrimDoSetupVertexBuffer;       // if true, draw methods just copy vertex data into pCurrentGeomContext
   bool _bDrawPrimDoSetupVertexBuffer;       // if true, draw methods just copy vertex data into pCurrentGeomContext
-  DXGeomNodeContext *_pCurrentGeomContext;  // used in vertex buffer setup
+  DXGeomNodeContext8 *_pCurrentGeomContext;  // used in vertex buffer setup
 
 
   // iterators for primitives
   // iterators for primitives
   Geom::VertexIterator vi;
   Geom::VertexIterator vi;
@@ -322,16 +320,9 @@ protected:
 
 
   bool _overlay_windows_supported;
   bool _overlay_windows_supported;
 
 
-  // vars for frames/sec meter
-  DWORD _start_time;
-  DWORD _start_frame_count;
-  DWORD _cur_frame_count;
-  float _current_fps,_fpsmeter_x_offset,_fpsmeter_y_offset;
-  ::CD3DFont *_pStatMeterFont;
-
 public:
 public:
   static GraphicsStateGuardian*
   static GraphicsStateGuardian*
-  make_DXGraphicsStateGuardian(const FactoryParams &params);
+  make_DXGraphicsStateGuardian8(const FactoryParams &params);
 
 
   static TypeHandle get_class_type(void);
   static TypeHandle get_class_type(void);
   static void init_type(void);
   static void init_type(void);
@@ -339,7 +330,7 @@ public:
   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
   INLINE void SetDXReady(bool status)  { _bDXisReady = status; }
   INLINE void SetDXReady(bool status)  { _bDXisReady = status; }
   INLINE bool GetDXReady(void)  { return _bDXisReady;}
   INLINE bool GetDXReady(void)  { return _bDXisReady;}
-  void DXGraphicsStateGuardian::SetTextureBlendMode(TextureApplyAttrib::Mode TexBlendMode,bool bJustEnable);
+  void DXGraphicsStateGuardian8::SetTextureBlendMode(TextureApplyAttrib::Mode TexBlendMode,bool bJustEnable);
 
 
   // Shader Stuff
   // Shader Stuff
   DXShaderHandle read_vertex_shader(string &filename);
   DXShaderHandle read_vertex_shader(string &filename);
@@ -364,7 +355,7 @@ private:
   static TypeHandle _type_handle;
   static TypeHandle _type_handle;
 };
 };
 
 
-#include "dxGraphicsStateGuardian8.I"
+#include "DXGraphicsStateGuardian8.I"
 
 
 #endif
 #endif
 
 

+ 7 - 7
panda/src/dxgsg8/dxSavedFrameBuffer8.I

@@ -1,4 +1,4 @@
-// Filename: dxSavedFrameBuffer.I
+// Filename: dxSavedFrameBuffer8.I
 // Created by:  drose (06Oct99)
 // Created by:  drose (06Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -18,22 +18,22 @@
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXSavedFrameBuffer::Constructor
+//     Function: DXSavedFrameBuffer8::Constructor
 //       Access: Public
 //       Access: Public
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE DXSavedFrameBuffer::
-DXSavedFrameBuffer(const RenderBuffer &buffer, CPT(DisplayRegion) dr) :
+INLINE DXSavedFrameBuffer8::
+DXSavedFrameBuffer8(const RenderBuffer &buffer, CPT(DisplayRegion) dr) :
   SavedFrameBuffer(buffer, dr)
   SavedFrameBuffer(buffer, dr)
 {
 {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXSavedFrameBuffer::Destructor
+//     Function: DXSavedFrameBuffer8::Destructor
 //       Access: Public
 //       Access: Public
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-INLINE DXSavedFrameBuffer::
-~DXSavedFrameBuffer() {
+INLINE DXSavedFrameBuffer8::
+~DXSavedFrameBuffer8() {
 }
 }
 
 

+ 2 - 2
panda/src/dxgsg8/dxSavedFrameBuffer8.cxx

@@ -1,4 +1,4 @@
-// Filename: dxSavedFrameBuffer.cxx
+// Filename: dxSavedFrameBuffer8.cxx
 // Created by:  drose (06Oct99)
 // Created by:  drose (06Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -18,4 +18,4 @@
 
 
 #include "dxSavedFrameBuffer8.h"
 #include "dxSavedFrameBuffer8.h"
 
 
-TypeHandle DXSavedFrameBuffer::_type_handle;
+TypeHandle DXSavedFrameBuffer8::_type_handle;

+ 7 - 7
panda/src/dxgsg8/dxSavedFrameBuffer8.h

@@ -1,4 +1,4 @@
-// Filename: dxSavedFrameBuffer.h
+// Filename: dxSavedFrameBuffer8.h
 // Created by:  drose (06Oct99)
 // Created by:  drose (06Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -28,14 +28,14 @@
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//   Class : DXSavedFrameBuffer
+//   Class : DXSavedFrameBuffer8
 // Description :
 // Description :
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDADX DXSavedFrameBuffer : public SavedFrameBuffer {
+class EXPCL_PANDADX DXSavedFrameBuffer8 : public SavedFrameBuffer {
 public:
 public:
-  INLINE DXSavedFrameBuffer(const RenderBuffer &buffer,
+  INLINE DXSavedFrameBuffer8(const RenderBuffer &buffer,
                 CPT(DisplayRegion) dr);
                 CPT(DisplayRegion) dr);
-  INLINE ~DXSavedFrameBuffer();
+  INLINE ~DXSavedFrameBuffer8();
 
 
   PT(Texture) _back_rgba;
   PT(Texture) _back_rgba;
   PT(PixelBuffer) _depth;
   PT(PixelBuffer) _depth;
@@ -46,7 +46,7 @@ public:
   }
   }
   static void init_type() {
   static void init_type() {
     SavedFrameBuffer::init_type();
     SavedFrameBuffer::init_type();
-    register_type(_type_handle, "DXSavedFrameBuffer",
+    register_type(_type_handle, "DXSavedFrameBuffer8",
           SavedFrameBuffer::get_class_type());
           SavedFrameBuffer::get_class_type());
   }
   }
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {
@@ -58,7 +58,7 @@ private:
   static TypeHandle _type_handle;
   static TypeHandle _type_handle;
 };
 };
 
 
-#include "dxSavedFrameBuffer8.I"
+#include "DXSavedFrameBuffer8.I"
 
 
 #endif
 #endif
 
 

+ 49 - 49
panda/src/dxgsg8/dxTextureContext8.cxx

@@ -67,7 +67,7 @@ char *PandaFilterNameStrs[] = {"FT_nearest","FT_linear","FT_nearest_mipmap_neare
 };
 };
 
 
 
 
-TypeHandle DXTextureContext::_type_handle;
+TypeHandle DXTextureContext8::_type_handle;
 
 
 #define SWAPDWORDS(X,Y)  { DWORD temp=X;  X=Y; Y=temp; }
 #define SWAPDWORDS(X,Y)  { DWORD temp=X;  X=Y; Y=temp; }
 
 
@@ -152,7 +152,7 @@ enum Format {
 */
 */
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXTextureContext::get_bits_per_pixel
+//     Function: DXTextureContext8::get_bits_per_pixel
 //       Access: Protected
 //       Access: Protected
 //  Description: Maps from the PixelBuffer's Format symbols
 //  Description: Maps from the PixelBuffer's Format symbols
 //               to bpp.  returns # of alpha bits
 //               to bpp.  returns # of alpha bits
@@ -160,7 +160,7 @@ enum Format {
 //                     not the stored format, which is indicated by pixelbuffer type
 //                     not the stored format, which is indicated by pixelbuffer type
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-unsigned int DXTextureContext::
+unsigned int DXTextureContext8::
 get_bits_per_pixel(PixelBuffer::Format format, int *alphbits) {
 get_bits_per_pixel(PixelBuffer::Format format, int *alphbits) {
     *alphbits = 0;      // assume no alpha bits
     *alphbits = 0;      // assume no alpha bits
     switch(format) {
     switch(format) {
@@ -725,7 +725,7 @@ HRESULT ConvertD3DSurftoPixBuf(RECT &SrcRect,IDirect3DSurface8 *pD3DSurf8,PixelB
     BYTE *pbuf=pixbuf->_image.p();
     BYTE *pbuf=pixbuf->_image.p();
 
 
     if(IsBadWritePtr(pD3DSurf8,sizeof(DWORD))) {
     if(IsBadWritePtr(pD3DSurf8,sizeof(DWORD))) {
-        dxgsg_cat.error() << "ConvertDDSurftoPixBuf failed: bad pD3DSurf ptr value (" << ((void*)pD3DSurf8) << ")\n";
+        dxgsg8_cat.error() << "ConvertDDSurftoPixBuf failed: bad pD3DSurf ptr value (" << ((void*)pD3DSurf8) << ")\n";
         exit(1);
         exit(1);
     }
     }
 
 
@@ -745,14 +745,14 @@ HRESULT ConvertD3DSurftoPixBuf(RECT &SrcRect,IDirect3DSurface8 *pD3DSurf8,PixelB
    // or scanlines will be too long
    // or scanlines will be too long
 
 
     if(!((dwCopyWidth==pixbuf->get_xsize()) && (dwCopyHeight<=(DWORD)pixbuf->get_ysize()))) {
     if(!((dwCopyWidth==pixbuf->get_xsize()) && (dwCopyHeight<=(DWORD)pixbuf->get_ysize()))) {
-        dxgsg_cat.error() << "ConvertDDSurftoPixBuf, PixBuf size too small to hold display surface!\n";
+        dxgsg8_cat.error() << "ConvertDDSurftoPixBuf, PixBuf size too small to hold display surface!\n";
         assert(0);
         assert(0);
         return E_FAIL;
         return E_FAIL;
     }
     }
 
 
     hr = pD3DSurf8->LockRect(&LockedRect,(CONST RECT*)NULL,(D3DLOCK_READONLY | D3DLOCK_NO_DIRTY_UPDATE /* | D3DLOCK_NOSYSLOCK */));
     hr = pD3DSurf8->LockRect(&LockedRect,(CONST RECT*)NULL,(D3DLOCK_READONLY | D3DLOCK_NO_DIRTY_UPDATE /* | D3DLOCK_NOSYSLOCK */));
     if(FAILED(hr)) {
     if(FAILED(hr)) {
-        dxgsg_cat.error() << "ConvertDDSurftoPixBuf LockRect() failed!" << D3DERRORSTRING(hr);
+        dxgsg8_cat.error() << "ConvertDDSurftoPixBuf LockRect() failed!" << D3DERRORSTRING(hr);
         return hr;
         return hr;
     }
     }
 
 
@@ -768,8 +768,8 @@ HRESULT ConvertD3DSurftoPixBuf(RECT &SrcRect,IDirect3DSurface8 *pD3DSurf8,PixelB
 
 
     // writes out last line in DDSurf first in PixelBuf, so Y line order precedes inversely
     // writes out last line in DDSurf first in PixelBuf, so Y line order precedes inversely
 
 
-    if(dxgsg_cat.is_debug()) {
-        dxgsg_cat.debug() << "ConvertD3DSurftoPixBuf converting " << D3DFormatStr(SurfDesc.Format) << "bpp DDSurf to "
+    if(dxgsg8_cat.is_debug()) {
+        dxgsg8_cat.debug() << "ConvertD3DSurftoPixBuf converting " << D3DFormatStr(SurfDesc.Format) << "bpp DDSurf to "
                           <<  dwNumComponents << "-channel panda PixelBuffer\n";
                           <<  dwNumComponents << "-channel panda PixelBuffer\n";
     }
     }
 
 
@@ -970,7 +970,7 @@ HRESULT ConvertD3DSurftoPixBuf(RECT &SrcRect,IDirect3DSurface8 *pD3DSurf8,PixelB
         }
         }
 
 
         default:
         default:
-            dxgsg_cat.error() << "ConvertD3DSurftoPixBuf: unsupported D3DFORMAT!\n";
+            dxgsg8_cat.error() << "ConvertD3DSurftoPixBuf: unsupported D3DFORMAT!\n";
     }
     }
 
 
     pD3DSurf8->UnlockRect();
     pD3DSurf8->UnlockRect();
@@ -983,7 +983,7 @@ HRESULT ConvertD3DSurftoPixBuf(RECT &SrcRect,IDirect3DSurface8 *pD3DSurf8,PixelB
 //       This code gets the attributes of the texture from the bitmap, creates the
 //       This code gets the attributes of the texture from the bitmap, creates the
 //       texture, and then copies the bitmap into the texture.
 //       texture, and then copies the bitmap into the texture.
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
+IDirect3DTexture8 *DXTextureContext8::CreateTexture(DXScreenData &scrn) {
     HRESULT hr;
     HRESULT hr;
     int cNumAlphaBits;     //  number of alpha bits in texture pixfmt
     int cNumAlphaBits;     //  number of alpha bits in texture pixfmt
     D3DFORMAT TargetPixFmt=D3DFMT_UNKNOWN;
     D3DFORMAT TargetPixFmt=D3DFMT_UNKNOWN;
@@ -1001,7 +1001,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
     assert(pixbuf_type==PixelBuffer::T_unsigned_byte);   // cant handle anything else now
     assert(pixbuf_type==PixelBuffer::T_unsigned_byte);   // cant handle anything else now
 
 
     if((pixbuf_type!=PixelBuffer::T_unsigned_byte) || (pbuf->get_component_width()!=1)) {
     if((pixbuf_type!=PixelBuffer::T_unsigned_byte) || (pbuf->get_component_width()!=1)) {
-        dxgsg_cat.error() << "CreateTexture failed, havent handled non 8-bit channel pixelbuffer types yet! \n";
+        dxgsg8_cat.error() << "CreateTexture failed, havent handled non 8-bit channel pixelbuffer types yet! \n";
         return NULL;
         return NULL;
     }
     }
 
 
@@ -1016,7 +1016,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
 
 
     if(cNumAlphaBits>0) {
     if(cNumAlphaBits>0) {
         if(cNumColorChannels==3) {
         if(cNumColorChannels==3) {
-            dxgsg_cat.error() << "ERROR: texture " << _tex->get_name() << " has no inherent alpha channel, but alpha format is requested (that would be wasteful)!\n";
+            dxgsg8_cat.error() << "ERROR: texture " << _tex->get_name() << " has no inherent alpha channel, but alpha format is requested (that would be wasteful)!\n";
             exit(1);
             exit(1);
         }
         }
     }
     }
@@ -1053,7 +1053,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
     DWORD TargetHeight=dwOrigHeight;
     DWORD TargetHeight=dwOrigHeight;
 
 
     if(!ISPOW2(dwOrigWidth) || !ISPOW2(dwOrigHeight)) {
     if(!ISPOW2(dwOrigWidth) || !ISPOW2(dwOrigHeight)) {
-        dxgsg_cat.error() << "ERROR: texture dimensions are not a power of 2 for " << _tex->get_name() << "! Please rescale them so it doesnt have to be done at runtime.\n";
+        dxgsg8_cat.error() << "ERROR: texture dimensions are not a power of 2 for " << _tex->get_name() << "! Please rescale them so it doesnt have to be done at runtime.\n";
         #ifndef NDEBUG
         #ifndef NDEBUG
           exit(1);  // want to catch badtexsize errors
           exit(1);  // want to catch badtexsize errors
         #else
         #else
@@ -1066,7 +1066,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
 
 
     if((dwOrigWidth>scrn.d3dcaps.MaxTextureWidth)||(dwOrigHeight>scrn.d3dcaps.MaxTextureHeight)) {
     if((dwOrigWidth>scrn.d3dcaps.MaxTextureWidth)||(dwOrigHeight>scrn.d3dcaps.MaxTextureHeight)) {
         #ifdef _DEBUG
         #ifdef _DEBUG
-           dxgsg_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << scrn.d3dcaps.MaxTextureWidth << "," << scrn.d3dcaps.MaxTextureHeight << ") !!\n"
+           dxgsg8_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << scrn.d3dcaps.MaxTextureWidth << "," << scrn.d3dcaps.MaxTextureHeight << ") !!\n"
            << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<<  scrn.d3dcaps.MaxTextureWidth << "," << scrn.d3dcaps.MaxTextureHeight << ") !\n";
            << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<<  scrn.d3dcaps.MaxTextureWidth << "," << scrn.d3dcaps.MaxTextureHeight << ") !\n";
         #endif
         #endif
 
 
@@ -1087,7 +1087,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
         bShrinkOriginal=true;
         bShrinkOriginal=true;
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
-        dxgsg_cat.debug() << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< TargetWidth<<"," << TargetHeight << ") to meet HW square texture reqmt\n";
+        dxgsg8_cat.debug() << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< TargetWidth<<"," << TargetHeight << ") to meet HW square texture reqmt\n";
 #endif
 #endif
     }
     }
 /*
 /*
@@ -1109,10 +1109,10 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
 
 
     char *szErrorMsg;
     char *szErrorMsg;
 
 
-    szErrorMsg = "CreateTexture failed: couldn't find compatible device Texture Pixel Format for input texture: ";
+    szErrorMsg = "CreateTexture failed: couldn't find compatible device Texture Pixel Format for input texture";
 
 
-    if(dxgsg_cat.is_spam())
-        dxgsg_cat.spam() << "CreateTexture handling target bitdepth: " << target_bpp << " alphabits: " << cNumAlphaBits << endl;
+    if(dxgsg8_cat.is_spam())
+        dxgsg8_cat.spam() << "CreateTexture handling target bitdepth: " << target_bpp << " alphabits: " << cNumAlphaBits << endl;
 
 
     // I could possibly replace some of this logic with D3DXCheckTextureRequirements(), but
     // I could possibly replace some of this logic with D3DXCheckTextureRequirements(), but
     // it wouldnt handle all my specialized low-memory cases perfectly
     // it wouldnt handle all my specialized low-memory cases perfectly
@@ -1298,7 +1298,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
     }
     }
 
 
     // if we've gotten here, haven't found a match
     // if we've gotten here, haven't found a match
-    dxgsg_cat.error() << szErrorMsg << ": " << _tex->get_name() << endl
+    dxgsg8_cat.error() << szErrorMsg << ": " << _tex->get_name() << endl
                       << "NumColorChannels: " <<cNumColorChannels << "; NumAlphaBits: " << cNumAlphaBits
                       << "NumColorChannels: " <<cNumColorChannels << "; NumAlphaBits: " << cNumAlphaBits
                       << "; targetbpp: " <<target_bpp << "; SupportedTexFmtsMask: 0x" << (void*)scrn.SupportedTexFmtsMask
                       << "; targetbpp: " <<target_bpp << "; SupportedTexFmtsMask: 0x" << (void*)scrn.SupportedTexFmtsMask
                       << "; NeedLuminance: " << bNeedLuminance << endl;
                       << "; NeedLuminance: " << bNeedLuminance << endl;
@@ -1339,9 +1339,9 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
 
 
         if(dx_mipmap_everything) {  // debug toggle, ok to leave in since its just a creation cost
         if(dx_mipmap_everything) {  // debug toggle, ok to leave in since its just a creation cost
            _bHasMipMaps=TRUE;
            _bHasMipMaps=TRUE;
-           if(dxgsg_cat.is_spam()) {
+           if(dxgsg8_cat.is_spam()) {
                if(ft != Texture::FT_linear_mipmap_linear)
                if(ft != Texture::FT_linear_mipmap_linear)
-                   dxgsg_cat.spam() << "Forcing trilinear mipmapping on DX texture [" << _tex->get_name() << "]\n";
+                   dxgsg8_cat.spam() << "Forcing trilinear mipmapping on DX texture [" << _tex->get_name() << "]\n";
            }
            }
            ft = Texture::FT_linear_mipmap_linear;
            ft = Texture::FT_linear_mipmap_linear;
            _tex->set_minfilter(ft);
            _tex->set_minfilter(ft);
@@ -1397,7 +1397,7 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
     _tex->set_anisotropic_degree(aniso_degree);
     _tex->set_anisotropic_degree(aniso_degree);
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
-    dxgsg_cat.spam() << "CreateTexture: setting aniso degree for "<< _tex->get_name() << " to: " << aniso_degree << endl;
+    dxgsg8_cat.spam() << "CreateTexture: setting aniso degree for "<< _tex->get_name() << " to: " << aniso_degree << endl;
 #endif
 #endif
 
 
     UINT cMipLevelCount;
     UINT cMipLevelCount;
@@ -1405,13 +1405,13 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
     if(_bHasMipMaps) {
     if(_bHasMipMaps) {
         cMipLevelCount=0;  // tell CreateTex to alloc space for all mip levels down to 1x1
         cMipLevelCount=0;  // tell CreateTex to alloc space for all mip levels down to 1x1
 
 
-        if(dxgsg_cat.is_debug())
-            dxgsg_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
+        if(dxgsg8_cat.is_debug())
+            dxgsg8_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
     } else cMipLevelCount=1;
     } else cMipLevelCount=1;
 
 
     if(FAILED( hr = scrn.pD3DDevice->CreateTexture(TargetWidth,TargetHeight,cMipLevelCount,0x0,
     if(FAILED( hr = scrn.pD3DDevice->CreateTexture(TargetWidth,TargetHeight,cMipLevelCount,0x0,
                                                    TargetPixFmt,D3DPOOL_MANAGED,&_pD3DTexture8) )) {
                                                    TargetPixFmt,D3DPOOL_MANAGED,&_pD3DTexture8) )) {
-        dxgsg_cat.error() << "pD3DDevice->CreateTexture() failed!" << D3DERRORSTRING(hr);
+        dxgsg8_cat.error() << "pD3DDevice->CreateTexture() failed!" << D3DERRORSTRING(hr);
         goto error_exit;
         goto error_exit;
     }
     }
 
 
@@ -1421,9 +1421,9 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
 #ifdef DO_CUSTOM_CONVERSIONS
 #ifdef DO_CUSTOM_CONVERSIONS
-    dxgsg_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converting " << ConvNameStrs[ConvNeeded] << " \n";
+    dxgsg8_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converting " << ConvNameStrs[ConvNeeded] << " \n";
 #else
 #else
-    dxgsg_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converting panda equivalent of " << D3DFormatStr(_PixBufD3DFmt) << " => " << D3DFormatStr(TargetPixFmt) << endl;
+    dxgsg8_cat.debug() << "CreateTexture: "<< _tex->get_name() <<" converting panda equivalent of " << D3DFormatStr(_PixBufD3DFmt) << " => " << D3DFormatStr(TargetPixFmt) << endl;
 #endif
 #endif
 #endif
 #endif
 
 
@@ -1439,23 +1439,23 @@ IDirect3DTexture8 *DXTextureContext::CreateTexture(DXScreenData &scrn) {
 
 
   error_exit:
   error_exit:
 
 
-    RELEASE(_pD3DTexture8,dxgsg,"texture",RELEASE_ONCE);
+    RELEASE(_pD3DTexture8,dxgsg8,"texture",RELEASE_ONCE);
     return NULL;
     return NULL;
 }
 }
 
 
-HRESULT DXTextureContext::
+HRESULT DXTextureContext8::
 FillDDSurfTexturePixels(void) {
 FillDDSurfTexturePixels(void) {
     HRESULT hr=E_FAIL;
     HRESULT hr=E_FAIL;
     assert(IS_VALID_PTR(_texture));
     assert(IS_VALID_PTR(_texture));
 
 
     if(!_texture->has_ram_image()) {
     if(!_texture->has_ram_image()) {
-      dxgsg_cat.warning() << "CreateTexture: tried to fill surface that has no ram image!\n";
+      dxgsg8_cat.warning() << "CreateTexture: tried to fill surface that has no ram image!\n";
       return S_OK;
       return S_OK;
     }
     }
 
 
     PixelBuffer *pbuf = _texture->get_ram_image();
     PixelBuffer *pbuf = _texture->get_ram_image();
     if (pbuf == (PixelBuffer *)NULL) {
     if (pbuf == (PixelBuffer *)NULL) {
-      dxgsg_cat.fatal() << "CreateTexture: get_ram_image() failed\n";
+      dxgsg8_cat.fatal() << "CreateTexture: get_ram_image() failed\n";
       // The texture doesn't have an image to load.
       // The texture doesn't have an image to load.
       return E_FAIL;
       return E_FAIL;
     }
     }
@@ -1473,7 +1473,7 @@ FillDDSurfTexturePixels(void) {
     IDirect3DSurface8 *pMipLevel0;
     IDirect3DSurface8 *pMipLevel0;
     hr=_pD3DTexture8->GetSurfaceLevel(0,&pMipLevel0);
     hr=_pD3DTexture8->GetSurfaceLevel(0,&pMipLevel0);
     if(FAILED(hr)) {
     if(FAILED(hr)) {
-       dxgsg_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", GetSurfaceLevel failed" << D3DERRORSTRING(hr);
+       dxgsg8_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", GetSurfaceLevel failed" << D3DERRORSTRING(hr);
        return E_FAIL;
        return E_FAIL;
     }
     }
 
 
@@ -1496,7 +1496,7 @@ FillDDSurfTexturePixels(void) {
         // alloc buffer for explicit D3DFMT_A8L8
         // alloc buffer for explicit D3DFMT_A8L8
         USHORT *pTempPixBuf=new USHORT[OrigWidth*OrigHeight];
         USHORT *pTempPixBuf=new USHORT[OrigWidth*OrigHeight];
         if(!IS_VALID_PTR(pTempPixBuf)) {
         if(!IS_VALID_PTR(pTempPixBuf)) {
-            dxgsg_cat.error() << "FillDDSurfaceTexturePixels couldnt alloc mem for temp pixbuf!\n";
+            dxgsg8_cat.error() << "FillDDSurfaceTexturePixels couldnt alloc mem for temp pixbuf!\n";
             goto exit_FillDDSurf;
             goto exit_FillDDSurf;
         }
         }
         bUsingTempPixBuf=true;
         bUsingTempPixBuf=true;
@@ -1516,7 +1516,7 @@ FillDDSurfTexturePixels(void) {
     hr=D3DXLoadSurfaceFromMemory(pMipLevel0,(PALETTEENTRY*)NULL,(RECT*)NULL,(LPCVOID)pPixels,SrcFormat,
     hr=D3DXLoadSurfaceFromMemory(pMipLevel0,(PALETTEENTRY*)NULL,(RECT*)NULL,(LPCVOID)pPixels,SrcFormat,
                                  SrcPixBufRowByteLength,(PALETTEENTRY*)NULL,&SrcSize,Lev0Filter,(D3DCOLOR)0x0);
                                  SrcPixBufRowByteLength,(PALETTEENTRY*)NULL,&SrcSize,Lev0Filter,(D3DCOLOR)0x0);
     if(FAILED(hr)) {
     if(FAILED(hr)) {
-       dxgsg_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", D3DXLoadSurfFromMem failed" << D3DERRORSTRING(hr);
+       dxgsg8_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", D3DXLoadSurfFromMem failed" << D3DERRORSTRING(hr);
        goto exit_FillDDSurf;
        goto exit_FillDDSurf;
     }
     }
 
 
@@ -1529,7 +1529,7 @@ FillDDSurfTexturePixels(void) {
 
 
         hr=D3DXFilterTexture(_pD3DTexture8,(PALETTEENTRY*)NULL,0,MipFilterFlags);
         hr=D3DXFilterTexture(_pD3DTexture8,(PALETTEENTRY*)NULL,0,MipFilterFlags);
         if(FAILED(hr)) {
         if(FAILED(hr)) {
-            dxgsg_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", D3DXFilterTex failed" << D3DERRORSTRING(hr);
+            dxgsg8_cat.error() << "FillDDSurfaceTexturePixels failed for "<< _tex->get_name() <<", D3DXFilterTex failed" << D3DERRORSTRING(hr);
             goto exit_FillDDSurf;
             goto exit_FillDDSurf;
         }
         }
     }
     }
@@ -1538,7 +1538,7 @@ FillDDSurfTexturePixels(void) {
     if(bUsingTempPixBuf) {
     if(bUsingTempPixBuf) {
       SAFE_DELETE_ARRAY(pPixels);
       SAFE_DELETE_ARRAY(pPixels);
     }
     }
-    RELEASE(pMipLevel0,dxgsg,"texture",RELEASE_ONCE);
+    RELEASE(pMipLevel0,dxgsg8,"texture",RELEASE_ONCE);
     return hr;
     return hr;
 }
 }
 
 
@@ -1548,13 +1548,13 @@ FillDDSurfTexturePixels(void) {
 // Name: DeleteTexture()
 // Name: DeleteTexture()
 // Desc: Release the surface used to store the texture
 // Desc: Release the surface used to store the texture
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-void DXTextureContext::
+void DXTextureContext8::
 DeleteTexture( ) {
 DeleteTexture( ) {
-    if(dxgsg_cat.is_spam()) {
-        dxgsg_cat.spam() << "Deleting DX texture for " << _tex->get_name() << "\n";
+    if(dxgsg8_cat.is_spam()) {
+        dxgsg8_cat.spam() << "Deleting DX texture for " << _tex->get_name() << "\n";
     }
     }
 
 
-    RELEASE(_pD3DTexture8,dxgsg,"texture",RELEASE_ONCE);
+    RELEASE(_pD3DTexture8,dxgsg8,"texture",RELEASE_ONCE);
 /*
 /*
 #ifdef DEBUG_RELEASES
 #ifdef DEBUG_RELEASES
     if(_surface) {
     if(_surface) {
@@ -1563,28 +1563,28 @@ DeleteTexture( ) {
         pDD->Release();
         pDD->Release();
 
 
         PRINTREFCNT(pDD,"before DeleteTex, IDDraw7");
         PRINTREFCNT(pDD,"before DeleteTex, IDDraw7");
-        RELEASE(_surface,dxgsg,"texture",false);
+        RELEASE(_surface,dxgsg8,"texture",false);
         PRINTREFCNT(pDD,"after DeleteTex, IDDraw7");
         PRINTREFCNT(pDD,"after DeleteTex, IDDraw7");
     }
     }
 #else
 #else
 
 
-    RELEASE(_pD3DSurf8,dxgsg,"texture",false);
+    RELEASE(_pD3DSurf8,dxgsg8,"texture",false);
  #endif
  #endif
 */
 */
 }
 }
 
 
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: DXTextureContext::Constructor
+//     Function: DXTextureContext8::Constructor
 //       Access: Public
 //       Access: Public
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-DXTextureContext::
-DXTextureContext(Texture *tex) :
+DXTextureContext8::
+DXTextureContext8(Texture *tex) :
 TextureContext(tex) {
 TextureContext(tex) {
 
 
-    if(dxgsg_cat.is_spam()) {
-       dxgsg_cat.spam() << "Creating DX texture [" << tex->get_name() << "], minfilter(" << PandaFilterNameStrs[tex->get_minfilter()] << "), magfilter("<<PandaFilterNameStrs[tex->get_magfilter()] << "), anisodeg(" << tex->get_anisotropic_degree() << ")\n";
+    if(dxgsg8_cat.is_spam()) {
+       dxgsg8_cat.spam() << "Creating DX texture [" << tex->get_name() << "], minfilter(" << PandaFilterNameStrs[tex->get_minfilter()] << "), magfilter("<<PandaFilterNameStrs[tex->get_magfilter()] << "), anisodeg(" << tex->get_anisotropic_degree() << ")\n";
     }
     }
 
 
     _pD3DTexture8 = NULL;
     _pD3DTexture8 = NULL;
@@ -1592,8 +1592,8 @@ TextureContext(tex) {
     _tex = tex;
     _tex = tex;
 }
 }
 
 
-DXTextureContext::
-~DXTextureContext() {
+DXTextureContext8::
+~DXTextureContext8() {
     DeleteTexture();
     DeleteTexture();
     TextureContext::~TextureContext();
     TextureContext::~TextureContext();
     _tex = NULL;
     _tex = NULL;

+ 10 - 10
panda/src/dxgsg8/dxTextureContext8.h

@@ -1,4 +1,4 @@
-// Filename: dxTextureContext.h
+// Filename: dxTextureContext8.h
 // Created by:  drose (07Oct99)
 // Created by:  drose (07Oct99)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -16,26 +16,26 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
-#ifndef DXTEXTURECONTEXT_H
-#define DXTEXTURECONTEXT_H
+#ifndef DXTEXTURECONTEXT8_H
+#define DXTEXTURECONTEXT8_H
 
 
 #include "dxgsg8base.h"
 #include "dxgsg8base.h"
-#include <texture.h>
-#include <textureContext.h>
+#include "texture.h"
+#include "textureContext.h"
 
 
 //#define DO_CUSTOM_CONVERSIONS
 //#define DO_CUSTOM_CONVERSIONS
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//   Class : DXTextureContext
+//   Class : DXTextureContext8
 // Description :
 // Description :
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-class EXPCL_PANDADX DXTextureContext : public TextureContext {
+class EXPCL_PANDADX DXTextureContext8 : public TextureContext {
   friend class DXGraphicsStateGuardian;
   friend class DXGraphicsStateGuardian;
   friend class wdxGraphicsWindow;
   friend class wdxGraphicsWindow;
 
 
 public:
 public:
-  DXTextureContext(Texture *tex);
-  ~DXTextureContext();
+  DXTextureContext8(Texture *tex);
+  ~DXTextureContext8();
 
 
   IDirect3DTexture8  *_pD3DTexture8;
   IDirect3DTexture8  *_pD3DTexture8;
   Texture *_tex;            // ptr to parent, primarily for access to namestr
   Texture *_tex;            // ptr to parent, primarily for access to namestr
@@ -62,7 +62,7 @@ public:
   }
   }
   static void init_type() {
   static void init_type() {
     TextureContext::init_type();
     TextureContext::init_type();
-    register_type(_type_handle, "DXTextureContext",
+    register_type(_type_handle, "DXTextureContext8",
           TextureContext::get_class_type());
           TextureContext::get_class_type());
   }
   }
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {

+ 2 - 0
panda/src/dxgsg8/dxgsg8_composite1.cxx

@@ -3,3 +3,5 @@
 #include "dxTextureContext8.cxx"
 #include "dxTextureContext8.cxx"
 #include "dxGeomNodeContext8.cxx"
 #include "dxGeomNodeContext8.cxx"
 #include "d3dfont8.cxx"
 #include "d3dfont8.cxx"
+#include "wdxGraphicsPipe8.cxx"
+#include "wdxGraphicsWindow8.cxx"

+ 0 - 1
panda/src/dxgsg8/dxgsg8base.h

@@ -186,7 +186,6 @@ typedef struct {
       LPDIRECT3D8       pD3D8;
       LPDIRECT3D8       pD3D8;
       HWND              hWnd;
       HWND              hWnd;
       HMONITOR          hMon;
       HMONITOR          hMon;
-      GraphicsWindow::Properties *pProps;  // can get window rect here (or from GetWindowRect(hWnd), can also get window size in PresParams
       DWORD             MaxAvailVidMem;
       DWORD             MaxAvailVidMem;
       ushort            CardIDNum;  // adapter ID
       ushort            CardIDNum;  // adapter ID
       ushort            depth_buffer_bitdepth;  //GetSurfaceDesc is not reliable so must store this explicitly
       ushort            depth_buffer_bitdepth;  //GetSurfaceDesc is not reliable so must store this explicitly

+ 2 - 12
panda/src/sgiglutdisplay/config_sgiglutdisplay.h → panda/src/dxgsg8/wdxGraphicsPipe8.I

@@ -1,5 +1,5 @@
-// Filename: config_sgiglutdisplay.h
-// Created by:  cary (07Oct99)
+// Filename: wdxGraphicsPipe8.I
+// Created by:  drose (20Dec02)
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //
 //
@@ -15,13 +15,3 @@
 // [email protected] .
 // [email protected] .
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-
-#ifndef CONFIG_SGIGLUTDISPLAY_H
-#define CONFIG_SGIGLUTDISPLAY_H
-
-#include <pandabase.h>
-#include <notifyCategoryProxy.h>
-
-NotifyCategoryDecl(sgiglutdisplay, EXPCL_PANDAGL, EXPTP_PANDAGL);
-
-#endif

+ 339 - 0
panda/src/dxgsg8/wdxGraphicsPipe8.cxx

@@ -0,0 +1,339 @@
+// Filename: wdxGraphicsPipe8.cxx
+// Created by:  drose (20Dec02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "wdxGraphicsPipe8.h"
+#include "wdxGraphicsWindow8.h"
+#include "config_dxgsg8.h"
+
+TypeHandle wdxGraphicsPipe8::_type_handle;
+
+// #define LOWVIDMEMTHRESHOLD 3500000
+// #define CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD 1000000
+#define LOWVIDMEMTHRESHOLD 5700000  // 4MB cards should fall below this
+#define CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD 1000000  // if # is > 1MB, card is lying and I cant tell what it is
+
+#define UNKNOWN_VIDMEM_SIZE 0xFFFFFFFF
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsPipe8::Constructor
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+wdxGraphicsPipe8::
+wdxGraphicsPipe8() {
+  _hDDrawDLL = NULL;
+  _hD3D8_DLL = NULL;
+  _is_valid = init();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsPipe8::Destructor
+//       Access: Public, Virtual
+//  Description: 
+////////////////////////////////////////////////////////////////////
+wdxGraphicsPipe8::
+~wdxGraphicsPipe8() {
+  if (_hDDrawDLL != NULL) {
+    FreeLibrary(_hDDrawDLL);
+    _hDDrawDLL = NULL;
+  }
+  if(_hD3D8_DLL != NULL) {
+    FreeLibrary(_hD3D8_DLL);
+    _hD3D8_DLL = NULL;
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsPipe8::pipe_constructor
+//       Access: Public, Static
+//  Description: This function is passed to the GraphicsPipeSelection
+//               object to allow the user to make a default
+//               wdxGraphicsPipe8.
+////////////////////////////////////////////////////////////////////
+PT(GraphicsPipe) wdxGraphicsPipe8::
+pipe_constructor() {
+  return new wdxGraphicsPipe8;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsPipe8::make_window
+//       Access: Protected, Virtual
+//  Description: Creates a new window on the pipe, if possible.
+////////////////////////////////////////////////////////////////////
+PT(GraphicsWindow) wdxGraphicsPipe8::
+make_window() {
+  if (!_is_valid) {
+    return NULL;
+  }
+
+  return new wdxGraphicsWindow8(this);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsPipe8::init
+//       Access: Private
+//  Description: Performs some initialization steps to load up
+//               function pointers from the relevant DLL's, and
+//               determine the number and type of available graphics
+//               adapters, etc.  Returns true on success, false on
+//               failure.
+////////////////////////////////////////////////////////////////////
+bool wdxGraphicsPipe8::
+init() {
+  static const char * const ddraw_name = "ddraw.dll";
+  _hDDrawDLL = LoadLibrary(ddraw_name);
+  if(_hDDrawDLL == 0) {
+    wdxdisplay8_cat.error()
+      << "can't locate " << ddraw_name << "!\n";
+    return false;
+  }
+
+  _DirectDrawCreateEx = 
+    (LPDIRECTDRAWCREATEEX)GetProcAddress(_hDDrawDLL, "DirectDrawCreateEx");
+  if (_DirectDrawCreateEx == NULL) {
+    wdxdisplay8_cat.error()
+      << "GetProcAddr failed for DDCreateEx" << endl;
+    return false;
+  }
+
+  _DirectDrawEnumerateExA = (LPDIRECTDRAWENUMERATEEX)GetProcAddress(_hDDrawDLL, "DirectDrawEnumerateExA");
+  if (_DirectDrawEnumerateExA == NULL) {
+    wdxdisplay8_cat.error()
+      << "GetProcAddr failed for DirectDrawEnumerateEx! (win95 system?)\n";
+    return false;
+  }
+
+  static const char * const d3d8_name = "d3d8.dll";
+  _hD3D8_DLL = LoadLibrary(d3d8_name);
+  if (_hD3D8_DLL == 0) {
+    wdxdisplay8_cat.error()
+      << "PandaDX8 requires DX8, can't locate " << d3d8_name << "!\n";
+    return false;
+  }
+
+  // dont want to statically link to possibly non-existent d3d8 dll,
+  // so must call D3DCr8 indirectly
+  static const char * const d3dcreate8_name = "Direct3DCreate8";
+  _Direct3DCreate8 =
+    (Direct3DCreate8_ProcPtr)GetProcAddress(_hD3D8_DLL, d3dcreate8_name);
+
+  if (_Direct3DCreate8 == NULL) {
+    wdxdisplay8_cat.error()
+      << "GetProcAddress for " << d3dcreate8_name << "failed!" << endl;
+    return false;
+  }
+
+  return find_all_card_memavails();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsPipe8::find_all_card_memavails
+//       Access: Private
+//  Description: Uses DX7 calls to determine how much video memory is
+//               available for each video adapter in the system.
+//               Returns true on success, false on failure.
+////////////////////////////////////////////////////////////////////
+bool wdxGraphicsPipe8::
+find_all_card_memavails() {
+  HRESULT hr;
+
+  hr = (*_DirectDrawEnumerateExA)(dx7_driver_enum_callback, this, 
+                                  DDENUM_ATTACHEDSECONDARYDEVICES | DDENUM_NONDISPLAYDEVICES);
+  if (FAILED(hr)) {
+    wdxdisplay8_cat.fatal()
+      << "DirectDrawEnumerateEx failed" << D3DERRORSTRING(hr);
+    return false;
+  }
+
+  if (_card_ids.empty()) {
+    wdxdisplay8_cat.error()
+      << "DirectDrawEnumerateEx enum'ed no devices!\n";
+    return false;
+  }
+
+  GUID ZeroGUID;
+  ZeroMemory(&ZeroGUID, sizeof(GUID));
+
+  if (_card_ids.size() > 1) {
+    assert(IsEqualGUID(ZeroGUID, _card_ids[0].DX7_DeviceGUID));
+    // delete enum of primary display (always the first), since it is
+    // duplicated by explicit entry
+    _card_ids.erase(_card_ids.begin());
+  }
+
+  for (UINT i=0; i < _card_ids.size(); i++) {
+    LPDIRECTDRAW7 pDD;
+    BYTE ddd_space[sizeof(DDDEVICEIDENTIFIER2)+4];  //bug in DX7 requires 4 extra bytes for GetDeviceID
+    DDDEVICEIDENTIFIER2 *pDX7DeviceID=(DDDEVICEIDENTIFIER2 *)&ddd_space[0];
+    GUID *pGUID= &(_card_ids[i].DX7_DeviceGUID);
+
+    if (IsEqualGUID(*pGUID, ZeroGUID)) {
+      pGUID=NULL;
+    }
+
+    // Create the Direct Draw Object
+    hr = (*_DirectDrawCreateEx)(pGUID,(void **)&pDD, IID_IDirectDraw7, NULL);
+    if (FAILED(hr)) {
+      wdxdisplay8_cat.error()
+        << "DirectDrawCreateEx failed for device (" << i
+        << ")" << D3DERRORSTRING(hr);
+      continue;
+    }
+
+    ZeroMemory(ddd_space, sizeof(DDDEVICEIDENTIFIER2));
+
+    hr = pDD->GetDeviceIdentifier(pDX7DeviceID, 0x0);
+    if (FAILED(hr)) {
+      wdxdisplay8_cat.error()
+        << "GetDeviceID failed for device ("<< i << ")" << D3DERRORSTRING(hr);
+      continue;
+    }
+
+    _card_ids[i].DeviceID = pDX7DeviceID->dwDeviceId;
+    _card_ids[i].VendorID = pDX7DeviceID->dwVendorId;
+
+    // Get Current VidMem avail.  Note this is only an estimate, when
+    // we switch to fullscreen mode from desktop, more vidmem will be
+    // available (typically 1.2 meg).  I dont want to switch to
+    // fullscreen more than once due to the annoying monitor flicker,
+    // so try to figure out optimal mode using this estimate
+    DDSCAPS2 ddsGAVMCaps;
+    DWORD dwVidMemTotal,dwVidMemFree;
+    dwVidMemTotal=dwVidMemFree=0;
+    {
+      // print out total INCLUDING AGP just for information purposes
+      // and future use.  The real value I'm interested in for
+      // purposes of measuring possible valid screen sizes shouldnt
+      // include AGP.
+      ZeroMemory(&ddsGAVMCaps, sizeof(DDSCAPS2));
+      ddsGAVMCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
+
+      hr = pDD->GetAvailableVidMem(&ddsGAVMCaps, &dwVidMemTotal, &dwVidMemFree);
+      if (FAILED(hr)) {
+        wdxdisplay8_cat.error()
+          << "GetAvailableVidMem failed for device #" << i 
+          << D3DERRORSTRING(hr);
+        // goto skip_device;
+        exit(1);  // probably want to exit, since it may be my fault
+      }
+    }
+
+    wdxdisplay8_cat.info()
+      << "GetAvailableVidMem (including AGP) returns Total: "
+      << dwVidMemTotal <<", Free: " << dwVidMemFree
+      << " for device #" << i << endl;
+
+    ZeroMemory(&ddsGAVMCaps, sizeof(DDSCAPS2));
+
+    // just want to measure localvidmem, not AGP texmem
+    ddsGAVMCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM;
+
+    hr = pDD->GetAvailableVidMem(&ddsGAVMCaps, &dwVidMemTotal, &dwVidMemFree);
+    if (FAILED(hr)) {
+      wdxdisplay8_cat.error()
+        << "GetAvailableVidMem failed for device #"<< i<< D3DERRORSTRING(hr);
+      // goto skip_device;
+      exit(1);  // probably want to exit, since it may be my fault
+    }
+
+    wdxdisplay8_cat.info()
+      << "GetAvailableVidMem (no AGP) returns Total: " << dwVidMemTotal
+      << ", Free: " << dwVidMemFree << " for device #"<< i<< endl;
+
+    pDD->Release();  // release DD obj, since this is all we needed it for
+
+    if (!dx_do_vidmemsize_check) {
+      // still calling the DD stuff to get deviceID, etc.  is this necessary?
+      _card_ids[i].MaxAvailVidMem = UNKNOWN_VIDMEM_SIZE;
+      _card_ids[i].bIsLowVidMemCard = false;
+      continue;
+    }
+
+    if (dwVidMemTotal == 0) {  // unreliable driver
+      dwVidMemTotal = UNKNOWN_VIDMEM_SIZE;
+    } else {
+      if (!ISPOW2(dwVidMemTotal)) {
+        // assume they wont return a proper max value, so
+        // round up to next pow of 2
+        UINT count=0;
+        while ((dwVidMemTotal >> count) != 0x0) {
+          count++;
+        }
+        dwVidMemTotal = (1 << count);
+      }
+    }
+
+    // after SetDisplayMode, GetAvailVidMem totalmem seems to go down
+    // by 1.2 meg (contradicting above comment and what I think would
+    // be correct behavior (shouldnt FS mode release the desktop
+    // vidmem?), so this is the true value
+    _card_ids[i].MaxAvailVidMem = dwVidMemTotal;
+
+    // I can never get this stuff to work reliably, so I'm just
+    // rounding up to nearest pow2.  Could try to get
+    // HardwareInformation.Memory_size MB number from registry like
+    // video control panel, but its not clear how to find the proper
+    // registry location for a given card
+
+    // assume buggy drivers (this means you, FireGL2) may return zero
+    // (or small amts) for dwVidMemTotal, so ignore value if its <
+    // CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD
+    bool bLowVidMemFlag = 
+      ((dwVidMemTotal > CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD) && 
+       (dwVidMemTotal< LOWVIDMEMTHRESHOLD));
+
+    _card_ids[i].bIsLowVidMemCard = bLowVidMemFlag;
+    wdxdisplay8_cat.info() 
+      << "SetLowVidMem flag to " << bLowVidMemFlag
+      << " based on adjusted VidMemTotal: " << dwVidMemTotal << endl;
+  }
+  return true;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wdxGraphicsPipe8::dx7_driver_enum_callback
+//       Access: Private, Static
+//  Description: 
+////////////////////////////////////////////////////////////////////
+BOOL WINAPI wdxGraphicsPipe8::
+dx7_driver_enum_callback(GUID *pGUID, TCHAR *strDesc, TCHAR *strName,
+                         VOID *argptr, HMONITOR hm) {
+  //    #define PRNT(XX) ((XX!=NULL) ? XX : "NULL")
+  //    cout << "strDesc: "<< PRNT(strDesc) << "  strName: "<< PRNT(strName)<<endl;
+  wdxGraphicsPipe8 *self = (wdxGraphicsPipe8 *)argptr;
+
+  CardID card_id;
+  ZeroMemory(&card_id, sizeof(CardID));
+
+  if (hm == NULL) {
+    card_id.hMon = MonitorFromWindow(GetDesktopWindow(), 
+                                     MONITOR_DEFAULTTOPRIMARY);
+  } else {
+    card_id.hMon = hm;
+  }
+
+  if (pGUID != NULL) {
+    memcpy(&card_id.DX7_DeviceGUID, pGUID, sizeof(GUID));
+  }
+
+  card_id.MaxAvailVidMem = UNKNOWN_VIDMEM_SIZE;
+
+  self->_card_ids.push_back(card_id);
+
+  return DDENUMRET_OK;
+}

+ 109 - 0
panda/src/dxgsg8/wdxGraphicsPipe8.h

@@ -0,0 +1,109 @@
+// Filename: wdxGraphicsPipe8.h
+// Created by:  drose (20Dec02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef WDXGRAPHICSPIPE8_H
+#define WDXGRAPHICSPIPE8_H
+
+#include "pandabase.h"
+#include "winGraphicsPipe.h"
+#include "pvector.h"
+
+#include <ddraw.h>
+
+typedef struct {
+   UINT    cardID;
+   char    szDriver[MAX_DEVICE_IDENTIFIER_STRING];
+   char    szDescription[MAX_DEVICE_IDENTIFIER_STRING];
+   GUID    guidDeviceIdentifier;
+   DWORD   VendorID, DeviceID;
+   HMONITOR hMon;
+} DXDeviceInfo;
+typedef pvector<DXDeviceInfo> DXDeviceInfoVec;
+
+////////////////////////////////////////////////////////////////////
+//       Class : wdxGraphicsPipe8
+// Description : This graphics pipe represents the interface for
+//               creating DirectX graphics windows.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDADX wdxGraphicsPipe8 : public WinGraphicsPipe {
+public:
+  wdxGraphicsPipe8();
+  virtual ~wdxGraphicsPipe8();
+
+  static PT(GraphicsPipe) pipe_constructor();
+
+protected:
+  virtual PT(GraphicsWindow) make_window();
+
+private:
+  bool init();
+  bool find_all_card_memavails();
+
+  static BOOL WINAPI
+  dx7_driver_enum_callback(GUID *pGUID, TCHAR *strDesc, TCHAR *strName,
+                           VOID *argptr, HMONITOR hm);
+
+private:
+  HINSTANCE _hDDrawDLL;
+  HINSTANCE _hD3D8_DLL;
+  bool _is_valid;
+
+  typedef LPDIRECT3D8 (WINAPI *Direct3DCreate8_ProcPtr)(UINT SDKVersion);
+  typedef HRESULT (WINAPI * LPDIRECTDRAWCREATEEX)(GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter);
+
+  LPDIRECTDRAWCREATEEX _DirectDrawCreateEx;
+  LPDIRECTDRAWENUMERATEEX _DirectDrawEnumerateExA;
+  Direct3DCreate8_ProcPtr _Direct3DCreate8;
+
+  // CardID is used in DX7 lowmem card-classification pass so DX8 can
+  // establish correspondence b/w DX7 mem info & DX8 device
+  struct CardID {
+    HMONITOR hMon;
+    DWORD MaxAvailVidMem;
+    bool  bIsLowVidMemCard;
+    GUID  DX7_DeviceGUID;
+    DWORD VendorID, DeviceID;
+    //   char  szDriver[MAX_DEVICE_IDENTIFIER_STRING];
+  };
+  
+  typedef pvector<CardID> CardIDs;
+  CardIDs _card_ids;
+
+
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    WinGraphicsPipe::init_type();
+    register_type(_type_handle, "wdxGraphicsPipe8",
+                  WinGraphicsPipe::get_class_type());
+  }
+  virtual TypeHandle get_type() const {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
+
+private:
+  static TypeHandle _type_handle;
+  friend class wdxGraphicsWindow8;
+};
+
+#include "wdxGraphicsPipe8.I"
+
+#endif

+ 17 - 0
panda/src/dxgsg8/wdxGraphicsWindow8.I

@@ -0,0 +1,17 @@
+// Filename: wdxGraphicsWindow8.I
+// Created by:  drose (20Dec02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////

Some files were not shown because too many files changed in this diff