Browse Source

tweak graphicsBuffer, add wglGraphicsBuffer

David Rose 22 years ago
parent
commit
57eefece08

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

@@ -44,6 +44,7 @@ PUBLISHED:
     FM_single_buffer = 0x0000,
     FM_single_buffer = 0x0000,
     FM_double_buffer = 0x0002,
     FM_double_buffer = 0x0002,
     FM_triple_buffer = 0x0004,
     FM_triple_buffer = 0x0004,
+    FM_buffer        = 0x0006,  // == (FM_single_buffer | FM_double_buffer | FM_triple_buffer)
     FM_accum =         0x0008,
     FM_accum =         0x0008,
     FM_alpha =         0x0010,
     FM_alpha =         0x0010,
     FM_depth =         0x0020,
     FM_depth =         0x0020,

+ 32 - 0
panda/src/display/graphicsBuffer.I

@@ -16,3 +16,35 @@
 //
 //
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsBuffer::has_texture
+//       Access: Published
+//  Description: Returns true if the GraphicsBuffer is set to render
+//               into a texture (because want_texture has been passed
+//               to the GraphicsBuffer constructor), or false
+//               otherwise.
+////////////////////////////////////////////////////////////////////
+INLINE bool GraphicsBuffer::
+has_texture() const {
+  return !(_texture.is_null());
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsBuffer::get_texture
+//       Access: Published
+//  Description: Returns the texture into which the GraphicsBuffer
+//               renders, if any, or NULL if want_texture was passed
+//               into the constructor as false.
+//
+//               If the texture is non-NULL, it may be applied to
+//               geometry to be rendered for any other windows or
+//               buffers that share the same GSG as this
+//               GraphicsBuffer.  The effect is undefined for windows
+//               that share a different GSG; usually in these cases
+//               the texture will be invalid.
+////////////////////////////////////////////////////////////////////
+INLINE Texture *GraphicsBuffer::
+get_texture() const {
+  return _texture;
+}

+ 97 - 1
panda/src/display/graphicsBuffer.cxx

@@ -29,7 +29,7 @@ TypeHandle GraphicsBuffer::_type_handle;
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsBuffer::
 GraphicsBuffer::
 GraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
 GraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
-               int x_size, int y_size) :
+               int x_size, int y_size, bool want_texture) :
   GraphicsOutput(pipe, gsg)
   GraphicsOutput(pipe, gsg)
 {
 {
 #ifdef DO_MEMORY_USAGE
 #ifdef DO_MEMORY_USAGE
@@ -41,9 +41,14 @@ GraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
       << "Creating new offscreen buffer using GSG " << (void *)gsg << "\n";
       << "Creating new offscreen buffer using GSG " << (void *)gsg << "\n";
   }
   }
 
 
+  if (want_texture) {
+    _texture = new Texture();
+  }
+
   _x_size = x_size;
   _x_size = x_size;
   _y_size = y_size;
   _y_size = y_size;
   _has_size = true;
   _has_size = true;
+  _open_request = OR_none;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -54,3 +59,94 @@ GraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
 GraphicsBuffer::
 GraphicsBuffer::
 ~GraphicsBuffer() {
 ~GraphicsBuffer() {
 }
 }
+ 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsBuffer::request_open
+//       Access: Public, Virtual
+//  Description: This is called by the GraphicsEngine to request that
+//               the buffer (or whatever) open itself or, in general,
+//               make itself valid, at the next call to
+//               process_events().
+////////////////////////////////////////////////////////////////////
+void GraphicsBuffer::
+request_open() {
+  _open_request = OR_open;
+}
+ 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsBuffer::request_close
+//       Access: Public, Virtual
+//  Description: This is called by the GraphicsEngine to request that
+//               the buffer (or whatever) close itself or, in general,
+//               make itself invalid, at the next call to
+//               process_events().  By that time we promise the gsg
+//               pointer will be cleared.
+////////////////////////////////////////////////////////////////////
+void GraphicsBuffer::
+request_close() {
+  _open_request = OR_none;
+}
+ 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsBuffer::set_close_now
+//       Access: Public, Virtual
+//  Description: This is called by the GraphicsEngine to insist that
+//               the buffer be closed immediately.  This is only
+//               called from the buffer thread.
+////////////////////////////////////////////////////////////////////
+void GraphicsBuffer::
+set_close_now() {
+  _open_request = OR_none;
+  close_buffer();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsBuffer::process_events
+//       Access: Public, Virtual
+//  Description: Honor any requests recently made via request_open()
+//               or request_close().
+//
+//               This function is called only within the window
+//               thread.
+////////////////////////////////////////////////////////////////////
+void GraphicsBuffer::
+process_events() {
+  switch (_open_request) {
+  case OR_none:
+    return;
+
+  case OR_open:
+    open_buffer();
+    break;
+
+  case OR_close:
+    close_buffer();
+    break;
+  }
+
+  _open_request = OR_none;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsBuffer::close_buffer
+//       Access: Protected, Virtual
+//  Description: Closes the buffer right now.  Called from the window
+//               thread.
+////////////////////////////////////////////////////////////////////
+void GraphicsBuffer::
+close_buffer() {
+  display_cat.info()
+    << "Closing " << get_type() << "\n";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsBuffer::open_buffer
+//       Access: Protected, Virtual
+//  Description: Opens the buffer right now.  Called from the window
+//               thread.  Returns true if the buffer is successfully
+//               opened, or false if there was a problem.
+////////////////////////////////////////////////////////////////////
+bool GraphicsBuffer::
+open_buffer() {
+  return false;
+}

+ 41 - 5
panda/src/display/graphicsBuffer.h

@@ -22,20 +22,56 @@
 #include "pandabase.h"
 #include "pandabase.h"
 
 
 #include "graphicsOutput.h"
 #include "graphicsOutput.h"
+#include "texture.h"
+#include "pointerTo.h"
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : GraphicsBuffer
 //       Class : GraphicsBuffer
-// Description : An offscreen buffer for rendering into.  Pretty much
-//               all you can do with this is render into it and then
-//               get the framebuffer out as an image.
+// Description : An offscreen buffer for rendering into.  This is
+//               similar in function to a GraphicsWindow, except that
+//               the output is not visible to the user.
+//
+//               If want_texture is passed true into the constructor,
+//               the GraphicsBuffer will render directly into a
+//               texture which can be retrieved via get_texture().
+//               This may then be applied to geometry for rendering in
+//               other windows or buffers using the same
+//               GraphicsStateGuardian.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDA GraphicsBuffer : public GraphicsOutput {
 class EXPCL_PANDA GraphicsBuffer : public GraphicsOutput {
 protected:
 protected:
   GraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
   GraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
-                 int x_size, int y_size);
+                 int x_size, int y_size, bool want_texture);
 
 
 PUBLISHED:
 PUBLISHED:
   virtual ~GraphicsBuffer();
   virtual ~GraphicsBuffer();
+
+  INLINE bool has_texture() const;  
+  INLINE Texture *get_texture() const;  
+
+public:
+  virtual void request_open();
+  virtual void request_close();
+
+  // 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 set_close_now();
+  virtual void process_events();
+
+protected:
+  virtual void close_buffer();
+  virtual bool open_buffer();
+
+protected:
+  PT(Texture) _texture;
+
+  enum OpenRequest {
+    OR_none,
+    OR_open,
+    OR_close,
+  };
+  OpenRequest _open_request;
   
   
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {
@@ -57,4 +93,4 @@ private:
 
 
 #include "graphicsBuffer.I"
 #include "graphicsBuffer.I"
 
 
-#endif /* GRAPHICSBUFFER_H */
+#endif

+ 3 - 2
panda/src/display/graphicsEngine.I

@@ -105,8 +105,9 @@ make_window(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE GraphicsBuffer *GraphicsEngine::
 INLINE GraphicsBuffer *GraphicsEngine::
 make_buffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
 make_buffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
-            int x_size, int y_size) {
-  return make_buffer(pipe, gsg, x_size, y_size, get_threading_model());
+            int x_size, int y_size, bool want_texture) {
+  return make_buffer(pipe, gsg, x_size, y_size, want_texture, 
+                     get_threading_model());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 6 - 2
panda/src/display/graphicsEngine.cxx

@@ -224,7 +224,7 @@ make_window(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 GraphicsBuffer *GraphicsEngine::
 GraphicsBuffer *GraphicsEngine::
 make_buffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
 make_buffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
-            int x_size, int y_size,
+            int x_size, int y_size, bool want_texture,
             const GraphicsThreadingModel &threading_model) {
             const GraphicsThreadingModel &threading_model) {
   if (gsg != (GraphicsStateGuardian *)NULL) {
   if (gsg != (GraphicsStateGuardian *)NULL) {
     nassertr(pipe == gsg->get_pipe(), NULL);
     nassertr(pipe == gsg->get_pipe(), NULL);
@@ -234,7 +234,8 @@ make_buffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
   }
   }
 
 
   // TODO: ask the window thread to make the buffer.
   // TODO: ask the window thread to make the buffer.
-  PT(GraphicsBuffer) buffer = pipe->make_buffer(gsg, x_size, y_size);
+  PT(GraphicsBuffer) buffer = 
+    pipe->make_buffer(gsg, x_size, y_size, want_texture);
   do_add_window(buffer, gsg, threading_model);
   do_add_window(buffer, gsg, threading_model);
   return buffer;
   return buffer;
 }
 }
@@ -881,6 +882,9 @@ do_add_window(GraphicsOutput *window, GraphicsStateGuardian *gsg,
 
 
     display_cat.info()
     display_cat.info()
       << "Created " << window->get_type() << "\n";
       << "Created " << window->get_type() << "\n";
+
+    // By default, try to open each window as it is added.
+    window->request_open();
   }
   }
 }
 }
 
 

+ 3 - 2
panda/src/display/graphicsEngine.h

@@ -36,6 +36,7 @@ class Pipeline;
 class DisplayRegion;
 class DisplayRegion;
 class GraphicsPipe;
 class GraphicsPipe;
 class FrameBufferProperties;
 class FrameBufferProperties;
+class Texture;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : GraphicsEngine
 //       Class : GraphicsEngine
@@ -78,10 +79,10 @@ PUBLISHED:
                               const GraphicsThreadingModel &threading_model);
                               const GraphicsThreadingModel &threading_model);
   INLINE GraphicsBuffer *make_buffer(GraphicsPipe *pipe,
   INLINE GraphicsBuffer *make_buffer(GraphicsPipe *pipe,
                                      GraphicsStateGuardian *gsg,
                                      GraphicsStateGuardian *gsg,
-                                     int x_size, int y_size);
+                                     int x_size, int y_size, bool want_texture);
   GraphicsBuffer *make_buffer(GraphicsPipe *pipe,
   GraphicsBuffer *make_buffer(GraphicsPipe *pipe,
                               GraphicsStateGuardian *gsg,
                               GraphicsStateGuardian *gsg,
-                              int x_size, int y_size,
+                              int x_size, int y_size, bool want_texture,
                               const GraphicsThreadingModel &threading_model);
                               const GraphicsThreadingModel &threading_model);
 
 
   bool remove_window(GraphicsOutput *window);
   bool remove_window(GraphicsOutput *window);

