opengl-bindings2 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,52 @@
1
+ module GL
2
+
3
+ def self.check_extension(ext_name)
4
+ get_string = GL.get_command(:glGetString) # [INTERNAL] Shortcut to get pointer without proper user setup.
5
+ version_number = get_string.call(GL::VERSION).to_s.split(/\./)
6
+ if version_number[0].to_i >= 3
7
+ # glGetString(GL_EXTENSIONS) was deprecated in OpenGL 3.0
8
+ # Ref.: http://sourceforge.net/p/glew/bugs/120/
9
+ get_integerv = GL.get_command(:glGetIntegerv)
10
+ get_stringi = GL.get_command(:glGetStringi)
11
+ extensions_count_buf = ' '
12
+ get_integerv.call(GL::NUM_EXTENSIONS, extensions_count_buf)
13
+ extensions_count = extensions_count_buf.unpack('L')[0]
14
+ extensions_count.times do |i|
15
+ supported_ext_name = get_stringi.call(GL::EXTENSIONS, i).to_s
16
+ return true if ext_name == supported_ext_name
17
+ end
18
+ return false
19
+ else
20
+ ext_strings = get_string.call(GL::EXTENSIONS).to_s.split(/ /)
21
+ return ext_strings.include? ext_name
22
+ end
23
+ end
24
+
25
+ def self.setup_extension(ext_name, skip_check: false)
26
+ if skip_check || self.check_extension(ext_name)
27
+ define_ext_enum = "define_ext_enum_#{ext_name}".to_sym
28
+ define_ext_command = "define_ext_command_#{ext_name}".to_sym
29
+ GLExt.send(define_ext_enum)
30
+ GLExt.send(define_ext_command)
31
+ end
32
+ end
33
+
34
+ def self.setup_extension_all(skip_check: false)
35
+ self.methods.each do |method_name|
36
+ if method_name =~ /define_ext_command_(.*)/
37
+ setup_extension($1, skip_check)
38
+ end
39
+ end
40
+ end
41
+
42
+ def self.get_extension_enum_symbols(ext_name)
43
+ get_ext_enum = "get_ext_enum_#{ext_name}".to_sym
44
+ GLExt.send(get_ext_enum)
45
+ end
46
+
47
+ def self.get_extension_command_symbols(ext_name)
48
+ get_ext_command = "get_ext_command_#{ext_name}".to_sym
49
+ GLExt.send(get_ext_command)
50
+ end
51
+
52
+ end