Module: GlSym

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

Constant Summary collapse

@@opengl_lib =
nil

Class Method Summary collapse

Class Method Details

.apple?Boolean

Returns:

  • (Boolean)


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

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

.linux?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
41
# File 'ext/opengl-core/opengl_stub.c', line 34

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

.load_gl_sym__(name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/opengl-core/gl_sym.rb', line 8

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

  @@opengl_lib[name]
end

.unix?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
# File 'ext/opengl-core/opengl_stub.c', line 24

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

.windows?Boolean

Returns:

  • (Boolean)


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

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