2022-11-30 15:56:10 +11:00
|
|
|
use crate::gl::BindTexture;
|
|
|
|
use crate::samplers::SamplerSet;
|
2023-01-15 19:01:23 +11:00
|
|
|
use crate::texture::InputTexture;
|
2022-11-30 17:38:05 +11:00
|
|
|
use librashader_reflect::reflect::semantics::TextureBinding;
|
2022-11-30 15:56:10 +11:00
|
|
|
|
|
|
|
pub struct Gl46BindTexture;
|
|
|
|
|
|
|
|
impl BindTexture for Gl46BindTexture {
|
2023-01-15 19:01:23 +11:00
|
|
|
fn bind_texture(samplers: &SamplerSet, binding: &TextureBinding, texture: &InputTexture) {
|
2022-11-30 15:56:10 +11:00
|
|
|
unsafe {
|
|
|
|
// eprintln!("setting {} to texunit {}", texture.image.handle, binding.binding);
|
|
|
|
gl::BindTextureUnit(binding.binding, texture.image.handle);
|
2022-11-30 17:38:05 +11:00
|
|
|
gl::BindSampler(
|
|
|
|
binding.binding,
|
|
|
|
samplers.get(texture.wrap_mode, texture.filter, texture.mip_filter),
|
|
|
|
);
|
2022-11-30 15:56:10 +11:00
|
|
|
}
|
|
|
|
}
|
2022-12-01 16:11:41 +11:00
|
|
|
|
2023-01-15 19:01:23 +11:00
|
|
|
fn gen_mipmaps(texture: &InputTexture) {
|
2022-12-22 13:39:31 +11:00
|
|
|
unsafe { gl::GenerateTextureMipmap(texture.image.handle) }
|
2022-12-01 16:11:41 +11:00
|
|
|
}
|
2022-11-30 17:38:05 +11:00
|
|
|
}
|