Search code examples
c++directxtexture-mappingdirectx-9

Set Texture Addressing Mode to border color in DirectX9


I am trying to set the Texture Addressing Mode to border color in my DirectX application. According to this source all I have to do is:

call IDirect3DDevice7::SetTextureStageState and pass the texture stage identifier as the first argument, the D3DTSS_BORDERCOLOR stage state value as the second argument, and the desired RGBA border color as the third argument

I try to use the following code:

m_device->SetTextureStageState(0, D3DTSS_BORDERCOLOR, 0);

But I get a compilation error saying

identifier "D3DTSS_BORDERCOLOR" is undefined


Solution

  • Are you sure you want to use DirectX7?

    You document is too old, that's for DirectX7 which is deprecate now, you should use the following function in DirectX9

    m_device->SetSamplerState(0, D3DSAMP_BORDERCOLOR, 0xffff0000) // red color
    

    Updated:

    In case you didn't set the correct address mode, here is the code for border mode.

    m_device->SetSamplerState(0, D3DSAMP_ADDRESSU,  D3DTADDRESS_BORDER);
    m_device->SetSamplerState(0, D3DSAMP_ADDRESSV,  D3DTADDRESS_BORDER);