-
-
Notifications
You must be signed in to change notification settings - Fork 479
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
Implement access of raw context handles #939
Conversation
Thanks for the PR. I haven't read the PR in details yet, but I have three remarks:
|
I appreciate the helpful feedback!
|
I'd say
The It's not necessarily a hard-written rule, but that's how all other traits of |
I believe you might have misunderstood my original question, but thanks for the helpful guideline. I was asking whether I should implement |
Well, the answer is yes. Just move the |
Sorry if I wasn't being clear then, haha. I meant implementing for |
src/api/osmesa/mod.rs
Outdated
@@ -186,6 +190,11 @@ impl OsMesaContext { | |||
pub fn get_pixel_format(&self) -> PixelFormat { | |||
unimplemented!(); | |||
} | |||
|
|||
#[inline] | |||
pub unsafe fn raw_handle(&self) -> osmesa_sys::OSMesaContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not a void pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't OSMesaContext
a mutable pointer to an opaque struct meant to be used identically to *mut c_void
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are equivalent, but using a c_void
makes it more semver-friendly. Sorry for not going into details.
You should return a *mut c_void
and cast the OSMesaContext
to it with as
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, will do.
EDIT: Should I use a *mut libc::c_void
or a *mut std::os::raw::c_void
? The two types aren't compatible with each other, unfortunately. See rust-lang/libc#180. I'm assuming the former, since you have libc
as a dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, please use the std::os::raw
one.
The libc
dependency should be removed eventually, but since doing so requires a major version bump, I never think about doing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, std::os::raw
it is!
src/api/wgl/mod.rs
Outdated
@@ -198,6 +197,11 @@ impl Context { | |||
pub fn get_pixel_format(&self) -> PixelFormat { | |||
self.pixel_format.clone() | |||
} | |||
|
|||
#[inline] | |||
pub unsafe fn raw_handle(&self) -> winapi::HDC { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a void pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Thank you, I should have made it into an HGLRC
instead.
src/os/macos.rs
Outdated
use os::GlContextExt; | ||
|
||
impl GlContextExt for Context { | ||
type Handle = id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a void pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What type should I use instead? I am not too familiar with OpenGL on Mac OS X.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. Same rules as with OSMesaContext
, then.
Thanks! |
Added
GlContextExt
trait, which grants type-safe access to the underlying OpenGL context (fixes Getting raw pointer to platform GL context #935).Fixed
CC @tomaka @kvark