// begin/end model rendering to screen void BeginModelRenderingView( CAnyProjection3D &prProjection, CDrawPort *pdp) { ASSERT( _iRenderingType==0 && _pdp==NULL); // set 3D projection _iRenderingType = 1; _pdp = pdp; prProjection->ObjectPlacementL() = CPlacement3D(FLOAT3D(0,0,0), ANGLE3D(0,0,0)); prProjection->Prepare(); // in case of mirror projection, move mirror clip plane a bit father from the mirrored models, // so we have less clipping (for instance, player feet) if( prProjection->pr_bMirror) prProjection->pr_plMirrorView.pl_distance -= 0.06f; // -0.06 is because entire projection is offseted by +0.05 _aprProjection = prProjection; _pdp->SetProjection( _aprProjection); // make FPU precision low _fpuOldPrecision = GetFPUPrecision(); SetFPUPrecision(FPT_24BIT); // prepare common arrays for simple shadows rendering _avtxCommon.PopAll(); _atexCommon.PopAll(); _acolCommon.PopAll(); // eventually setup truform extern INDEX gap_bForceTruform; extern INDEX ogl_bTruformLinearNormals; if( ogl_bTruformLinearNormals) ogl_bTruformLinearNormals = 1; if( gap_bForceTruform) { gap_bForceTruform = 1; gfxSetTruform( _pGfx->gl_iTessellationLevel, ogl_bTruformLinearNormals); } }
// assure that floating point precision is 53 bits void AssureFPT_53(void) { if (GetFPUPrecision()!=FPT_53BIT) { ASSERTALWAYS( "Floating precision must be set to 53 bits during CSG!"); SetFPUPrecision(FPT_53BIT); } }
/* * Destructor with automatic restoring of FPU precision. */ CSetFPUPrecision::~CSetFPUPrecision(void) { // check consistency ASSERT(GetFPUPrecision()==sfp_fptNewPrecision); // restore old precision if needed if (sfp_fptNewPrecision!=sfp_fptOldPrecision) { SetFPUPrecision(sfp_fptOldPrecision); } }
/* * Constructor with automatic setting of FPU precision. */ CSetFPUPrecision::CSetFPUPrecision(enum FPUPrecisionType fptNew) { // remember old precision sfp_fptOldPrecision = GetFPUPrecision(); // set new precision if needed sfp_fptNewPrecision = fptNew; if (sfp_fptNewPrecision!=sfp_fptOldPrecision) { SetFPUPrecision(fptNew); } }
void EndModelRenderingView( BOOL bRestoreOrtho/*=TRUE*/) { ASSERT( _iRenderingType==1 && _pdp!=NULL); // assure that FPU precision was low all the model rendering time, then revert to old FPU precision ASSERT( GetFPUPrecision()==FPT_24BIT); SetFPUPrecision(_fpuOldPrecision); // restore front face direction gfxFrontFace(GFX_CCW); // render all batched shadows extern void RenderBatchedSimpleShadows_View(void); RenderBatchedSimpleShadows_View(); // back to 2D projection? if( bRestoreOrtho) _pdp->SetOrtho(); _iRenderingType = 0; _pdp = NULL; // eventually disable re-enable clipping gfxEnableClipping(); if( _aprProjection->pr_bMirror || _aprProjection->pr_bWarp) gfxEnableClipPlane(); }