:right-sidebar: True GLShader =================================================================== .. currentmodule:: gi.repository.Gsk .. class:: GLShader(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: GLShader(**properties) new_from_bytes(sourcecode:GLib.Bytes) -> Gsk.GLShader new_from_resource(resource_path:str) -> Gsk.GLShader Constructors ------------ .. rst-class:: interim-class .. class:: GLShader :no-index: .. classmethod:: new_from_bytes(sourcecode: ~gi.repository.GLib.Bytes) -> ~gi.repository.Gsk.GLShader Creates a ``GskGLShader`` that will render pixels using the specified code. :param sourcecode: GLSL sourcecode for the shader, as a ``GBytes`` .. classmethod:: new_from_resource(resource_path: str) -> ~gi.repository.Gsk.GLShader Creates a ``GskGLShader`` that will render pixels using the specified code. :param resource_path: path to a resource that contains the GLSL sourcecode for the shader Methods ------- .. rst-class:: interim-class .. class:: GLShader :no-index: .. method:: compile(renderer: ~gi.repository.Gsk.Renderer) -> bool Tries to compile the ``shader`` for the given ``renderer``. If there is a problem, this function returns :const:`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. :param renderer: a ``GskRenderer`` .. method:: find_uniform_by_name(name: str) -> int Looks for a uniform by the name ``name``, and returns the index of the uniform, or -1 if it was not found. :param name: uniform name .. method:: get_arg_bool(args: ~gi.repository.GLib.Bytes, idx: int) -> bool Gets the value of the uniform ``idx`` in the ``args`` block. The uniform must be of bool type. :param args: uniform arguments :param idx: index of the uniform .. method:: get_arg_float(args: ~gi.repository.GLib.Bytes, idx: int) -> float Gets the value of the uniform ``idx`` in the ``args`` block. The uniform must be of float type. :param args: uniform arguments :param idx: index of the uniform .. method:: get_arg_int(args: ~gi.repository.GLib.Bytes, idx: int) -> int Gets the value of the uniform ``idx`` in the ``args`` block. The uniform must be of int type. :param args: uniform arguments :param idx: index of the uniform .. method:: get_arg_uint(args: ~gi.repository.GLib.Bytes, idx: int) -> int Gets the value of the uniform ``idx`` in the ``args`` block. The uniform must be of uint type. :param args: uniform arguments :param idx: index of the uniform .. method:: get_arg_vec2(args: ~gi.repository.GLib.Bytes, idx: int, out_value: ~gi.repository.Graphene.Vec2) -> None Gets the value of the uniform ``idx`` in the ``args`` block. The uniform must be of vec2 type. :param args: uniform arguments :param idx: index of the uniform :param out_value: location to store the uniform value in .. method:: get_arg_vec3(args: ~gi.repository.GLib.Bytes, idx: int, out_value: ~gi.repository.Graphene.Vec3) -> None Gets the value of the uniform ``idx`` in the ``args`` block. The uniform must be of vec3 type. :param args: uniform arguments :param idx: index of the uniform :param out_value: location to store the uniform value in .. method:: get_arg_vec4(args: ~gi.repository.GLib.Bytes, idx: int, out_value: ~gi.repository.Graphene.Vec4) -> None Gets the value of the uniform ``idx`` in the ``args`` block. The uniform must be of vec4 type. :param args: uniform arguments :param idx: index of the uniform :param out_value: location to store set the uniform value in .. method:: get_args_size() -> int Get the size of the data block used to specify arguments for this shader. .. method:: get_n_textures() -> 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. .. method:: get_n_uniforms() -> int Get the number of declared uniforms for this shader. .. method:: get_resource() -> str | None Gets the resource path for the GLSL sourcecode being used to render this shader. .. method:: get_source() -> ~gi.repository.GLib.Bytes Gets the GLSL sourcecode being used to render this shader. .. method:: get_uniform_name(idx: int) -> str Get the name of the declared uniform for this shader at index ``idx``. :param idx: index of the uniform .. method:: get_uniform_offset(idx: int) -> int Get the offset into the data block where data for this uniforms is stored. :param idx: index of the uniform .. method:: get_uniform_type(idx: int) -> ~gi.repository.Gsk.GLUniformType Get the type of the declared uniform for this shader at index ``idx``. :param idx: index of the uniform Properties ---------- .. rst-class:: interim-class .. class:: GLShader :no-index: .. attribute:: props.resource :type: str Resource containing the source code for the shader. If the shader source is not coming from a resource, this will be :const:`None`. .. attribute:: props.source :type: ~gi.repository.GLib.Bytes