//----------------------------------------------------------------------------------------------------- // FIXME : // Check this works on consoles. void C2DRenderUtils::InternalDrawLine(float fX1, float fY1, float fX2, float fY2, const ColorF& cfDiffuse) { #if C2DRU_USE_DVN_VB m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &fX1, &fY1 ); m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &fX2, &fY2 ); SVF_P3F_C4B_T2F aVertices[2]; uint32 uiDiffuse = cfDiffuse.pack_argb8888(); const float fOff = -0.5f; aVertices[0].color.dcolor = uiDiffuse; aVertices[0].xyz = Vec3(fX1+fOff, fY1+fOff, 0.0f); aVertices[0].st = Vec2(0, 0); aVertices[1].color.dcolor = uiDiffuse; aVertices[1].xyz = Vec3(fX2+fOff, fY2+fOff, 0.0f); aVertices[1].st = Vec2(1, 1); m_pRenderer->SelectTMU(0); /* if(iTextureID) { m_pRenderer->EnableTMU(true); m_pRenderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0); m_pRenderer->SetTexture(iTextureID); } else */ { m_pRenderer->EnableTMU(false); m_pRenderer->SetWhiteTexture(); } uint16 ausIndices[] = {0,1}; m_pRenderer->DrawDynVB(aVertices,ausIndices,2,2,eptLineList); #else const float fOff = 0.0f; m_pLayoutManager->ConvertFromVirtualToNormalisedScreenSpace( &fX1, &fY1 ); m_pLayoutManager->ConvertFromVirtualToNormalisedScreenSpace( &fX2, &fY2 ); const Vec3 p1(fX1+fOff, fY1+fOff, 0.0f); const Vec3 p2(fX2+fOff, fY2+fOff, 0.0f); const ColorB lineCol = cfDiffuse; m_pAuxGeom->DrawLine( p1, lineCol, p2, lineCol, 1.0f ); #endif }
//----------------------------------------------------------------------------------------------------- void C2DRenderUtils::InternalDrawTriangle(float fX0,float fY0,float fX1,float fY1,float fX2,float fY2,const ColorF& cfColor) { #if C2DRU_USE_DVN_VB m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &fX0, &fY0 ); m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &fX1, &fY1 ); m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &fX2, &fY2 ); SVF_P3F_C4B_T2F aVertices[3]; uint32 uiColor = cfColor.pack_argb8888(); const float fOff = -0.5f; aVertices[0].color.dcolor = uiColor; aVertices[0].xyz = Vec3(fX0+fOff, fY0+fOff, 0.0f); aVertices[0].st = Vec2(0, 0); aVertices[1].color.dcolor = uiColor; aVertices[1].xyz = Vec3(fX1+fOff, fY1+fOff, 0.0f); aVertices[1].st = Vec2(0, 0); aVertices[2].color.dcolor = uiColor; aVertices[2].xyz = Vec3(fX2+fOff, fY2+fOff, 0.0f); aVertices[2].st = Vec2(0, 0); uint16 ausIndices[] = {0,1,2}; m_pRenderer->SetWhiteTexture(); m_pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST); m_pRenderer->DrawDynVB(aVertices,ausIndices,3,sizeof(ausIndices)/sizeof(ausIndices[0]),eptTriangleList); #else // C2DRU_USE_DVN_VB const float fOff = 0.0; m_pLayoutManager->ConvertFromVirtualToNormalisedScreenSpace( &fX0, &fY0 ); m_pLayoutManager->ConvertFromVirtualToNormalisedScreenSpace( &fX1, &fY1 ); m_pLayoutManager->ConvertFromVirtualToNormalisedScreenSpace( &fX2, &fY2 ); Vec3 p0(fX0+fOff, fY0+fOff, 0.0f); Vec3 p1(fX1+fOff, fY1+fOff, 0.0f); Vec3 p2(fX2+fOff, fY2+fOff, 0.0f); //std::swap(p0.y,p0.z); //std::swap(p1.y,p1.z); //std::swap(p2.y,p2.z); m_pAuxGeom->DrawTriangle( p0, cfColor, p1, cfColor, p2, cfColor ); #endif // C2DRU_USE_DVN_VB }
//----------------------------------------------------------------------- void gkAuxRenderer::SetDrawColor( ColorF& color ) { m_curColor = (DWORD)color.pack_argb8888(); }
//----------------------------------------------------------------------------------------------------- void C2DRenderUtils::InternalDrawQuad( float fX, float fY, float fSizeX, float fSizeY, const ColorF& cfDiffuse, # if C2DRU_USE_DVN_VB const ColorF& cfDiffuseTL, const ColorF& cfDiffuseTR, const ColorF& cfDiffuseDL, const ColorF& cfDiffuseDR, # endif // C2DRU_USE_DVN_VB int iTextureID # if C2DRU_USE_DVN_VB , float fUTexCoordsTL, float fVTexCoordsTL, float fUTexCoordsTR, float fVTexCoordsTR, float fUTexCoordsDL, float fVTexCoordsDL, float fUTexCoordsDR, float fVTexCoordsDR # endif ) { #if C2DRU_USE_DVN_VB SVF_P3F_C4B_T2F aVertices[4]; #endif const float fOff = 0.0f;//-0.5f; Vec2 p1( fX+fOff, fY+fOff ); Vec2 p2( fX+fSizeX+fOff, fY+fSizeY+fOff ); m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &(p1.x), &(p1.y) ); m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &(p2.x), &(p2.y) ); const float z = 0.0f; uint32 uiDiffuse = cfDiffuse.pack_argb8888(); #if C2DRU_USE_DVN_VB uint32 uiDiffuseTL = cfDiffuseTL.pack_argb8888(); uint32 uiDiffuseTR = cfDiffuseTR.pack_argb8888(); uint32 uiDiffuseDL = cfDiffuseDL.pack_argb8888(); uint32 uiDiffuseDR = cfDiffuseDR.pack_argb8888(); aVertices[0].color.dcolor = uiDiffuse ? uiDiffuse : uiDiffuseTL; aVertices[0].xyz = Vec3( p1.x, p1.y, z ); aVertices[0].st = Vec2(fUTexCoordsTL, fVTexCoordsTL); aVertices[1].color.dcolor = uiDiffuse ? uiDiffuse : uiDiffuseTR; aVertices[1].xyz = Vec3( p2.x, p1.y, z ); aVertices[1].st = Vec2(fUTexCoordsTR, fVTexCoordsTR); aVertices[2].color.dcolor = uiDiffuse ? uiDiffuse : uiDiffuseDL; aVertices[2].xyz = Vec3( p1.x, p2.y, z ); aVertices[2].st = Vec2(fUTexCoordsDL, fVTexCoordsDL); aVertices[3].color.dcolor = uiDiffuse ? uiDiffuse : uiDiffuseDR; aVertices[3].xyz = Vec3( p2.x, p2.y, z ); aVertices[3].st = Vec2(fUTexCoordsDR, fVTexCoordsDR); m_pRenderer->SelectTMU(0); if(iTextureID >= 0) { m_pRenderer->EnableTMU(true); m_pRenderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0); m_pRenderer->SetTexture(iTextureID); } else { m_pRenderer->EnableTMU(false); m_pRenderer->SetWhiteTexture(); // needed for XBox? Seems to use previous texture otherwise. } uint16 ausIndices[] = {0,1,2,3}; m_pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST); //m_pRenderer->DrawDynVB(aVertices,ausIndices,4,4,R_PRIMV_TRIANGLE_STRIP); #else InternalDrawImage(iTextureID,fX,fY,fSizeX,fSizeY,0.0f,cfDiffuse,0,0,1,1); #endif //C2DRU_USE_DVN_VB }