slint/examples/opengl_texture
Simon Hausmann 0c9199b17f
Add support for flipping borrowed OpenGL textures vertically (#3205)
Closes #2986

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2023-08-02 13:11:13 +02:00
..
build.rs Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Cargo.toml Bump version number to 1.2.0 2023-07-25 10:44:53 +00:00
CMakeLists.txt Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
main.cpp Fix rendering OpenGL texture import example with some GL drivers 2023-06-28 14:38:09 +02:00
main.rs Add support for flipping borrowed OpenGL textures vertically (#3205) 2023-08-02 13:11:13 +02:00
README.md Add support for importing OpenGL textures into Slint 2023-06-01 15:56:55 +02:00
scene.slint Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00

OpenGL Texture Import Example

This example application demonstrates how import an OpenGL texture into a Sline scene:

  1. First a graphical effect is rendered using low-level OpenGL code, into a texture.
  2. The texture is imported into a slint::Image and set on an Image element.
  3. 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().