# NativeGlFrameProducer

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-media-opengl/struct-nativeglframeproducer/

**struct** · [`ferroui-media-opengl`](/docs/0.5.0/api/ferroui-media-opengl/) · v0.5.0

```rust
struct NativeGlFrameProducer
```



[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media.OpenGL/lib.rs#L29)

## Members

- [`import_native`](#function-import_native)
- [`from_interop`](#function-from_interop)
- [`budget`](#function-budget)
- [`with_budget`](#function-with_budget)
- [`device`](#function-device)
- [`device_generation`](#function-device_generation)
- [`retirement_wakeup`](#function-retirement_wakeup)
- [`invoke`](#function-invoke)
- [`produce`](#function-produce)
- [`produce_owned`](#function-produce_owned)

<a id="function-import_native"></a>

### import_native

```rust
unsafe fn import_native(self: &Self, metadata: FrameMetadata, import: impl FnOnce(&Rc<dyn IGlContext>) -> Result<NativeTextureView, MediaError> + Send + 'static) -> MediaFuture<Option<ReadyGlFrame>>
```

Creates a lease-backed alias without allocating/copying image storage.
Admission reserves retained native bytes before importing. Saturation
drops the captured native frame without queuing a render job.
## Safety
The callback must obey NativeTextureView::new's contract. Native producer
storage must remain immutable until the callback releases it. Metadata
must describe the sampled alias and count all retained native allocation.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media.OpenGL/native_view.rs#L74)

<a id="function-from_interop"></a>

### from_interop

```rust
fn from_interop(interop: &dyn ICompositionGpuInterop, budget: FrameBudget) -> Result<Self, MediaError>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media.OpenGL/lib.rs#L37)

<a id="function-budget"></a>

### budget

```rust
fn budget(self: &Self) -> FrameBudget
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media.OpenGL/lib.rs#L69)

<a id="function-with_budget"></a>

### with_budget

```rust
fn with_budget(self: &Self, budget: FrameBudget) -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media.OpenGL/lib.rs#L72)

<a id="function-device"></a>

### device

```rust
fn device(self: &Self) -> DeviceIdentity
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media.OpenGL/lib.rs#L78)

<a id="function-device_generation"></a>

### device_generation

```rust
fn device_generation(self: &Self) -> u64
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media.OpenGL/lib.rs#L81)

<a id="function-retirement_wakeup"></a>

### retirement_wakeup

```rust
fn retirement_wakeup(self: &Self) -> Arc<dyn Fn() -> () + Send + Sync>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media.OpenGL/lib.rs#L84)

<a id="function-invoke"></a>

### invoke

```rust
fn invoke<T: Send + 'static>(self: &Self, job: impl FnOnce(&Rc<dyn IGlContext>) -> Result<T, MediaError> + Send + 'static) -> MediaFuture<T>
```

Runs a narrow native operation on the render thread with the admitted
GL context current. The closure must restore any GL state it changes.
Captures and results must be Send; the context never leaves its thread.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media.OpenGL/lib.rs#L90)

<a id="function-produce"></a>

### produce

```rust
fn produce(self: &Self, metadata: FrameMetadata, draw: impl FnOnce(&Rc<dyn IGlContext>, u32) -> Result<(), MediaError> + Send + 'static) -> MediaFuture<Option<ReadyGlFrame>>
```

Reserves before allocation. Saturation returns None without queuing a
draw. `draw` must write the complete image and preserve GL state. A GPU
fence retains storage even if this future is canceled after submission.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media.OpenGL/lib.rs#L166)

<a id="function-produce_owned"></a>

### produce_owned

```rust
fn produce_owned<T: std::any::Any + Send + Sync>(self: &Self, metadata: FrameMetadata, producer_owner: T, draw: impl FnOnce(&Rc<dyn IGlContext>, u32) -> Result<(), MediaError> + Send + 'static) -> MediaFuture<Option<ReadyGlFrame>>
```

`producer_owner` keeps borrowed native input alive through conversion
completion, even when the session is replaced while the job is queued.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media.OpenGL/lib.rs#L175)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Clone`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
