Browse Source

fix no-ddraw HW bug

cxgeorge 24 năm trước cách đây
mục cha
commit
b8aa4a77bd
1 tập tin đã thay đổi với 14 bổ sung9 xóa
  1. 14 9
      panda/src/wgldisplay/wglGraphicsWindow.cxx

+ 14 - 9
panda/src/wgldisplay/wglGraphicsWindow.cxx

@@ -248,15 +248,20 @@ static DWORD GetAvailVidMem(void) {
     ZeroMemory(&ddsCaps,sizeof(DDSCAPS2));
     ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; //set internally by DX anyway, dont think this any different than 0x0
 
-    if(FAILED(  hr = pDD2->GetAvailableVidMem(&ddsCaps,&dwTotal,&dwFree))) {
-        wgldisplay_cat.fatal() << "GetAvailableVidMem failed : result = " << ConvDDErrorToString(hr) << endl;
-        exit(1);
+    if(FAILED(hr = pDD2->GetAvailableVidMem(&ddsCaps,&dwTotal,&dwFree))) {
+        if(hr==DDERR_NODIRECTDRAWHW) {
+           if(wgldisplay_cat.is_debug())
+               wgldisplay_cat.debug() << "GetAvailableVidMem returns no-DDraw HW, assuming we have plenty of vidmem\n";
+           dwTotal=dwFree=0x7FFFFFFF;
+        } else {
+            wgldisplay_cat.fatal() << "GetAvailableVidMem failed : result = " << ConvDDErrorToString(hr) << endl;
+            exit(1);
+        }
+    } else {
+       if(wgldisplay_cat.is_debug())
+           wgldisplay_cat.debug() << "before FullScreen switch: GetAvailableVidMem returns Total: " << dwTotal/1000000.0 << "  Free: " << dwFree/1000000.0 << endl;
     }
 
-#ifdef _DEBUG
-    wgldisplay_cat.debug() << "before FullScreen switch: GetAvailableVidMem returns Total: " << dwTotal/1000000.0 << "  Free: " << dwFree/1000000.0 << endl;
-#endif
-
     pDD2->Release();  // bye-bye ddraw
 
     return dwFree;
@@ -1023,8 +1028,8 @@ void wglGraphicsWindow::end_frame(void) {
 
   {
     PStatTimer timer(_swap_pcollector);
-	 if(_is_synced) glFinish();
-	 else SwapBuffers(_hdc);
+     if(_is_synced) glFinish();
+     else SwapBuffers(_hdc);
   }
   GraphicsWindow::end_frame();
 }