c++windowsdirectx-9direct3d9

c++ directx 9 textute filtering error using IDirect3DDevice9::SetSamplerState


i have a issue when i use IDirect3DDevice9::SetSamplerState

void Draw(GraphicsDevice *gDevice, float gameTime)
{
    // here's the problem
    IDirect3DDevice9::SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
    //Simple RGB value for the background so use XRGB instead of ARGB
    gDevice->Clear(D3DCOLOR_XRGB(0, 100, 100));
    gDevice->begin();

    //Draw logic here.
    if (sprite && sprite->IsInitialized()) sprite->Draw(gameTime);
    gDevice->end();
    gDevice->present();
}

the errors is 'IDirect3DDevice9::SetSamplerState': illegal call of non-static member function and a nonstatic member reference must be relative to a specific object


Solution

  • You should probably review the basics of C++ object-oriented programming.

    That statement is only legal if SetSamplerState is a static function in the IDirect3DDevice9 class.

    It's not, so you need to use:

    gDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
    

    As you are new to DirectX programming, I strong recommend you learn Direct3D 11 instead of legacy Direct3D 9. There are plenty of resources on the Internet, including the DirectX Tool Kit for DirectX 11.