c++ directx 9 textute filtering error using IDirect3DDevice9

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

本文关键字:error using IDirect3DDevice9 filtering textute directx c++      更新时间:2023-10-16

当我使用 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类中的静态函数时,该语句才合法。

它不是,所以你需要使用:

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

由于您不熟悉 DirectX 编程,我强烈建议您学习 Direct3D 11 而不是传统的 Direct3D 9。互联网上有很多资源,包括用于DirectX 11的DirectX工具包。