Class: Gsk::GLShader
- Inherits:
-
Object
- Object
- Gsk::GLShader
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#args_size ⇒ Integer
Get the size of the data block used to specify arguments for this shader.
-
#compile(renderer) ⇒ Boolean
Tries to compile the shader for the given renderer.
-
#find_uniform_by_name(name) ⇒ Integer
Looks for a uniform by the name name, and returns the index of the uniform, or -1 if it was not found.
-
#format_args(array) ⇒ GLib::Bytes
Formats the uniform data as needed for feeding the named uniforms values into the shader.
-
#format_args_va(uniforms) ⇒ GLib::Bytes
Formats the uniform data as needed for feeding the named uniforms values into the shader.
-
#get_arg_bool(args, idx) ⇒ Boolean
Gets the value of the uniform idx in the args block.
-
#get_arg_float(args, idx) ⇒ Gsk::gfloat
Gets the value of the uniform idx in the args block.
-
#get_arg_int(args, idx) ⇒ Integer
Gets the value of the uniform idx in the args block.
-
#get_arg_uint(args, idx) ⇒ Integer
Gets the value of the uniform idx in the args block.
-
#get_arg_vec2(args, idx, out_value) ⇒ nil
Gets the value of the uniform idx in the args block.
-
#get_arg_vec3(args, idx, out_value) ⇒ nil
Gets the value of the uniform idx in the args block.
-
#get_arg_vec4(args, idx, out_value) ⇒ nil
Gets the value of the uniform idx in the args block.
-
#get_uniform_name(idx) ⇒ String
Get the name of the declared uniform for this shader at index idx.
-
#get_uniform_offset(idx) ⇒ Integer
Get the offset into the data block where data for this uniforms is stored.
-
#get_uniform_type(idx) ⇒ Gsk::GLUniformType
Get the type of the declared uniform for this shader at index idx.
-
#initialize(resource_path) ⇒ Gsk::GLShader
constructor
Creates a
GskGLShaderthat will render pixels using the specified code. -
#n_textures ⇒ Integer
Returns the number of textures that the shader requires.
-
#n_uniforms ⇒ Integer
Get the number of declared uniforms for this shader.
-
#resource ⇒ String
Resource containing the source code for the shader.
-
#resource=(resource) ⇒ String
Resource containing the source code for the shader.
-
#source ⇒ GLib::Bytes
Source.
- #source=(source) ⇒ GLib::Bytes
Constructor Details
#initialize(resource_path) ⇒ Gsk::GLShader
Creates a GskGLShader that will render pixels using the specified code.
Instance Method Details
#args_size ⇒ Integer
Get the size of the data block used to specify arguments for this shader.
#compile(renderer) ⇒ Boolean
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.
#find_uniform_by_name(name) ⇒ Integer
Looks for a uniform by the name name, and returns the index of the uniform, or -1 if it was not found.
#format_args(array) ⇒ GLib::Bytes
Formats the uniform data as needed for feeding the named uniforms values into the shader.
The argument list is a list of pairs of names, and values for the types
that match the declared uniforms (i.e. double/int/guint/gboolean for
primitive values and graphene_vecN_t * for vecN uniforms).
Any uniforms of the shader that are not included in the argument list are zero-initialized.
#format_args_va(uniforms) ⇒ GLib::Bytes
Formats the uniform data as needed for feeding the named uniforms values into the shader.
The argument list is a list of pairs of names, and values for the
types that match the declared uniforms (i.e. double/int/guint/gboolean
for primitive values and graphene_vecN_t * for vecN uniforms).
It is an error to pass a uniform name that is not declared by the shader.
Any uniforms of the shader that are not included in the argument list are zero-initialized.
#get_arg_bool(args, idx) ⇒ Boolean
Gets the value of the uniform idx in the args block.
The uniform must be of bool type.
#get_arg_float(args, idx) ⇒ Gsk::gfloat
Gets the value of the uniform idx in the args block.
The uniform must be of float type.
#get_arg_int(args, idx) ⇒ Integer
Gets the value of the uniform idx in the args block.
The uniform must be of int type.
#get_arg_uint(args, idx) ⇒ Integer
Gets the value of the uniform idx in the args block.
The uniform must be of uint type.
#get_arg_vec2(args, idx, out_value) ⇒ nil
Gets the value of the uniform idx in the args block.
The uniform must be of vec2 type.
#get_arg_vec3(args, idx, out_value) ⇒ nil
Gets the value of the uniform idx in the args block.
The uniform must be of vec3 type.
#get_arg_vec4(args, idx, out_value) ⇒ nil
Gets the value of the uniform idx in the args block.
The uniform must be of vec4 type.
#get_uniform_name(idx) ⇒ String
Get the name of the declared uniform for this shader at index idx.
#get_uniform_offset(idx) ⇒ Integer
Get the offset into the data block where data for this uniforms is stored.
#get_uniform_type(idx) ⇒ Gsk::GLUniformType
Get the type of the declared uniform for this shader at index idx.
#n_textures ⇒ Integer
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.
#n_uniforms ⇒ Integer
Get the number of declared uniforms for this shader.
#resource ⇒ String
Resource containing the source code for the shader.
If the shader source is not coming from a resource, this will be nil.
#resource=(resource) ⇒ String
Resource containing the source code for the shader.
If the shader source is not coming from a resource, this will be nil.
#source ⇒ GLib::Bytes
Returns source.