opengl-bindings2 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +686 -0
- data/LICENSE.txt +21 -0
- data/README.md +564 -0
- data/lib/glfw.rb +699 -0
- data/lib/glu.rb +366 -0
- data/lib/glut.rb +575 -0
- data/lib/opengl.rb +36 -0
- data/lib/opengl_command.rb +7356 -0
- data/lib/opengl_common.rb +81 -0
- data/lib/opengl_enum.rb +1818 -0
- data/lib/opengl_es.rb +31 -0
- data/lib/opengl_es_command.rb +2526 -0
- data/lib/opengl_es_enum.rb +1011 -0
- data/lib/opengl_es_ext.rb +28 -0
- data/lib/opengl_es_ext_command.rb +8969 -0
- data/lib/opengl_es_ext_enum.rb +6078 -0
- data/lib/opengl_ext.rb +28 -0
- data/lib/opengl_ext_command.rb +33331 -0
- data/lib/opengl_ext_common.rb +52 -0
- data/lib/opengl_ext_enum.rb +14137 -0
- data/lib/opengl_linux.rb +63 -0
- data/lib/opengl_macosx.rb +68 -0
- data/lib/opengl_platform.rb +43 -0
- data/lib/opengl_windows.rb +71 -0
- data/sample/README.md +55 -0
- data/sample/glfw_get.bat +6 -0
- data/sample/glfw_get.sh +3 -0
- data/sample/report_env.rb +84 -0
- data/sample/simple.rb +57 -0
- metadata +75 -0
@@ -0,0 +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( 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
|