35 lines
855 B
Markdown
35 lines
855 B
Markdown
|
|
# RHIDevice::CreateSampler
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
virtual RHISampler* CreateSampler(const SamplerDesc& desc) = 0;
|
||
|
|
```
|
||
|
|
|
||
|
|
创建纹理采样器。
|
||
|
|
|
||
|
|
**参数:**
|
||
|
|
- `desc` - 采样器描述符,包含过滤模式、寻址模式等
|
||
|
|
|
||
|
|
**返回:** 新创建的采样器指针,失败返回 `nullptr`
|
||
|
|
|
||
|
|
**复杂度:** O(1)
|
||
|
|
|
||
|
|
**示例:**
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
SamplerDesc samplerDesc;
|
||
|
|
samplerDesc.filter = (uint32_t)FilterMode::Anisotropic;
|
||
|
|
samplerDesc.addressU = (uint32_t)TextureAddressMode::Wrap;
|
||
|
|
samplerDesc.addressV = (uint32_t)TextureAddressMode::Wrap;
|
||
|
|
samplerDesc.addressW = (uint32_t)TextureAddressMode::Wrap;
|
||
|
|
samplerDesc.maxAnisotropy = 16;
|
||
|
|
samplerDesc.minLod = 0;
|
||
|
|
samplerDesc.maxLod = FLT_MAX;
|
||
|
|
|
||
|
|
RHISampler* sampler = device->CreateSampler(samplerDesc);
|
||
|
|
```
|
||
|
|
|
||
|
|
## 相关文档
|
||
|
|
|
||
|
|
- [RHIDevice 总览](device.md) - 返回类总览
|
||
|
|
- [RHISampler](../sampler/sampler.md) - 采样器类
|