Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking a program is using #188

Open
nanoqsh opened this issue Oct 22, 2021 · 2 comments
Open

Checking a program is using #188

nanoqsh opened this issue Oct 22, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@nanoqsh
Copy link

nanoqsh commented Oct 22, 2021

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?

@grovesNL
Copy link
Owner

Hi! 👋 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.

@grovesNL grovesNL added the enhancement New feature or request label Oct 23, 2021
@grovesNL
Copy link
Owner

Related to #187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants