struct Gloop::Program::Uniforms

Overview

Access to active uniforms from a program.

Use #at to reference a uniform by its location. Use the string variants of #[] and #[]? to reference a uniform by its name.

NOTE The uniform index is different than its location. The location is used to get and set a uniform's value. The index is used to retrieve metadata of the uniform.

Included Modules

Defined in:

gloop/program/uniforms.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(context : Context, name : Name) #

Creates a references to the active uniforms in a program.


[View source]

Instance Method Detail

def [](name : String) : UniformLocation #

References an active uniform from this program by its name.

Raises if there are no uniforms with the specified name.

The location of the uniform is resolved, but not cached. Repeated calls to this method will resolve the location of the uniform by name. It's recommended that the instance returned is kept for repeated use.

  • OpenGL function: glGetUniformLocation
  • OpenGL version: 2.0

[View source]
def []?(name : String) : UniformLocation | Nil #

References an active uniform from this program by its name.

Returns nil if there are no uniforms with the specified name.

The location of the uniform is resolved, but not cached. Repeated calls to this method will resolve the location of the uniform by name. It's recommended that the instance returned is kept for repeated use.

  • OpenGL function: glGetUniformLocation
  • OpenGL version: 2.0

[View source]
def at(location : Int32) : UniformLocation #

References an active uniform from this program by its location.


[View source]
def locate(name : String) : Int32 #

Gets the location of a named uniform.

Returns -1 if the uniform wasn't found.

  • OpenGL function: glGetUniformLocation
  • OpenGL version: 2.0

[View source]
def locate!(name : String) : Int32 #

Gets the location of a named uniform.

Raises an error if the uniform wasn't found.

  • OpenGL function: glGetUniformLocation
  • OpenGL version: 2.0

[View source]
def locate?(name : String) : Int32 | Nil #

Gets the location of a named uniform.

Returns nil if the uniform wasn't found.

  • OpenGL function: glGetUniformLocation
  • OpenGL version: 2.0

[View source]
def name(index : UInt32) : String #

Retrieves the name of the specified uniform.

  • OpenGL function: glGetActiveUniformName
  • OpenGL version: 3.1

[View source]
def size #

Number of active attributes in the program.

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

[View source]
def unsafe_fetch(index : Int) #

Retrieves a uniform at the specified index.

  • OpenGL function: glGetActiveUniform
  • OpenGL version: 2.0

[View source]