diff --git a/README.md b/README.md index 208fd7e..e70177f 100644 --- a/README.md +++ b/README.md @@ -109,13 +109,13 @@ https://github.com/vaiorabbit/ruby-opengl ## Contents ## * 'opengl.rb' includes these scripts: - * 'opengl_command.rb' : OpenGL command wrapper (glDrawRangeElements, etc.). Generated via generator/generate_command.rb. - * 'opengl_enum.rb' : OpenGL enum wrapper (GL_TRIANGLE_STRIP, etc.). Generated via generator/generate_enum.rb. - * 'opengl_common.rb' : Provides utility functions. - * 'opengl_platform.rb' : Provides platform check functions (OpneGL.get_platform). - * 'opengl_windows.rb' : Provides functions for Windows platform (wglGetProcAddress, wglGetCurrentContext, wglGetCurrentDC). - * 'opengl_macosx.rb' : Provides functions for Mac OS X platform (CGLGetCurrentContext, CGLGetShareGroup). - * 'opengl_linux.rb' : Provides functions for Linux (X Window) platform (glXGetCurrentContext, glXGetCurrentDisplay). + * 'opengl_command.rb' : OpenGL command wrapper (glDrawRangeElements, etc.). Generated via generator/generate_command.rb. + * 'opengl_enum.rb' : OpenGL enum wrapper (GL_TRIANGLE_STRIP, etc.). Generated via generator/generate_enum.rb. + * 'opengl_common.rb' : Provides utility functions. + * 'opengl_platform.rb' : Provides platform check functions (OpneGL.get_platform). + * 'opengl_interface_cgl.rb' : Provides functions for the Mac OS X platform (CGLGetCurrentContext, CGLGetShareGroup). + * 'opengl_interface_glx.rb' : Provides functions for various X11 platforms (glXGetCurrentContext, glXGetCurrentDisplay). + * 'opengl_interface_wgl.rb' : Provides functions for the Windows platform (wglGetProcAddress, wglGetCurrentContext, wglGetCurrentDC). * 'opengl_es.rb' is almost the same with 'opengl.rb', except for including 'opengl_es_command.rb' and 'opengl_es_enum.rb'. @@ -489,13 +489,13 @@ https://github.com/vaiorabbit/ruby-opengl ## 内容 ## * 'opengl.rb' を require することで下記のスクリプトを取り込みます: - * 'opengl_command.rb' : OpenGL 関数のラッパーコード (glDrawRangeElements, etc.)。 generator/generate_command.rb で自動生成されたものです。 - * 'opengl_enum.rb' : OpenGL enum のラッパーコード (GL_TRIANGLE_STRIP, etc.)。 generator/generate_enum.rb で自動生成されたものです。 - * 'opengl_common.rb' : 共通のユーティリティ関数を提供しています。 - * 'opengl_platform.rb' : 動作プラットフォームの判別機能を提供しています (OpneGL.get_platform)。 - * 'opengl_windows.rb' : Windows 用の機能を提供しています (wglGetProcAddress, wglGetCurrentContext, wglGetCurrentDC). - * 'opengl_macosx.rb' : Mac OS X 用の機能を提供しています (CGLGetCurrentContext, CGLGetShareGroup). - * 'opengl_linux.rb' : Linux (X Window) 用の機能を提供しています (glXGetCurrentContext, glXGetCurrentDisplay). + * 'opengl_command.rb' : OpenGL 関数のラッパーコード (glDrawRangeElements, etc.)。 generator/generate_command.rb で自動生成されたものです。 + * 'opengl_enum.rb' : OpenGL enum のラッパーコード (GL_TRIANGLE_STRIP, etc.)。 generator/generate_enum.rb で自動生成されたものです。 + * 'opengl_common.rb' : 共通のユーティリティ関数を提供しています。 + * 'opengl_platform.rb' : 動作プラットフォームの判別機能を提供しています (OpneGL.get_platform)。 + * 'opengl_interface_cgl.rb' : Mac OS X 用の機能を提供しています (CGLGetCurrentContext, CGLGetShareGroup). + * 'opengl_interface_glx.rb' : X11 用の機能を提供しています (glXGetCurrentContext, glXGetCurrentDisplay). + * 'opengl_interface_wgl.rb' : Windows 用の機能を提供しています (wglGetProcAddress, wglGetCurrentContext, wglGetCurrentDC). * 'opengl_es.rb' は 'opengl_es_command.rb' と 'opengl_es_enum.rb' を取り込む以外は 'opengl.rb' と同じです。 diff --git a/lib/opengl.rb b/lib/opengl.rb index df5335a..02efe10 100644 --- a/lib/opengl.rb +++ b/lib/opengl.rb @@ -4,11 +4,11 @@ require_relative 'opengl_command' case GL.get_platform when :OPENGL_PLATFORM_WINDOWS - require_relative 'opengl_windows' + require_relative 'opengl_interface_wgl' when :OPENGL_PLATFORM_MACOSX - require_relative 'opengl_macosx' -when :OPENGL_PLATFORM_LINUX - require_relative 'opengl_linux' + require_relative 'opengl_interface_cgl' +when :OPENGL_PLATFORM_LINUX, :OPENGL_PLATFORM_FREEBSD + require_relative 'opengl_interface_glx' end =begin diff --git a/lib/opengl_es.rb b/lib/opengl_es.rb index 3bbcb76..33762ee 100644 --- a/lib/opengl_es.rb +++ b/lib/opengl_es.rb @@ -3,7 +3,7 @@ require_relative 'opengl_es_enum' require_relative 'opengl_es_command' if GL.get_platform == :OPENGL_PLATFORM_WINDOWS - require_relative 'opengl_windows' + require_relative 'opengl_interface_wgl' end =begin diff --git a/lib/opengl_macosx.rb b/lib/opengl_interface_cgl.rb similarity index 100% rename from lib/opengl_macosx.rb rename to lib/opengl_interface_cgl.rb diff --git a/lib/opengl_linux.rb b/lib/opengl_interface_glx.rb similarity index 100% rename from lib/opengl_linux.rb rename to lib/opengl_interface_glx.rb diff --git a/lib/opengl_windows.rb b/lib/opengl_interface_wgl.rb similarity index 100% rename from lib/opengl_windows.rb rename to lib/opengl_interface_wgl.rb diff --git a/lib/opengl_platform.rb b/lib/opengl_platform.rb index 9c0c7b8..f6c07fb 100644 --- a/lib/opengl_platform.rb +++ b/lib/opengl_platform.rb @@ -1,13 +1,17 @@ require 'rbconfig' module GL - @@opengl_platform = case RbConfig::CONFIG['host_os'] + host_os = RbConfig::CONFIG['host_os'] + + @@opengl_platform = case host_os when /mswin|msys|mingw|cygwin/ :OPENGL_PLATFORM_WINDOWS when /darwin/ :OPENGL_PLATFORM_MACOSX when /linux/ :OPENGL_PLATFORM_LINUX + when /freebsd/ + :OPENGL_PLATFORM_FREEBSD else raise RuntimeError, "OpenGL : Unknown OS: #{host_os.inspect}" end