+ 12 - 36
panda/src/display/graphicsOutput.cxx

@@ -461,6 +461,18 @@ request_close() {
 void GraphicsOutput::
 void GraphicsOutput::
 set_close_now() {
 set_close_now() {
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsOutput::reset_window
+//       Access: Protected, Virtual
+//  Description: resets the window framebuffer from its derived
+//               children. Does nothing here.
+////////////////////////////////////////////////////////////////////
+void GraphicsOutput::
+reset_window(bool swapchain) {
+  display_cat.info()
+    << "Resetting " << get_type() << "\n";
+}
  
  
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsOutput::begin_frame
 //     Function: GraphicsOutput::begin_frame
@@ -588,42 +600,6 @@ void GraphicsOutput::
 process_events() {
 process_events() {
 }
 }
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsOutput::close_window
-//       Access: Protected, Virtual
-//  Description: Closes the window right now.  Called from the window
-//               thread.
-////////////////////////////////////////////////////////////////////
-void GraphicsOutput::
-close_window() {
-  display_cat.info()
-    << "Closing " << get_type() << "\n";
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsOutput::reset_window
-//       Access: Protected, Virtual
-//  Description: resets the window framebuffer from its derived
-//               children. Does nothing here.
-////////////////////////////////////////////////////////////////////
-void GraphicsOutput::
-reset_window(bool swapchain) {
-  display_cat.info()
-    << "Resetting " << get_type() << "\n";
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: GraphicsOutput::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 GraphicsOutput::
-open_window() {
-  return false;
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsOutput::declare_channel
 //     Function: GraphicsOutput::declare_channel
 //       Access: Protected
 //       Access: Protected

+ 2 - 5
panda/src/display/graphicsOutput.h

@@ -101,9 +101,10 @@ public:
 
 
   virtual void request_open();
   virtual void request_open();
   virtual void request_close();
   virtual void request_close();
+
   virtual void set_close_now();
   virtual void set_close_now();
+  virtual void reset_window(bool swapchain);
 
 
-public:
   // It is an error to call any of the following methods from any
   // It is an error to call any of the following methods from any
   // thread other than the draw thread.  These methods are normally
   // thread other than the draw thread.  These methods are normally
   // called by the GraphicsEngine.
   // called by the GraphicsEngine.
@@ -126,10 +127,6 @@ public:
   virtual void process_events();
   virtual void process_events();
 
 
 protected:
 protected:
-  virtual void close_window();
-  virtual bool open_window();
-  virtual void reset_window(bool swapchain);
-
   void declare_channel(int index, GraphicsChannel *chan);
   void declare_channel(int index, GraphicsChannel *chan);
   
   
 protected:
 protected:

+ 1 - 1
panda/src/display/graphicsPipe.cxx

@@ -164,6 +164,6 @@ make_window(GraphicsStateGuardian *) {
 //  Description: Creates a new offscreen buffer on the pipe, if possible.
 //  Description: Creates a new offscreen buffer on the pipe, if possible.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 PT(GraphicsBuffer) GraphicsPipe::
 PT(GraphicsBuffer) GraphicsPipe::
-make_buffer(GraphicsStateGuardian *, int, int) {
+make_buffer(GraphicsStateGuardian *, int, int, bool) {
   return NULL;
   return NULL;
 }
 }

+ 3 - 1
panda/src/display/graphicsPipe.h

@@ -32,6 +32,7 @@ class GraphicsWindow;
 class GraphicsBuffer;
 class GraphicsBuffer;
 class GraphicsStateGuardian;
 class GraphicsStateGuardian;
 class FrameBufferProperties;
 class FrameBufferProperties;
+class Texture;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : GraphicsPipe
 //       Class : GraphicsPipe
@@ -94,7 +95,8 @@ protected:
   virtual PT(GraphicsStateGuardian) make_gsg(const FrameBufferProperties &properties);
   virtual PT(GraphicsStateGuardian) make_gsg(const FrameBufferProperties &properties);
   virtual void close_gsg(GraphicsStateGuardian *gsg);
   virtual void close_gsg(GraphicsStateGuardian *gsg);
   virtual PT(GraphicsWindow) make_window(GraphicsStateGuardian *gsg);
   virtual PT(GraphicsWindow) make_window(GraphicsStateGuardian *gsg);
-  virtual PT(GraphicsBuffer) make_buffer(GraphicsStateGuardian *gsg, int x_size, int y_size);
+  virtual PT(GraphicsBuffer) make_buffer(GraphicsStateGuardian *gsg, 
+                                         int x_size, int y_size, bool want_texture);
 
 
   Mutex _lock;
   Mutex _lock;
 
 

+ 36 - 0
panda/src/display/graphicsWindow.cxx

@@ -537,6 +537,42 @@ set_properties_now(WindowProperties &properties) {
   }
   }
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::close_window
+//       Access: Protected, Virtual
+//  Description: Closes the window right now.  Called from the window
+//               thread.
+////////////////////////////////////////////////////////////////////
+void GraphicsWindow::
+close_window() {
+  display_cat.info()
+    << "Closing " << get_type() << "\n";
+}
+
+////////////////////////////////////////////////////////////////////
+//     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::
+open_window() {
+  return false;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: GraphicsWindow::reset_window
+//       Access: Protected, Virtual
+//  Description: resets the window framebuffer from its derived
+//               children. Does nothing here.
+////////////////////////////////////////////////////////////////////
+void GraphicsWindow::
+reset_window(bool swapchain) {
+  display_cat.info()
+    << "Resetting " << get_type() << "\n";
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::do_reshape_request
 //     Function: GraphicsWindow::do_reshape_request
 //       Access: Protected, Virtual
 //       Access: Protected, Virtual

+ 5 - 1
panda/src/display/graphicsWindow.h

@@ -73,15 +73,19 @@ public:
 public:
 public:
   virtual void request_open();
   virtual void request_open();
   virtual void request_close();
   virtual void request_close();
-  virtual void set_close_now();
 
 
   // It is an error to call any of the following methods from any
   // It is an error to call any of the following methods from any
   // thread other than the window thread.  These methods are normally
   // thread other than the window thread.  These methods are normally
   // called by the GraphicsEngine.
   // called by the GraphicsEngine.
+  virtual void set_close_now();
   virtual void process_events();
   virtual void process_events();
   virtual void set_properties_now(WindowProperties &properties);
   virtual void set_properties_now(WindowProperties &properties);
 
 
 protected:
 protected:
+  virtual void close_window();
+  virtual bool open_window();
+  virtual void reset_window(bool swapchain);
+
   virtual bool do_reshape_request(int x_origin, int y_origin,
   virtual bool do_reshape_request(int x_origin, int y_origin,
                                   int x_size, int y_size);
                                   int x_size, int y_size);
 
 

+ 0 - 29
panda/src/glgsg/glGraphicsStateGuardian.cxx

@@ -1643,35 +1643,6 @@ draw_sphere(GeomSphere *geom, GeomContext *) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 TextureContext *GLGraphicsStateGuardian::
 TextureContext *GLGraphicsStateGuardian::
 prepare_texture(Texture *tex) {
 prepare_texture(Texture *tex) {
-  GLint max_tex_size; 
-  glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_tex_size); 
-
-  int xsize = tex->_pbuffer->get_xsize();
-  int ysize = tex->_pbuffer->get_ysize();
-
-  if ((xsize> max_tex_size) || (ysize > max_tex_size)) {
-    glgsg_cat.warning() 
-      << tex->get_name() <<": "<< xsize << "x" << ysize
-      << " exceeds max tex size " << max_tex_size << "x" << max_tex_size << endl;
-    // Rather than returning NULL in these error cases, which will
-    // crab out Panda, we simply let GL go ahead and do the best it
-    // can do.
-  }
-
-  // regular GL does not allow non-pow2 size textures
-  // the GL_NV_texture_rectangle EXT does allow non-pow2 sizes, albeit with no mipmaps or coord wrapping
-  // should probably add checks for that in here at some point
-  // or you could use gluBuild2DMipMaps to scale the texture to the nearest pow2 size
-
-  if (!(ISPOW2(xsize) && ISPOW2(ysize))) {
-    glgsg_cat.warning() 
-      << tex->get_name() <<": "<< xsize << "x" << ysize 
-      << " is not a power of 2 size!\n";
-    // Rather than returning NULL in these error cases, which will
-    // crab out Panda, we simply let GL go ahead and do the best it
-    // can do.
-  }
-
   GLTextureContext *gtc = new GLTextureContext(tex);
   GLTextureContext *gtc = new GLTextureContext(tex);
   glGenTextures(1, &gtc->_index);
   glGenTextures(1, &gtc->_index);
 
 

+ 1 - 1
panda/src/grutil/frameRateMeter.I

@@ -24,7 +24,7 @@
 //               render itself into the indicated window.
 //               render itself into the indicated window.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void FrameRateMeter::
 INLINE void FrameRateMeter::
-setup_layer(GraphicsWindow *window) {
+setup_layer(GraphicsOutput *window) {
   setup_layer(window->get_channel(0));
   setup_layer(window->get_channel(0));
 }
 }
 
 

+ 2 - 2
panda/src/grutil/frameRateMeter.h

@@ -22,7 +22,7 @@
 #include "pandabase.h"
 #include "pandabase.h"
 #include "textNode.h"
 #include "textNode.h"
 #include "nodePath.h"
 #include "nodePath.h"
-#include "graphicsWindow.h"
+#include "graphicsOutput.h"
 #include "graphicsLayer.h"
 #include "graphicsLayer.h"
 #include "pointerTo.h"
 #include "pointerTo.h"
 #include "pStatCollector.h"
 #include "pStatCollector.h"
@@ -47,7 +47,7 @@ PUBLISHED:
   FrameRateMeter(const string &name);
   FrameRateMeter(const string &name);
   virtual ~FrameRateMeter();
   virtual ~FrameRateMeter();
 
 
-  INLINE void setup_layer(GraphicsWindow *window);
+  INLINE void setup_layer(GraphicsOutput *window);
   void setup_layer(GraphicsChannel *channel);
   void setup_layer(GraphicsChannel *channel);
   void clear_layer();
   void clear_layer();
 
 

+ 6 - 6
panda/src/wgldisplay/Sources.pp

@@ -13,21 +13,21 @@
   #define COMBINED_SOURCES $[TARGET]_composite1.cxx 
   #define COMBINED_SOURCES $[TARGET]_composite1.cxx 
   
   
   #define INSTALL_HEADERS \
   #define INSTALL_HEADERS \
-     config_wgldisplay.h \
-     wglGraphicsPipe.I wglGraphicsPipe.h \
-     wglGraphicsStateGuardian.I wglGraphicsStateGuardian.h \
-     wglGraphicsWindow.I wglGraphicsWindow.h
-//     Win32Defs.h  
+    config_wgldisplay.h \
+    wglGraphicsBuffer.I wglGraphicsBuffer.h \
+    wglGraphicsPipe.I wglGraphicsPipe.h \
+    wglGraphicsStateGuardian.I wglGraphicsStateGuardian.h \
+    wglGraphicsWindow.I wglGraphicsWindow.h
     
     
   #define INCLUDED_SOURCES \
   #define INCLUDED_SOURCES \
     config_wgldisplay.cxx \
     config_wgldisplay.cxx \
+    wglGraphicsBuffer.cxx \
     wglGraphicsPipe.cxx \
     wglGraphicsPipe.cxx \
     wglGraphicsStateGuardian.cxx \
     wglGraphicsStateGuardian.cxx \
     wglGraphicsWindow.cxx
     wglGraphicsWindow.cxx
 
 
   #define SOURCES \
   #define SOURCES \
     $[INSTALL_HEADERS]
     $[INSTALL_HEADERS]
-//    wglext.h
 
 
 
 
 #end lib_target
 #end lib_target

+ 2 - 0
panda/src/wgldisplay/config_wgldisplay.cxx

@@ -17,6 +17,7 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
 #include "config_wgldisplay.h"
 #include "config_wgldisplay.h"
+#include "wglGraphicsBuffer.h"
 #include "wglGraphicsPipe.h"
 #include "wglGraphicsPipe.h"
 #include "wglGraphicsStateGuardian.h"
 #include "wglGraphicsStateGuardian.h"
 #include "wglGraphicsWindow.h"
 #include "wglGraphicsWindow.h"
@@ -46,6 +47,7 @@ init_libwgldisplay() {
   }
   }
   initialized = true;
   initialized = true;
 
 
+  wglGraphicsBuffer::init_type();
   wglGraphicsPipe::init_type();
   wglGraphicsPipe::init_type();
   wglGraphicsStateGuardian::init_type();
   wglGraphicsStateGuardian::init_type();
   wglGraphicsWindow::init_type();
   wglGraphicsWindow::init_type();

+ 17 - 0
panda/src/wgldisplay/wglGraphicsBuffer.I

@@ -0,0 +1,17 @@
+// Filename: wglGraphicsWindow.I
+// Created by:  drose (08Feb04)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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] .
+//
+////////////////////////////////////////////////////////////////////

+ 1646 - 0
panda/src/wgldisplay/wglGraphicsBuffer.cxx

@@ -0,0 +1,1646 @@
+// Filename: wglGraphicsBuffer.cxx
+// Created by:  drose (08Feb04)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 "wglGraphicsBuffer.h"
+#include "config_wgldisplay.h"
+#include "wglGraphicsPipe.h"
+#include "glGraphicsStateGuardian.h"
+#include "frameBufferProperties.h"
+
+#include <wingdi.h>
+#include <ddraw.h>
+#include <tchar.h>
+
+TypeHandle wglGraphicsBuffer::_type_handle;
+const char * const wglGraphicsBuffer::_window_class_name = "wglGraphicsBuffer";
+bool wglGraphicsBuffer::_window_class_registered = false;
+
+static char *ConvDDErrorToString(const HRESULT &error);
+static const char * const errorbox_title = "Panda3D Error";
+
+// spare me the trouble of linking with dxguid.lib or defining ALL the dx guids in this .obj by #defining INITGUID
+#define MY_DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+        EXTERN_C const GUID DECLSPEC_SELECTANY name \
+                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
+
+MY_DEFINE_GUID(IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56);
+
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+wglGraphicsBuffer::
+wglGraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
+                  int x_size, int y_size, bool want_texture) :
+  GraphicsBuffer(pipe, gsg, x_size, y_size, want_texture) 
+{
+  _hWnd = (HWND)0;
+  _hdc = (HDC)0;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::Destructor
+//       Access: Public, Virtual
+//  Description:
+////////////////////////////////////////////////////////////////////
+wglGraphicsBuffer::
+~wglGraphicsBuffer() {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::make_current
+//       Access: Public, Virtual
+//  Description: This function will be called within the draw thread
+//               during begin_frame() to ensure the graphics context
+//               is ready for drawing.
+////////////////////////////////////////////////////////////////////
+void wglGraphicsBuffer::
+make_current() {
+  wglGraphicsStateGuardian *wglgsg;
+  DCAST_INTO_V(wglgsg, _gsg);
+  wglMakeCurrent(_hdc, wglgsg->get_context(_hdc));
+    
+  // Now that we have made the context current to a window, we can
+  // reset the GSG state if this is the first time it has been used.
+  // (We can't just call reset() when we construct the GSG, because
+  // reset() requires having a current context.)
+  wglgsg->reset_if_new();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::release_gsg
+//       Access: Public, Virtual
+//  Description: Releases the current GSG pointer, if it is currently
+//               held, and resets the GSG to NULL.  The window will be
+//               permanently unable to render; this is normally called
+//               only just before destroying the window.  This should
+//               only be called from within the draw thread.
+////////////////////////////////////////////////////////////////////
+void wglGraphicsBuffer::
+release_gsg() {
+  wglMakeCurrent(_hdc, NULL);
+  GraphicsBuffer::release_gsg();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::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 wglGraphicsBuffer::
+begin_flip() {
+  /*
+  if (_gsg != (GraphicsStateGuardian *)NULL) {
+    make_current();
+    glFinish();
+    SwapBuffers(_hdc);
+  }
+  */
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::close_buffer
+//       Access: Protected, Virtual
+//  Description: Closes the buffer right now.  Called from the window
+//               thread.
+////////////////////////////////////////////////////////////////////
+void wglGraphicsBuffer::
+close_buffer() {
+  if (_hWnd) {
+    DestroyWindow(_hWnd);
+    _hWnd = 0;
+  }
+  if (_hdc) {
+    DeleteDC(_hdc);
+    _hdc = 0;
+  }
+
+  _is_valid = false;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::open_buffer
+//       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 wglGraphicsBuffer::
+open_buffer() {
+  DWORD window_style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
+
+  register_window_class();
+  HINSTANCE hinstance = GetModuleHandle(NULL);
+  _hWnd = CreateWindow(_window_class_name, "", window_style, 
+                       0, 0, _x_size, _y_size,
+                       NULL, NULL, hinstance, 0);
+
+  if (!_hWnd) {
+    wgldisplay_cat.error()
+      << "CreateWindow() failed!" << endl;
+    show_error_message();
+    return false;
+  }
+
+  wglGraphicsStateGuardian *wglgsg;
+  DCAST_INTO_R(wglgsg, _gsg, false);
+
+  _hdc = GetDC(_hWnd);
+
+  int pfnum = wglgsg->get_pfnum();
+  PIXELFORMATDESCRIPTOR pixelformat;
+  DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), 
+                      &pixelformat);
+
+#ifdef _DEBUG
+  char msg[200];
+  sprintf(msg, "Selected GL PixelFormat is #%d", pfnum);
+  print_pfd(&pixelformat, msg);
+#endif
+
+  if (!SetPixelFormat(_hdc, pfnum, &pixelformat)) {
+    wgldisplay_cat.error()
+      << "SetPixelFormat(" << pfnum << ") failed after window create\n";
+    close_buffer();
+    return false;
+  }
+
+#ifndef NDEBUG
+  if (gl_force_invalid) {
+    wgldisplay_cat.error()
+      << "Artificially failing window.\n";
+    close_buffer();
+    return false;
+  }
+#endif  // NDEBUG
+
+  // Initializes _colormap
+  setup_colormap(pixelformat);
+
+  _is_valid = true;
+  return true;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::setup_colormap
+//       Access: Private
+//  Description: Sets up a colormap for the window matching the
+//               selected pixel format.  This is necessary before
+//               creating a GL context.
+////////////////////////////////////////////////////////////////////
+void wglGraphicsBuffer::
+setup_colormap(const PIXELFORMATDESCRIPTOR &pixelformat) {
+  LOGPALETTE *logical;
+  int n;
+
+  if (!(pixelformat.dwFlags & PFD_NEED_PALETTE ||
+      pixelformat.iPixelType == PFD_TYPE_COLORINDEX))
+    return;
+
+  n = 1 << pixelformat.cColorBits;
+
+  /* allocate a bunch of memory for the logical palette (assume 256
+     colors in a Win32 palette */
+  logical = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) +
+                                sizeof(PALETTEENTRY) * n);
+  memset(logical, 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * n);
+
+  /* set the entries in the logical palette */
+  logical->palVersion = 0x300;
+  logical->palNumEntries = n;
+
+  /* start with a copy of the current system palette */
+  GetSystemPaletteEntries(_hdc, 0, 256, &logical->palPalEntry[0]);
+
+  if (pixelformat.iPixelType == PFD_TYPE_RGBA) {
+    int redMask = (1 << pixelformat.cRedBits) - 1;
+    int greenMask = (1 << pixelformat.cGreenBits) - 1;
+    int blueMask = (1 << pixelformat.cBlueBits) - 1;
+    int i;
+
+    /* fill in an RGBA color palette */
+    for (i = 0; i < n; ++i) {
+      logical->palPalEntry[i].peRed =
+        (((i >> pixelformat.cRedShift)   & redMask)   * 255) / redMask;
+      logical->palPalEntry[i].peGreen =
+        (((i >> pixelformat.cGreenShift) & greenMask) * 255) / greenMask;
+        logical->palPalEntry[i].peBlue =
+        (((i >> pixelformat.cBlueShift)  & blueMask)  * 255) / blueMask;
+      logical->palPalEntry[i].peFlags = 0;
+    }
+  }
+
+  _colormap = CreatePalette(logical);
+  free(logical);
+
+  SelectPalette(_hdc, _colormap, FALSE);
+  RealizePalette(_hdc);
+}
+
+#ifdef _DEBUG
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::print_pfd
+//       Access: Private, Static
+//  Description: Reports information about the selected pixel format
+//               descriptor, along with the indicated message.
+////////////////////////////////////////////////////////////////////
+void wglGraphicsBuffer::
+print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg) {
+  OGLDriverType drvtype;
+  if ((pfd->dwFlags & PFD_GENERIC_ACCELERATED) && 
+      (pfd->dwFlags & PFD_GENERIC_FORMAT)) {
+    drvtype=MCD;
+  } else if (!(pfd->dwFlags & PFD_GENERIC_ACCELERATED) && !(pfd->dwFlags & PFD_GENERIC_FORMAT)) {
+    drvtype=ICD;
+  } else {
+    drvtype=Software;
+  }
+
+#define PRINT_FLAG(FLG) ((pfd->dwFlags &  PFD_##FLG) ? (" PFD_" #FLG "|") : "")
+  wgldisplay_cat.spam()
+    << "================================\n";
+
+  wgldisplay_cat.spam()
+    << msg << ", " << OGLDrvStrings[drvtype] << " driver\n"
+    << "PFD flags: 0x" << (void*)pfd->dwFlags << " (" 
+    << PRINT_FLAG(GENERIC_ACCELERATED) 
+    << PRINT_FLAG(GENERIC_FORMAT)
+    << PRINT_FLAG(DOUBLEBUFFER)
+    << PRINT_FLAG(SUPPORT_OPENGL)
+    << PRINT_FLAG(SUPPORT_GDI)
+    << PRINT_FLAG(STEREO)
+    << PRINT_FLAG(DRAW_TO_WINDOW)
+    << PRINT_FLAG(DRAW_TO_BITMAP)
+    << PRINT_FLAG(SWAP_EXCHANGE)
+    << PRINT_FLAG(SWAP_COPY)
+    << PRINT_FLAG(SWAP_LAYER_BUFFERS)
+    << PRINT_FLAG(NEED_PALETTE)
+    << PRINT_FLAG(NEED_SYSTEM_PALETTE)
+    << PRINT_FLAG(SUPPORT_DIRECTDRAW) << ")\n"
+    << "PFD iPixelType: "
+    << ((pfd->iPixelType==PFD_TYPE_RGBA) ? "PFD_TYPE_RGBA":"PFD_TYPE_COLORINDEX")
+    << endl
+    << "PFD cColorBits: " << (DWORD)pfd->cColorBits
+    << "  R: " << (DWORD)pfd->cRedBits
+    <<" G: " << (DWORD)pfd->cGreenBits
+    <<" B: " << (DWORD)pfd->cBlueBits << endl
+    << "PFD cAlphaBits: " << (DWORD)pfd->cAlphaBits
+    << "  DepthBits: " << (DWORD)pfd->cDepthBits
+    <<" StencilBits: " << (DWORD)pfd->cStencilBits
+    <<" AccumBits: " << (DWORD)pfd->cAccumBits
+    << endl;
+}
+#endif
+
+
+static char *
+ConvDDErrorToString(const HRESULT &error) {
+  switch(error) {
+  case E_FAIL:
+    return "Unspecified error E_FAIL";
+    
+  case DD_OK:
+    return "No error.\0";
+    
+  case DDERR_ALREADYINITIALIZED     : // (5)
+    return "DDERR_ALREADYINITIALIZED        ";//: // (5)
+  case DDERR_CANNOTATTACHSURFACE        : // (10)
+    return "DDERR_CANNOTATTACHSURFACE       ";//: // (10)
+  case DDERR_CANNOTDETACHSURFACE        : // (20)
+    return "DDERR_CANNOTDETACHSURFACE       ";//: // (20)
+  case DDERR_CURRENTLYNOTAVAIL          : // (40)
+    return "DDERR_CURRENTLYNOTAVAIL         ";//: // (40)
+  case DDERR_EXCEPTION              : // (55)
+    return "DDERR_EXCEPTION             ";//: // (55)
+  case DDERR_HEIGHTALIGN            : // (90)
+    return "DDERR_HEIGHTALIGN           ";//: // (90)
+  case DDERR_INCOMPATIBLEPRIMARY        : // (95)
+    return "DDERR_INCOMPATIBLEPRIMARY       ";//: // (95)
+  case DDERR_INVALIDCAPS            : // (100)
+    return "DDERR_INVALIDCAPS           ";//: // (100)
+  case DDERR_INVALIDCLIPLIST            : // (110)
+    return "DDERR_INVALIDCLIPLIST           ";//: // (110)
+  case DDERR_INVALIDMODE            : // (120)
+    return "DDERR_INVALIDMODE           ";//: // (120)
+  case DDERR_INVALIDOBJECT          : // (130)
+    return "DDERR_INVALIDOBJECT         ";//: // (130)
+  case DDERR_INVALIDPIXELFORMAT     : // (145)
+    return "DDERR_INVALIDPIXELFORMAT        ";//: // (145)
+  case DDERR_INVALIDRECT            : // (150)
+    return "DDERR_INVALIDRECT           ";//: // (150)
+  case DDERR_LOCKEDSURFACES         : // (160)
+    return "DDERR_LOCKEDSURFACES            ";//: // (160)
+  case DDERR_NO3D               : // (170)
+    return "DDERR_NO3D              ";//: // (170)
+  case DDERR_NOALPHAHW              : // (180)
+    return "DDERR_NOALPHAHW             ";//: // (180)
+  case DDERR_NOCLIPLIST         : // (205)
+    return "DDERR_NOCLIPLIST            ";//: // (205)
+  case DDERR_NOCOLORCONVHW          : // (210)
+    return "DDERR_NOCOLORCONVHW         ";//: // (210)
+  case DDERR_NOCOOPERATIVELEVELSET      : // (212)
+    return "DDERR_NOCOOPERATIVELEVELSET     ";//: // (212)
+  case DDERR_NOCOLORKEY         : // (215)
+    return "DDERR_NOCOLORKEY            ";//: // (215)
+  case DDERR_NOCOLORKEYHW           : // (220)
+    return "DDERR_NOCOLORKEYHW          ";//: // (220)
+  case DDERR_NODIRECTDRAWSUPPORT        : // (222)
+    return "DDERR_NODIRECTDRAWSUPPORT       ";//: // (222)
+  case DDERR_NOEXCLUSIVEMODE            : // (225)
+    return "DDERR_NOEXCLUSIVEMODE           ";//: // (225)
+  case DDERR_NOFLIPHW               : // (230)
+    return "DDERR_NOFLIPHW              ";//: // (230)
+  case DDERR_NOGDI              : // (240)
+    return "DDERR_NOGDI             ";//: // (240)
+  case DDERR_NOMIRRORHW         : // (250)
+    return "DDERR_NOMIRRORHW            ";//: // (250)
+  case DDERR_NOTFOUND               : // (255)
+    return "DDERR_NOTFOUND              ";//: // (255)
+  case DDERR_NOOVERLAYHW            : // (260)
+    return "DDERR_NOOVERLAYHW           ";//: // (260)
+  case DDERR_NORASTEROPHW           : // (280)
+    return "DDERR_NORASTEROPHW          ";//: // (280)
+  case DDERR_NOROTATIONHW           : // (290)
+    return "DDERR_NOROTATIONHW          ";//: // (290)
+  case DDERR_NOSTRETCHHW            : // (310)
+    return "DDERR_NOSTRETCHHW           ";//: // (310)
+  case DDERR_NOT4BITCOLOR           : // (316)
+    return "DDERR_NOT4BITCOLOR          ";//: // (316)
+  case DDERR_NOT4BITCOLORINDEX          : // (317)
+    return "DDERR_NOT4BITCOLORINDEX         ";//: // (317)
+  case DDERR_NOT8BITCOLOR           : // (320)
+    return "DDERR_NOT8BITCOLOR          ";//: // (320)
+  case DDERR_NOTEXTUREHW            : // (330)
+    return "DDERR_NOTEXTUREHW           ";//: // (330)
+  case DDERR_NOVSYNCHW              : // (335)
+    return "DDERR_NOVSYNCHW             ";//: // (335)
+  case DDERR_NOZBUFFERHW            : // (340)
+    return "DDERR_NOZBUFFERHW           ";//: // (340)
+  case DDERR_NOZOVERLAYHW           : // (350)
+    return "DDERR_NOZOVERLAYHW          ";//: // (350)
+  case DDERR_OUTOFCAPS              : // (360)
+    return "DDERR_OUTOFCAPS             ";//: // (360)
+  case DDERR_OUTOFVIDEOMEMORY           : // (380)
+    return "DDERR_OUTOFVIDEOMEMORY          ";//: // (380)
+  case DDERR_OVERLAYCANTCLIP            : // (382)
+    return "DDERR_OVERLAYCANTCLIP           ";//: // (382)
+  case DDERR_OVERLAYCOLORKEYONLYONEACTIVE   : // (384)
+    return "DDERR_OVERLAYCOLORKEYONLYONEACTIVE  ";//: // (384)
+  case DDERR_PALETTEBUSY            : // (387)
+    return "DDERR_PALETTEBUSY           ";//: // (387)
+  case DDERR_COLORKEYNOTSET         : // (400)
+    return "DDERR_COLORKEYNOTSET            ";//: // (400)
+  case DDERR_SURFACEALREADYATTACHED     : // (410)
+    return "DDERR_SURFACEALREADYATTACHED        ";//: // (410)
+  case DDERR_SURFACEALREADYDEPENDENT        : // (420)
+    return "DDERR_SURFACEALREADYDEPENDENT       ";//: // (420)
+  case DDERR_SURFACEBUSY            : // (430)
+    return "DDERR_SURFACEBUSY           ";//: // (430)
+  case DDERR_CANTLOCKSURFACE                   : // (435)
+    return "DDERR_CANTLOCKSURFACE";//: // (435)
+  case DDERR_SURFACEISOBSCURED          : // (440)
+    return "DDERR_SURFACEISOBSCURED         ";//: // (440)
+  case DDERR_SURFACELOST            : // (450)
+    return "DDERR_SURFACELOST           ";//: // (450)
+  case DDERR_SURFACENOTATTACHED     : // (460)
+    return "DDERR_SURFACENOTATTACHED        ";//: // (460)
+  case DDERR_TOOBIGHEIGHT           : // (470)
+    return "DDERR_TOOBIGHEIGHT          ";//: // (470)
+  case DDERR_TOOBIGSIZE         : // (480)
+    return "DDERR_TOOBIGSIZE            ";//: // (480)
+  case DDERR_TOOBIGWIDTH            : // (490)
+    return "DDERR_TOOBIGWIDTH           ";//: // (490)
+  case DDERR_UNSUPPORTEDFORMAT          : // (510)
+    return "DDERR_UNSUPPORTEDFORMAT         ";//: // (510)
+  case DDERR_UNSUPPORTEDMASK            : // (520)
+    return "DDERR_UNSUPPORTEDMASK           ";//: // (520)
+  case DDERR_VERTICALBLANKINPROGRESS        : // (537)
+    return "DDERR_VERTICALBLANKINPROGRESS       ";//: // (537)
+  case DDERR_WASSTILLDRAWING            : // (540)
+    return "DDERR_WASSTILLDRAWING           ";//: // (540)
+  case DDERR_XALIGN             : // (560)
+    return "DDERR_XALIGN                ";//: // (560)
+  case DDERR_INVALIDDIRECTDRAWGUID      : // (561)
+    return "DDERR_INVALIDDIRECTDRAWGUID     ";//: // (561)
+  case DDERR_DIRECTDRAWALREADYCREATED       : // (562)
+    return "DDERR_DIRECTDRAWALREADYCREATED      ";//: // (562)
+  case DDERR_NODIRECTDRAWHW         : // (563)
+    return "DDERR_NODIRECTDRAWHW            ";//: // (563)
+  case DDERR_PRIMARYSURFACEALREADYEXISTS    : // (564)
+    return "DDERR_PRIMARYSURFACEALREADYEXISTS   ";//: // (564)
+  case DDERR_NOEMULATION            : // (565)
+    return "DDERR_NOEMULATION           ";//: // (565)
+  case DDERR_REGIONTOOSMALL         : // (566)
+    return "DDERR_REGIONTOOSMALL            ";//: // (566)
+  case DDERR_CLIPPERISUSINGHWND     : // (567)
+    return "DDERR_CLIPPERISUSINGHWND        ";//: // (567)
+  case DDERR_NOCLIPPERATTACHED          : // (568)
+    return "DDERR_NOCLIPPERATTACHED         ";//: // (568)
+  case DDERR_NOHWND             : // (569)
+    return "DDERR_NOHWND                ";//: // (569)
+  case DDERR_HWNDSUBCLASSED         : // (570)
+    return "DDERR_HWNDSUBCLASSED            ";//: // (570)
+  case DDERR_HWNDALREADYSET         : // (571)
+    return "DDERR_HWNDALREADYSET            ";//: // (571)
+  case DDERR_NOPALETTEATTACHED          : // (572)
+    return "DDERR_NOPALETTEATTACHED         ";//: // (572)
+  case DDERR_NOPALETTEHW            : // (573)
+    return "DDERR_NOPALETTEHW           ";//: // (573)
+  case DDERR_BLTFASTCANTCLIP            : // (574)
+    return "DDERR_BLTFASTCANTCLIP           ";//: // (574)
+  case DDERR_NOBLTHW                : // (575)
+    return "DDERR_NOBLTHW               ";//: // (575)
+  case DDERR_NODDROPSHW         : // (576)
+    return "DDERR_NODDROPSHW            ";//: // (576)
+  case DDERR_OVERLAYNOTVISIBLE          : // (577)
+    return "DDERR_OVERLAYNOTVISIBLE         ";//: // (577)
+  case DDERR_NOOVERLAYDEST          : // (578)
+    return "DDERR_NOOVERLAYDEST         ";//: // (578)
+  case DDERR_INVALIDPOSITION            : // (579)
+    return "DDERR_INVALIDPOSITION           ";//: // (579)
+  case DDERR_NOTAOVERLAYSURFACE     : // (580)
+    return "DDERR_NOTAOVERLAYSURFACE        ";//: // (580)
+  case DDERR_EXCLUSIVEMODEALREADYSET        : // (581)
+    return "DDERR_EXCLUSIVEMODEALREADYSET       ";//: // (581)
+  case DDERR_NOTFLIPPABLE           : // (582)
+    return "DDERR_NOTFLIPPABLE          ";//: // (582)
+  case DDERR_CANTDUPLICATE          : // (583)
+    return "DDERR_CANTDUPLICATE         ";//: // (583)
+  case DDERR_NOTLOCKED              : // (584)
+    return "DDERR_NOTLOCKED             ";//: // (584)
+  case DDERR_CANTCREATEDC           : // (585)
+    return "DDERR_CANTCREATEDC          ";//: // (585)
+  case DDERR_NODC               : // (586)
+    return "DDERR_NODC              ";//: // (586)
+  case DDERR_WRONGMODE              : // (587)
+    return "DDERR_WRONGMODE             ";//: // (587)
+  case DDERR_IMPLICITLYCREATED          : // (588)
+    return "DDERR_IMPLICITLYCREATED         ";//: // (588)
+  case DDERR_NOTPALETTIZED          : // (589)
+    return "DDERR_NOTPALETTIZED         ";//: // (589)
+  case DDERR_UNSUPPORTEDMODE            : // (590)
+    return "DDERR_UNSUPPORTEDMODE           ";//: // (590)
+  case DDERR_NOMIPMAPHW         : // (591)
+    return "DDERR_NOMIPMAPHW            ";//: // (591)
+  case DDERR_INVALIDSURFACETYPE                : // (592)
+    return "DDERR_INVALIDSURFACETYPE";//: // (592)
+  case DDERR_NOOPTIMIZEHW                      : // (600)
+    return "DDERR_NOOPTIMIZEHW";//: // (600)
+  case DDERR_NOTLOADED                         : // (601)
+    return "DDERR_NOTLOADED";//: // (601)
+  case DDERR_NOFOCUSWINDOW                     : // (602)
+    return "DDERR_NOFOCUSWINDOW";//: // (602)
+  case DDERR_DCALREADYCREATED           : // (620)
+    return "DDERR_DCALREADYCREATED          ";//: // (620)
+  case DDERR_NONONLOCALVIDMEM                  : // (630)
+    return "DDERR_NONONLOCALVIDMEM";//: // (630)
+  case DDERR_CANTPAGELOCK           : // (640)
+    return "DDERR_CANTPAGELOCK          ";//: // (640)
+  case DDERR_CANTPAGEUNLOCK         : // (660)
+    return "DDERR_CANTPAGEUNLOCK            ";//: // (660)
+  case DDERR_NOTPAGELOCKED          : // (680)
+    return "DDERR_NOTPAGELOCKED         ";//: // (680)
+  case DDERR_MOREDATA                   : // (690)
+    return "DDERR_MOREDATA                  ";//: // (690)
+  case DDERR_VIDEONOTACTIVE             : // (695)
+    return "DDERR_VIDEONOTACTIVE            ";//: // (695)
+  case DDERR_DEVICEDOESNTOWNSURFACE         : // (699)
+    return "DDERR_DEVICEDOESNTOWNSURFACE        ";//: // (699)
+
+  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;
+  }
+}
+  
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::register_window_class
+//       Access: Private, Static
+//  Description: Registers a Window class for all wglGraphicsBuffers.
+//               This only needs to be done once per session.
+////////////////////////////////////////////////////////////////////
+void wglGraphicsBuffer::
+register_window_class() {
+  if (_window_class_registered) {
+    return;
+  }
+
+  WNDCLASS wc;
+
+  HINSTANCE instance = GetModuleHandle(NULL);
+
+  // Clear before filling in window structure!
+  ZeroMemory(&wc, sizeof(WNDCLASS));
+  wc.style = CS_OWNDC;
+  wc.lpfnWndProc = (WNDPROC)static_window_proc;
+  wc.hInstance = instance;
+  wc.lpszClassName = _window_class_name;
+  
+  if (!RegisterClass(&wc)) {
+    wgldisplay_cat.error()
+      << "could not register window class!" << endl;
+    return;
+  }
+  _window_class_registered = true;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::static_window_proc
+//       Access: Private, Static
+//  Description: This is attached to the window class for all
+//               WinGraphicsWindow windows; it is called to handle
+//               window events.
+////////////////////////////////////////////////////////////////////
+LONG WINAPI wglGraphicsBuffer::
+static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
+  return DefWindowProc(hwnd, msg, wparam, lparam);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsBuffer::show_error_message
+//       Access: Private, Static
+//  Description: Pops up a dialog box with the indicated Windows error
+//               message ID (or the last error message generated) for
+//               meaningful display to the user.
+////////////////////////////////////////////////////////////////////
+void wglGraphicsBuffer::
+show_error_message(DWORD message_id) {
+  LPTSTR message_buffer;
+
+  if (message_id == 0) {
+    message_id = GetLastError();
+  }
+  
+  FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+                NULL, message_id,
+                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language
+                (LPTSTR)&message_buffer,  // the weird ptrptr->ptr cast is intentional, see FORMAT_MESSAGE_ALLOCATE_BUFFER
+                1024, NULL);
+  MessageBox(GetDesktopWindow(), message_buffer, _T(errorbox_title), MB_OK);
+  wgldisplay_cat.fatal() << "System error msg: " << message_buffer << endl;
+  LocalFree(message_buffer);
+}

+ 90 - 0
panda/src/wgldisplay/wglGraphicsBuffer.h

@@ -0,0 +1,90 @@
+// Filename: wglGraphicsBuffer.h
+// Created by:  drose (08Feb04)
+//
+////////////////////////////////////////////////////////////////////
+//
+// 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 WGLGRAPHICSBUFFER_H
+#define WGLGRAPHICSBUFFER_H
+
+#include "pandabase.h"
+#include "graphicsBuffer.h"
+
+#include <windows.h>
+
+////////////////////////////////////////////////////////////////////
+//       Class : wglGraphicsBuffer
+// Description : An offscreen render buffer.  In OpenGL under Windows,
+//               this simply renders into a window that is never made
+//               visible.  There's a Windows interface for rendering
+//               into a DIB, but this puts restrictions on the kind of
+//               pixelformat we can use, and thus makes it difficult
+//               to support one GSG rendering into an offscreen buffer
+//               and also into a window.
+////////////////////////////////////////////////////////////////////
+class EXPCL_PANDAGL wglGraphicsBuffer : public GraphicsBuffer {
+public:
+  wglGraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
+                    int x_size, int y_size, bool want_texture);
+  virtual ~wglGraphicsBuffer();
+
+  virtual void make_current();
+  virtual void release_gsg();
+
+  virtual void begin_flip();
+
+protected:
+  virtual void close_buffer();
+  virtual bool open_buffer();
+
+private:
+  void setup_colormap(const PIXELFORMATDESCRIPTOR &pixelformat);
+
+#ifdef _DEBUG
+  static void print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg);
+#endif
+
+  static void register_window_class();
+  static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
+  static void show_error_message(DWORD message_id = 0);
+
+  HWND _hWnd;
+  HDC _hdc;
+  HPALETTE _colormap;
+
+  static const char * const _window_class_name;
+  static bool _window_class_registered;
+
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    GraphicsBuffer::init_type();
+    register_type(_type_handle, "wglGraphicsBuffer",
+                  GraphicsBuffer::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 "wglGraphicsBuffer.I"
+
+#endif

+ 60 - 44
panda/src/wgldisplay/wglGraphicsPipe.cxx

@@ -19,6 +19,8 @@
 #include "wglGraphicsPipe.h"
 #include "wglGraphicsPipe.h"
 #include "config_wgldisplay.h"
 #include "config_wgldisplay.h"
 #include "config_windisplay.h"
 #include "config_windisplay.h"
+#include "wglGraphicsWindow.h"
+#include "wglGraphicsBuffer.h"
 
 
 typedef enum {Software, MCD, ICD} OGLDriverType;
 typedef enum {Software, MCD, ICD} OGLDriverType;
 static const char * const OGLDrvStrings[] = { "Software", "MCD", "ICD" };
 static const char * const OGLDrvStrings[] = { "Software", "MCD", "ICD" };
@@ -82,14 +84,16 @@ make_gsg(const FrameBufferProperties &properties) {
   if (!_is_valid) {
   if (!_is_valid) {
     return NULL;
     return NULL;
   }
   }
-  
+
+  // Make a copy of the supplied properties so we can possibly modify
+  // them to suit our available properties.
   FrameBufferProperties new_properties = properties;
   FrameBufferProperties new_properties = properties;
 
 
-  // Get a handle to the screen's DC so we can choose a pixel format
-  // (and a corresponding set of frame buffer properties) suitable for
-  // rendering to windows on this screen.
+  // We need a DC to examine the available pixel formats.  We'll use
+  // the screen DC.
   HDC hdc = GetDC(NULL);
   HDC hdc = GetDC(NULL);
   int pfnum = choose_pfnum(new_properties, hdc);
   int pfnum = choose_pfnum(new_properties, hdc);
+  ReleaseDC(NULL, hdc);
 
 
   if (gl_force_pixfmt != 0) {
   if (gl_force_pixfmt != 0) {
     wgldisplay_cat.info()
     wgldisplay_cat.info()
@@ -103,12 +107,8 @@ make_gsg(const FrameBufferProperties &properties) {
       << "config() - picking pixfmt #" << pfnum <<endl;
       << "config() - picking pixfmt #" << pfnum <<endl;
   }
   }
 
 
-  // Now we're done with the screen's hdc, so release it.
-  ReleaseDC(NULL, hdc);
-
-  // Now we can make a GSG.
   PT(wglGraphicsStateGuardian) gsg = 
   PT(wglGraphicsStateGuardian) gsg = 
-    new wglGraphicsStateGuardian(new_properties, pfnum);
+    new wglGraphicsStateGuardian(properties, pfnum);
 
 
   return gsg.p();
   return gsg.p();
 }
 }
@@ -123,9 +123,20 @@ make_window(GraphicsStateGuardian *gsg) {
   return new wglGraphicsWindow(this, gsg);
   return new wglGraphicsWindow(this, gsg);
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsPipe::make_buffer
+//       Access: Protected, Virtual
+//  Description: Creates a new offscreen buffer on the pipe, if possible.
+////////////////////////////////////////////////////////////////////
+PT(GraphicsBuffer) wglGraphicsPipe::
+make_buffer(GraphicsStateGuardian *gsg, int x_size, int y_size, 
+            bool want_texture) {
+  return new wglGraphicsBuffer(this, gsg, x_size, y_size, want_texture);
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: wglGraphicsPipe::choose_pfnum
 //     Function: wglGraphicsPipe::choose_pfnum
-//       Access: Private
+//       Access: Private, Static
 //  Description: Selects a suitable pixel format number for the given
 //  Description: Selects a suitable pixel format number for the given
 //               frame buffer properties.  Returns the selected number
 //               frame buffer properties.  Returns the selected number
 //               if successful, or 0 otherwise.
 //               if successful, or 0 otherwise.
@@ -134,9 +145,8 @@ make_window(GraphicsStateGuardian *gsg) {
 //               the actual visual chosen.
 //               the actual visual chosen.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 int wglGraphicsPipe::
 int wglGraphicsPipe::
-choose_pfnum(FrameBufferProperties &properties, HDC hdc) const {
+choose_pfnum(FrameBufferProperties &properties, HDC hdc) {
   int pfnum;
   int pfnum;
-  bool bUsingSoftware = false;
 
 
   if (force_software_renderer) {
   if (force_software_renderer) {
     pfnum = find_pixfmtnum(properties, hdc, false);
     pfnum = find_pixfmtnum(properties, hdc, false);
@@ -146,7 +156,6 @@ choose_pfnum(FrameBufferProperties &properties, HDC hdc) const {
         << "Couldn't find compatible software-renderer OpenGL pixfmt, check your window properties!\n";
         << "Couldn't find compatible software-renderer OpenGL pixfmt, check your window properties!\n";
       return 0;
       return 0;
     }
     }
-    bUsingSoftware = true;
 
 
   } else {
   } else {
     pfnum = find_pixfmtnum(properties, hdc, true);
     pfnum = find_pixfmtnum(properties, hdc, true);
@@ -156,7 +165,11 @@ choose_pfnum(FrameBufferProperties &properties, HDC hdc) const {
         if (pfnum == 0) {
         if (pfnum == 0) {
           wgldisplay_cat.error()
           wgldisplay_cat.error()
             << "Couldn't find HW or Software OpenGL pixfmt appropriate for this desktop!!\n";
             << "Couldn't find HW or Software OpenGL pixfmt appropriate for this desktop!!\n";
+        } else {
+          wgldisplay_cat.info()
+            << "Couldn't find compatible OGL HW pixelformat, using software rendering.\n";
         }
         }
+
       } else {
       } else {
         wgldisplay_cat.error()
         wgldisplay_cat.error()
           << "Couldn't find HW-accelerated OpenGL pixfmt appropriate for this desktop!!\n";
           << "Couldn't find HW-accelerated OpenGL pixfmt appropriate for this desktop!!\n";
@@ -168,21 +181,15 @@ choose_pfnum(FrameBufferProperties &properties, HDC hdc) const {
           << "desktop screen pixeldepth to 16bpp,and check your panda window properties\n";
           << "desktop screen pixeldepth to 16bpp,and check your panda window properties\n";
         return 0;
         return 0;
       }
       }
-      bUsingSoftware = true;
     }
     }
   }
   }
   
   
-  if (bUsingSoftware) {
-    wgldisplay_cat.info()
-      << "Couldn't find compatible OGL HW pixelformat, using software rendering.\n";
-  }
-  
   return pfnum;
   return pfnum;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: wglGraphicsPipe::find_pixfmtnum
 //     Function: wglGraphicsPipe::find_pixfmtnum
-//       Access: Private
+//       Access: Private, Static
 //  Description: This helper routine looks for either HW-only or
 //  Description: This helper routine looks for either HW-only or
 //               SW-only format, but not both.  Returns the
 //               SW-only format, but not both.  Returns the
 //               pixelformat number, or 0 if a suitable format could
 //               pixelformat number, or 0 if a suitable format could
@@ -190,7 +197,7 @@ choose_pfnum(FrameBufferProperties &properties, HDC hdc) const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 int wglGraphicsPipe::
 int wglGraphicsPipe::
 find_pixfmtnum(FrameBufferProperties &properties, HDC hdc,
 find_pixfmtnum(FrameBufferProperties &properties, HDC hdc,
-               bool bLookforHW) const {
+               bool bLookforHW) {
   int frame_buffer_mode = properties.get_frame_buffer_mode();
   int frame_buffer_mode = properties.get_frame_buffer_mode();
   bool want_depth_bits = properties.has_depth_bits();
   bool want_depth_bits = properties.has_depth_bits();
   bool want_color_bits = properties.has_color_bits();
   bool want_color_bits = properties.has_color_bits();
@@ -201,14 +208,14 @@ find_pixfmtnum(FrameBufferProperties &properties, HDC hdc,
   pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
   pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
   pfd.nVersion = 1;
   pfd.nVersion = 1;
 
 
-  // just use the pixfmt of the current desktop
-
-  int MaxPixFmtNum = 
-    DescribePixelFormat(hdc, 1, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
-  int cur_bpp = GetDeviceCaps(hdc,BITSPIXEL);
-  int pfnum;
+  // We have to call DescribePixelFormat() once just to get the
+  // highest pfnum available.  Then we can iterate through all of the
+  // pfnums.
+  int max_pfnum = DescribePixelFormat(hdc, 1, 0, NULL);
+  int cur_bpp = GetDeviceCaps(hdc, BITSPIXEL);
+  int pfnum = 0;
 
 
-  for(pfnum = 1; pfnum <= MaxPixFmtNum; pfnum++) {
+  for (pfnum = 1; pfnum <= max_pfnum; pfnum++) {
     DescribePixelFormat(hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
     DescribePixelFormat(hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
 
 
     // official, nvidia sanctioned way.
     // official, nvidia sanctioned way.
@@ -237,58 +244,70 @@ find_pixfmtnum(FrameBufferProperties &properties, HDC hdc,
     }
     }
 
 
     DWORD dwReqFlags = (PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW);
     DWORD dwReqFlags = (PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW);
+    if ((frame_buffer_mode & FrameBufferProperties::FM_double_buffer) != 0) {
+      dwReqFlags|= PFD_DOUBLEBUFFER;
+    }
 
 
     if (wgldisplay_cat.is_debug()) {
     if (wgldisplay_cat.is_debug()) {
-      wgldisplay_cat->debug()
+      wgldisplay_cat.debug()
         << "----------------" << endl;
         << "----------------" << endl;
 
 
       if ((frame_buffer_mode & FrameBufferProperties::FM_alpha) != 0) {
       if ((frame_buffer_mode & FrameBufferProperties::FM_alpha) != 0) {
-        wgldisplay_cat->debug()
+        wgldisplay_cat.debug()
           << "want alpha, pfd says '"
           << "want alpha, pfd says '"
           << (int)(pfd.cAlphaBits) << "'" << endl;
           << (int)(pfd.cAlphaBits) << "'" << endl;
       }
       }
       if ((frame_buffer_mode & FrameBufferProperties::FM_depth) != 0) {
       if ((frame_buffer_mode & FrameBufferProperties::FM_depth) != 0) {
-        wgldisplay_cat->debug()
+        wgldisplay_cat.debug()
           << "want depth, pfd says '"
           << "want depth, pfd says '"
           << (int)(pfd.cDepthBits) << "'" << endl;
           << (int)(pfd.cDepthBits) << "'" << endl;
       }
       }
       if ((frame_buffer_mode & FrameBufferProperties::FM_stencil) != 0) {
       if ((frame_buffer_mode & FrameBufferProperties::FM_stencil) != 0) {
-        wgldisplay_cat->debug()
+        wgldisplay_cat.debug()
           << "want stencil, pfd says '"
           << "want stencil, pfd says '"
           << (int)(pfd.cStencilBits) << "'" << endl;
           << (int)(pfd.cStencilBits) << "'" << endl;
       }
       }
-      wgldisplay_cat->debug()
+      wgldisplay_cat.debug()
         << "final flag check " << (int)(pfd.dwFlags & dwReqFlags) << " =? "
         << "final flag check " << (int)(pfd.dwFlags & dwReqFlags) << " =? "
         << (int)dwReqFlags << endl;
         << (int)dwReqFlags << endl;
-      wgldisplay_cat->debug() 
+      wgldisplay_cat.debug() 
         << "pfd bits = " << (int)(pfd.cColorBits) << endl;
         << "pfd bits = " << (int)(pfd.cColorBits) << endl;
-      wgldisplay_cat->debug() 
+      wgldisplay_cat.debug() 
         << "cur_bpp = " << cur_bpp << endl;
         << "cur_bpp = " << cur_bpp << endl;
     }
     }
 
 
-    if ((frame_buffer_mode & FrameBufferProperties::FM_double_buffer) != 0) {
-      dwReqFlags|= PFD_DOUBLEBUFFER;
-    }
     if ((frame_buffer_mode & FrameBufferProperties::FM_alpha) != 0 && 
     if ((frame_buffer_mode & FrameBufferProperties::FM_alpha) != 0 && 
         (pfd.cAlphaBits==0)) {
         (pfd.cAlphaBits==0)) {
+      wgldisplay_cat.debug() 
+        << "  rejecting because alpha is missing.\n";
       continue;
       continue;
     }
     }
     if ((frame_buffer_mode & FrameBufferProperties::FM_depth) != 0 && 
     if ((frame_buffer_mode & FrameBufferProperties::FM_depth) != 0 && 
         (pfd.cDepthBits==0)) {
         (pfd.cDepthBits==0)) {
+      wgldisplay_cat.debug() 
+        << "  rejecting because depth is missing.\n";
       continue;
       continue;
     }
     }
     if ((frame_buffer_mode & FrameBufferProperties::FM_stencil) != 0 && 
     if ((frame_buffer_mode & FrameBufferProperties::FM_stencil) != 0 && 
         (pfd.cStencilBits==0)) {
         (pfd.cStencilBits==0)) {
+      wgldisplay_cat.debug() 
+        << "  rejecting because stencil is missing.\n";
       continue;
       continue;
     }
     }
 
 
     if ((pfd.dwFlags & dwReqFlags) != dwReqFlags) {
     if ((pfd.dwFlags & dwReqFlags) != dwReqFlags) {
+      wgldisplay_cat.debug() 
+        << "  rejecting because some other required flags are missing.\n";
       continue;
       continue;
     }
     }
 
 
     // now we ignore the specified want_color_bits for windowed mode
     // now we ignore the specified want_color_bits for windowed mode
     // instead we use the current screen depth
     // instead we use the current screen depth
 
 
+    // drose: Does this help anything?  Checking the current screen
+    // depth doesn't make sense if we are rendering offscreen or if we
+    // are planning to open a fullscreen window, and it seems like it
+    // shouldn't be necessary anyway.
     if ((pfd.cColorBits!=cur_bpp) && 
     if ((pfd.cColorBits!=cur_bpp) && 
         (!((cur_bpp==16) && (pfd.cColorBits==15))) && 
         (!((cur_bpp==16) && (pfd.cColorBits==15))) && 
         (!((cur_bpp==32) && (pfd.cColorBits==24)))) {
         (!((cur_bpp==32) && (pfd.cColorBits==24)))) {
@@ -299,12 +318,9 @@ find_pixfmtnum(FrameBufferProperties &properties, HDC hdc,
     // Note: could go continue looping looking for more alpha bits or
     // Note: could go continue looping looking for more alpha bits or
     // more depth bits so this would pick 16bpp depth buffer, probably
     // more depth bits so this would pick 16bpp depth buffer, probably
     // not 24bpp
     // not 24bpp
-    break;
+    return pfnum;
   }
   }
 
 
-  if (pfnum > MaxPixFmtNum) {
-    pfnum = 0;
-  }
-
-  return pfnum;
+  // No pfnum was acceptable.
+  return 0;
 }
 }

+ 5 - 4
panda/src/wgldisplay/wglGraphicsPipe.h

@@ -39,11 +39,12 @@ public:
 protected:
 protected:
   virtual PT(GraphicsStateGuardian) make_gsg(const FrameBufferProperties &properties);
   virtual PT(GraphicsStateGuardian) make_gsg(const FrameBufferProperties &properties);
   virtual PT(GraphicsWindow) make_window(GraphicsStateGuardian *gsg);
   virtual PT(GraphicsWindow) make_window(GraphicsStateGuardian *gsg);
-
+  virtual PT(GraphicsBuffer) make_buffer(GraphicsStateGuardian *gsg, 
+                                         int x_size, int y_size, bool want_texture);
 private:
 private:
-  int choose_pfnum(FrameBufferProperties &properties, HDC hdc) const;
-  int find_pixfmtnum(FrameBufferProperties &properties, HDC hdc,
-                     bool bLookforHW) const;
+  static int choose_pfnum(FrameBufferProperties &properties, HDC hdc);
+  static int find_pixfmtnum(FrameBufferProperties &properties, HDC hdc,
+                            bool bLookforHW);
 
 
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {

+ 6 - 1
panda/src/wgldisplay/wglGraphicsStateGuardian.I

@@ -20,7 +20,12 @@
 //     Function: wglGraphicsStateGuardian::get_pfnum
 //     Function: wglGraphicsStateGuardian::get_pfnum
 //       Access: Public
 //       Access: Public
 //  Description: Returns the pixel format number chosen for windows
 //  Description: Returns the pixel format number chosen for windows
-//               that use this context.
+//               that use this context.  In OpenGL under Microsoft
+//               Windows, the window must be created first and then
+//               the GL context is created from the window, and the
+//               context inherits the pixel format of the window.
+//               Therefore, all windows that share a particular
+//               context must also share the same pixel format.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE int wglGraphicsStateGuardian::
 INLINE int wglGraphicsStateGuardian::
 get_pfnum() const {
 get_pfnum() const {

+ 5 - 1
panda/src/wgldisplay/wglGraphicsStateGuardian.h

@@ -39,8 +39,12 @@ public:
 private:
 private:
   void make_context(HDC hdc);
   void make_context(HDC hdc);
 
 
-  bool _made_context;
+  // All windows that share a particular GL context must also share
+  // the same pixel format; therefore, we store the pixel format
+  // number in the GSG.
   int _pfnum;
   int _pfnum;
+
+  bool _made_context;
   HGLRC _context;
   HGLRC _context;
 
 
 public:
 public:

+ 0 - 1267
panda/src/wgldisplay/wglGraphicsWindow.cxx

@@ -29,13 +29,6 @@ TypeHandle wglGraphicsWindow::_type_handle;
 
 
 static char *ConvDDErrorToString(const HRESULT &error);
 static char *ConvDDErrorToString(const HRESULT &error);
 
 
-// spare me the trouble of linking with dxguid.lib or defining ALL the dx guids in this .obj by #defining INITGUID
-#define MY_DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
-        EXTERN_C const GUID DECLSPEC_SELECTANY name \
-                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
-
-MY_DEFINE_GUID(IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56);
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //  Function: GetAvailVidMem
 //  Function: GetAvailVidMem
 //  Description: Uses DDraw to get available video memory
 //  Description: Uses DDraw to get available video memory
@@ -235,7 +228,6 @@ open_window() {
 
 
   // Set up the pixel format of the window appropriately for GL.
   // Set up the pixel format of the window appropriately for GL.
   int pfnum = wglgsg->get_pfnum();
   int pfnum = wglgsg->get_pfnum();
-
   PIXELFORMATDESCRIPTOR pixelformat;
   PIXELFORMATDESCRIPTOR pixelformat;
   DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), 
   DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), 
                       &pixelformat);
                       &pixelformat);
@@ -412,1262 +404,3 @@ print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg) {
 }
 }
 #endif
 #endif
 
 
-
-static char *
-ConvDDErrorToString(const HRESULT &error) {
-  switch(error) {
-  case E_FAIL:
-    return "Unspecified error E_FAIL";
-    
-  case DD_OK:
-    return "No error.\0";
-    
-  case DDERR_ALREADYINITIALIZED     : // (5)
-    return "DDERR_ALREADYINITIALIZED        ";//: // (5)
-  case DDERR_CANNOTATTACHSURFACE        : // (10)
-    return "DDERR_CANNOTATTACHSURFACE       ";//: // (10)
-  case DDERR_CANNOTDETACHSURFACE        : // (20)
-    return "DDERR_CANNOTDETACHSURFACE       ";//: // (20)
-  case DDERR_CURRENTLYNOTAVAIL          : // (40)
-    return "DDERR_CURRENTLYNOTAVAIL         ";//: // (40)
-  case DDERR_EXCEPTION              : // (55)
-    return "DDERR_EXCEPTION             ";//: // (55)
-  case DDERR_HEIGHTALIGN            : // (90)
-    return "DDERR_HEIGHTALIGN           ";//: // (90)
-  case DDERR_INCOMPATIBLEPRIMARY        : // (95)
-    return "DDERR_INCOMPATIBLEPRIMARY       ";//: // (95)
-  case DDERR_INVALIDCAPS            : // (100)
-    return "DDERR_INVALIDCAPS           ";//: // (100)
-  case DDERR_INVALIDCLIPLIST            : // (110)
-    return "DDERR_INVALIDCLIPLIST           ";//: // (110)
-  case DDERR_INVALIDMODE            : // (120)
-    return "DDERR_INVALIDMODE           ";//: // (120)
-  case DDERR_INVALIDOBJECT          : // (130)
-    return "DDERR_INVALIDOBJECT         ";//: // (130)
-  case DDERR_INVALIDPIXELFORMAT     : // (145)
-    return "DDERR_INVALIDPIXELFORMAT        ";//: // (145)
-  case DDERR_INVALIDRECT            : // (150)
-    return "DDERR_INVALIDRECT           ";//: // (150)
-  case DDERR_LOCKEDSURFACES         : // (160)
-    return "DDERR_LOCKEDSURFACES            ";//: // (160)
-  case DDERR_NO3D               : // (170)
-    return "DDERR_NO3D              ";//: // (170)
-  case DDERR_NOALPHAHW              : // (180)
-    return "DDERR_NOALPHAHW             ";//: // (180)
-  case DDERR_NOCLIPLIST         : // (205)
-    return "DDERR_NOCLIPLIST            ";//: // (205)
-  case DDERR_NOCOLORCONVHW          : // (210)
-    return "DDERR_NOCOLORCONVHW         ";//: // (210)
-  case DDERR_NOCOOPERATIVELEVELSET      : // (212)
-    return "DDERR_NOCOOPERATIVELEVELSET     ";//: // (212)
-  case DDERR_NOCOLORKEY         : // (215)
-    return "DDERR_NOCOLORKEY            ";//: // (215)
-  case DDERR_NOCOLORKEYHW           : // (220)
-    return "DDERR_NOCOLORKEYHW          ";//: // (220)
-  case DDERR_NODIRECTDRAWSUPPORT        : // (222)
-    return "DDERR_NODIRECTDRAWSUPPORT       ";//: // (222)
-  case DDERR_NOEXCLUSIVEMODE            : // (225)
-    return "DDERR_NOEXCLUSIVEMODE           ";//: // (225)
-  case DDERR_NOFLIPHW               : // (230)
-    return "DDERR_NOFLIPHW              ";//: // (230)
-  case DDERR_NOGDI              : // (240)
-    return "DDERR_NOGDI             ";//: // (240)
-  case DDERR_NOMIRRORHW         : // (250)
-    return "DDERR_NOMIRRORHW            ";//: // (250)
-  case DDERR_NOTFOUND               : // (255)
-    return "DDERR_NOTFOUND              ";//: // (255)
-  case DDERR_NOOVERLAYHW            : // (260)
-    return "DDERR_NOOVERLAYHW           ";//: // (260)
-  case DDERR_NORASTEROPHW           : // (280)
-    return "DDERR_NORASTEROPHW          ";//: // (280)
-  case DDERR_NOROTATIONHW           : // (290)
-    return "DDERR_NOROTATIONHW          ";//: // (290)
-  case DDERR_NOSTRETCHHW            : // (310)
-    return "DDERR_NOSTRETCHHW           ";//: // (310)
-  case DDERR_NOT4BITCOLOR           : // (316)
-    return "DDERR_NOT4BITCOLOR          ";//: // (316)
-  case DDERR_NOT4BITCOLORINDEX          : // (317)
-    return "DDERR_NOT4BITCOLORINDEX         ";//: // (317)
-  case DDERR_NOT8BITCOLOR           : // (320)
-    return "DDERR_NOT8BITCOLOR          ";//: // (320)
-  case DDERR_NOTEXTUREHW            : // (330)
-    return "DDERR_NOTEXTUREHW           ";//: // (330)
-  case DDERR_NOVSYNCHW              : // (335)
-    return "DDERR_NOVSYNCHW             ";//: // (335)
-  case DDERR_NOZBUFFERHW            : // (340)
-    return "DDERR_NOZBUFFERHW           ";//: // (340)
-  case DDERR_NOZOVERLAYHW           : // (350)
-    return "DDERR_NOZOVERLAYHW          ";//: // (350)
-  case DDERR_OUTOFCAPS              : // (360)
-    return "DDERR_OUTOFCAPS             ";//: // (360)
-  case DDERR_OUTOFVIDEOMEMORY           : // (380)
-    return "DDERR_OUTOFVIDEOMEMORY          ";//: // (380)
-  case DDERR_OVERLAYCANTCLIP            : // (382)
-    return "DDERR_OVERLAYCANTCLIP           ";//: // (382)
-  case DDERR_OVERLAYCOLORKEYONLYONEACTIVE   : // (384)
-    return "DDERR_OVERLAYCOLORKEYONLYONEACTIVE  ";//: // (384)
-  case DDERR_PALETTEBUSY            : // (387)
-    return "DDERR_PALETTEBUSY           ";//: // (387)
-  case DDERR_COLORKEYNOTSET         : // (400)
-    return "DDERR_COLORKEYNOTSET            ";//: // (400)
-  case DDERR_SURFACEALREADYATTACHED     : // (410)
-    return "DDERR_SURFACEALREADYATTACHED        ";//: // (410)
-  case DDERR_SURFACEALREADYDEPENDENT        : // (420)
-    return "DDERR_SURFACEALREADYDEPENDENT       ";//: // (420)
-  case DDERR_SURFACEBUSY            : // (430)
-    return "DDERR_SURFACEBUSY           ";//: // (430)
-  case DDERR_CANTLOCKSURFACE                   : // (435)
-    return "DDERR_CANTLOCKSURFACE";//: // (435)
-  case DDERR_SURFACEISOBSCURED          : // (440)
-    return "DDERR_SURFACEISOBSCURED         ";//: // (440)
-  case DDERR_SURFACELOST            : // (450)
-    return "DDERR_SURFACELOST           ";//: // (450)
-  case DDERR_SURFACENOTATTACHED     : // (460)
-    return "DDERR_SURFACENOTATTACHED        ";//: // (460)
-  case DDERR_TOOBIGHEIGHT           : // (470)
-    return "DDERR_TOOBIGHEIGHT          ";//: // (470)
-  case DDERR_TOOBIGSIZE         : // (480)
-    return "DDERR_TOOBIGSIZE            ";//: // (480)
-  case DDERR_TOOBIGWIDTH            : // (490)
-    return "DDERR_TOOBIGWIDTH           ";//: // (490)
-  case DDERR_UNSUPPORTEDFORMAT          : // (510)
-    return "DDERR_UNSUPPORTEDFORMAT         ";//: // (510)
-  case DDERR_UNSUPPORTEDMASK            : // (520)
-    return "DDERR_UNSUPPORTEDMASK           ";//: // (520)
-  case DDERR_VERTICALBLANKINPROGRESS        : // (537)
-    return "DDERR_VERTICALBLANKINPROGRESS       ";//: // (537)
-  case DDERR_WASSTILLDRAWING            : // (540)
-    return "DDERR_WASSTILLDRAWING           ";//: // (540)
-  case DDERR_XALIGN             : // (560)
-    return "DDERR_XALIGN                ";//: // (560)
-  case DDERR_INVALIDDIRECTDRAWGUID      : // (561)
-    return "DDERR_INVALIDDIRECTDRAWGUID     ";//: // (561)
-  case DDERR_DIRECTDRAWALREADYCREATED       : // (562)
-    return "DDERR_DIRECTDRAWALREADYCREATED      ";//: // (562)
-  case DDERR_NODIRECTDRAWHW         : // (563)
-    return "DDERR_NODIRECTDRAWHW            ";//: // (563)
-  case DDERR_PRIMARYSURFACEALREADYEXISTS    : // (564)
-    return "DDERR_PRIMARYSURFACEALREADYEXISTS   ";//: // (564)
-  case DDERR_NOEMULATION            : // (565)
-    return "DDERR_NOEMULATION           ";//: // (565)
-  case DDERR_REGIONTOOSMALL         : // (566)
-    return "DDERR_REGIONTOOSMALL            ";//: // (566)
-  case DDERR_CLIPPERISUSINGHWND     : // (567)
-    return "DDERR_CLIPPERISUSINGHWND        ";//: // (567)
-  case DDERR_NOCLIPPERATTACHED          : // (568)
-    return "DDERR_NOCLIPPERATTACHED         ";//: // (568)
-  case DDERR_NOHWND             : // (569)
-    return "DDERR_NOHWND                ";//: // (569)
-  case DDERR_HWNDSUBCLASSED         : // (570)
-    return "DDERR_HWNDSUBCLASSED            ";//: // (570)
-  case DDERR_HWNDALREADYSET         : // (571)
-    return "DDERR_HWNDALREADYSET            ";//: // (571)
-  case DDERR_NOPALETTEATTACHED          : // (572)
-    return "DDERR_NOPALETTEATTACHED         ";//: // (572)
-  case DDERR_NOPALETTEHW            : // (573)
-    return "DDERR_NOPALETTEHW           ";//: // (573)
-  case DDERR_BLTFASTCANTCLIP            : // (574)
-    return "DDERR_BLTFASTCANTCLIP           ";//: // (574)
-  case DDERR_NOBLTHW                : // (575)
-    return "DDERR_NOBLTHW               ";//: // (575)
-  case DDERR_NODDROPSHW         : // (576)
-    return "DDERR_NODDROPSHW            ";//: // (576)
-  case DDERR_OVERLAYNOTVISIBLE          : // (577)
-    return "DDERR_OVERLAYNOTVISIBLE         ";//: // (577)
-  case DDERR_NOOVERLAYDEST          : // (578)
-    return "DDERR_NOOVERLAYDEST         ";//: // (578)
-  case DDERR_INVALIDPOSITION            : // (579)
-    return "DDERR_INVALIDPOSITION           ";//: // (579)
-  case DDERR_NOTAOVERLAYSURFACE     : // (580)
-    return "DDERR_NOTAOVERLAYSURFACE        ";//: // (580)
-  case DDERR_EXCLUSIVEMODEALREADYSET        : // (581)
-    return "DDERR_EXCLUSIVEMODEALREADYSET       ";//: // (581)
-  case DDERR_NOTFLIPPABLE           : // (582)
-    return "DDERR_NOTFLIPPABLE          ";//: // (582)
-  case DDERR_CANTDUPLICATE          : // (583)
-    return "DDERR_CANTDUPLICATE         ";//: // (583)
-  case DDERR_NOTLOCKED              : // (584)
-    return "DDERR_NOTLOCKED             ";//: // (584)
-  case DDERR_CANTCREATEDC           : // (585)
-    return "DDERR_CANTCREATEDC          ";//: // (585)
-  case DDERR_NODC               : // (586)
-    return "DDERR_NODC              ";//: // (586)
-  case DDERR_WRONGMODE              : // (587)
-    return "DDERR_WRONGMODE             ";//: // (587)
-  case DDERR_IMPLICITLYCREATED          : // (588)
-    return "DDERR_IMPLICITLYCREATED         ";//: // (588)
-  case DDERR_NOTPALETTIZED          : // (589)
-    return "DDERR_NOTPALETTIZED         ";//: // (589)
-  case DDERR_UNSUPPORTEDMODE            : // (590)
-    return "DDERR_UNSUPPORTEDMODE           ";//: // (590)
-  case DDERR_NOMIPMAPHW         : // (591)
-    return "DDERR_NOMIPMAPHW            ";//: // (591)
-  case DDERR_INVALIDSURFACETYPE                : // (592)
-    return "DDERR_INVALIDSURFACETYPE";//: // (592)
-  case DDERR_NOOPTIMIZEHW                      : // (600)
-    return "DDERR_NOOPTIMIZEHW";//: // (600)
-  case DDERR_NOTLOADED                         : // (601)
-    return "DDERR_NOTLOADED";//: // (601)
-  case DDERR_NOFOCUSWINDOW                     : // (602)
-    return "DDERR_NOFOCUSWINDOW";//: // (602)
-  case DDERR_DCALREADYCREATED           : // (620)
-    return "DDERR_DCALREADYCREATED          ";//: // (620)
-  case DDERR_NONONLOCALVIDMEM                  : // (630)
-    return "DDERR_NONONLOCALVIDMEM";//: // (630)
-  case DDERR_CANTPAGELOCK           : // (640)
-    return "DDERR_CANTPAGELOCK          ";//: // (640)
-  case DDERR_CANTPAGEUNLOCK         : // (660)
-    return "DDERR_CANTPAGEUNLOCK            ";//: // (660)
-  case DDERR_NOTPAGELOCKED          : // (680)
-    return "DDERR_NOTPAGELOCKED         ";//: // (680)
-  case DDERR_MOREDATA                   : // (690)
-    return "DDERR_MOREDATA                  ";//: // (690)
-  case DDERR_VIDEONOTACTIVE             : // (695)
-    return "DDERR_VIDEONOTACTIVE            ";//: // (695)
-  case DDERR_DEVICEDOESNTOWNSURFACE         : // (699)
-    return "DDERR_DEVICEDOESNTOWNSURFACE        ";//: // (699)
-
-  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;
-  }
-}

+ 1 - 0
panda/src/wgldisplay/wgldisplay_composite1.cxx

@@ -1,4 +1,5 @@
 #include "config_wgldisplay.cxx"
 #include "config_wgldisplay.cxx"
+#include "wglGraphicsBuffer.cxx"
 #include "wglGraphicsPipe.cxx"
 #include "wglGraphicsPipe.cxx"
 #include "wglGraphicsStateGuardian.cxx"
 #include "wglGraphicsStateGuardian.cxx"
 #include "wglGraphicsWindow.cxx"
 #include "wglGraphicsWindow.cxx"