Jump to content
  • Advertisement
Sign in to follow this  
codingsmallcat

a problem of blend texture

This topic is 3004 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!