Welcome, Guest. Please login or register.

Author Topic: Alpha blend fade, directx to warp3d question  (Read 1179 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline kas1eTopic starter

Alpha blend fade, directx to warp3d question
« on: January 06, 2005, 07:47:50 AM »
Hi to all. Question to warp3d programmers/developers.

I have little 'alpha fade in/out' on directx, but can't port it to warp3d.Mainly problem in funcs, and order of work. So, how i can write in warp3d this (dx example):


----------------------------------------------------------------------

  // to said, where take color for mixing 0-level texture's.
  // take it from first argv
  pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);


  // first argv - texture
  pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);


  // where take alpha ?
  // take from first argv
  pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);


  // first argv - TFACTOR (we can setup this value, look at down)
  pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);


  // allow alhpa blend
  pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);


  //  how mixing SRC alpha
  pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);


  // how mixing DST alpha
  pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);


 // clear screen with black color

 pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
                    D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 );

 pd3dDevice->BeginScene();
 pd3dDevice->EndScene();

 pd3dDevice->Present( NULL, NULL, NULL, NULL );

 Sleep(1500);


 // ------ FADE ALPHA LOOP -----


 for(float alpha=0;alpha<1.0f;alpha+=0.01)
 {
     Sleep(30);
     pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
                         D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 );

     pd3dDevice->BeginScene();

      // Setup  TFACTOR
     pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, D3DXCOLOR(0, 0, 0, alpha));
     pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 );
     pd3dDevice->EndScene();

     pd3dDevice->Present( NULL, NULL, NULL, NULL );

 };

----------------------------------------------------------------------


 Any help will be very good. Thanks in advance.