فهرست منبع

add anti-aliasing flag

cxgeorge 24 سال پیش
والد
کامیت
4770614973
2فایلهای تغییر یافته به همراه35 افزوده شده و 2 حذف شده
  1. 21 2
      panda/src/dxgsg/dxGraphicsStateGuardian.cxx
  2. 14 0
      panda/src/wdxdisplay/wdxGraphicsWindow.cxx

+ 21 - 2
panda/src/dxgsg/dxGraphicsStateGuardian.cxx

@@ -20,6 +20,7 @@
 #pragma hdrstop
 
 
+//#define DISABLE_DECALING
 #define DISABLE_POLYGON_OFFSET_DECALING
 // currently doesnt work well enough in toontown models for us to use
 // prob is when viewer gets close to decals, they disappear into wall poly, need to investigate
@@ -422,6 +423,15 @@ init_dx(  LPDIRECTDRAW7     context,
 #endif
 
     _d3dDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, _CurShadeMode);
+
+    if(dx_full_screen_antialiasing) {
+      if(_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT) {
+        _d3dDevice->SetRenderState(D3DRENDERSTATE_ANTIALIAS,D3DANTIALIAS_SORTINDEPENDENT);
+        dxgsg_cat.debug() << "enabling full-screen anti-aliasing\n";
+      } else {
+        dxgsg_cat.debug() << "device doesnt support full-screen anti-aliasing\n";
+      }
+    }
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -4882,6 +4892,8 @@ begin_decal(GeomNode *base_geom) {
         _d3dDevice->SetRenderState(D3DRENDERSTATE_ZBIAS, POLYGON_OFFSET_MULTIPLIER * _decal_level); // _decal_level better not be higher than 8!
     } else
 #endif
+
+#ifndef DISABLE_DECALING
     {
         if (_decal_level > 1)
             base_geom->draw(this);  // If we're already decaling, just draw the geometry.
@@ -4897,6 +4909,9 @@ begin_decal(GeomNode *base_geom) {
             // buffer write off during this.
         }
     }
+#else
+            base_geom->draw(this);
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -4908,9 +4923,13 @@ begin_decal(GeomNode *base_geom) {
 ////////////////////////////////////////////////////////////////////
 void DXGraphicsStateGuardian::
 end_decal(GeomNode *base_geom) {
-    nassertv(base_geom != (GeomNode *)NULL);
-
     _decal_level--;
+
+#ifdef DISABLE_DECALING
+    return;
+#endif
+
+    nassertv(base_geom != (GeomNode *)NULL);
 //  nassertv(_decal_level >= 1);
 
 #ifndef DISABLE_POLYGON_OFFSET_DECALING

+ 14 - 0
panda/src/wdxdisplay/wdxGraphicsWindow.cxx

@@ -28,6 +28,8 @@ TypeHandle wdxGraphicsWindow::_type_handle;
 //         need to replace this with global hwnd->wdx classptr STL map obj
 wdxGraphicsWindow* global_dxwin = NULL;
 
+extern bool dx_full_screen_antialiasing;
+
 #define MOUSE_ENTERED 0
 #define MOUSE_EXITED 1
 
@@ -952,6 +954,12 @@ dx_setup() {
                                  DDSCAPS_FLIP | DDSCAPS_COMPLEX;
         ddsd.dwBackBufferCount = 1;
 
+        if(dx_full_screen_antialiasing) {
+            // cant check that d3ddevice has this capability yet, so got to set it anyway.
+            // hope this is OK.
+            ddsd.ddsCaps.dwCaps2 |= DDSCAPS2_HINTANTIALIASING; 
+        }
+
         PRINTVIDMEM(pDD,&ddsd.ddsCaps,"initial primary & backbuf");
 
         // Create the primary surface
@@ -1087,6 +1095,12 @@ dx_setup() {
         SurfaceDesc.dwWidth  = dwRenderWidth;
         SurfaceDesc.dwHeight = dwRenderHeight;
 
+        if(dx_full_screen_antialiasing) {
+            // cant check that d3ddevice has this capability yet, so got to set it anyway.
+            // hope this is OK.
+            SurfaceDesc.ddsCaps.dwCaps2 |= DDSCAPS2_HINTANTIALIASING; 
+        }
+
         PRINTVIDMEM(pDD,&SurfaceDesc.ddsCaps,"initial backbuf");
 
         // Create the backbuffer. (might want to handle failure due to running out of video memory.