Thread: Sweet
View Single Post
Old 30th September 2005, 17:19   #32
redi jedi
Will code for food
 
Join Date: Mar 2005
Location: orlando
Posts: 521
@eos - lol good call

if (fVideoEchoAlpha > 0.001f)
{
// video echo
lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);

for (int i=0; i<2; i++)
{
fZoom = (i==0) ? 1.0f : fVideoEchoZoom;

float temp_lo = 0.5f - 0.5f/fZoom;
float temp_hi = 0.5f + 0.5f/fZoom;
v3[0].tu = temp_lo;
v3[0].tv = temp_hi;
v3[1].tu = temp_hi;
v3[1].tv = temp_hi;
v3[2].tu = temp_lo;
v3[2].tv = temp_lo;
v3[3].tu = temp_hi;
v3[3].tv = temp_lo;

// flipping
if (i==1)
{
for (int j=0; j<4; j++)
{
if (nVideoEchoOrientation % 2)
v3[j].tu = 1.0f - v3[j].tu;
if (nVideoEchoOrientation >= 2)
v3[j].tv = 1.0f - v3[j].tv;
}
}

float mix = (i==1) ? fVideoEchoAlpha : 1.0f - fVideoEchoAlpha;
for (int k=0; k<4; k++)
v3[k].Diffuse = D3DCOLOR_RGBA_01(mix*shade[k][0],mix*shade[k][1],mix*shade[k][2],1);

lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));

if (i==0)
{
lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
}

if (fGammaAdj > 0.001f)
{
// draw layer 'i' a 2nd (or 3rd, or 4th...) time, additively
int nRedraws = (int)(fGammaAdj - 0.0001f);
float gamma;

for (int nRedraw=0; nRedraw < nRedraws; nRedraw++)
{
if (nRedraw == nRedraws-1)
gamma = fGammaAdj - (int)(fGammaAdj - 0.0001f);
else
gamma = 1.0f;

for (int k=0; k<4; k++)
v3[k].Diffuse = D3DCOLOR_RGBA_01(gamma*mix*shade[k][0],gamma*mix*shade[k][1],gamma*mix*shade[k][2],1);
lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
}
}
}
}

well it doesnt quite calculate everything twice, just renders twice, or more for gama... do you think using a texture, like the shapes, would be faster? i might be able to figure that out

Blah!
redi jedi is offline   Reply With Quote