EAGL.Shader (eagl v0.1.0)
View SourceModule for OpenGL shader management. Handles shader creation, compilation, and program linking.
Summary
Functions
Convenience function to cache uniform locations for repeated use. Returns a map of uniform names to their locations.
Checks if a shader compiled successfully.
Cleans up a shader program and all its attached shaders.
Cleans up a shader.
Creates a program, attaches shaders, links, and returns the link status.
Creates and compiles a shader of the specified type with the given source code. Returns the shader ID.
Get uniform location for a program. Similar to wings_gl:uloc/2. Returns the uniform location or -1 if not found.
Set uniform value with automatic type detection. Similar to wings_gl:set_uloc/3. Supports various EAGL.Math types and basic values.
Set uniform value at a specific location with automatic type detection.
Convenience function to set multiple uniforms at once. Takes a program and a keyword list of uniform_name -> value pairs.
Types
@type mat2() :: EAGL.Math.mat2()
@type mat3() :: EAGL.Math.mat3()
@type mat4() :: EAGL.Math.mat4()
@type quat() :: EAGL.Math.quat()
@type vec2() :: EAGL.Math.vec2()
@type vec3() :: EAGL.Math.vec3()
@type vec4() :: EAGL.Math.vec4()
Functions
@spec cache_uniform_locations(non_neg_integer(), [String.t() | atom()]) :: %{ required(String.t()) => integer() }
Convenience function to cache uniform locations for repeated use. Returns a map of uniform names to their locations.
Checks if a shader compiled successfully.
Cleans up a shader program and all its attached shaders.
Cleans up a shader.
Creates a program, attaches shaders, links, and returns the link status.
@spec create_shader(non_neg_integer(), String.t()) :: {:ok, non_neg_integer()} | {:error, String.t()}
Creates and compiles a shader of the specified type with the given source code. Returns the shader ID.
@spec get_uniform_location(non_neg_integer(), String.t() | charlist()) :: integer()
Get uniform location for a program. Similar to wings_gl:uloc/2. Returns the uniform location or -1 if not found.
@spec set_uniform(non_neg_integer(), String.t() | charlist(), uniform_value()) :: :ok
Set uniform value with automatic type detection. Similar to wings_gl:set_uloc/3. Supports various EAGL.Math types and basic values.
@spec set_uniform_at_location(integer(), uniform_value()) :: :ok
@spec set_uniform_at_location(integer(), vec3()) :: :ok
@spec set_uniform_at_location(integer(), vec2()) :: :ok
@spec set_uniform_at_location(integer(), vec4() | quat()) :: :ok
@spec set_uniform_at_location(integer(), mat4()) :: :ok
@spec set_uniform_at_location(integer(), mat3()) :: :ok
@spec set_uniform_at_location(integer(), mat2()) :: :ok
@spec set_uniform_at_location(integer(), float()) :: :ok
@spec set_uniform_at_location(integer(), integer()) :: :ok
@spec set_uniform_at_location(integer(), boolean()) :: :ok
Set uniform value at a specific location with automatic type detection.
@spec set_uniforms(non_neg_integer(), [{atom(), uniform_value()}]) :: :ok
Convenience function to set multiple uniforms at once. Takes a program and a keyword list of uniform_name -> value pairs.