使用 IDirect3DDevice9::SetSamplerState 的 c++ directx 9 纹理过滤错误

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

我在使用 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();
}

错误是 'IDirect3DDevice9::SetSamplerState': 非法调用非静态成员函数 并且非静态成员引用必须相对于特定对象

您应该复习一下 C++ 面向对象编程的基础知识。

仅当 SetSamplerStateIDirect3DDevice9 class 中的静态函数时,该语句才合法。

不是,所以你需要使用:

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.