struct Gloop::Shader
- Gloop::Shader
- Gloop::Object
- Struct
- Value
- Object
Overview
Base type for all shaders. Encapsulates functionality for working with a stage of the graphics processing pipeline.
See: https://www.khronos.org/opengl/wiki/Shader
Included Modules
- Gloop::Parameters
Defined in:
gloop/shader.crgloop/shader/compilation_error.cr
gloop/shader/type.cr
Constructors
-
.create(context : Context, type : Type) : self
Creates an empty shader of the specified type.
Instance Method Summary
-
#compile : Bool
Attempts to compile the shader.
-
#compile! : Nil
Attempts to compile the shader.
-
#compiled? : Bool
Checks if this shader was compiled successfully.
-
#delete : Nil
Deletes this shader object.
-
#deleted? : Bool
Checks if this shader is flagged for deletion.
-
#exists?
Determines if this shader is known to the context.
-
#info_log : String | Nil
Retrieves information about the shader's compilation.
-
#info_log_size
Retrieves the size of the information log for this shader.
-
#object_type
Indicates that this is a shader object.
-
#source : String | Nil
Retrieves the shader's source code.
-
#source=(source)
Updates the source code for the shader.
-
#source_size
Retrieves the size of this shadaer's source code.
-
#sources=(sources : Enumerable)
Updates the source code for the shader.
-
#type : Gloop::Shader::Type
Retrieves the type of this shader.
Instance methods inherited from struct Gloop::Object
context : Context
context,
name : Name
name,
none?
none?,
object_type
object_type,
to_s(io)
to_s,
to_unsafe : UInt32
to_unsafe
Constructor methods inherited from struct Gloop::Object
new(context : Context, name : Name)
new,
none(context) : self
none
Instance methods inherited from module Gloop::Labelable
label : String
label,
label=(label : Nil)label=(label) label=, max_label_size : Int32 max_label_size, name name, object_type object_type
Constructor Detail
Creates an empty shader of the specified type.
- OpenGL function:
glCreateShader
- OpenGL version: 2.0
- OpenGL enum
GL_COMPUTE_SHADER
available in version 4.3 or higher
Instance Method Detail
Attempts to compile the shader.
Returns true if the compilation was successful, false otherwise.
The source of the shader must be previously set by calling #source=
or #sources=
.
The result of the compilation can be checked with #compiled?
.
Additional information from the compilation may be available from #info_log
.
See: #compile!
- OpenGL function:
glCompileShader
- OpenGL version: 2.0
Attempts to compile the shader.
Raises CompilationError
if the compilation fails.
The source of the shader must be previously set by calling #source=
or #sources=
.
Additional information from the compilation may be available from #info_log
.
See: #compile
- OpenGL function:
glCompileShader
- OpenGL version: 2.0
Checks if this shader was compiled successfully.
See: #compile
- OpenGL function:
glGetShaderiv
- OpenGL enum:
GL_COMPILE_STATUS
- OpenGL version: 2.0
Deletes this shader object.
Frees memory and invalidates the name associated with this shader object.
This method effectively undoes the effects of a call to .create
.
If this shader object is attached to a Program
object, it will be flagged for deletion,
but it will not be deleted until it is no longer attached to any Program
object, for any rendering context.
See: #deleted?
- OpenGL function:
glDeleteShader
- OpenGL version: 2.0
Checks if this shader is flagged for deletion.
See: #delete
- OpenGL function:
glGetShaderiv
- OpenGL enum:
GL_DELETE_STATUS
- OpenGL version: 2.0
Determines if this shader is known to the context.
Returns true if this shader was previously created with .create
and not yet deleted with #delete
.
- OpenGL function:
glIsShader
- OpenGL version: 2.0
Retrieves information about the shader's compilation.
Nil will be returned if there's no log available.
The information log is OpenGL's mechanism for conveying information about the compilation to application developers. Even if the compilation was successful, some useful information may be in it.
- OpenGL function:
glGetShaderInfoLog
- OpenGL version: 2.0
Retrieves the size of the information log for this shader.
If the log is unavailable, nil is returned.
See: #info_log
- OpenGL function:
glGetShaderiv
- OpenGL enum:
GL_INFO_LOG_LENGTH
- OpenGL version: 2.0
Retrieves the shader's source code.
This will be the concatenation if multiple sources were provided (see #sources=
).
Nil is returned if the source is not available.
- OpenGL function:
glGetShaderSource
- OpenGL version: 2.0
Updates the source code for the shader.
This does not compile the shader, it merely stores the source code.
Any existing source code will be replaced.
If source is not already a string, it will be stringified by calling #to_s
on it.
- OpenGL function:
glShaderSource
- OpenGL version: 2.0
Retrieves the size of this shadaer's source code.
If the source is unavailable, nil is returned.
See: #source
- OpenGL function:
glGetShaderiv
- OpenGL enum:
GL_SHADER_SOURCE_LENGTH
- OpenGL version: 2.0
Updates the source code for the shader.
This does not compile the shader, it merely stores the source code. Any existing source code will be replaced. The sources must be a collection of items that can be stringified (or already strings).
- OpenGL function:
glShaderSource
- OpenGL version: 2.0
Retrieves the type of this shader.
- OpenGL function:
glGetShaderiv
- OpenGL enum:
GL_SHADER_TYPE
- OpenGL version: 2.0