Sign in to follow this  
codingsmallcat

a problem of blend texture

Recommended Posts

codingsmallcat    127
hi My problem is it I have four texture and I draw map four times .this time I get the blend effect . now I pickup a trigon of map .I need it show red color.I set diffuse color is oxccff0000 when fifth draw map. but there are some error in it .it is not red .it is black. could you tell me way it is black? thank you . my code is it
device->SetTexture(0, Tex_1);
    device->SetRenderState( D3DRS_ALPHABLENDENABLE,TRUE);
    device->SetRenderState( D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
    device->SetRenderState( D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
    device->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX,0);
    device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 ); 
    //device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTA_DIFFUSE ); 
    device->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
    device->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1 );
    device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,rowidth*colheight,0,(rowidth-1)*(colheight-1)*2);
    device->SetTexture(0, Tex_2);
    device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
    device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,rowidth*colheight,0,(rowidth-1)*(colheight-1)*2);
    device->SetTexture(0, Tex_3);
    device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
    device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,rowidth*colheight,0,(rowidth-1)*(colheight-1)*2);
    device->SetTexture(0, Tex_4);
    
    device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
    device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    
    device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
    device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,rowidth*colheight,0,(rowidth-1)*(colheight-1)*2);
    MyTr->Lock(0,0,(void **) &mymap,0);
    for (int i =0;i<64*64;i++){
        //mymap[i]._color=(diffusevt[i]<<24);
        
    
            mymap[i]._color=0xccff0000;
        
        
    }
    MyTr->Unlock();
    
    device->SetTexture(0, Tex_4);
    device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE );
    
    device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1  );
    device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,rowidth*colheight,0,(rowidth-1)*(colheight-1)*2);


Share this post


Link to post
Share on other sites
ET3D    810
Can't tell you why it doesn't work, but I can tell you how to do it better. When you want everything to have a specific colour, use SetRenderState(D3DRS_TEXTUREFACTOR, colour) and use D3DTA_TFACTOR for ARG1. This way you don't have to lock anything, which is a costly operation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this