Trait slint::platform::femtovg_renderer::OpenGLInterface
pub unsafe trait OpenGLInterface {
// Required methods
fn ensure_current(&self) -> Result<(), Box<dyn Error + Sync + Send>>;
fn swap_buffers(&self) -> Result<(), Box<dyn Error + Sync + Send>>;
fn resize(
&self,
width: NonZero<u32>,
height: NonZero<u32>
) -> Result<(), Box<dyn Error + Sync + Send>>;
fn get_proc_address(&self, name: &CStr) -> *const c_void;
}
Expand description
This trait describes the interface GPU accelerated renderers in Slint require to render with OpenGL.
It serves the purpose to ensure that the OpenGL context is current before running any OpenGL commands, as well as providing access to the OpenGL implementation by function pointers.
§Safety
This trait is unsafe because an implementation of get_proc_address could return dangling pointers. In practice an implementation of this trait should just forward to the EGL/WGL/CGL C library that implements EGL/CGL/WGL.
Required Methods§
fn ensure_current(&self) -> Result<(), Box<dyn Error + Sync + Send>>
fn ensure_current(&self) -> Result<(), Box<dyn Error + Sync + Send>>
Ensures that the OpenGL context is current when returning from this function.
fn swap_buffers(&self) -> Result<(), Box<dyn Error + Sync + Send>>
fn swap_buffers(&self) -> Result<(), Box<dyn Error + Sync + Send>>
This function is called by the renderers when all OpenGL commands have been issued and the back buffer is reading for on-screen presentation. Typically implementations forward this to platform specific APIs such as eglSwapBuffers.
fn resize(
&self,
width: NonZero<u32>,
height: NonZero<u32>
) -> Result<(), Box<dyn Error + Sync + Send>>
fn resize( &self, width: NonZero<u32>, height: NonZero<u32> ) -> Result<(), Box<dyn Error + Sync + Send>>
This function is called by the renderers when the surface needs to be resized, typically in response to the windowing system notifying of a change in the window system. For most implementations this is a no-op, with the exception for wayland for example.
fn get_proc_address(&self, name: &CStr) -> *const c_void
fn get_proc_address(&self, name: &CStr) -> *const c_void
Returns the address of the OpenGL function specified by name, or a null pointer if the function does not exist.