// render bounding box static void RenderWireframeBox( FLOAT3D vMinVtx, FLOAT3D vMaxVtx, COLOR col) { // only for OpenGL (for now) if( _pGfx->gl_eCurrentAPI!=GAT_OGL) return; // prepare wireframe OpenGL settings gfxDisableDepthTest(); gfxDisableDepthWrite(); gfxDisableBlend(); gfxDisableAlphaTest(); gfxDisableTexture(); // fill vertex array so it represents bounding box FLOAT3D vBoxVtxs[8]; vBoxVtxs[0] = FLOAT3D( vMinVtx(1), vMinVtx(2), vMinVtx(3)); vBoxVtxs[1] = FLOAT3D( vMaxVtx(1), vMinVtx(2), vMinVtx(3)); vBoxVtxs[2] = FLOAT3D( vMaxVtx(1), vMinVtx(2), vMaxVtx(3)); vBoxVtxs[3] = FLOAT3D( vMinVtx(1), vMinVtx(2), vMaxVtx(3)); vBoxVtxs[4] = FLOAT3D( vMinVtx(1), vMaxVtx(2), vMinVtx(3)); vBoxVtxs[5] = FLOAT3D( vMaxVtx(1), vMaxVtx(2), vMinVtx(3)); vBoxVtxs[6] = FLOAT3D( vMaxVtx(1), vMaxVtx(2), vMaxVtx(3)); vBoxVtxs[7] = FLOAT3D( vMinVtx(1), vMaxVtx(2), vMaxVtx(3)); // connect vertices into lines of bounding box INDEX iBoxLines[12][2]; iBoxLines[ 0][0] = 0; iBoxLines[ 0][1] = 1; iBoxLines[ 1][0] = 1; iBoxLines[ 1][1] = 2; iBoxLines[ 2][0] = 2; iBoxLines[ 2][1] = 3; iBoxLines[ 3][0] = 3; iBoxLines[ 3][1] = 0; iBoxLines[ 4][0] = 0; iBoxLines[ 4][1] = 4; iBoxLines[ 5][0] = 1; iBoxLines[ 5][1] = 5; iBoxLines[ 6][0] = 2; iBoxLines[ 6][1] = 6; iBoxLines[ 7][0] = 3; iBoxLines[ 7][1] = 7; iBoxLines[ 8][0] = 4; iBoxLines[ 8][1] = 5; iBoxLines[ 9][0] = 5; iBoxLines[ 9][1] = 6; iBoxLines[10][0] = 6; iBoxLines[10][1] = 7; iBoxLines[11][0] = 7; iBoxLines[11][1] = 4; // for all vertices in bounding box glCOLOR(col); pglBegin( GL_LINES); for( INDEX i=0; i<12; i++) { // get starting and ending vertices of one line FLOAT3D &v0 = vBoxVtxs[iBoxLines[i][0]]; FLOAT3D &v1 = vBoxVtxs[iBoxLines[i][1]]; pglVertex3f( v0(1), v0(2), v0(3)); pglVertex3f( v1(1), v1(2), v1(3)); } pglEnd(); OGL_CHECKERROR; }
// fill rate benchmark static DOUBLE FillRatePass(INDEX ct) { if( !_pdp->Lock()) { ASSERT(FALSE); return 0.0; } StartTimer(); _pdp->Fill(C_GRAY|255); _pdp->FillZBuffer(1.0f); GFXVertex avtx[4]; avtx[0].x = 0; avtx[0].y = 0; avtx[0].z = 0.5f; avtx[1].x = 0; avtx[1].y = _pixSizeJ; avtx[1].z = 0.5f; avtx[2].x = _pixSizeI; avtx[2].y = _pixSizeJ; avtx[2].z = 0.5f; avtx[3].x = _pixSizeI; avtx[3].y = 0; avtx[3].z = 0.5f; GFXTexCoord atex[4] = { {0,0}, {0,1}, {1,1}, {1,0} }; GFXColor acol[4] = { 0xFF0000FF, 0xFF00FF00, 0xFFFF0000, 0xFFFF00FF }; INDEX_T aidx[6] = { 0,1,2, 0,2,3}; gfxSetVertexArray( &avtx[0], 4); gfxSetTexCoordArray( &atex[0], FALSE); gfxSetColorArray( &acol[0]); if(_bTexture) { gfxEnableTexture(); if(_bMultiTexture) { gfxSetTextureUnit(1); gfxEnableTexture(); gfxSetTexture( _ulTexObject, _tpLocal); gfxSetTexCoordArray(atex, FALSE); gfxSetTextureUnit(0); } } else { gfxDisableTexture(); } if(_bBlend) { gfxEnableBlend(); if(_bTexture) { gfxBlendFunc( GFX_SRC_ALPHA, GFX_INV_SRC_ALPHA); } else { gfxBlendFunc( GFX_ONE, GFX_ONE); } } else { gfxDisableBlend(); } if(_bDepth) { gfxEnableDepthTest(); gfxEnableDepthWrite(); } else { gfxDisableDepthTest(); gfxDisableDepthWrite(); } gfxDisableAlphaTest(); for( INDEX i=0; i<ct; i++) gfxDrawElements( 6, &aidx[0]); if(_bMultiTexture) { gfxSetTextureUnit(1); gfxDisableTexture(); gfxSetTextureUnit(0); } _pdp->Unlock(); gfxFinish(); _pvp->SwapBuffers(); return StopTimer(); }
static DOUBLE TrisTroughputPass(INDEX ct) { if( !_pdp->Lock()) { ASSERT(FALSE); return 0.0; } StartTimer(); gfxSetFrustum( -0.5f, +0.5f, -0.5f, +0.5f, 0.5f, 2.0f); gfxSetViewMatrix(NULL); gfxCullFace(GFX_NONE); _pdp->Fill(C_GRAY|255); _pdp->FillZBuffer(1.0f); if(_bTexture) { gfxEnableTexture(); } else { gfxDisableTexture(); } if(_bBlend) { gfxEnableBlend(); gfxBlendFunc( GFX_ONE, GFX_ONE); } else { gfxDisableBlend(); } if(_bDepth) { gfxEnableDepthTest(); gfxEnableDepthWrite(); } else { gfxDisableDepthTest(); gfxDisableDepthWrite(); } gfxDisableAlphaTest(); gfxSetVertexArray( &_avtx[0], _avtx.Count()); gfxLockArrays(); gfxSetTexCoordArray( &_atex[0], FALSE); gfxSetColorArray( &_acol[0]); if(_bMultiTexture) { gfxSetTextureUnit(1); gfxEnableTexture(); gfxSetTexture( _ulTexObject, _tpLocal); gfxSetTexCoordArray( &_atex[0], FALSE); gfxSetTextureUnit(0); } for( INDEX i=0; i<ct; i++) gfxDrawElements( _aiElements.Count(), &_aiElements[0]); gfxUnlockArrays(); if(_bMultiTexture) { gfxSetTextureUnit(1); gfxDisableTexture(); gfxSetTextureUnit(0); } _pdp->Unlock(); gfxFinish(); _pvp->SwapBuffers(); return StopTimer(); }
void shaDisableDepthTest(void) { gfxDisableDepthTest(); }