Welcome, Guest. Please login or register.
Amiga Kit Amiga Store Iridium Banner AMIStore App Store A1200/A600 4xIDE Interface

AuthorTopic: Alpha blend fade, directx to warp3d question  (Read 963 times)

0 Members and 1 Guest are viewing this topic.

Offline kas1e

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.