opengl-bindings 1.6.11 → 1.6.13

Sign up to get free protection for your applications and to get access to all the features.
data/lib/opengl_common.rb CHANGED
@@ -1,54 +1,54 @@
1
- module OpenGL
2
-
3
- GL_FUNCTIONS_MAP = {}
4
- GL_FUNCTIONS_ARGS_MAP = {}
5
- GL_FUNCTIONS_RETVAL_MAP = {}
6
- @@gl_dll = nil
7
-
8
- def self.load_lib(lib = nil, path = nil)
9
- if lib == nil && path == nil
10
- case self.get_platform
11
- when :OPENGL_PLATFORM_WINDOWS
12
- lib, path = 'opengl32.dll', 'C:/Windows/System32'
13
- when :OPENGL_PLATFORM_MACOSX
14
- lib, path = 'libGL.dylib','/System/Library/Frameworks/OpenGL.framework/Libraries'
15
- else
16
- lib = 'libGL.so'
17
- end
18
- end
19
- if path
20
- @@gl_dll = Fiddle.dlopen( path + '/' + lib )
21
- else
22
- @@gl_dll = Fiddle.dlopen( lib )
23
- end
24
- end
25
-
26
- def self.load_dll(lib = nil, path = nil)
27
- puts "Warning OpenGl.load_dll is deprecated, use OpenGL.load_lib instead"
28
- self.load_lib(lib, path)
29
- end
30
-
31
- def self.get_command( sym )
32
- if GL_FUNCTIONS_MAP[sym] == nil
33
- bind_command( sym )
34
- end
35
- return GL_FUNCTIONS_MAP[sym]
36
- end
37
-
38
- def self.bind_command( sym )
39
- begin
40
- GL_FUNCTIONS_MAP[sym] = Fiddle::Function.new( @@gl_dll[sym.to_s],
41
- GL_FUNCTIONS_ARGS_MAP[sym],
42
- GL_FUNCTIONS_RETVAL_MAP[sym] )
43
- rescue Exception => e
44
- if self.get_platform == :OPENGL_PLATFORM_WINDOWS
45
- func_ptr = wglGetProcAddress(sym.to_s)
46
- GL_FUNCTIONS_MAP[sym] = Fiddle::Function.new( func_ptr,
47
- GL_FUNCTIONS_ARGS_MAP[sym],
48
- GL_FUNCTIONS_RETVAL_MAP[sym] )
49
- end
50
- raise RuntimeError if GL_FUNCTIONS_MAP[sym] == nil
51
- end
52
- end
53
-
54
- end
1
+ module OpenGL
2
+
3
+ GL_FUNCTIONS_MAP = {}
4
+ GL_FUNCTIONS_ARGS_MAP = {}
5
+ GL_FUNCTIONS_RETVAL_MAP = {}
6
+ @@gl_dll = nil
7
+
8
+ def self.load_lib(lib = nil, path = nil)
9
+ if lib == nil && path == nil
10
+ case self.get_platform
11
+ when :OPENGL_PLATFORM_WINDOWS
12
+ lib, path = 'opengl32.dll', 'C:/Windows/System32'
13
+ when :OPENGL_PLATFORM_MACOSX
14
+ lib, path = 'libGL.dylib','/System/Library/Frameworks/OpenGL.framework/Libraries'
15
+ else
16
+ lib = 'libGL.so'
17
+ end
18
+ end
19
+ if path
20
+ @@gl_dll = Fiddle.dlopen( path + '/' + lib )
21
+ else
22
+ @@gl_dll = Fiddle.dlopen( lib )
23
+ end
24
+ end
25
+
26
+ def self.load_dll(lib = nil, path = nil)
27
+ puts "Warning OpenGl.load_dll is deprecated, use OpenGL.load_lib instead"
28
+ self.load_lib(lib, path)
29
+ end
30
+
31
+ def self.get_command( sym )
32
+ if GL_FUNCTIONS_MAP[sym] == nil
33
+ bind_command( sym )
34
+ end
35
+ return GL_FUNCTIONS_MAP[sym]
36
+ end
37
+
38
+ def self.bind_command( sym )
39
+ begin
40
+ GL_FUNCTIONS_MAP[sym] = Fiddle::Function.new( @@gl_dll[sym.to_s],
41
+ GL_FUNCTIONS_ARGS_MAP[sym],
42
+ GL_FUNCTIONS_RETVAL_MAP[sym] )
43
+ rescue Exception => e
44
+ if self.get_platform == :OPENGL_PLATFORM_WINDOWS
45
+ func_ptr = wglGetProcAddress(sym.to_s)
46
+ GL_FUNCTIONS_MAP[sym] = Fiddle::Function.new( func_ptr,
47
+ GL_FUNCTIONS_ARGS_MAP[sym],
48
+ GL_FUNCTIONS_RETVAL_MAP[sym] )
49
+ end
50
+ raise RuntimeError if GL_FUNCTIONS_MAP[sym] == nil
51
+ end
52
+ end
53
+
54
+ end