slint/examples/opengl_underlay
David Faure 29e289fbdf Move the workspace to rust edition 2024
Motivation: the git pre-commit hook is confused by the mix of 2021 and
2024 in the same workspace...

The only problem this raises is the std::env::set_var("LANGUAGE", lang) in
demos/printerdemo/rust/lib.rs, pre-existing but now explicitly marked as unsafe
because it actually is. Added a TODO there.
2025-12-09 12:11:04 +01:00
..
build.rs
Cargo.toml Move the workspace to rust edition 2024 2025-12-09 12:11:04 +01:00
CMakeLists.txt
index.html Wasm Demos: fix size of the canvas 2023-12-01 09:41:02 +01:00
main.cpp Improve pause behaviour of opengl_underlay example for C++ 2025-09-09 07:07:49 +02:00
main.rs Pause the underlay animation instead of resetting it. (#9360) 2025-09-08 14:18:36 +03:00
README.md Remove license header from .md/.mdx files 2025-12-04 21:58:09 +01:00
scene.slint Redesigned shader & interface example for OpenGL undelay 2025-09-06 15:38:02 +02:00

OpenGL Underlay Example

This example application demonstrates how layer two scenes together in a window:

  1. First a graphical effect is rendered using low-level OpenGL code (underlay).
  2. A scene of Slint elements is rendered above.

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. Afterwards, Slint will render the scene of elements into the same back-buffer as the previous OpenGL code rendered into.

Since the graphical effect is continuous, the code in the callback requests a redraw of the contents by calling slint::Window::request_redraw().

Screenshot of OpenGL Underlay