# OpenGlControlBase

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-opengl/controls/struct-openglcontrolbase/

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

```rust
struct OpenGlControlBase
```

Base class for controls that render using OpenGL.
Provides infrastructure for OpenGL context management, surface creation, and rendering lifecycle.

The control automatically manages OpenGL context creation, surface setup, and cleanup.

**Important:** Any interaction with [`GlInterface`](/docs/0.5.0/api/ferroui-opengl/struct-glinterface/) should only happen within the
`on_open_gl_init`, `on_open_gl_deinit`, or `on_open_gl_render` overrides.

The framework ensures proper OpenGL context synchronization and makes the context current
only during these calls. Accessing OpenGL functions outside of them may result in
undefined behavior, crashes, or rendering corruption.

The class is abstract: a deriving class implements `on_open_gl_render`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.OpenGL/controls/open_gl_control_base.rs#L43)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`on_open_gl_init`](#function-on_open_gl_init)
- [`on_open_gl_deinit`](#function-on_open_gl_deinit)
- [`on_open_gl_lost`](#function-on_open_gl_lost)
- [`on_open_gl_render`](#function-on_open_gl_render)
- [`construct`](#function-construct)
- [`gl_version`](#function-gl_version)
- [`invalidate_visual`](#function-invalidate_visual)
- [`request_next_frame_rendering`](#function-request_next_frame_rendering)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.OpenGL/controls/open_gl_control_base.rs#L55)

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

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<OpenGlControlBase>
```

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.OpenGL/controls/open_gl_control_base.rs#L55)

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

### on_open_gl_init

```rust
fn on_open_gl_init(self: &Self, gl: &GlInterface)
```

Called when the OpenGL context is first created.

`gl` is the interface for making OpenGL calls. Use `GlInterface::get_proc_address`
to access additional APIs not covered by `GlInterface`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.OpenGL/controls/open_gl_control_base.rs#L55)

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

### on_open_gl_deinit

```rust
fn on_open_gl_deinit(self: &Self, gl: &GlInterface)
```

Called when the OpenGL context is being destroyed.

`gl` is the interface for making OpenGL calls. Use `GlInterface::get_proc_address`
to access additional APIs not covered by `GlInterface`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.OpenGL/controls/open_gl_control_base.rs#L55)

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

### on_open_gl_lost

```rust
fn on_open_gl_lost(self: &Self)
```

Called when the OpenGL context is lost and cannot be recovered.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.OpenGL/controls/open_gl_control_base.rs#L55)

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

### on_open_gl_render

```rust
fn on_open_gl_render(self: &Self, gl: &GlInterface, fb: i32)
```

Called to render the OpenGL content for the current frame.

`gl` is the interface for making OpenGL calls. Use `GlInterface::get_proc_address`
to access additional APIs not covered by `GlInterface`. `fb` is the framebuffer
ID to render into.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.OpenGL/controls/open_gl_control_base.rs#L55)

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

### construct

```rust
fn construct() -> Self
```

Creates the class data; see `ferroui_base::FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.OpenGL/controls/open_gl_control_base.rs#L127)

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

### gl_version

```rust
fn gl_version(self: &Self) -> Option<GlVersion>
```

Gets the OpenGL version information for the current context: `None` while the
control has no context (the default value of the version in the original).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.OpenGL/controls/open_gl_control_base.rs#L149)

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

### invalidate_visual

```rust
fn invalidate_visual(self: &Self)
```

Requests that the control be rendered on the next frame; hides the member of the
visual, as the original does.

> **Deprecated.** Use request_next_frame_rendering()

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.OpenGL/controls/open_gl_control_base.rs#L279)

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

### request_next_frame_rendering

```rust
fn request_next_frame_rendering(self: &Self)
```

Requests that the control be rendered on the next frame.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.OpenGL/controls/open_gl_control_base.rs#L284)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`OpenGlControlBaseImplExt`](/docs/0.5.0/api/ferroui-opengl/controls/trait-openglcontrolbaseimplext/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- [`InputElementImplExt`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimplext/)
- [`InteractiveImplExt`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimplext/)
- [`LayoutableImplExt`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`StyledElementImplExt`](/docs/0.5.0/api/ferroui-base/trait-styledelementimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- [`VisualImplExt`](/docs/0.5.0/api/ferroui-base/trait-visualimplext/)
- `ErasedDestructor`
- `IntoEither`
- [`ControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-controlimplext/)
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<OpenGlControlBase>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`LayoutableImpl`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimpl/)
- [`InteractiveImpl`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimpl/)
- [`InputElementImpl`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimpl/)
- [`ControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-controlimpl/)
- [`OpenGlControlBaseImpl`](/docs/0.5.0/api/ferroui-opengl/controls/trait-openglcontrolbaseimpl/)
- [`VisualImpl`](/docs/0.5.0/api/ferroui-base/trait-visualimpl/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)

## Availability

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