Checking a program is using
When I set a value in uniform, I want to check a program is using
let current_program: i32 = gl.get_parameter_i32(glow::CURRENT_PROGRAM);
let location_program: NativeProgram = location.program;
assert_eq!(current_program, location_program);
But I can't compare them since the NativeProgram has no getter to stored number (as I know).
Is there any way to do this?
Hi! :wave: I think we need to change how NativeProgram and WebProgramKey work, so we can handle cases like this. Somebody else asked about this recently too so it would be nice to fix this.
The problem is that we have an i32 there, but different types than i32 on both native and web. The solution might be to return Self::Program somehow (e.g. add a get_parameter_program function or return an enum from get_parameter), but this is also tricky because:
- the web backend expects to be the owner of
Self::Program - technically the current program might have been created by something outside of glow (though I'm not too worried about this case)
We could probably solve this by adding some functions or enum return types and removing Copy from a lot of the web types, so I'll try that out soon and hopefully fix this in the next version of glow.
For now you might be able to work around it by caching the program whenever you call use_program, then checking the cached program instead (e.g. something like assert_eq!(self.last_program_used, location_program)). This should avoid the need to call get_parameter_i32.
Related to #187