Trait thindx::d3d9::IDirect3DBaseTexture9Ext
source · [−]pub trait IDirect3DBaseTexture9Ext: AsSafe<IDirect3DBaseTexture9> {
fn generate_mip_sub_levels(&self) { ... }
fn get_auto_gen_filter_type(&self) -> TextureFilterType { ... }
fn get_level_count(&self) -> u32 { ... }
fn get_lod(&self) -> u32 { ... }
fn set_auto_gen_filter_type(
&self,
filter_type: impl Into<TextureFilterType>
) -> Result<(), MethodError> { ... }
fn set_lod(&self, new_lod: u32) -> u32 { ... }
}
Expand description
[docs.microsoft.com] IDirect3DBaseTexture9 extension methods
Methods
thindx | docs.microsoft.com | Description |
---|---|---|
generate_mip_sub_levels | GenerateMipSubLevels | Generate mipmap sublevels. |
get_auto_gen_filter_type | GetAutoGenFilterType | Get the filter type that is used for automatically generated mipmap sublevels. |
get_level_count | GetLevelCount | Returns the number of texture levels in a multilevel texture. |
get_lod | GetLOD | Returns a value clamped to the maximum level-of-detail set for a managed texture (this method is not supported for an unmanaged texture). |
set_auto_gen_filter_type | SetAutoGenFilterType | Set the filter type that is used for automatically generated mipmap sublevels. |
set_lod | SetLOD | Sets the most detailed level-of-detail for a managed texture. |
Provided methods
fn generate_mip_sub_levels(&self)
fn generate_mip_sub_levels(&self)
[docs.microsoft.com] IDirect3DBaseTexture9::GenerateMipSubLevels
Generate mipmap sublevels.
Example
texture.generate_mip_sub_levels();
fn get_auto_gen_filter_type(&self) -> TextureFilterType
fn get_auto_gen_filter_type(&self) -> TextureFilterType
[docs.microsoft.com] IDirect3DBaseTexture9::GetAutoGenFilterType
Get the filter type that is used for automatically generated mipmap sublevels.
Example
assert_eq!(TextureFilterType::Linear, texture.get_auto_gen_filter_type());
fn get_level_count(&self) -> u32
fn get_level_count(&self) -> u32
[docs.microsoft.com] IDirect3DBaseTexture9::GetLevelCount
Returns the number of texture levels in a multilevel texture.
Warning: If you create a texture with Usage::AutoGenMipMap to make that texture automatically generate sublevels, get_level_count always returns 1 for the number of levels.
Returns
- D3DERR::INVALIDCALL
- Ok(
1
) If created with Usage::AutoGenMipMap - Ok(
levels
) Otherwise
Example
// Automatic level count
let texture = device.create_texture(128, 128, 0, Usage::None, Format::A8R8G8B8, Pool::Default, ()).unwrap();
assert_eq!(8, texture.get_level_count()); // [128, 64, 32, 16, 8, 4, 2, 1].len() == 8
// Explicit level count
let texture = device.create_texture(128, 128, 3, Usage::None, Format::A8R8G8B8, Pool::Default, ()).unwrap();
assert_eq!(3, texture.get_level_count());
[docs.microsoft.com] IDirect3DBaseTexture9::GetLOD
Returns a value clamped to the maximum level-of-detail set for a managed texture (this method is not supported for an unmanaged texture).
Returns
lod
Pool::Managed textures0
Unmanaged textures
Example
let texture = device.create_texture(128, 128, 0, Usage::None, Format::A8R8G8B8, Pool::Managed, ()).unwrap();
assert_eq!(0, texture.get_lod());
assert_eq!(0, texture.set_lod(5));
assert_eq!(5, texture.get_lod());
// Silently noops for unmanaged textures:
let texture = device.create_texture(128, 128, 0, Usage::None, Format::A8R8G8B8, Pool::Default, ()).unwrap();
assert_eq!(0, texture.get_lod());
assert_eq!(0, texture.set_lod(5));
assert_eq!(0, texture.get_lod());
fn set_auto_gen_filter_type(
&self,
filter_type: impl Into<TextureFilterType>
) -> Result<(), MethodError>
fn set_auto_gen_filter_type(
&self,
filter_type: impl Into<TextureFilterType>
) -> Result<(), MethodError>
[docs.microsoft.com] IDirect3DBaseTexture9::SetAutoGenFilterType
Changing the filter type “dirties” the mipmap sublevels and causes them to be regenerated.
The (default) filter type set at texture creation time is TexF::Linear.
If the driver does not support a linear filter, the filter type will be set to TexF::Point.
All filter types supported by the driver for regular texture filtering are supported for autogeneration except TexF::None.
set_auto_gen_filter_type
will fail unless the driver sets the appropriate D3DPTFILTERCAPS_MINFxxx
caps.
These values are specified in the TextureFilterCaps and/or CubeTextureFilterCaps members of Caps.
For more information about texture filter types, see TextureFilterType.
This method has no effect if the texture is not created with Usage::AutoGenMipMap. In this case, no failure is returned. For more information about usage constants, see Usage.
Returns
- D3DERR::INVALIDCALL On invalid TextureFilterTypes
- D3DERR::INVALIDCALL On TextureFilterTypes not supported by the driver
- Ok(
()
)
Example
texture.set_auto_gen_filter_type(TextureFilterType::Point).unwrap();
texture.set_auto_gen_filter_type(TextureFilterType::Linear).unwrap();
let _ = texture.set_auto_gen_filter_type(TextureFilterType::ConvolutionMono); // may not be supported
assert_eq!(D3DERR::INVALIDCALL, texture.set_auto_gen_filter_type(TextureFilterType::None).err());
assert_eq!(D3DERR::INVALIDCALL, texture.set_auto_gen_filter_type(TextureFilterType::from_unchecked(9001)).err());
assert_eq!(D3DERR::INVALIDCALL, texture.set_auto_gen_filter_type(TextureFilterType::from_unchecked(!0)).err());
assert_eq!(D3DERR::INVALIDCALL, texture.set_auto_gen_filter_type(TextureFilterType::from_unchecked(!0-4)).err());
assert_eq!(D3DERR::INVALIDCALL, texture.set_auto_gen_filter_type(TextureFilterType::from_unchecked(!0-100)).err());
[docs.microsoft.com] IDirect3DBaseTexture9::SetLOD
Sets the most detailed level-of-detail for a Pool::Managed texture.
Returns
0
- for nonmanaged textures (e.g. not Pool::Managed?)old_lod
: u32 - the previous most detailed level-of-detail supported.
Example
let texture = device.create_texture(128, 128, 0, Usage::None, Format::A8R8G8B8, Pool::Managed, ()).unwrap();
assert_eq!(0, texture.set_lod(5));
assert_eq!(5, texture.set_lod(6));
assert_eq!(6, texture.set_lod(9001));
assert_eq!(7, texture.set_lod(0)); // 9001 was clamped to `get_level_count()-1`
// Silently noops for unmanaged textures:
let texture = device.create_texture(128, 128, 0, Usage::None, Format::A8R8G8B8, Pool::Default, ()).unwrap();
assert_eq!(0, texture.get_lod());
assert_eq!(0, texture.set_lod(5));
assert_eq!(0, texture.get_lod());