mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-24 01:02:38 +00:00
1.2 KiB
1.2 KiB
OpenGL Texture Import Example
This example application demonstrates how import an OpenGL texture into a Slint scene:
- First a graphical effect is rendered using low-level OpenGL code, into a texture.
- The texture is imported into a
slint::Imageand set on anImageelement. - A scene of Slint elements is rendered with the texture shown in the
Image.
This is implemented using the set_rendering_notifier function on the slint::Window type. It takes a callback as a parameter and that is invoked during different phases of the rendering. In this example the invocation during the setup phase is used to prepare the pipeline for OpenGL rendering later. Then the BeforeRendering phase is used to render the graphical effect with OpenGL into a texture. Then the texture is imported and Slint will render the scene of elements with the texture.
Since the graphical effect is continuous, the code in the callback requests a redraw of the contents by calling slint::Window::request_redraw().