Skip to main content

register_window_geometry_shader

Function register_window_geometry_shader 

Source
pub fn register_window_geometry_shader(source: &str) -> Option<u8>
Expand description

Register a geometry shader with the compositor.

source is a complete GLSL ES 3.20 geometry shader. It runs between the compositor’s vertex and fragment stages, for both the window content and its border, and must follow this interface:

#version 320 es
layout(triangles) in;
layout(triangle_strip, max_vertices = N) out;

in vec2 v_texcoord[];          // pass through, interpolated, to g_texcoord
in vec2 v_local[];             // [0, 1] across the window, (0, 0) at the top left
in vec4 v_world[];             // position in screen pixels
out vec2 g_texcoord;

uniform mat4 u_world_to_clip;  // gl_Position = u_world_to_clip * world
uniform vec2 u_window_size;    // window size in pixels

It may also declare any uniforms set with crate::window::Window::set_shader_uniform.

The content and the border only line up if the displacement is a function of v_local, v_world and the uniforms alone. Displaced vertices may leave the window’s bounds.

Geometry shaders require an OpenGL ES 3.2 context. Without one, or if the shader fails to compile, the compositor logs a warning and draws the window without it.

Returns the shader ID on success (pass to crate::window::Window::set_geometry_shader), or None if registration failed.