pub struct GlTextureHandle { /* private fields */ }Expand description
GL texture name (GLuint) + binding metadata.
Implementations§
Source§impl GlTextureHandle
impl GlTextureHandle
Sourcepub unsafe fn try_from_raw(
name: u32,
target: GlTextureTarget,
format: GlInternalFormat,
context: *mut c_void,
share_group: Option<u64>,
keep_alive: Option<KeepAlive>,
) -> Result<Self, InvalidHandleError>
pub unsafe fn try_from_raw( name: u32, target: GlTextureTarget, format: GlInternalFormat, context: *mut c_void, share_group: Option<u64>, keep_alive: Option<KeepAlive>, ) -> Result<Self, InvalidHandleError>
Wrap a GL texture name plus its binding metadata. Borrowing: the
handle is stored non-owningly, this type has no Drop, and every
obligation below extends to each Clone.
§Safety
namemust be a texture name that is live incontext’s share group — allocated byglGenTextures/glCreateTexturesand not yet deleted. GL names are small integers, so an arbitraryu32is not distinguishable from a real one at the API boundary and will silently address whatever texture the driver later assigns that name.name == 0is rejected asInvalidHandleError::NullHandleand is not a caller obligation.targetandformatmust be the texture’s actual binding target and sized internal format. Consumers bind withtargetand interpret texels byformat; a mismatchedtargetis a GL error, a mismatchedformatmisreads the texel data.context == nullmeans “whatever context is current on the consuming thread”. That is sound only in a single-context process, or when the caller has independently guaranteed the consumer runs on a thread with a context in the right share group. Otherwise pass the real context handle.share_group, whenSome, must identify the share groupnamebelongs to; importers use it to refuse names from an unrelated group.- Thread affinity — this is the sharp edge. GL contexts are
current on at most one thread at a time and texture names are
only meaningful to a thread whose current context is in the
same share group.
GlTextureHandleis neverthelessSend + Sync, because the handle is inert data; the caller asserts that whichever thread ultimately touches it has an appropriate context current, and that the producer is not concurrently issuing GL commands against the same name from another. - Lifetime: nothing is retained and there is no
Drop, soglDeleteTexturesmust not run while this value or anyCloneof it is reachable. Pass akeep_aliveanchor to discharge that; withNonethe caller carries it.
pub fn name(&self) -> u32
pub fn target(&self) -> GlTextureTarget
pub fn format(&self) -> GlInternalFormat
pub fn context(&self) -> *mut c_void
pub fn keep_alive(&self) -> Option<&KeepAlive>
Trait Implementations§
Source§impl Clone for GlTextureHandle
impl Clone for GlTextureHandle
Source§impl Debug for GlTextureHandle
impl Debug for GlTextureHandle
impl Send for GlTextureHandle
impl Sync for GlTextureHandle
Auto Trait Implementations§
impl !RefUnwindSafe for GlTextureHandle
impl !UnwindSafe for GlTextureHandle
impl Freeze for GlTextureHandle
impl Unpin for GlTextureHandle
impl UnsafeUnpin for GlTextureHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more