void BlitRect(LPDIRECT3DDEVICE8 lpDevice, LPDIRECT3DTEXTURE8 lpSrc, RECT* destRect, D3DXVECTOR4* srcTextureCoodRect, D3DCOLOR col,float z) { // calculate rhw static float inc = 0.05f; static float rhw=1.0f; ///(z*990.0f+10.0f); if ((rhw<=0) || (rhw>=1)) inc = - inc; rhw += inc; // set up rectangle D3DTLVERTEX verts[4]; verts[0]=D3DTLVERTEX(D3DXVECTOR3(destRect->left-0.5f, destRect->top-0.5f, z),rhw,col,srcTextureCoodRect->x,srcTextureCoodRect->y); verts[1]=D3DTLVERTEX(D3DXVECTOR3(destRect->right-0.5f, destRect->top-0.5f, z),rhw,col,srcTextureCoodRect->z,srcTextureCoodRect->y); verts[2]=D3DTLVERTEX(D3DXVECTOR3(destRect->right-0.5f, destRect->bottom-0.5f, z),rhw,col,srcTextureCoodRect->z,srcTextureCoodRect->w); verts[3]=D3DTLVERTEX(D3DXVECTOR3(destRect->left-0.5f, destRect->bottom-0.5f, z),rhw,col,srcTextureCoodRect->x,srcTextureCoodRect->w); // set the texture lpDevice->SetTexture(0,lpSrc); // configure shader for vertex type lpDevice->SetVertexShader(D3DFVF_TLVERTEX); // draw the rectangle //lpDevice->SetTextureStageState(0, D3DTSS_MINFILTER , D3DTEXF_POINT); lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,verts,sizeof(D3DTLVERTEX)); }
void RageDisplay_D3D::DrawTrianglesInternal( const RageSpriteVertex v[], int iNumVerts ) { g_pd3dDevice->SetVertexShader( D3DFVF_RageSpriteVertex ); SendCurrentMatrices(); g_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, // PrimitiveType iNumVerts/3, // PrimitiveCount, v, // pVertexStreamZeroData, sizeof(RageSpriteVertex) ); }
//----------------------------------------------------------------------------- // Name: XBUtil_RenderSpline() // Desc: For debugging purposes, visually renders a spline. //----------------------------------------------------------------------------- VOID XBUtil_RenderSpline( LPDIRECT3DDEVICE8 pd3dDevice, const D3DXVECTOR3* pSpline, DWORD dwNumSplinePts, DWORD dwColor, BOOL bRenderAxes ) { pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TFACTOR ); pd3dDevice->SetVertexShader( D3DFVF_XYZ ); for( FLOAT u = 0; u < dwNumSplinePts; u += 1.0f ) { D3DXVECTOR3 p[2]; D3DXVECTOR3 vTangent, vSide, vUp; XBUtil_GetSplinePoint( pSpline, dwNumSplinePts, u+0, &p[0], &vTangent ); XBUtil_GetSplinePoint( pSpline, dwNumSplinePts, u+1, &p[1], NULL ); D3DXVec3Normalize( &vTangent, &vTangent ); D3DXVECTOR3 v1( 0, 1, 0 ); D3DXVec3Cross( &vSide, &v1, &vTangent ); D3DXVec3Cross( &vUp, &vTangent, &vSide ); pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, dwColor ); pd3dDevice->DrawPrimitiveUP( D3DPT_LINELIST, 1, p, sizeof(D3DXVECTOR3) ); if( bRenderAxes ) { p[1] = p[0] + vTangent/4; pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, 0xffff0000 ); pd3dDevice->DrawPrimitiveUP( D3DPT_LINELIST, 1, p, sizeof(D3DXVECTOR3) ); p[1] = p[0] + vSide/4; pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, 0xff00ff00 ); pd3dDevice->DrawPrimitiveUP( D3DPT_LINELIST, 1, p, sizeof(D3DXVECTOR3) ); p[1] = p[0] + vUp/4; pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, 0xffffffff ); pd3dDevice->DrawPrimitiveUP( D3DPT_LINELIST, 1, p, sizeof(D3DXVECTOR3) ); } } }
void RenderGradientBackground() { // clear textures g_pd3dDevice->SetTexture( 0, NULL ); g_pd3dDevice->SetTexture( 1, NULL ); d3dSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DISABLE ); d3dSetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); // don't write to z-buffer d3dSetRenderState( D3DRS_ZENABLE, FALSE ); g_pd3dDevice->SetVertexShader( D3DFVF_XYZRHW | D3DFVF_DIFFUSE ); g_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, g_BGVertices, sizeof(BG_VERTEX) ); return; }
void render_bg(LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECT3DTEXTURE8 bg) { // Render the secondary color surface to the screen struct VERTEX { D3DXVECTOR4 p; FLOAT tu, tv; }; VERTEX v[4]; v[0].p = D3DXVECTOR4( 0 - 0.5f, 0 - 0.5f, 0, 0 ); v[0].tu = 0; v[0].tv = 0; v[1].p = D3DXVECTOR4( 640 - 0.5f, 0 - 0.5f, 0, 0 ); v[1].tu = 640; v[1].tv = 0; v[2].p = D3DXVECTOR4( 640 - 0.5f, 480 - 0.5f, 0, 0 ); v[2].tu = 640; v[2].tv = 480; v[3].p = D3DXVECTOR4( 0 - 0.5f, 480 - 0.5f, 0, 0 ); v[3].tu = 0; v[3].tv = 480; pd3dDevice->SetVertexShader( D3DFVF_XYZRHW|D3DFVF_TEX1); pd3dDevice->SetTexture( 0, bg); pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE); pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR ); pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP ); pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP ); pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER , D3DTEXF_LINEAR); pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER , D3DTEXF_LINEAR); pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, 0xff202020); pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE ); pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); /* int i=0; // for(int i=32;i>0;i=i-3) { v[0].tu = 0+i; v[0].tv = 0+i; v[1].tu = 640-i; v[1].tv = 0+i; v[2].tu = 640-i; v[2].tv = 480-i; v[3].tu = 0+i; v[3].tv = 480-i; */ WRAP(pd3dDevice->DrawPrimitiveUP( D3DPT_QUADLIST, 1, v, 6*sizeof(FLOAT) )); pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, -1); pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE); }