pub trait GLContextExt: IsA<GLContext> + 'static {
Show 21 methods
// Provided methods
fn allowed_apis(&self) -> GLAPI { ... }
fn api(&self) -> GLAPI { ... }
fn is_debug_enabled(&self) -> bool { ... }
fn display(&self) -> Option<Display> { ... }
fn is_forward_compatible(&self) -> bool { ... }
fn required_version(&self) -> (i32, i32) { ... }
fn shared_context(&self) -> Option<GLContext> { ... }
fn surface(&self) -> Option<Surface> { ... }
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 { ... }
}
Provided Methods§
Sourcefn allowed_apis(&self) -> GLAPI
Available on crate feature v4_6
only.
fn allowed_apis(&self) -> GLAPI
v4_6
only.Sourcefn api(&self) -> GLAPI
Available on crate feature v4_6
only.
fn api(&self) -> GLAPI
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
Sourcefn is_debug_enabled(&self) -> bool
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
Sourcefn is_forward_compatible(&self) -> bool
fn is_forward_compatible(&self) -> bool
Sourcefn required_version(&self) -> (i32, i32)
fn required_version(&self) -> (i32, i32)
Retrieves required OpenGL version set as a requirement for the @self
realization. It will not change even if a greater OpenGL version is supported
and used after the @self is realized. See
version()
for the real version in use.
§Returns
§major
return location for the major version to request
§minor
return location for the minor version to request
👎Deprecated: Since 4.4
Sourcefn is_legacy(&self) -> bool
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
Available on crate feature v4_4
only.
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.
Sourcefn make_current(&self)
fn make_current(&self)
Makes the @self the current one.
Sourcefn set_allowed_apis(&self, apis: GLAPI)
Available on crate feature v4_6
only.
fn set_allowed_apis(&self, apis: GLAPI)
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
Sourcefn set_debug_enabled(&self, enabled: bool)
fn set_debug_enabled(&self, enabled: bool)
Sourcefn set_forward_compatible(&self, compatible: bool)
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
Sourcefn set_required_version(&self, major: i32, minor: i32)
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.
Setting @major and @minor lower than the minimum versions required by GTK will result in the context choosing the minimum version.
The @self must not be realized or made current prior to calling this function.
§major
the major version to request
§minor
the minor version to request
Sourcefn set_use_es(&self, use_es: i32)
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
fn connect_allowed_apis_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
v4_6
only.fn connect_api_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
v4_6
only.Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.