Module: GL::GLSym Private

Defined in:
lib/opengl-core/gl-sym.rb,
lib/opengl-core/gl-sym/fiddle-symbol-loader.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Symbol loading is currently handled by Fiddle, though it’s entirely possible for someone to swap out loaders they want.

Loaders must provide two methods:

- load_sym(name, types)
  name is the name of the GL symbol to load, types is a dictionary
  of keys return_type and parameter_types, the former being a symbol
  defining the return type of the function and parameter_types being an
  array of the parameter types received by the function.

- unload()
  Called to unload any resources held by the loader in the event that the
  loader is swapped out at runtime.

Defined Under Namespace

Classes: FiddleSymbolLoader

Constant Summary collapse

GL_COMMAND_TYPES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Filled by gl_commands.rb

{}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.__cached_functions__Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
# File 'lib/opengl-core/gl-sym.rb', line 36

def __cached_functions__
  @__cached_functions__
end

.loaderObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
# File 'lib/opengl-core/gl-sym.rb', line 35

def loader
  @loader
end

Class Method Details

.__loader__=Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
# File 'lib/opengl-core/gl-sym.rb', line 38

def loader=(value)
  @loader = value
end

.load_sym(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Loads the GL symbol with the given name. It’s assumed that this symbol has its types defined in GL_COMMAND_TYPES.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/opengl-core/gl-sym.rb', line 48

def load_sym(name)
  functions = (self.__cached_functions__ ||= {})
  functions[name] ||= begin
    symfunc = self.loader.load_sym(name, GL_COMMAND_TYPES[name])

    if symfunc.nil?
      raise NoMethodError, "GL function #{name} could not be loaded"
    end

    symfunc
  end
end