Bläddra i källkod

check framebuffer properties for match when creating pbuffer

David Rose 22 år sedan
förälder
incheckning
dba1064551

+ 7 - 1
panda/src/wgldisplay/wglGraphicsBuffer.cxx

@@ -264,7 +264,7 @@ open_buffer() {
       << "Created PBuffer " << _pbuffer << ", DC " << _pbuffer_dc << "\n";
       << "Created PBuffer " << _pbuffer << ", DC " << _pbuffer_dc << "\n";
 
 
     wglMakeCurrent(_pbuffer_dc, wglgsg->get_context(_pbuffer_dc));
     wglMakeCurrent(_pbuffer_dc, wglgsg->get_context(_pbuffer_dc));
-    wglgsg->report_gl_errors();
+    wglgsg->report_my_gl_errors();
 
 
     // Now that the pbuffer is created, we don't need the window any
     // Now that the pbuffer is created, we don't need the window any
     // more.
     // more.
@@ -400,6 +400,12 @@ make_pbuffer() {
     iattrib_list[ni++] = WGL_STENCIL_BITS_ARB;
     iattrib_list[ni++] = WGL_STENCIL_BITS_ARB;
     iattrib_list[ni++] = pfd.cStencilBits;
     iattrib_list[ni++] = pfd.cStencilBits;
 
 
+    // Match up properties.
+    iattrib_list[ni++] = WGL_DOUBLE_BUFFER_ARB;
+    iattrib_list[ni++] = ((pfd.dwFlags & PFD_DOUBLEBUFFER) != 0);
+    iattrib_list[ni++] = WGL_STEREO_ARB;
+    iattrib_list[ni++] = ((pfd.dwFlags & PFD_STEREO) != 0);
+
     // Terminate the lists.
     // Terminate the lists.
     nassertr(ni < max_attrib_list && nf < max_attrib_list, NULL);
     nassertr(ni < max_attrib_list && nf < max_attrib_list, NULL);
     iattrib_list[ni] = 0;
     iattrib_list[ni] = 0;

+ 51 - 2
panda/src/wgldisplay/wglGraphicsPipe.cxx

@@ -277,8 +277,8 @@ find_pixfmtnum(FrameBufferProperties &properties, HDC hdc,
           << "stencil = " << (int)(pfd.cStencilBits) << "\n";
           << "stencil = " << (int)(pfd.cStencilBits) << "\n";
       }
       }
       wgldisplay_cat.debug()
       wgldisplay_cat.debug()
-        << "flags = " << hex << (int)(pfd.dwFlags) << " (missing "
-        << (int)((~pfd.dwFlags) & dwReqFlags) << dec << ")\n";
+        << "flags = " << format_pfd_flags(pfd.dwFlags) << " (missing "
+        << format_pfd_flags((~pfd.dwFlags) & dwReqFlags) << ")\n";
     }
     }
 
 
     if ((frame_buffer_mode & FrameBufferProperties::FM_alpha) != 0 && 
     if ((frame_buffer_mode & FrameBufferProperties::FM_alpha) != 0 && 
@@ -360,3 +360,52 @@ find_pixfmtnum(FrameBufferProperties &properties, HDC hdc,
 
 
   return found_pfnum;
   return found_pfnum;
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: wglGraphicsPipe::format_pfd_flags
+//       Access: Private, Static
+//  Description: Returns pfd_flags formatted as a string in a
+//               user-friendly way.
+////////////////////////////////////////////////////////////////////
+string wglGraphicsPipe::
+format_pfd_flags(DWORD pfd_flags) {
+  struct FlagDef {
+    DWORD flag;
+    const char *name;
+  };
+  static FlagDef flag_def[] = {
+    { PFD_DRAW_TO_WINDOW, "PFD_DRAW_TO_WINDOW" },
+    { PFD_DRAW_TO_BITMAP, "PFD_DRAW_TO_BITMAP" },
+    { PFD_SUPPORT_GDI, "PFD_SUPPORT_GDI" },
+    { PFD_SUPPORT_OPENGL, "PFD_SUPPORT_OPENGL" },
+    { PFD_GENERIC_ACCELERATED, "PFD_GENERIC_ACCELERATED" },
+    { PFD_GENERIC_FORMAT, "PFD_GENERIC_FORMAT" },
+    { PFD_NEED_PALETTE, "PFD_NEED_PALETTE" },
+    { PFD_NEED_SYSTEM_PALETTE, "PFD_NEED_SYSTEM_PALETTE" },
+    { PFD_DOUBLEBUFFER, "PFD_DOUBLEBUFFER" },
+    { PFD_STEREO, "PFD_STEREO" },
+    { PFD_SWAP_LAYER_BUFFERS, "PFD_SWAP_LAYER_BUFFERS" },
+    { PFD_SWAP_COPY, "PFD_SWAP_COPY" },
+    { PFD_SWAP_EXCHANGE, "PFD_SWAP_EXCHANGE" },
+  };
+  static const int num_flag_defs = sizeof(flag_def) / sizeof(FlagDef);
+
+  ostringstream out;
+
+  const char *sep = "";
+  bool got_any = false;
+  for (int i = 0; i < num_flag_defs; i++) {
+    if (pfd_flags & flag_def[i].flag) {
+      out << sep << flag_def[i].name;
+      pfd_flags &= ~flag_def[i].flag;
+      sep = "|";
+      got_any = true;
+    }
+  }
+
+  if (pfd_flags != 0 || !got_any) {
+    out << sep << hex << "0x" << pfd_flags << dec;
+  }
+
+  return out.str();
+}

+ 1 - 0
panda/src/wgldisplay/wglGraphicsPipe.h

@@ -45,6 +45,7 @@ private:
   static int choose_pfnum(FrameBufferProperties &properties, HDC hdc);
   static int choose_pfnum(FrameBufferProperties &properties, HDC hdc);
   static int find_pixfmtnum(FrameBufferProperties &properties, HDC hdc,
   static int find_pixfmtnum(FrameBufferProperties &properties, HDC hdc,
                             bool bLookforHW);
                             bool bLookforHW);
+  static string format_pfd_flags(DWORD pfd_flags);
 
 
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {