pub trait GLContextExt: 'static {
Show 19 methods // Required methods fn allowed_apis(&self) -> GLAPI; fn api(&self) -> GLAPI; fn is_debug_enabled(&self) -> bool; fn is_forward_compatible(&self) -> bool; fn required_version(&self) -> (i32, i32); fn shared_context(&self) -> Option<GLContext>; fn uses_es(&self) -> bool; fn version(&self) -> (i32, i32); fn is_legacy(&self) -> bool; fn is_shared(&self, other: &impl IsA<GLContext>) -> bool; fn make_current(&self); fn realize(&self) -> Result<(), Error>; fn set_allowed_apis(&self, apis: GLAPI); fn set_debug_enabled(&self, enabled: bool); fn set_forward_compatible(&self, compatible: bool); fn set_required_version(&self, major: i32, minor: i32); fn set_use_es(&self, use_es: i32); fn connect_allowed_apis_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId; fn connect_api_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId;
}
Expand description

Trait containing all GLContext methods.

Implementors

GLContext

Required Methods§

source

fn allowed_apis(&self) -> GLAPI

Available on crate feature v4_6 only.

Gets the allowed APIs set via gdk_gl_context_set_allowed_apis().

Returns

the allowed APIs

source

fn api(&self) -> GLAPI

Available on crate feature v4_6 only.

Gets the API currently in use.

If the renderer has not been realized yet, 0 is returned.

Returns

the currently used API

source

fn is_debug_enabled(&self) -> bool

Retrieves whether the context is doing extra validations and runtime checking.

See set_debug_enabled().

Returns

true if debugging is enabled

source

fn is_forward_compatible(&self) -> bool

Retrieves whether the context is forward-compatible.

See set_forward_compatible().

Returns

true if the context should be forward-compatible

source

fn required_version(&self) -> (i32, i32)

Retrieves required OpenGL version.

See set_required_version().

Returns
major

return location for the major version to request

minor

return location for the minor version to request

source

fn shared_context(&self) -> Option<GLContext>

Used to retrieves the GLContext that this @self share data with.

As many contexts can share data now and no single shared context exists anymore, this function has been deprecated and now always returns None.

Deprecated since 4.4

Use is_shared() to check if contexts can be shared.

Returns

None

source

fn uses_es(&self) -> bool

Checks whether the @self is using an OpenGL or OpenGL ES profile.

Returns

true if the GLContext is using an OpenGL ES profile

source

fn version(&self) -> (i32, i32)

Retrieves the OpenGL version of the @self.

The @self must be realized prior to calling this function.

Returns
major

return location for the major version

minor

return location for the minor version

source

fn is_legacy(&self) -> bool

Whether the GLContext is in legacy mode or not.

The GLContext must be realized before calling this function.

When realizing a GL context, GDK will try to use the OpenGL 3.2 core profile; this profile removes all the OpenGL API that was deprecated prior to the 3.2 version of the specification. If the realization is successful, this function will return false.

If the underlying OpenGL implementation does not support core profiles, GDK will fall back to a pre-3.2 compatibility profile, and this function will return true.

You can use the value returned by this function to decide which kind of OpenGL API to use, or whether to do extension discovery, or what kind of shader programs to load.

Returns

true if the GL context is in legacy mode

source

fn is_shared(&self, other: &impl IsA<GLContext>) -> bool

Available on crate feature v4_4 only.

Checks if the two GL contexts can share resources.

When they can, the texture IDs from @other can be used in @self. This is particularly useful when passing GLTexture objects between different contexts.

Contexts created for the same display with the same properties will always be compatible, even if they are created for different surfaces. For other contexts it depends on the GL backend.

Both contexts must be realized for this check to succeed. If either one is not, this function will return false.

other

the GLContext that should be compatible with @self

Returns

true if the two GL contexts are compatible.

source

fn make_current(&self)

Makes the @self the current one.

source

fn realize(&self) -> Result<(), Error>

Realizes the given GLContext.

It is safe to call this function on a realized GLContext.

Returns

true if the context is realized

source

fn set_allowed_apis(&self, apis: GLAPI)

Available on crate feature v4_6 only.

Sets the allowed APIs. When gdk_gl_context_realize() is called, only the allowed APIs will be tried. If you set this to 0, realizing will always fail.

If you set it on a realized context, the property will not have any effect. It is only relevant during gdk_gl_context_realize().

By default, all APIs are allowed.

apis

the allowed APIs

source

fn set_debug_enabled(&self, enabled: bool)

Sets whether the GLContext should perform extra validations and runtime checking.

This is useful during development, but has additional overhead.

The GLContext must not be realized or made current prior to calling this function.

enabled

whether to enable debugging in the context

source

fn set_forward_compatible(&self, compatible: bool)

Sets whether the GLContext should be forward-compatible.

Forward-compatible contexts must not support OpenGL functionality that has been marked as deprecated in the requested version; non-forward compatible contexts, on the other hand, must support both deprecated and non deprecated functionality.

The GLContext must not be realized or made current prior to calling this function.

compatible

whether the context should be forward-compatible

source

fn set_required_version(&self, major: i32, minor: i32)

Sets the major and minor version of OpenGL to request.

Setting @major and @minor to zero will use the default values.

The GLContext must not be realized or made current prior to calling this function.

major

the major version to request

minor

the minor version to request

source

fn set_use_es(&self, use_es: i32)

Requests that GDK create an OpenGL ES context instead of an OpenGL one.

Not all platforms support OpenGL ES.

The @self must not have been realized.

By default, GDK will attempt to automatically detect whether the underlying GL implementation is OpenGL or OpenGL ES once the @self is realized.

You should check the return value of uses_es() after calling realize() to decide whether to use the OpenGL or OpenGL ES API, extensions, or shaders.

use_es

whether the context should use OpenGL ES instead of OpenGL, or -1 to allow auto-detection

source

fn connect_allowed_apis_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

Available on crate feature v4_6 only.
source

fn connect_api_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Available on crate feature v4_6 only.

Implementors§