From c999770414ea32f31ad777854bba213c76058a61 Mon Sep 17 00:00:00 2001 From: jgleesawn Date: Tue, 13 Jan 2015 13:18:50 -0500 Subject: [PATCH 1/7] Modified gen_from_xml.rb so it generates (glx/wgl)-(commands/enums).rb files. Specifically to lead into using wglGetProcAddress so the library will work on windows platforms. --- gen_from_xml.rb | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/gen_from_xml.rb b/gen_from_xml.rb index 6c897ce..485c9e1 100755 --- a/gen_from_xml.rb +++ b/gen_from_xml.rb @@ -4,17 +4,20 @@ require 'open-uri' require 'fiddle' -KHRONOS_GL_XML = 'https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/gl.xml' - -if !File.exist?('gl.xml') - puts "gl.xml doesn't exist: downloading <#{KHRONOS_GL_XML}>..." - curl_pid = Process.spawn("curl --output 'gl.xml' '#{KHRONOS_GL_XML}'") - Process.wait(curl_pid) - if !$?.exited? || !$?.success? - puts "Download failed. Try again." - exit 1 +KHRONOS_GL_XMLS = ['gl.xml','glx.xml','wgl.xml'] +KHRONOS_GL_XML_PATH = 'https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/' + +KHRONOS_GL_XMLS.each do |filename| + if !File.exist?(filename) + puts "#{filename} doesn't exist: downloading <#{KHRONOS_GL_XML_PATH}#{filename}>..." + curl_pid = Process.spawn("curl --output '#{filename}' '#{KHRONOS_GL_XML_PATH}#{filename}'") + Process.wait(curl_pid) + if !$?.exited? || !$?.success? + puts "Download failed. Try again." + exit 1 + end + puts "Download complete." end - puts "Download complete." end # name => String @@ -98,6 +101,10 @@ def generate_binding_impl(document) begin gl_commands = get_commands(document) gl_enums = get_enums(document) +# puts document +# gl_commands.each { |comm| puts comm.to_s } +# puts gl_commands.to_s +# puts gl_enums.to_s pull_feature = proc { |feature| feature_name = feature['name'] @@ -122,13 +129,13 @@ def generate_binding_impl(document) } extensions = document.xpath("registry/extensions/extension") - core_exts = extensions.select { |ext| ext['supported'] =~ /\bglcore\b/ } + core_exts = extensions.select { |ext| ext['supported'] =~ /\bglcore\b/ || ext['supported'] =~ /\bglx\b/ || ext['supported'] =~ /\bwgl\b/ } core_exts.each { |ext| ext.xpath('extension/require/*[(self::command|self::enum)]').each(&pull_feature) } features = document.xpath('registry/feature') - gl_features = features.select { |feature| feature['api'] =~ /\bgl\b/ } + gl_features = features.select { |feature| feature['api'] =~ /\bgl\b/ || feature['api'] =~ /\bglx\b/ || feature['api'] =~ /\bwgl\b/ } gl_features.each { |feature| feature.xpath('require/*[(self::command|self::enum)]').each(&pull_feature) if GEN_GL3_AND_UP @@ -230,7 +237,7 @@ def #{name}__(#{param_string}) # Read gl.xml -document_paths = [ 'gl.xml' ] +document_paths = [ 'gl.xml', 'glx.xml', 'wgl.xml' ] document_paths.each { |path| From 353a15fe17234ebb1555ebdae0f0884c726666d5 Mon Sep 17 00:00:00 2001 From: jgleesawn Date: Wed, 14 Jan 2015 15:43:47 -0500 Subject: [PATCH 2/7] fiddle-symbol-loader.rb: Implemented SymLoaderHash, utilizes Fiddle's Win32Types FIX THIS: SymLoaderHash Always returns a type, defaults to Fiddle::TYPE_VOIDP I just didn't want to statically define PROC and others By doing this, it no longer raises ArgumentError when "No type mapping defined" --- lib/opengl-core.rb | 4 ++ .../gl-sym/fiddle-symbol-loader.rb | 42 ++++++++++++------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/lib/opengl-core.rb b/lib/opengl-core.rb index abf5782..a75c85f 100644 --- a/lib/opengl-core.rb +++ b/lib/opengl-core.rb @@ -11,6 +11,10 @@ require 'opengl-core/gl-sym' require 'opengl-core/gl-enums' require 'opengl-core/gl-commands' +require 'opengl-core/glx-enums' +require 'opengl-core/glx-commands' +require 'opengl-core/wgl-enums' +require 'opengl-core/wgl-commands' module GL diff --git a/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb b/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb index 50f5784..2772bdd 100644 --- a/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb +++ b/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb @@ -8,14 +8,22 @@ require 'fiddle' +require 'fiddle/import' +require 'fiddle/types' require 'rbconfig' - module GL module GLSym -class FiddleSymbolLoader +module Fiddle::Win32Types + +end + +class SymLoaderHash + extend Fiddle::Importer + @type_alias = {} + include Fiddle::Win32Types TYPE_MAPPINGS = { :'void' => Fiddle::TYPE_VOID, @@ -55,21 +63,28 @@ class FiddleSymbolLoader :'GLDEBUGPROC' => Fiddle::TYPE_VOIDP, :'GLDEBUGPROCARB' => Fiddle::TYPE_VOIDP, :'GLDEBUGPROCKHR' => Fiddle::TYPE_VOIDP, - :'GLDEBUGPROCAMD' => Fiddle::TYPE_VOIDP, - } - - TYPE_MAPPINGS.default_proc = -> (hash, key) do - if key.to_s.end_with?('*') - hash[key] = Fiddle::TYPE_VOIDP - else - raise ArgumentError, "No type mapping defined for #{key}" - end - end + :'GLDEBUGPROCAMD' => Fiddle::TYPE_VOIDP + } + def self.[](key) + if key.to_s.end_with?('*') + TYPE_MAPPINGS[key] = Fiddle::TYPE_VOIDP + elsif @type_alias.has_key?(key) + TYPE_MAPPINGS[key] = SymLoaderHash.parse_ctype key, @type_alias + else + TYPE_MAPPINGS[key] = Fiddle::TYPE_VOIDP +# raise ArgumentError, "No type mapping defined for #{key}" + end + end + def self.[]=(key, val) + TYPE_MAPPINGS[key] = val + end +end +class FiddleSymbolLoader def fiddle_typed(types) case types when Array then types.map { |i| fiddle_typed(i) } - else TYPE_MAPPINGS[types.to_sym] + else SymLoaderHash[types.to_s] end end @@ -118,7 +133,6 @@ def load_sym(name, types) begin sym = @opengl_lib[name.to_s] - Fiddle::Function.new( sym, fiddle_typed(types[:parameter_types]), From 84e359064cb6e56eeeabfde2a261830f84ae9c58 Mon Sep 17 00:00:00 2001 From: jgleesawn Date: Thu, 15 Jan 2015 22:39:23 -0500 Subject: [PATCH 3/7] Pre-debug output cleanup. Works if @opengl_lib = Fiddle.dlopen('opengl32.dll') in initialize. Otherwise if @opengl_lib = nil, it doesn't call functions properly for some reason. --- lib/opengl-core/gl-sym.rb | 8 ++- .../gl-sym/fiddle-symbol-loader.rb | 57 +++++++++++++++---- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/lib/opengl-core/gl-sym.rb b/lib/opengl-core/gl-sym.rb index a389e03..9db2c45 100644 --- a/lib/opengl-core/gl-sym.rb +++ b/lib/opengl-core/gl-sym.rb @@ -51,7 +51,13 @@ def load_sym(name) symfunc = self.loader.load_sym(name, GL_COMMAND_TYPES[name]) if symfunc.nil? - raise NoMethodError, "GL function #{name} could not be loaded" + symfunc = self.loader.load_ext_sym(name, GL_COMMAND_TYPES[name]) + puts "func address: #{symfunc.ptr.to_i} abi: #{symfunc.abi}" + if symfunc.ptr.to_i > -2 && symfunc.ptr.to_i < 5 + raise NoMethodError, "GL function #{name} could not be loaded" + end + else + puts "func address: #{symfunc.ptr.to_i} abi: #{symfunc.abi}" end symfunc diff --git a/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb b/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb index 2772bdd..1fc876e 100644 --- a/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb +++ b/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb @@ -16,10 +16,6 @@ module GL module GLSym -module Fiddle::Win32Types - -end - class SymLoaderHash extend Fiddle::Importer @type_alias = {} @@ -63,15 +59,18 @@ class SymLoaderHash :'GLDEBUGPROC' => Fiddle::TYPE_VOIDP, :'GLDEBUGPROCARB' => Fiddle::TYPE_VOIDP, :'GLDEBUGPROCKHR' => Fiddle::TYPE_VOIDP, - :'GLDEBUGPROCAMD' => Fiddle::TYPE_VOIDP + :'GLDEBUGPROCAMD' => Fiddle::TYPE_VOIDP, + + :'PROC' => Fiddle::TYPE_VOIDP, + :'HGLRC' => Fiddle::TYPE_VOIDP } def self.[](key) - if key.to_s.end_with?('*') + if TYPE_MAPPINGS.has_key?(key) + TYPE_MAPPINGS[key] + elsif key.to_s.end_with?('*') TYPE_MAPPINGS[key] = Fiddle::TYPE_VOIDP - elsif @type_alias.has_key?(key) - TYPE_MAPPINGS[key] = SymLoaderHash.parse_ctype key, @type_alias else - TYPE_MAPPINGS[key] = Fiddle::TYPE_VOIDP + TYPE_MAPPINGS[key] = SymLoaderHash.parse_ctype key.to_s, @type_alias # raise ArgumentError, "No type mapping defined for #{key}" end end @@ -84,12 +83,13 @@ class FiddleSymbolLoader def fiddle_typed(types) case types when Array then types.map { |i| fiddle_typed(i) } - else SymLoaderHash[types.to_s] + else SymLoaderHash[types.to_sym] end end def initialize @opengl_lib = nil + @glGetProcAddress = nil @loaded = {} end @@ -108,7 +108,7 @@ def unload # GL_COMMAND_TYPES. The returned value is cached in GL_COMMAND_FUNCTIONS and # returned if load_sym is called for the same name again. def load_sym(name, types) - if @opengl_lib.nil? + if @opengl_lib.nil? || @glGetProcAddress.nil? # Platform detection based on code by Thomas Enebo, written for this # Stack Overflow answer: http://stackoverflow.com/a/13586108/457812. As # such, this particular bit of code is also available under the same @@ -128,21 +128,54 @@ def load_sym(name, types) raise 'Unrecognized platform' end + getProcAddressName = + case host + when %r[ mac\sos | darwin ]ix + :aglGetProcAddress + when %r[ mswin | msys | mingw | cygwin | bcwin | wince | emc ]ix + :wglGetProcAddress + when %r[ linux | solaris | bsd]ix + :glXGetProcAddress + else + raise 'Unrecognized platform' + end + @opengl_lib = Fiddle.dlopen(lib_path) + getProcAddress = @opengl_lib[getProcAddressName.to_s] + + + @glGetProcAddress = Fiddle::Function.new( + getProcAddress, + fiddle_typed(GL_COMMAND_TYPES[getProcAddressName][:parameter_types]), + fiddle_typed(GL_COMMAND_TYPES[getProcAddressName][:return_type]) + ) + puts "#{getProcAddressName.to_s}: #{@glGetProcAddress.ptr}" end begin +puts "#{name.to_s}: #{fiddle_typed(types[:parameter_types]).to_s}, #{fiddle_typed(types[:return_type]).to_s}" + sym = @opengl_lib[name.to_s] + puts "sym: #{sym}" Fiddle::Function.new( sym, fiddle_typed(types[:parameter_types]), fiddle_typed(types[:return_type]) ) rescue Fiddle::DLError - nil + nil end if @opengl_lib end + def load_ext_sym(name, types) + sym = @glGetProcAddress.call(name.to_s) + Fiddle::Function.new( + sym, + fiddle_typed(types[:parameter_types]), + fiddle_typed(types[:return_type]) + ) + end + end # FiddleSymbolLoader end # GLSym From 584bddc4d8815068b00d38ed712cda66c70e5c64 Mon Sep 17 00:00:00 2001 From: jgleesawn Date: Thu, 15 Jan 2015 23:09:14 -0500 Subject: [PATCH 4/7] Removed debug messages. Added @opengl_lib = Fiddle::dlopen('opengl32.dll') to initialize For some reason it won't load functions properly otherwise. --- lib/opengl-core/gl-sym.rb | 3 --- lib/opengl-core/gl-sym/fiddle-symbol-loader.rb | 6 +----- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/opengl-core/gl-sym.rb b/lib/opengl-core/gl-sym.rb index 9db2c45..0899aa2 100644 --- a/lib/opengl-core/gl-sym.rb +++ b/lib/opengl-core/gl-sym.rb @@ -52,12 +52,9 @@ def load_sym(name) if symfunc.nil? symfunc = self.loader.load_ext_sym(name, GL_COMMAND_TYPES[name]) - puts "func address: #{symfunc.ptr.to_i} abi: #{symfunc.abi}" if symfunc.ptr.to_i > -2 && symfunc.ptr.to_i < 5 raise NoMethodError, "GL function #{name} could not be loaded" end - else - puts "func address: #{symfunc.ptr.to_i} abi: #{symfunc.abi}" end symfunc diff --git a/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb b/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb index 1fc876e..32082b8 100644 --- a/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb +++ b/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb @@ -88,7 +88,7 @@ def fiddle_typed(types) end def initialize - @opengl_lib = nil + @opengl_lib = Fiddle::dlopen('opengl32.dll') @glGetProcAddress = nil @loaded = {} end @@ -149,14 +149,10 @@ def load_sym(name, types) fiddle_typed(GL_COMMAND_TYPES[getProcAddressName][:parameter_types]), fiddle_typed(GL_COMMAND_TYPES[getProcAddressName][:return_type]) ) - puts "#{getProcAddressName.to_s}: #{@glGetProcAddress.ptr}" end begin -puts "#{name.to_s}: #{fiddle_typed(types[:parameter_types]).to_s}, #{fiddle_typed(types[:return_type]).to_s}" - sym = @opengl_lib[name.to_s] - puts "sym: #{sym}" Fiddle::Function.new( sym, fiddle_typed(types[:parameter_types]), From 6da1d02c9455bdebcb111aee5bc285ba394f3de0 Mon Sep 17 00:00:00 2001 From: jgleesawn Date: Fri, 16 Jan 2015 11:51:49 -0500 Subject: [PATCH 5/7] Removed commented code. Replaced Tabs with Spaces. --- gen_from_xml.rb | 4 -- lib/opengl-core/gl-sym.rb | 8 ++-- .../gl-sym/fiddle-symbol-loader.rb | 40 +++++++++---------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/gen_from_xml.rb b/gen_from_xml.rb index 485c9e1..9ab0450 100755 --- a/gen_from_xml.rb +++ b/gen_from_xml.rb @@ -101,10 +101,6 @@ def generate_binding_impl(document) begin gl_commands = get_commands(document) gl_enums = get_enums(document) -# puts document -# gl_commands.each { |comm| puts comm.to_s } -# puts gl_commands.to_s -# puts gl_enums.to_s pull_feature = proc { |feature| feature_name = feature['name'] diff --git a/lib/opengl-core/gl-sym.rb b/lib/opengl-core/gl-sym.rb index 0899aa2..a377875 100644 --- a/lib/opengl-core/gl-sym.rb +++ b/lib/opengl-core/gl-sym.rb @@ -51,10 +51,10 @@ def load_sym(name) symfunc = self.loader.load_sym(name, GL_COMMAND_TYPES[name]) if symfunc.nil? - symfunc = self.loader.load_ext_sym(name, GL_COMMAND_TYPES[name]) - if symfunc.ptr.to_i > -2 && symfunc.ptr.to_i < 5 - raise NoMethodError, "GL function #{name} could not be loaded" - end + symfunc = self.loader.load_ext_sym(name, GL_COMMAND_TYPES[name]) + if symfunc.ptr.to_i > -2 && symfunc.ptr.to_i < 5 + raise NoMethodError, "GL function #{name} could not be loaded" + end end symfunc diff --git a/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb b/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb index 32082b8..c640d7e 100644 --- a/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb +++ b/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb @@ -17,9 +17,9 @@ module GL module GLSym class SymLoaderHash - extend Fiddle::Importer - @type_alias = {} - include Fiddle::Win32Types + extend Fiddle::Importer + @type_alias = {} + include Fiddle::Win32Types TYPE_MAPPINGS = { :'void' => Fiddle::TYPE_VOID, @@ -61,22 +61,21 @@ class SymLoaderHash :'GLDEBUGPROCKHR' => Fiddle::TYPE_VOIDP, :'GLDEBUGPROCAMD' => Fiddle::TYPE_VOIDP, - :'PROC' => Fiddle::TYPE_VOIDP, - :'HGLRC' => Fiddle::TYPE_VOIDP - } - def self.[](key) - if TYPE_MAPPINGS.has_key?(key) - TYPE_MAPPINGS[key] - elsif key.to_s.end_with?('*') - TYPE_MAPPINGS[key] = Fiddle::TYPE_VOIDP - else - TYPE_MAPPINGS[key] = SymLoaderHash.parse_ctype key.to_s, @type_alias -# raise ArgumentError, "No type mapping defined for #{key}" - end - end - def self.[]=(key, val) - TYPE_MAPPINGS[key] = val - end + :'PROC' => Fiddle::TYPE_VOIDP, + :'HGLRC' => Fiddle::TYPE_VOIDP + } + def self.[](key) + if TYPE_MAPPINGS.has_key?(key) + TYPE_MAPPINGS[key] + elsif key.to_s.end_with?('*') + TYPE_MAPPINGS[key] = Fiddle::TYPE_VOIDP + else + TYPE_MAPPINGS[key] = SymLoaderHash.parse_ctype key.to_s, @type_alias #parse_ctype Raises an error on "unsupported type" + end + end + def self.[]=(key, val) + TYPE_MAPPINGS[key] = val + end end class FiddleSymbolLoader @@ -153,13 +152,14 @@ def load_sym(name, types) begin sym = @opengl_lib[name.to_s] + Fiddle::Function.new( sym, fiddle_typed(types[:parameter_types]), fiddle_typed(types[:return_type]) ) rescue Fiddle::DLError - nil + nil end if @opengl_lib end From 25f007069e59d0f1609e1f32d75c2fa7c5d208e4 Mon Sep 17 00:00:00 2001 From: jgleesawn Date: Fri, 16 Jan 2015 11:51:49 -0500 Subject: [PATCH 6/7] Removed commented code. Replaced Tabs with Spaces. --- gen_from_xml.rb | 4 - lib/opengl-core/gl-sym.rb | 8 +- .../gl-sym/fiddle-symbol-loader.rb | 78 +++++++++---------- 3 files changed, 43 insertions(+), 47 deletions(-) diff --git a/gen_from_xml.rb b/gen_from_xml.rb index 485c9e1..9ab0450 100755 --- a/gen_from_xml.rb +++ b/gen_from_xml.rb @@ -101,10 +101,6 @@ def generate_binding_impl(document) begin gl_commands = get_commands(document) gl_enums = get_enums(document) -# puts document -# gl_commands.each { |comm| puts comm.to_s } -# puts gl_commands.to_s -# puts gl_enums.to_s pull_feature = proc { |feature| feature_name = feature['name'] diff --git a/lib/opengl-core/gl-sym.rb b/lib/opengl-core/gl-sym.rb index 0899aa2..a377875 100644 --- a/lib/opengl-core/gl-sym.rb +++ b/lib/opengl-core/gl-sym.rb @@ -51,10 +51,10 @@ def load_sym(name) symfunc = self.loader.load_sym(name, GL_COMMAND_TYPES[name]) if symfunc.nil? - symfunc = self.loader.load_ext_sym(name, GL_COMMAND_TYPES[name]) - if symfunc.ptr.to_i > -2 && symfunc.ptr.to_i < 5 - raise NoMethodError, "GL function #{name} could not be loaded" - end + symfunc = self.loader.load_ext_sym(name, GL_COMMAND_TYPES[name]) + if symfunc.ptr.to_i > -2 && symfunc.ptr.to_i < 5 + raise NoMethodError, "GL function #{name} could not be loaded" + end end symfunc diff --git a/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb b/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb index 32082b8..b7213fc 100644 --- a/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb +++ b/lib/opengl-core/gl-sym/fiddle-symbol-loader.rb @@ -17,9 +17,9 @@ module GL module GLSym class SymLoaderHash - extend Fiddle::Importer - @type_alias = {} - include Fiddle::Win32Types + extend Fiddle::Importer + @type_alias = {} + include Fiddle::Win32Types TYPE_MAPPINGS = { :'void' => Fiddle::TYPE_VOID, @@ -61,22 +61,21 @@ class SymLoaderHash :'GLDEBUGPROCKHR' => Fiddle::TYPE_VOIDP, :'GLDEBUGPROCAMD' => Fiddle::TYPE_VOIDP, - :'PROC' => Fiddle::TYPE_VOIDP, - :'HGLRC' => Fiddle::TYPE_VOIDP - } - def self.[](key) - if TYPE_MAPPINGS.has_key?(key) - TYPE_MAPPINGS[key] - elsif key.to_s.end_with?('*') - TYPE_MAPPINGS[key] = Fiddle::TYPE_VOIDP - else - TYPE_MAPPINGS[key] = SymLoaderHash.parse_ctype key.to_s, @type_alias -# raise ArgumentError, "No type mapping defined for #{key}" - end - end - def self.[]=(key, val) - TYPE_MAPPINGS[key] = val - end + :'PROC' => Fiddle::TYPE_VOIDP, + :'HGLRC' => Fiddle::TYPE_VOIDP + } + def self.[](key) + if TYPE_MAPPINGS.has_key?(key) + TYPE_MAPPINGS[key] + elsif key.to_s.end_with?('*') + TYPE_MAPPINGS[key] = Fiddle::TYPE_VOIDP + else + TYPE_MAPPINGS[key] = SymLoaderHash.parse_ctype key.to_s, @type_alias #parse_ctype Raises an error on "unsupported type" + end + end + def self.[]=(key, val) + TYPE_MAPPINGS[key] = val + end end class FiddleSymbolLoader @@ -128,49 +127,50 @@ def load_sym(name, types) raise 'Unrecognized platform' end - getProcAddressName = - case host + getProcAddressName = + case host when %r[ mac\sos | darwin ]ix - :aglGetProcAddress + :aglGetProcAddress when %r[ mswin | msys | mingw | cygwin | bcwin | wince | emc ]ix - :wglGetProcAddress + :wglGetProcAddress when %r[ linux | solaris | bsd]ix - :glXGetProcAddress + :glXGetProcAddress else raise 'Unrecognized platform' end @opengl_lib = Fiddle.dlopen(lib_path) - getProcAddress = @opengl_lib[getProcAddressName.to_s] + getProcAddress = @opengl_lib[getProcAddressName.to_s] - @glGetProcAddress = Fiddle::Function.new( - getProcAddress, - fiddle_typed(GL_COMMAND_TYPES[getProcAddressName][:parameter_types]), - fiddle_typed(GL_COMMAND_TYPES[getProcAddressName][:return_type]) - ) + @glGetProcAddress = Fiddle::Function.new( + getProcAddress, + fiddle_typed(GL_COMMAND_TYPES[getProcAddressName][:parameter_types]), + fiddle_typed(GL_COMMAND_TYPES[getProcAddressName][:return_type]) + ) end begin sym = @opengl_lib[name.to_s] + Fiddle::Function.new( sym, fiddle_typed(types[:parameter_types]), fiddle_typed(types[:return_type]) ) rescue Fiddle::DLError - nil + nil end if @opengl_lib end - def load_ext_sym(name, types) - sym = @glGetProcAddress.call(name.to_s) - Fiddle::Function.new( - sym, - fiddle_typed(types[:parameter_types]), - fiddle_typed(types[:return_type]) - ) - end + def load_ext_sym(name, types) + sym = @glGetProcAddress.call(name.to_s) + Fiddle::Function.new( + sym, + fiddle_typed(types[:parameter_types]), + fiddle_typed(types[:return_type]) + ) + end end # FiddleSymbolLoader From 760ffe831a53bee2ddd8b2ec112b15ee76f3fe9e Mon Sep 17 00:00:00 2001 From: jgleesawn Date: Fri, 16 Jan 2015 12:13:09 -0500 Subject: [PATCH 7/7] Last commit about spacing hopefully. --- lib/opengl-core/gl-sym.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/opengl-core/gl-sym.rb b/lib/opengl-core/gl-sym.rb index a377875..e4a40ed 100644 --- a/lib/opengl-core/gl-sym.rb +++ b/lib/opengl-core/gl-sym.rb @@ -51,10 +51,10 @@ def load_sym(name) symfunc = self.loader.load_sym(name, GL_COMMAND_TYPES[name]) if symfunc.nil? - symfunc = self.loader.load_ext_sym(name, GL_COMMAND_TYPES[name]) - if symfunc.ptr.to_i > -2 && symfunc.ptr.to_i < 5 + symfunc = self.loader.load_ext_sym(name, GL_COMMAND_TYPES[name]) + if symfunc.ptr.to_i > -2 && symfunc.ptr.to_i < 5 raise NoMethodError, "GL function #{name} could not be loaded" - end + end end symfunc