package ocgtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Wrappers.Gl_shader

type t = [ `gl_shader | `object_ ] Gobject.obj
val new_from_bytes : Glib_bytes.t -> t

Create a new GLShader

val new_from_resource : string -> t

Create a new GLShader

val get_uniform_type : t -> int -> Gsk_enums.gluniformtype

Get the type of the declared uniform for this shader at index @idx.

val get_uniform_offset : t -> int -> int

Get the offset into the data block where data for this uniforms is stored.

val get_uniform_name : t -> int -> string

Get the name of the declared uniform for this shader at index @idx.

val get_source : t -> Glib_bytes.t

Gets the GLSL sourcecode being used to render this shader.

val get_resource : t -> string option

Gets the resource path for the GLSL sourcecode being used to render this shader.

val get_n_uniforms : t -> int

Get the number of declared uniforms for this shader.

val get_n_textures : t -> int

Returns the number of textures that the shader requires.

This can be used to check that the a passed shader works in your usecase. It is determined by looking at the highest u_textureN value that the shader defines.

val get_args_size : t -> Gsize.t

Get the size of the data block used to specify arguments for this shader.

val get_arg_vec4 : t -> Glib_bytes.t -> int -> Ocgtk_graphene.Graphene.Wrappers.Vec4.t -> unit

Gets the value of the uniform @idx in the @args block.

The uniform must be of vec4 type.

val get_arg_vec3 : t -> Glib_bytes.t -> int -> Ocgtk_graphene.Graphene.Wrappers.Vec3.t -> unit

Gets the value of the uniform @idx in the @args block.

The uniform must be of vec3 type.

val get_arg_vec2 : t -> Glib_bytes.t -> int -> Ocgtk_graphene.Graphene.Wrappers.Vec2.t -> unit

Gets the value of the uniform @idx in the @args block.

The uniform must be of vec2 type.

val get_arg_uint : t -> Glib_bytes.t -> int -> UInt32.t

Gets the value of the uniform @idx in the @args block.

The uniform must be of uint type.

val get_arg_int : t -> Glib_bytes.t -> int -> Int32.t

Gets the value of the uniform @idx in the @args block.

The uniform must be of int type.

val get_arg_float : t -> Glib_bytes.t -> int -> float

Gets the value of the uniform @idx in the @args block.

The uniform must be of float type.

val get_arg_bool : t -> Glib_bytes.t -> int -> bool

Gets the value of the uniform @idx in the @args block.

The uniform must be of bool type.

val find_uniform_by_name : t -> string -> int

Looks for a uniform by the name @name, and returns the index of the uniform, or -1 if it was not found.

val compile : t -> [ `renderer | `object_ ] Gobject.obj -> (bool, GError.t) result

Tries to compile the @shader for the given @renderer.

If there is a problem, this function returns %FALSE and reports an error. You should use this function before relying on the shader for rendering and use a fallback with a simpler shader or without shaders if it fails.

Note that this will modify the rendering state (for example change the current GL context) and requires the renderer to be set up. This means that the widget has to be realized. Commonly you want to call this from the realize signal of a widget, or during widget snapshot.