push_gl_shader


Description:

public void push_gl_shader (GLShader shader, Rect bounds, owned Bytes take_args)

Push a [class@Gsk.

GLShaderNode].

The node uses the given [class@Gsk.GLShader] and uniform values Additionally this takes a list of n_children other nodes which will be passed to the [class@Gsk.GLShaderNode].

The take_args argument is a block of data to use for uniform arguments, as per types and offsets defined by the shader . Normally this is generated by [method@Gsk.GLShader.format_args] or [struct@Gsk.ShaderArgsBuilder].

The snapshotter takes ownership of take_args, so the caller should not free it after this.

If the renderer doesn't support GL shaders, or if there is any problem when compiling the shader, then the node will draw pink. You should use [method@Gsk.GLShader.compile] to ensure the shader will work for the renderer before using it.

If the shader requires textures (see [method@Gsk.GLShader.get_n_textures]), then it is expected that you call [ method@Gtk.Snapshot.gl_shader_pop_texture] the number of times that are required. Each of these calls will generate a node that is added as a child to the `GskGLShaderNode`, which in turn will render these offscreen and pass as a texture to the shader.

Once all textures (if any) are pop:ed, you must call the regular [method@Gtk.Snapshot.pop].

If you want to use pre-existing textures as input to the shader rather than rendering new ones, use [method@Gtk.Snapshot.append_texture] to push a texture node. These will be used directly rather than being re-rendered.

For details on how to write shaders, see [class@Gsk.GLShader].

Parameters:

this

a `GtkSnapshot`

shader

The code to run

bounds

the rectangle to render into

take_args

Data block with arguments for the shader.