struct Gloop::Program

Overview

Represents one or more shaders.

See: https://www.khronos.org/opengl/wiki/GLSL_Object#Program_objects

Included Modules

Defined in:

gloop/program.cr
gloop/program/binary.cr
gloop/program/link_error.cr
gloop/program/uniform_location.cr
gloop/program/uniforms.cr

Constructors

Class Method Summary

Instance Method Summary

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

def self.create(context) : self #

Creates a new program.

  • OpenGL function: glCreateProgram
  • OpenGL version: 2.0

[View source]
def self.from_binary(context, binary) : self #

Creates a program from an existing binary.

See: .create, #binary=


[View source]

Class Method Detail

def self.current(context) #

Retrieves the current program in use.

Returns a null-object (.none) if there isn't a program in use.

See: #use

  • OpenGL function: glGetIntegerv
  • OpenGL enum: GL_CURRENT_PROGRAM
  • OpenGL version: 2.0

[View source]
def self.current?(context) #

Retrieves the current program in use.

Returns nil if there isn't a program in use.

See: #use

  • OpenGL function: glGetIntegerv
  • OpenGL enum: GL_CURRENT_PROGRAM
  • OpenGL version: 2.0

[View source]
def self.uninstall(context) : Nil #

Uninstalls any existing program from the context's rendering state.

  • OpenGL function: glUseProgram
  • OpenGL version: 2.0

[View source]

Instance Method Detail

def attach(shader) : Nil #

Attaches the specified shader to this program.

  • OpenGL function: glAttachShader
  • OpenGL version: 2.0

[View source]
def binary : Binary #

Retrieves the binary data representing the compiled and linked program.

  • OpenGL function: glGetProgramBinary
  • OpenGL version: 4.1

[View source]
def binary=(binary) #

Load an existing program binary.

  • OpenGL function: glProgramBinary
  • OpenGL version: 4.1

[View source]
def binary_size #

Retrieves the length, in bytes, of the program's binary.

If linking failed or the binary is unavailable, this will be zero.

See: #binary

  • OpenGL function: glGetProgramiv
  • OpenGL enum: GL_PROGRAM_BINARY_LENGTH
  • OpenGL version: 4.1

[View source]
def delete : Nil #

Indicates to OpenGL that this program can be deleted.

When there are no more references to the program, its resources will be released.

See: #deleted?

  • OpenGL function: glDeleteProgram
  • OpenGL version: 2.0

[View source]
def deleted? : Bool #

Checks if the program has been deleted.

Note: This property only returns true if the program is deleted, but still exists. If it doesn't exist (all resources freed), then this property can return false.

See: #delete

  • OpenGL function: glGetProgramiv
  • OpenGL enum: GL_DELETE_STATUS
  • OpenGL version: 2.0

[View source]
def detach(shader) : Nil #

Detaches the specified shader from this program.

  • OpenGL function: glDetachShader
  • OpenGL version: 2.0

[View source]
def exists? #

Checks if this program is known to the graphics driver.

  • OpenGL function: glIsProgram
  • OpenGL version: 2.0

[View source]
def info_log : String | Nil #

Retrieves information about the program's link process and validation.

Nil will be returned if there's no log available.

The information log is OpenGL's mechanism for conveying information to application developers. Even if the linkage or validation was successful, some useful information may be in it.

  • OpenGL function: glGetProgramInfoLog
  • OpenGL version: 2.0

[View source]
def info_log_size #

Retrieves the size of the information log for this program.

If the log is unavailable, nil is returned.

See: #info_log

  • OpenGL function: glGetProgramiv
  • OpenGL enum: GL_INFO_LOG_LENGTH
  • OpenGL version: 2.0

[View source]
def link : Bool #

Attempts to link the shaders together to build the final program.

Returns true if the link process was successful, false otherwise.

See: #link!

  • OpenGL function: glLinkProgram
  • OpenGL version: 2.0

[View source]
def link! : Nil #

Attempts to link the shaders together to build the final program.

Raises LinkError if the process fails.

See: #link

  • OpenGL function: glLinkProgram
  • OpenGL version: 2.0

[View source]
def linked? : Bool #

Checks if the program has been linked successfully.

See: #link

  • OpenGL function: glGetProgramiv
  • OpenGL enum: `GL_LINK_STATUS
  • OpenGL version: 2.0

[View source]
def object_type #

Indicates that this is a program object.


[View source]
def shader_count #

Retrieves the number of shaders currently attached to the program.

See: #shaders

  • OpenGL function: glGetProgramiv
  • OpenGL enum: GL_ATTACHED_SHADERS
  • OpenGL version: 2.0

[View source]
def shaders : Indexable(Shader) #

Retrieves the shaders attached to the program.

  • OpenGL function: glGetAttachedShaders
  • OpenGL version: 2.0

[View source]
def uniforms : Uniforms #

Provides access to the active uniforms in this program.


[View source]
def use : Nil #

Installs this program as part of the context's rendering state.

  • OpenGL function: glUseProgram
  • OpenGL version: 2.0

[View source]
def use(&) #

Installs this program as part of the context's rendering state.

Restores the previous program after the block returns.

  • OpenGL function: glUseProgram
  • OpenGL version: 2.0

[View source]
def valid? : Bool #

Checks the result of the last validation.

See: #validate

  • OpenGL function: glGetProgramiv
  • OpenGL enum: GL_VALIDATE_STATUS
  • OpenGL version: 2.0

[View source]
def validate : Bool #

Checks if the program can be used in OpenGL's current state.

Returns true if the program is valid. Stores information about validation in #info_log.

See: #valid?

  • OpenGL function: glValidateProgram
  • OpenGL version: 2.0

[View source]