Trait gdk4::prelude::GLContextExt[][src]

pub trait GLContextExt: 'static {
Show 14 methods 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<P: IsA<GLContext>>(&self, other: &P) -> bool;
fn make_current(&self);
fn realize(&self) -> Result<(), Error>;
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);
}
Expand description

Trait containing all GLContext methods.

Implementors

GLContext

Required methods

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

See set_debug_enabled().

Returns

true if debugging is enabled

Retrieves whether the context is forward-compatible.

See set_forward_compatible().

Returns

true if the context should be forward-compatible

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

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

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

Returns

true if the GLContext is using an OpenGL ES profile

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

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

This is supported 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.

Makes the self the current one.

Realizes the given GLContext.

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

Returns

true if the context is realized

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

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

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

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

Implementors