Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/dxgsg7/dxGraphicsStateGuardian7.I

Go to the documentation of this file.
00001 // Filename: dxGraphicsStateGuardian7.I
00002 // Created by:  mike (02Feb99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "config_dxgsg7.h"
00020 #include <graphicsWindow.h>
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //     Function: DXGraphicsStateGuardian7::enable_line_smooth
00024 //       Access:
00025 //  Description:
00026 ////////////////////////////////////////////////////////////////////
00027 INLINE void DXGraphicsStateGuardian7::
00028 enable_line_smooth(bool val) {
00029   if(_line_smooth_enabled != val) {
00030     _line_smooth_enabled = val;
00031   #ifdef NDEBUG
00032     {
00033         if(val && (_pScrn->D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
00034            dxgsg7_cat.error() << "no HW support for line smoothing!!\n";
00035     }
00036   #endif
00037 
00038     _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_EDGEANTIALIAS, (DWORD)val);
00039   }
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: DXGraphicsStateGuardian7::enable_dither
00044 //       Access:
00045 //  Description:
00046 ////////////////////////////////////////////////////////////////////
00047 INLINE void DXGraphicsStateGuardian7::
00048 enable_dither(bool val) {
00049   if (_dither_enabled != val) {
00050 
00051   #ifdef _DEBUG
00052     {
00053         if(val && !(_pScrn->D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER))
00054            dxgsg7_cat.error() << "no HW support for color dithering!!\n";
00055         return;
00056     }
00057   #endif
00058 
00059     _dither_enabled = val;
00060     _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, (DWORD)val);
00061   }
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: DXGraphicsStateGuardian7::enable_stencil_test
00066 //       Access:
00067 //  Description:
00068 ////////////////////////////////////////////////////////////////////
00069 INLINE void DXGraphicsStateGuardian7::
00070 enable_stencil_test(bool val) {
00071   if (_stencil_test_enabled != val) {
00072     _stencil_test_enabled = val;
00073     _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_STENCILENABLE, (DWORD)val);
00074   }
00075 }
00076 
00077 ////////////////////////////////////////////////////////////////////
00078 //     Function: DXGraphicsStateGuardian7::enable_color_material
00079 //       Access:
00080 //  Description:
00081 ////////////////////////////////////////////////////////////////////
00082 INLINE void DXGraphicsStateGuardian7::
00083 enable_color_material(bool val) {
00084   if (_color_material_enabled != val) {
00085     _color_material_enabled = val;
00086   }
00087 }
00088 
00089 ////////////////////////////////////////////////////////////////////
00090 //     Function: DXGraphicsStateGuardian7::enable_blend
00091 //       Access:
00092 //  Description:
00093 ////////////////////////////////////////////////////////////////////
00094 INLINE void DXGraphicsStateGuardian7::
00095 enable_blend(bool val) {
00096   if (_blend_enabled != val) {
00097     _blend_enabled = val;
00098     _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, (DWORD)val);
00099   }
00100 }
00101 
00102 ////////////////////////////////////////////////////////////////////
00103 //     Function: DXGraphicsStateGuardian7::enable_blend
00104 //       Access:
00105 //  Description:
00106 ////////////////////////////////////////////////////////////////////
00107 INLINE void DXGraphicsStateGuardian7::
00108 set_shademode(D3DSHADEMODE val) {
00109   if (_CurShadeMode != val) {
00110     _CurShadeMode = val;
00111     _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, (DWORD)val);
00112   }
00113 }
00114 
00115 INLINE void DXGraphicsStateGuardian7::
00116 enable_primitive_clipping(bool val) {
00117   if (_clipping_enabled != val) {
00118     _clipping_enabled = val;
00119     _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_CLIPPING, (DWORD)val);
00120   }
00121 }
00122 
00123 ////////////////////////////////////////////////////////////////////
00124 //     Function: DXGraphicsStateGuardian7::enable_fog
00125 //       Access:
00126 //  Description:
00127 ////////////////////////////////////////////////////////////////////
00128 INLINE void DXGraphicsStateGuardian7::
00129 enable_fog(bool val) {
00130   if ((_fog_enabled != val) && (_doFogType!=None)) {
00131     _fog_enabled = val;
00132     _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, (DWORD)val);
00133   }
00134 }
00135 
00136 ////////////////////////////////////////////////////////////////////
00137 //     Function: DXGraphicsStateGuardian7::enable_alpha_test
00138 //       Access:
00139 //  Description:
00140 ////////////////////////////////////////////////////////////////////
00141 INLINE void DXGraphicsStateGuardian7::
00142 enable_alpha_test(bool val )
00143 {
00144   if (_alpha_test_enabled != val) {
00145     _alpha_test_enabled = val;
00146     _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, (DWORD)val);
00147   }
00148 }
00149 
00150 ////////////////////////////////////////////////////////////////////
00151 //     Function: DXGraphicsStateGuardian7::call_dxLightModelAmbient
00152 //       Access:
00153 //  Description:
00154 ////////////////////////////////////////////////////////////////////
00155 INLINE void DXGraphicsStateGuardian7::
00156 call_dxLightModelAmbient( const Colorf& color)
00157 {
00158   if (_lmodel_ambient != color) {
00159     _lmodel_ambient = color;
00160 #ifdef GSG_VERBOSE
00161     dxgsg7_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
00162 #endif
00163     _pScrn->pD3DDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
00164                 D3DRGBA(color[0], color[1], color[2], color[3]));
00165   }
00166 }
00167 
00168 ////////////////////////////////////////////////////////////////////
00169 //     Function: DXGraphicsStateGuardian7::call_dxAlphaFunc
00170 //       Access:
00171 //  Description:
00172 ////////////////////////////////////////////////////////////////////
00173 INLINE void DXGraphicsStateGuardian7::
00174 call_dxAlphaFunc(D3DCMPFUNC func, float reference_alpha) {
00175   if (_alpha_func != func) {
00176     _alpha_func = func;
00177 #ifdef GSG_VERBOSE
00178     dxgsg7_cat.debug() << "dxAlphaFunc(";
00179     switch (func) {
00180     case D3DCMP_NEVER:
00181       dxgsg7_cat.debug(false) << "D3DCMP_NEVER";
00182       break;
00183     case D3DCMP_LESS:
00184       dxgsg7_cat.debug(false) << "D3DCMP_LESS";
00185       break;
00186     case D3DCMP_EQUAL:
00187       dxgsg7_cat.debug(false) << "D3DCMP_EQUAL";
00188       break;
00189 #ifdef D3DCMP_LEQUAL
00190     case D3DCMP_LEQUAL:
00191       dxgsg7_cat.debug(false) << "D3DCMP_LEQUAL";
00192       break;
00193 #endif
00194     case D3DCMP_GREATER:
00195       dxgsg7_cat.debug(false) << "D3DCMP_GREATER";
00196       break;
00197     case D3DCMP_NOTEQUAL:
00198       dxgsg7_cat.debug(false) << "D3DCMP_NOTEQUAL";
00199       break;
00200 #ifdef D3DCMP_GEQUAL
00201     case D3DCMP_GEQUAL:
00202       dxgsg7_cat.debug(false) << "D3DCMP_GEQUAL";
00203       break;
00204 #endif
00205     case D3DCMP_ALWAYS:
00206       dxgsg7_cat.debug(false) << "D3DCMP_ALWAYS";
00207       break;
00208     }
00209     dxgsg7_cat.debug() << " , " << reference_alpha << ")" << endl;
00210 #endif
00211     _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, func);
00212   }
00213 
00214   if(_alpha_func_refval != reference_alpha) {
00215       _alpha_func_refval = reference_alpha;
00216       _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF, (UINT) (reference_alpha*255.0f));  //d3d uses 0x0-0xFF, not a float
00217   }
00218 }
00219 
00220 INLINE void DXGraphicsStateGuardian7::
00221 call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
00222 {
00223   if (_blend_source_func != sfunc)
00224     {
00225     _blend_source_func = sfunc;
00226     _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, sfunc);
00227 #ifdef GSG_VERBOSE
00228     dxgsg7_cat.debug() << "dxSrcBlendFunc(";
00229     switch (sfunc)
00230         {
00231         case D3DBLEND_ZERO:
00232           dxgsg7_cat.debug(false) << "ZERO, ";
00233           break;
00234         case D3DBLEND_ONE:
00235           dxgsg7_cat.debug(false) << "ONE, ";
00236           break;
00237         case D3DBLEND_DESTCOLOR:
00238           dxgsg7_cat.debug(false) << "DESTCOLOR, ";
00239           break;
00240         case D3DBLEND_INVDESTCOLOR:
00241           dxgsg7_cat.debug(false) << "INVDESTCOLOR, ";
00242           break;
00243         case D3DBLEND_SRCALPHA:
00244           dxgsg7_cat.debug(false) << "SRCALPHA, ";
00245           break;
00246         case D3DBLEND_INVSRCALPHA:
00247           dxgsg7_cat.debug(false) << "INVSRCALPHA, ";
00248           break;
00249         case D3DBLEND_DESTALPHA:
00250           dxgsg7_cat.debug(false) << "DESTALPHA, ";
00251           break;
00252         case D3DBLEND_INVDESTALPHA:
00253           dxgsg7_cat.debug(false) << "INVDESTALPHA, ";
00254           break;
00255         case D3DBLEND_SRCALPHASAT:
00256           dxgsg7_cat.debug(false) << "SRCALPHASAT, ";
00257           break;
00258         default:
00259           dxgsg7_cat.debug(false) << "unknown, ";
00260           break;
00261         }
00262     dxgsg7_cat.debug(false) << endl;
00263 #endif
00264     }
00265   if ( _blend_dest_func != dfunc)
00266     {
00267     _blend_dest_func = dfunc;
00268     _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, dfunc);
00269 #ifdef GSG_VERBOSE
00270     dxgsg7_cat.debug() << "dxDstBlendFunc(";
00271     switch (dfunc)
00272         {
00273         case D3DBLEND_ZERO:
00274           dxgsg7_cat.debug(false) << "ZERO, ";
00275           break;
00276         case D3DBLEND_ONE:
00277           dxgsg7_cat.debug(false) << "ONE, ";
00278           break;
00279         case D3DBLEND_DESTCOLOR:
00280           dxgsg7_cat.debug(false) << "DESTCOLOR, ";
00281           break;
00282         case D3DBLEND_INVDESTCOLOR:
00283           dxgsg7_cat.debug(false) << "INVDESTCOLOR, ";
00284           break;
00285         case D3DBLEND_SRCALPHA:
00286           dxgsg7_cat.debug(false) << "SRCALPHA, ";
00287           break;
00288         case D3DBLEND_INVSRCALPHA:
00289           dxgsg7_cat.debug(false) << "INVSRCALPHA, ";
00290           break;
00291         case D3DBLEND_DESTALPHA:
00292           dxgsg7_cat.debug(false) << "DESTALPHA, ";
00293           break;
00294         case D3DBLEND_INVDESTALPHA:
00295           dxgsg7_cat.debug(false) << "INVDESTALPHA, ";
00296           break;
00297         case D3DBLEND_SRCALPHASAT:
00298           dxgsg7_cat.debug(false) << "SRCALPHASAT, ";
00299           break;
00300         }
00301     dxgsg7_cat.debug(false) << endl;
00302 #endif
00303     }
00304 }
00305 
00306 INLINE void DXGraphicsStateGuardian7::
00307 enable_zwritemask(bool val) {
00308     if (_depth_write_enabled != val) {
00309         _depth_write_enabled = val;
00310         _pScrn->pD3DDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, val);
00311     }
00312 }
00313 
00314 /**  unimplemented
00315 
00316 ////////////////////////////////////////////////////////////////////
00317 //     Function: DXGraphicsStateGuardian7::enable_multisample
00318 //       Access:
00319 //  Description:
00320 ////////////////////////////////////////////////////////////////////
00321 INLINE void DXGraphicsStateGuardian7::
00322 enable_multisample(bool val) {
00323   _multisample_enabled = val;
00324   #ifdef NDEBUG
00325     dxgsg7_cat.error() << "dx multisample unimplemented!!\n";
00326   #endif
00327 }
00328 
00329 ////////////////////////////////////////////////////////////////////
00330 //     Function: DXGraphicsStateGuardian7::enable_multisample_alpha_one
00331 //       Access:
00332 //  Description:
00333 ////////////////////////////////////////////////////////////////////
00334 INLINE void DXGraphicsStateGuardian7::
00335 enable_multisample_alpha_one(bool val) {
00336   if (_multisample_alpha_one_enabled != val) {
00337     _multisample_alpha_one_enabled = val;
00338   }
00339 }
00340 
00341 ////////////////////////////////////////////////////////////////////
00342 //     Function: DXGraphicsStateGuardian7::enable_multisample_alpha_mask
00343 //       Access:
00344 //  Description:
00345 ////////////////////////////////////////////////////////////////////
00346 INLINE void DXGraphicsStateGuardian7::
00347 enable_multisample_alpha_mask(bool val) {
00348   if (_multisample_alpha_mask_enabled != val) {
00349     _multisample_alpha_mask_enabled = val;
00350   }
00351 }
00352 
00353 ////////////////////////////////////////////////////////////////////
00354 //     Function: DXGraphicsStateGuardian7::enable_point_smooth
00355 //       Access:
00356 //  Description:
00357 ////////////////////////////////////////////////////////////////////
00358 INLINE void DXGraphicsStateGuardian7::
00359 enable_point_smooth(bool val) {
00360   // _point_smooth_enabled = val;
00361 
00362   #ifdef NDEBUG
00363     dxgsg7_cat.error() << "dx point smoothing unimplemented!!\n";
00364   #endif
00365 }
00366 */
00367 

Generated on Fri May 2 00:37:02 2003 for Panda by doxygen1.3