Created
September 2, 2013 15:13
-
-
Save vaiorabbit/6413933 to your computer and use it in GitHub Desktop.
ポイントはrescue節でのwglGetProcAddress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module OpenGL | |
| def self.bind_command( sym ) | |
| begin | |
| GL_FUNCTIONS_MAP[sym] = Fiddle::Function.new( @@gl_dll[sym.to_s], | |
| GL_FUNCTIONS_ARGS_MAP[sym], | |
| GL_FUNCTIONS_RETVAL_MAP[sym] ) | |
| rescue Exception => e | |
| func_ptr = wglGetProcAddress(sym.to_s) | |
| # p sym.to_s | |
| GL_FUNCTIONS_MAP[sym] = Fiddle::Function.new( func_ptr, | |
| GL_FUNCTIONS_ARGS_MAP[sym], | |
| GL_FUNCTIONS_RETVAL_MAP[sym] ) | |
| raise RuntimeError if GL_FUNCTIONS_RETVAL_MAP[sym] == nil | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'fiddle' | |
| module OpenGL | |
| WGL_FUNCTIONS_MAP = {} | |
| WGL_FUNCTIONS_ARGS_MAP = {} | |
| WGL_FUNCTIONS_RETVAL_MAP = {} | |
| def self.get_wgl_command( sym ) | |
| if WGL_FUNCTIONS_MAP[sym] == nil | |
| bind_wgl_command( sym ) | |
| end | |
| return WGL_FUNCTIONS_MAP[sym] | |
| end | |
| def self.bind_wgl_command( sym ) | |
| WGL_FUNCTIONS_MAP[sym] = Fiddle::Function.new( @@gl_dll[sym.to_s], | |
| WGL_FUNCTIONS_ARGS_MAP[sym], | |
| WGL_FUNCTIONS_RETVAL_MAP[sym] ) | |
| raise RuntimeError if WGL_FUNCTIONS_RETVAL_MAP[sym] == nil | |
| end | |
| WGL_FUNCTIONS_ARGS_MAP[:wglGetProcAddress] = [Fiddle::TYPE_VOIDP] | |
| WGL_FUNCTIONS_RETVAL_MAP[:wglGetProcAddress] = Fiddle::TYPE_VOIDP | |
| def wglGetProcAddress(_lpszProc_) | |
| f = OpenGL::get_wgl_command(:wglGetProcAddress) | |
| f.call(_lpszProc_) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment