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

glGetPointerv's pointer argument gets the wrong mutability #541

Open
hikari-no-yume opened this issue Jan 30, 2023 · 1 comment
Open

glGetPointerv's pointer argument gets the wrong mutability #541

hikari-no-yume opened this issue Jan 30, 2023 · 1 comment

Comments

@hikari-no-yume
Copy link

Example usage:

let mut pointer: *mut GLvoid = std::ptr::null_mut();
gl21::GetPointerv(gl21::NORMAL_ARRAY_POINTER, &mut pointer);

I was surprised when Clippy gave me this warning:

warning: the function gl21::GetPointerv doesn't need a mutable reference

Looking at the generated documentation, it seems that gl_generator produced this signature:

pub unsafe fn GetPointerv(pname: u32, params: *const *mut c_void)

I think the mutability here is the exact opposite of what it should be: the pointer returned is *const so far as the API should care, but it needs a *mut pointer to be able to write it out. Though I see that the Khronos C headers use void** so *mut *mut might be more faithful to the original API.

This happens for at least OpenGL 2.1 compatibility profile and OpenGL ES 1.1.

I might eventually attempt to fix this myself, I assume it's something simple.

@Lokathor
Copy link

*mut *mut is probably the best way in this situation.

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

No branches or pull requests

2 participants