1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use super::{object::*, policy::*, types::*};
use crate::uses::*;
pub type Sampler = Object<SamplObj>;
impl Sampler {
pub fn Parameter(&mut self, name: GLenum, args: impl SamplerArg) {
args.apply(self.obj, name);
}
}
pub trait SamplerArg {
fn apply(&self, _: u32, _: GLenum);
}
impl SamplerArg for GLenum {
fn apply(&self, obj: u32, name: GLenum) {
GLCheck!(gl::SamplerParameteri(obj, name, i32(*self)));
}
}
impl SamplerArg for f32 {
fn apply(&self, obj: u32, name: GLenum) {
GLCheck!(gl::SamplerParameterf(obj, name, *self));
}
}
impl SamplerArg for Vec4 {
fn apply(&self, obj: u32, name: GLenum) {
GLCheck!(gl::SamplerParameterfv(obj, name, [*self].as_ptr() as *const f32));
}
}