opengl-bindings2 2.0.0.rc1 → 2.0.0rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +691 -686
- data/README.md +564 -564
- data/lib/glfw.rb +699 -699
- data/lib/glu.rb +366 -366
- data/lib/glut.rb +575 -575
- data/lib/opengl.rb +36 -36
- data/lib/opengl_command.rb +7356 -7356
- data/lib/opengl_common.rb +81 -81
- data/lib/opengl_enum.rb +1818 -1818
- data/lib/opengl_es.rb +31 -31
- data/lib/opengl_es_command.rb +2526 -2526
- data/lib/opengl_es_enum.rb +1011 -1011
- data/lib/opengl_es_ext.rb +28 -28
- data/lib/opengl_es_ext_command.rb +8969 -8969
- data/lib/opengl_es_ext_enum.rb +6078 -6078
- data/lib/opengl_ext.rb +28 -28
- data/lib/opengl_ext_command.rb +33331 -33331
- data/lib/opengl_ext_common.rb +52 -52
- data/lib/opengl_ext_enum.rb +14137 -14137
- data/lib/opengl_linux.rb +63 -63
- data/lib/opengl_macosx.rb +68 -68
- data/lib/opengl_platform.rb +43 -43
- data/lib/opengl_windows.rb +71 -71
- data/sample/README.md +55 -55
- data/sample/glfw_get.bat +6 -6
- data/sample/glfw_get.sh +3 -3
- data/sample/report_env.rb +7 -7
- data/sample/simple.rb +57 -57
- metadata +3 -3
data/lib/opengl_common.rb
CHANGED
@@ -1,81 +1,81 @@
|
|
1
|
-
module GL
|
2
|
-
|
3
|
-
GL_FUNCTIONS_MAP = {}
|
4
|
-
@@gl_dll = nil
|
5
|
-
|
6
|
-
# Open dll/dylib/so for symbol import
|
7
|
-
# - Note that OpenGL APIs won't be available until you call import_symbols
|
8
|
-
def self.open_lib(lib_path: nil)
|
9
|
-
if lib_path == nil
|
10
|
-
case self.get_platform
|
11
|
-
when :OPENGL_PLATFORM_WINDOWS
|
12
|
-
lib_path = 'C:/Windows/System32/opengl32.dll'
|
13
|
-
when :OPENGL_PLATFORM_MACOSX
|
14
|
-
lib_path = '/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib'
|
15
|
-
else
|
16
|
-
lib_path = 'libGL.so' # not tested
|
17
|
-
end
|
18
|
-
end
|
19
|
-
@@gl_dll = Fiddle.dlopen(lib_path)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Import OpenGL APIs
|
23
|
-
# - Call this after OpenGL context becomes vailable (e.g.: glfwMakeContextCurrent)
|
24
|
-
def self.import_symbols(output_error: false)
|
25
|
-
GL_FUNCTION_SYMBOLS.each do |sym|
|
26
|
-
begin
|
27
|
-
bind_command(sym) if GL_FUNCTIONS_MAP[sym] == nil || GL_FUNCTIONS_MAP[sym].ptr == 0
|
28
|
-
rescue
|
29
|
-
$stderr.puts("[Warning] opengl_common.rb : Failed to import #{sym}.") if output_error
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.load_lib(lib_path = nil, output_import_error = false)
|
35
|
-
if lib_path == nil
|
36
|
-
lib_path = case self.get_platform
|
37
|
-
when :OPENGL_PLATFORM_WINDOWS
|
38
|
-
'C:/Windows/System32/opengl32.dll'
|
39
|
-
when :OPENGL_PLATFORM_MACOSX
|
40
|
-
'/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib'
|
41
|
-
else
|
42
|
-
libGL.so # not tested
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
open_lib(lib_path: lib_path)
|
47
|
-
import_symbols(output_error: output_import_error)
|
48
|
-
end
|
49
|
-
|
50
|
-
# [OBSOLETE]
|
51
|
-
def self.load_dll(lib = nil, path = nil)
|
52
|
-
$stderr.puts "[Warning] opengl_common.rb : OpenGL.load_dll is deprecated, use OpenGL.load_lib instead"
|
53
|
-
self.load_lib(lib, path)
|
54
|
-
end
|
55
|
-
|
56
|
-
# [INTERNAL]
|
57
|
-
def self.get_command(
|
58
|
-
if GL_FUNCTIONS_MAP[sym] == nil
|
59
|
-
bind_command(
|
60
|
-
end
|
61
|
-
return GL_FUNCTIONS_MAP[sym]
|
62
|
-
end
|
63
|
-
|
64
|
-
# [INTERNAL]
|
65
|
-
def self.bind_command(
|
66
|
-
begin
|
67
|
-
GL_FUNCTIONS_MAP[sym] = Fiddle::Function.new(
|
68
|
-
|
69
|
-
|
70
|
-
rescue
|
71
|
-
if self.get_platform == :OPENGL_PLATFORM_WINDOWS
|
72
|
-
func_ptr = wglGetProcAddress(sym.to_s)
|
73
|
-
GL_FUNCTIONS_MAP[sym] = Fiddle::Function.new(
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
raise RuntimeError if GL_FUNCTIONS_MAP[sym] == nil
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
1
|
+
module GL
|
2
|
+
|
3
|
+
GL_FUNCTIONS_MAP = {}
|
4
|
+
@@gl_dll = nil
|
5
|
+
|
6
|
+
# Open dll/dylib/so for symbol import
|
7
|
+
# - Note that OpenGL APIs won't be available until you call import_symbols
|
8
|
+
def self.open_lib(lib_path: nil)
|
9
|
+
if lib_path == nil
|
10
|
+
case self.get_platform
|
11
|
+
when :OPENGL_PLATFORM_WINDOWS
|
12
|
+
lib_path = 'C:/Windows/System32/opengl32.dll'
|
13
|
+
when :OPENGL_PLATFORM_MACOSX
|
14
|
+
lib_path = '/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib'
|
15
|
+
else
|
16
|
+
lib_path = 'libGL.so' # not tested
|
17
|
+
end
|
18
|
+
end
|
19
|
+
@@gl_dll = Fiddle.dlopen(lib_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Import OpenGL APIs
|
23
|
+
# - Call this after OpenGL context becomes vailable (e.g.: glfwMakeContextCurrent)
|
24
|
+
def self.import_symbols(output_error: false)
|
25
|
+
GL_FUNCTION_SYMBOLS.each do |sym|
|
26
|
+
begin
|
27
|
+
bind_command(sym) if GL_FUNCTIONS_MAP[sym] == nil || GL_FUNCTIONS_MAP[sym].ptr == 0
|
28
|
+
rescue
|
29
|
+
$stderr.puts("[Warning] opengl_common.rb : Failed to import #{sym}.") if output_error
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.load_lib(lib_path = nil, output_import_error = false)
|
35
|
+
if lib_path == nil
|
36
|
+
lib_path = case self.get_platform
|
37
|
+
when :OPENGL_PLATFORM_WINDOWS
|
38
|
+
'C:/Windows/System32/opengl32.dll'
|
39
|
+
when :OPENGL_PLATFORM_MACOSX
|
40
|
+
'/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib'
|
41
|
+
else
|
42
|
+
'libGL.so' # not tested
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
open_lib(lib_path: lib_path)
|
47
|
+
import_symbols(output_error: output_import_error)
|
48
|
+
end
|
49
|
+
|
50
|
+
# [OBSOLETE]
|
51
|
+
def self.load_dll(lib = nil, path = nil)
|
52
|
+
$stderr.puts "[Warning] opengl_common.rb : OpenGL.load_dll is deprecated, use OpenGL.load_lib instead"
|
53
|
+
self.load_lib(lib, path)
|
54
|
+
end
|
55
|
+
|
56
|
+
# [INTERNAL]
|
57
|
+
def self.get_command(sym)
|
58
|
+
if GL_FUNCTIONS_MAP[sym] == nil
|
59
|
+
bind_command(sym)
|
60
|
+
end
|
61
|
+
return GL_FUNCTIONS_MAP[sym]
|
62
|
+
end
|
63
|
+
|
64
|
+
# [INTERNAL]
|
65
|
+
def self.bind_command(sym)
|
66
|
+
begin
|
67
|
+
GL_FUNCTIONS_MAP[sym] = Fiddle::Function.new(@@gl_dll[sym.to_s],
|
68
|
+
GL_FUNCTIONS_ARGS_MAP[sym],
|
69
|
+
GL_FUNCTIONS_RETVAL_MAP[sym])
|
70
|
+
rescue
|
71
|
+
if self.get_platform == :OPENGL_PLATFORM_WINDOWS
|
72
|
+
func_ptr = wglGetProcAddress(sym.to_s)
|
73
|
+
GL_FUNCTIONS_MAP[sym] = Fiddle::Function.new(func_ptr,
|
74
|
+
GL_FUNCTIONS_ARGS_MAP[sym],
|
75
|
+
GL_FUNCTIONS_RETVAL_MAP[sym])
|
76
|
+
end
|
77
|
+
raise RuntimeError if GL_FUNCTIONS_MAP[sym] == nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|