a problem of blend texture

Started by
0 comments, last by ET3D 13 years, 11 months ago
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._color=(diffusevt<<24);
        
    
            mymap._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);


Advertisement
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.

This topic is closed to new replies.

Advertisement