Module: Gl::GlSym Private

Defined in:
lib/opengl-core/gl_sym.rb,
ext/opengl-core/opengl_stub.c

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.

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

{}
GL_COMMAND_FUNCTIONS =

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 load_gl_sym

{}
@@opengl_lib =

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

OpenGL library handle.

nil

Class Method Summary collapse

Class Method Details

.__load_gl_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 a symbol from the GL library. If the GL library hasn’t yet been loaded it will also do that. The returned function will be a wrapped Fiddle function using the types that function name is associated with in GL_COMMAND_TYPES. The returned value is cached in GL_COMMAND_FUNCTIONS and returned if load_gl_sym is called for the same name again.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/opengl-core/gl_sym.rb', line 22

def self.__load_gl_sym__(name)
  if @@opengl_lib.nil?
    lib_path = case
    when apple?
      '/System/Library/Frameworks/OpenGL.framework/OpenGL'
    when windows? || Fiddle::WINDOWS
      'opengl32.dll'
    when unix? || linux?
      'libGL.so.1'
    else
      raise 'Unrecognized platform'
    end
    @@opengl_lib = Fiddle.dlopen(lib_path)
  end

  fn = GL_COMMAND_FUNCTIONS[name]
  if fn.nil?
    fn = (GL_COMMAND_FUNCTIONS[name] = begin
      sym = @@opengl_lib[name.to_s]
      types = GL_COMMAND_TYPES[name]
      Fiddle::Function.new(sym, types[:parameter_types], types[:return_type])
    rescue
      false
    end)
  end

  fn
end

.apple?Boolean

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.

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
# File 'ext/opengl-core/opengl_stub.c', line 5

static VALUE plat_is_apple(VALUE self)
{
  #if defined(__APPLE__)
  return Qtrue;
  #else
  return Qfalse;
  #endif
}

.linux?Boolean

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.

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
# File 'ext/opengl-core/opengl_stub.c', line 38

static VALUE plat_is_linux(VALUE self)
{
  #if defined(__linux__) || defined(linux) || defined(__linux)
  return Qtrue;
  #else
  return Qfalse;
  #endif
}

.unix?Boolean

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.

Returns:

  • (Boolean)


27
28
29
30
31
32
33
34
# File 'ext/opengl-core/opengl_stub.c', line 27

static VALUE plat_is_unix(VALUE self)
{
  #if defined(__unix) || defined(__unix__) || defined(unix) || defined(__APPLE__)
  return Qtrue;
  #else
  return Qfalse;
  #endif
}

.windows?Boolean

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.

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
# File 'ext/opengl-core/opengl_stub.c', line 16

static VALUE plat_is_windows(VALUE self)
{
  #if defined(_WIN32) || defined(__MINGW32__) || defined(__CYGWIN__)
  return Qtrue;
  #else
  return Qfalse;
  #endif
}