opengl-bindings2 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +686 -0
- data/LICENSE.txt +21 -0
- data/README.md +564 -0
- data/lib/glfw.rb +699 -0
- data/lib/glu.rb +366 -0
- data/lib/glut.rb +575 -0
- data/lib/opengl.rb +36 -0
- data/lib/opengl_command.rb +7356 -0
- data/lib/opengl_common.rb +81 -0
- data/lib/opengl_enum.rb +1818 -0
- data/lib/opengl_es.rb +31 -0
- data/lib/opengl_es_command.rb +2526 -0
- data/lib/opengl_es_enum.rb +1011 -0
- data/lib/opengl_es_ext.rb +28 -0
- data/lib/opengl_es_ext_command.rb +8969 -0
- data/lib/opengl_es_ext_enum.rb +6078 -0
- data/lib/opengl_ext.rb +28 -0
- data/lib/opengl_ext_command.rb +33331 -0
- data/lib/opengl_ext_common.rb +52 -0
- data/lib/opengl_ext_enum.rb +14137 -0
- data/lib/opengl_linux.rb +63 -0
- data/lib/opengl_macosx.rb +68 -0
- data/lib/opengl_platform.rb +43 -0
- data/lib/opengl_windows.rb +71 -0
- data/sample/README.md +55 -0
- data/sample/glfw_get.bat +6 -0
- data/sample/glfw_get.sh +3 -0
- data/sample/report_env.rb +84 -0
- data/sample/simple.rb +57 -0
- metadata +75 -0
data/lib/opengl_linux.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'fiddle'
|
2
|
+
|
3
|
+
module GL
|
4
|
+
|
5
|
+
GLX_FUNCTIONS_MAP = {}
|
6
|
+
GLX_FUNCTIONS_ARGS_MAP = {}
|
7
|
+
GLX_FUNCTIONS_RETVAL_MAP = {}
|
8
|
+
|
9
|
+
def self.get_glx_command( sym )
|
10
|
+
if GLX_FUNCTIONS_MAP[sym] == nil
|
11
|
+
bind_glx_command( sym )
|
12
|
+
end
|
13
|
+
return GLX_FUNCTIONS_MAP[sym]
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.bind_glx_command( sym )
|
17
|
+
GLX_FUNCTIONS_MAP[sym] = Fiddle::Function.new( @@gl_dll[sym.to_s],
|
18
|
+
GLX_FUNCTIONS_ARGS_MAP[sym],
|
19
|
+
GLX_FUNCTIONS_RETVAL_MAP[sym] )
|
20
|
+
raise RuntimeError if GLX_FUNCTIONS_RETVAL_MAP[sym] == nil
|
21
|
+
end
|
22
|
+
|
23
|
+
GLX_FUNCTIONS_ARGS_MAP[:glXGetCurrentContext] = []
|
24
|
+
GLX_FUNCTIONS_RETVAL_MAP[:glXGetCurrentContext] = Fiddle::TYPE_VOIDP
|
25
|
+
|
26
|
+
def glXGetCurrentContext()
|
27
|
+
f = GL::get_glx_command(:glXGetCurrentContext)
|
28
|
+
f.call()
|
29
|
+
end
|
30
|
+
|
31
|
+
GLX_FUNCTIONS_ARGS_MAP[:glXGetCurrentDisplay] = [Fiddle::TYPE_VOIDP]
|
32
|
+
GLX_FUNCTIONS_RETVAL_MAP[:glXGetCurrentDisplay] = Fiddle::TYPE_VOIDP
|
33
|
+
|
34
|
+
def glXGetCurrentDisplay(_glx_ctxobj_)
|
35
|
+
f = GL::get_glx_command(:glXGetCurrentDisplay)
|
36
|
+
f.call(_glx_ctxobj_)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
=begin
|
42
|
+
Ruby-OpenGL : Yet another OpenGL wrapper for Ruby (and wrapper code generator)
|
43
|
+
Copyright (c) 2013-2022 vaiorabbit <http://twitter.com/vaiorabbit>
|
44
|
+
|
45
|
+
This software is provided 'as-is', without any express or implied
|
46
|
+
warranty. In no event will the authors be held liable for any damages
|
47
|
+
arising from the use of this software.
|
48
|
+
|
49
|
+
Permission is granted to anyone to use this software for any purpose,
|
50
|
+
including commercial applications, and to alter it and redistribute it
|
51
|
+
freely, subject to the following restrictions:
|
52
|
+
|
53
|
+
1. The origin of this software must not be misrepresented; you must not
|
54
|
+
claim that you wrote the original software. If you use this software
|
55
|
+
in a product, an acknowledgment in the product documentation would be
|
56
|
+
appreciated but is not required.
|
57
|
+
|
58
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
59
|
+
misrepresented as being the original software.
|
60
|
+
|
61
|
+
3. This notice may not be removed or altered from any source
|
62
|
+
distribution.
|
63
|
+
=end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'fiddle'
|
2
|
+
|
3
|
+
module GL
|
4
|
+
|
5
|
+
CGL_FUNCTIONS_MAP = {}
|
6
|
+
CGL_FUNCTIONS_ARGS_MAP = {}
|
7
|
+
CGL_FUNCTIONS_RETVAL_MAP = {}
|
8
|
+
|
9
|
+
@@cgl_dll = nil
|
10
|
+
|
11
|
+
def self.get_cgl_command( sym )
|
12
|
+
if @@cgl_dll == nil
|
13
|
+
@@cgl_dll = Fiddle.dlopen('/System/Library/Frameworks/OpenGL.framework/OpenGL')
|
14
|
+
end
|
15
|
+
if CGL_FUNCTIONS_MAP[sym] == nil
|
16
|
+
bind_cgl_command( sym )
|
17
|
+
end
|
18
|
+
return CGL_FUNCTIONS_MAP[sym]
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.bind_cgl_command( sym )
|
22
|
+
CGL_FUNCTIONS_MAP[sym] = Fiddle::Function.new( @@cgl_dll[sym.to_s],
|
23
|
+
CGL_FUNCTIONS_ARGS_MAP[sym],
|
24
|
+
CGL_FUNCTIONS_RETVAL_MAP[sym] )
|
25
|
+
raise RuntimeError if CGL_FUNCTIONS_RETVAL_MAP[sym] == nil
|
26
|
+
end
|
27
|
+
|
28
|
+
CGL_FUNCTIONS_ARGS_MAP[:CGLGetCurrentContext] = []
|
29
|
+
CGL_FUNCTIONS_RETVAL_MAP[:CGLGetCurrentContext] = Fiddle::TYPE_VOIDP
|
30
|
+
|
31
|
+
def CGLGetCurrentContext()
|
32
|
+
f = GL::get_cgl_command(:CGLGetCurrentContext)
|
33
|
+
f.call()
|
34
|
+
end
|
35
|
+
|
36
|
+
CGL_FUNCTIONS_ARGS_MAP[:CGLGetShareGroup] = [Fiddle::TYPE_VOIDP]
|
37
|
+
CGL_FUNCTIONS_RETVAL_MAP[:CGLGetShareGroup] = Fiddle::TYPE_VOIDP
|
38
|
+
|
39
|
+
def CGLGetShareGroup(_cgl_ctxobj_)
|
40
|
+
f = GL::get_cgl_command(:CGLGetShareGroup)
|
41
|
+
f.call(_cgl_ctxobj_)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
=begin
|
47
|
+
Ruby-OpenGL : Yet another OpenGL wrapper for Ruby (and wrapper code generator)
|
48
|
+
Copyright (c) 2013-2022 vaiorabbit <http://twitter.com/vaiorabbit>
|
49
|
+
|
50
|
+
This software is provided 'as-is', without any express or implied
|
51
|
+
warranty. In no event will the authors be held liable for any damages
|
52
|
+
arising from the use of this software.
|
53
|
+
|
54
|
+
Permission is granted to anyone to use this software for any purpose,
|
55
|
+
including commercial applications, and to alter it and redistribute it
|
56
|
+
freely, subject to the following restrictions:
|
57
|
+
|
58
|
+
1. The origin of this software must not be misrepresented; you must not
|
59
|
+
claim that you wrote the original software. If you use this software
|
60
|
+
in a product, an acknowledgment in the product documentation would be
|
61
|
+
appreciated but is not required.
|
62
|
+
|
63
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
64
|
+
misrepresented as being the original software.
|
65
|
+
|
66
|
+
3. This notice may not be removed or altered from any source
|
67
|
+
distribution.
|
68
|
+
=end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
module GL
|
4
|
+
@@opengl_platform = case RbConfig::CONFIG['host_os']
|
5
|
+
when /mswin|msys|mingw|cygwin/
|
6
|
+
:OPENGL_PLATFORM_WINDOWS
|
7
|
+
when /darwin/
|
8
|
+
:OPENGL_PLATFORM_MACOSX
|
9
|
+
when /linux/
|
10
|
+
:OPENGL_PLATFORM_LINUX
|
11
|
+
else
|
12
|
+
raise RuntimeError, "OpenGL : Unknown OS: #{host_os.inspect}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.get_platform()
|
16
|
+
return @@opengl_platform
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
=begin
|
22
|
+
Ruby-OpenGL : Yet another OpenGL wrapper for Ruby (and wrapper code generator)
|
23
|
+
Copyright (c) 2013-2022 vaiorabbit <http://twitter.com/vaiorabbit>
|
24
|
+
|
25
|
+
This software is provided 'as-is', without any express or implied
|
26
|
+
warranty. In no event will the authors be held liable for any damages
|
27
|
+
arising from the use of this software.
|
28
|
+
|
29
|
+
Permission is granted to anyone to use this software for any purpose,
|
30
|
+
including commercial applications, and to alter it and redistribute it
|
31
|
+
freely, subject to the following restrictions:
|
32
|
+
|
33
|
+
1. The origin of this software must not be misrepresented; you must not
|
34
|
+
claim that you wrote the original software. If you use this software
|
35
|
+
in a product, an acknowledgment in the product documentation would be
|
36
|
+
appreciated but is not required.
|
37
|
+
|
38
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
39
|
+
misrepresented as being the original software.
|
40
|
+
|
41
|
+
3. This notice may not be removed or altered from any source
|
42
|
+
distribution.
|
43
|
+
=end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'fiddle'
|
2
|
+
|
3
|
+
module GL
|
4
|
+
|
5
|
+
WGL_FUNCTIONS_MAP = {}
|
6
|
+
WGL_FUNCTIONS_ARGS_MAP = {}
|
7
|
+
WGL_FUNCTIONS_RETVAL_MAP = {}
|
8
|
+
|
9
|
+
def self.get_wgl_command( sym )
|
10
|
+
if WGL_FUNCTIONS_MAP[sym] == nil
|
11
|
+
bind_wgl_command( sym )
|
12
|
+
end
|
13
|
+
return WGL_FUNCTIONS_MAP[sym]
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.bind_wgl_command( sym )
|
17
|
+
WGL_FUNCTIONS_MAP[sym] = Fiddle::Function.new( @@gl_dll[sym.to_s],
|
18
|
+
WGL_FUNCTIONS_ARGS_MAP[sym],
|
19
|
+
WGL_FUNCTIONS_RETVAL_MAP[sym] )
|
20
|
+
raise RuntimeError if WGL_FUNCTIONS_RETVAL_MAP[sym] == nil
|
21
|
+
end
|
22
|
+
|
23
|
+
WGL_FUNCTIONS_ARGS_MAP[:wglGetProcAddress] = [Fiddle::TYPE_VOIDP]
|
24
|
+
WGL_FUNCTIONS_RETVAL_MAP[:wglGetProcAddress] = Fiddle::TYPE_VOIDP
|
25
|
+
|
26
|
+
def self.wglGetProcAddress(_lpszProc_)
|
27
|
+
f = GL::get_wgl_command(:wglGetProcAddress)
|
28
|
+
f.call(_lpszProc_)
|
29
|
+
end
|
30
|
+
|
31
|
+
WGL_FUNCTIONS_ARGS_MAP[:wglGetCurrentContext] = []
|
32
|
+
WGL_FUNCTIONS_RETVAL_MAP[:wglGetCurrentContext] = Fiddle::TYPE_VOIDP
|
33
|
+
|
34
|
+
def wglGetCurrentContext()
|
35
|
+
f = GL::get_wgl_command(:wglGetCurrentContext)
|
36
|
+
f.call()
|
37
|
+
end
|
38
|
+
|
39
|
+
WGL_FUNCTIONS_ARGS_MAP[:wglGetCurrentDC] = []
|
40
|
+
WGL_FUNCTIONS_RETVAL_MAP[:wglGetCurrentDC] = Fiddle::TYPE_VOIDP
|
41
|
+
|
42
|
+
def wglGetCurrentDC()
|
43
|
+
f = GL::get_wgl_command(:wglGetCurrentDC)
|
44
|
+
f.call()
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
=begin
|
50
|
+
Ruby-OpenGL : Yet another OpenGL wrapper for Ruby (and wrapper code generator)
|
51
|
+
Copyright (c) 2013-2022 vaiorabbit <http://twitter.com/vaiorabbit>
|
52
|
+
|
53
|
+
This software is provided 'as-is', without any express or implied
|
54
|
+
warranty. In no event will the authors be held liable for any damages
|
55
|
+
arising from the use of this software.
|
56
|
+
|
57
|
+
Permission is granted to anyone to use this software for any purpose,
|
58
|
+
including commercial applications, and to alter it and redistribute it
|
59
|
+
freely, subject to the following restrictions:
|
60
|
+
|
61
|
+
1. The origin of this software must not be misrepresented; you must not
|
62
|
+
claim that you wrote the original software. If you use this software
|
63
|
+
in a product, an acknowledgment in the product documentation would be
|
64
|
+
appreciated but is not required.
|
65
|
+
|
66
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
67
|
+
misrepresented as being the original software.
|
68
|
+
|
69
|
+
3. This notice may not be removed or altered from any source
|
70
|
+
distribution.
|
71
|
+
=end
|
data/sample/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
For more samples, visit https://github.com/vaiorabbit/ruby-opengl/tree/master/sample .
|
2
|
+
|
3
|
+
## Getting GLFW (http://www.glfw.org) ##
|
4
|
+
|
5
|
+
* Windows
|
6
|
+
* Put glfw3.dll here. You can download pre-compiled binaries via:
|
7
|
+
* http://www.glfw.org/download.html
|
8
|
+
* If you have RubyInstaller2 with DevKit(MSYS2 gcc & make) and CMake, you can use glfw_build.bat:
|
9
|
+
* > ./glfw_build.bat
|
10
|
+
|
11
|
+
* Mac OS X
|
12
|
+
* Run ./glfw_build.sh to get ./libglfw.dylib.
|
13
|
+
|
14
|
+
## Getting GLUT ##
|
15
|
+
|
16
|
+
* Windows
|
17
|
+
* Use freeglut (http://freeglut.sourceforge.net).
|
18
|
+
* See https://sourceforge.net/p/freeglut/code/HEAD/tree/trunk/freeglut/freeglut/COPYING for copyright information
|
19
|
+
* Put freeglut.dll here.
|
20
|
+
* Windows pre-compiled binaries:
|
21
|
+
* http://www.transmissionzero.co.uk/software/freeglut-devel/
|
22
|
+
|
23
|
+
* Mac OS X
|
24
|
+
* glut.rb refers /System/Library/Frameworks/GLUT.framework by default.
|
25
|
+
* If you want to use other GLUT dll, specify the dll path and file name
|
26
|
+
via the arguments of 'GLUT.load_dll'.
|
27
|
+
* See util/setup_dll.rb for example.
|
28
|
+
* https://github.com/vaiorabbit/ruby-opengl/blob/master/sample/util/setup_dll.rb
|
29
|
+
|
30
|
+
-------------------------------------------------------------------------------
|
31
|
+
|
32
|
+
## GLFWのセットアップ (http://www.glfw.org) ##
|
33
|
+
|
34
|
+
* Windows
|
35
|
+
* glfw3.dll をここに配置してください。コンパイル済みバイナリはこちら:
|
36
|
+
* http://www.glfw.org/download.html
|
37
|
+
* RubyInstaller2 とその DevKit(MSYS2 gcc & make)、さらに CMake もインストールしている場合は glfw_build.bat も使えます:
|
38
|
+
* > ./glfw_build.bat
|
39
|
+
|
40
|
+
* Mac OS X
|
41
|
+
* ./glfw_build.sh を実行すると ./libglfw.dylib ができあがります。
|
42
|
+
|
43
|
+
## GLUTのセットアップ ##
|
44
|
+
|
45
|
+
* Windows
|
46
|
+
* freeglut を使ってください (http://freeglut.sourceforge.net).
|
47
|
+
* freeglut.dll をここに配置してください。
|
48
|
+
* コンパイル済みバイナリはこちら:
|
49
|
+
* http://www.transmissionzero.co.uk/software/freeglut-devel/
|
50
|
+
|
51
|
+
* Mac OS X
|
52
|
+
* glut.rb はデフォルトで /System/Library/Frameworks/GLUT.framework を使います。
|
53
|
+
* もしこれとは別のGLUTを使いたい場合は 'GLUT.load_dll' の引数で指定してください。
|
54
|
+
* util/setup_dll.rb が使用例となっています。
|
55
|
+
* https://github.com/vaiorabbit/ruby-opengl/blob/master/sample/util/setup_dll.rb
|
data/sample/glfw_get.bat
ADDED
data/sample/glfw_get.sh
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
# opengl-bindings
|
4
|
+
# * http://rubygems.org/gems/opengl-bindings
|
5
|
+
# * http://github.com/vaiorabbit/ruby-opengl
|
6
|
+
#
|
7
|
+
require 'opengl'
|
8
|
+
require 'glfw'
|
9
|
+
|
10
|
+
if __FILE__ == $0
|
11
|
+
|
12
|
+
GLFW.load_lib()
|
13
|
+
GLFW.Init()
|
14
|
+
|
15
|
+
window = nil
|
16
|
+
|
17
|
+
# https://www.opengl.org/wiki/History_of_OpenGL
|
18
|
+
versions = [[4, 5], [4, 4], [4, 3], [4, 2], [4, 1], [4, 0],
|
19
|
+
[3, 3], [3, 2], [3, 1], [3, 0],
|
20
|
+
[2, 1], [2, 0],
|
21
|
+
[1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [1, 0]]
|
22
|
+
|
23
|
+
versions.each do |version|
|
24
|
+
ver_major = version[0]
|
25
|
+
ver_minor = version[1]
|
26
|
+
GLFW.DefaultWindowHints()
|
27
|
+
if GL.get_platform == :OPENGL_PLATFORM_MACOSX
|
28
|
+
GLFW.WindowHint(GLFW::OPENGL_FORWARD_COMPAT, GLFW::TRUE)
|
29
|
+
end
|
30
|
+
if ver_major >= 4 || (ver_major >= 3 && ver_minor >= 2)
|
31
|
+
GLFW.WindowHint(GLFW::OPENGL_PROFILE, GLFW::OPENGL_CORE_PROFILE)
|
32
|
+
else
|
33
|
+
GLFW.WindowHint(GLFW::OPENGL_PROFILE, GLFW::OPENGL_ANY_PROFILE)
|
34
|
+
end
|
35
|
+
GLFW.WindowHint(GLFW::CONTEXT_VERSION_MAJOR, ver_major)
|
36
|
+
GLFW.WindowHint(GLFW::CONTEXT_VERSION_MINOR, ver_minor)
|
37
|
+
GLFW.WindowHint(GLFW::DECORATED, 0)
|
38
|
+
window = GLFW.CreateWindow( 1, 1, "Report OpenGL Environment", nil, nil )
|
39
|
+
break unless window.null?
|
40
|
+
end
|
41
|
+
|
42
|
+
if window.null?
|
43
|
+
GLFW.DefaultWindowHints()
|
44
|
+
GLFW.WindowHint(GLFW::DECORATED, 0)
|
45
|
+
window = GLFW.CreateWindow( 1, 1, "Report OpenGL Environment", nil, nil )
|
46
|
+
if window.null?
|
47
|
+
puts "Failed to create the OpenGL context."
|
48
|
+
GLFW.Terminate()
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
GLFW.MakeContextCurrent( window )
|
54
|
+
|
55
|
+
GL.load_lib()
|
56
|
+
|
57
|
+
version_string = GL::GetString(GL::VERSION).to_s
|
58
|
+
version_number = version_string.split(/\./)
|
59
|
+
|
60
|
+
vendor_string = GL::GetString(GL::VENDOR).to_s
|
61
|
+
renderer_string = GL::GetString(GL::RENDERER).to_s
|
62
|
+
slangver_string = GL::GetString(GL::SHADING_LANGUAGE_VERSION).to_s
|
63
|
+
|
64
|
+
puts "Version : #{version_string}"
|
65
|
+
puts "Vendor : #{vendor_string}"
|
66
|
+
puts "Renderer : #{renderer_string}"
|
67
|
+
puts "Shader : #{slangver_string}"
|
68
|
+
puts "Extensions :"
|
69
|
+
if version_number[0].to_i >= 3
|
70
|
+
# glGetString(GL_EXTENSIONS) was deprecated in OpenGL 3.0
|
71
|
+
# Ref.: http://sourceforge.net/p/glew/bugs/120/
|
72
|
+
extensions_count_buf = ' '
|
73
|
+
GL::GetIntegerv( GL::NUM_EXTENSIONS, extensions_count_buf )
|
74
|
+
extensions_count = extensions_count_buf.unpack('L')[0]
|
75
|
+
extensions_count.times do |i|
|
76
|
+
puts GL::GetStringi( GL::EXTENSIONS, i ).to_s
|
77
|
+
end
|
78
|
+
else
|
79
|
+
puts GL::GetString(GL::EXTENSIONS).to_s.split(/ /)
|
80
|
+
end
|
81
|
+
|
82
|
+
GLFW.DestroyWindow( window )
|
83
|
+
GLFW.Terminate()
|
84
|
+
end
|
data/sample/simple.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#
|
2
|
+
# For more samples, visit https://github.com/vaiorabbit/ruby-opengl/tree/master/sample .
|
3
|
+
#
|
4
|
+
# Ref.: /glfw-3.0.1/examples/simple.c
|
5
|
+
#
|
6
|
+
require 'opengl'
|
7
|
+
require 'glfw'
|
8
|
+
|
9
|
+
# Press ESC to exit.
|
10
|
+
key_callback = GLFW::create_callback(:GLFWkeyfun) do |window, key, scancode, action, mods|
|
11
|
+
GLFW.SetWindowShouldClose(window, 1) if key == GLFW::KEY_ESCAPE && action == GLFW::PRESS
|
12
|
+
end
|
13
|
+
|
14
|
+
if __FILE__ == $PROGRAM_NAME
|
15
|
+
GLFW.load_lib()
|
16
|
+
GLFW.Init()
|
17
|
+
|
18
|
+
window = GLFW.CreateWindow(640, 480, "Simple example", nil, nil)
|
19
|
+
GLFW.MakeContextCurrent(window)
|
20
|
+
GLFW.SetKeyCallback(window, key_callback)
|
21
|
+
|
22
|
+
GL.load_lib()
|
23
|
+
|
24
|
+
width_buf = ' ' * 8
|
25
|
+
height_buf = ' ' * 8
|
26
|
+
until GLFW.WindowShouldClose(window) == GLFW::TRUE
|
27
|
+
GLFW.GetFramebufferSize(window, width_buf, height_buf)
|
28
|
+
width = width_buf.unpack1('L')
|
29
|
+
height = height_buf.unpack1('L')
|
30
|
+
ratio = width.to_f / height.to_f
|
31
|
+
|
32
|
+
GL.Viewport(0, 0, width, height)
|
33
|
+
GL.Clear(GL::COLOR_BUFFER_BIT)
|
34
|
+
GL.MatrixMode(GL::PROJECTION)
|
35
|
+
GL.LoadIdentity()
|
36
|
+
GL.Ortho(-ratio, ratio, -1.0, 1.0, 1.0, -1.0)
|
37
|
+
GL.MatrixMode(GL::MODELVIEW)
|
38
|
+
|
39
|
+
GL.LoadIdentity()
|
40
|
+
GL.Rotatef(GLFW.GetTime() * 50.0, 0.0, 0.0, 1.0)
|
41
|
+
|
42
|
+
GL.Begin(GL::TRIANGLES)
|
43
|
+
GL.Color3f(1.0, 0.0, 0.0)
|
44
|
+
GL.Vertex3f(-0.6, -0.4, 0.0)
|
45
|
+
GL.Color3f(0.0, 1.0, 0.0)
|
46
|
+
GL.Vertex3f(0.6, -0.4, 0.0)
|
47
|
+
GL.Color3f(0.0, 0.0, 1.0)
|
48
|
+
GL.Vertex3f(0.0, 0.6, 0.0)
|
49
|
+
GL.End()
|
50
|
+
|
51
|
+
GLFW.SwapBuffers(window)
|
52
|
+
GLFW.PollEvents()
|
53
|
+
end
|
54
|
+
|
55
|
+
GLFW.DestroyWindow(window)
|
56
|
+
GLFW.Terminate()
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opengl-bindings2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0.rc1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- vaiorabbit
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-01-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: 'Ruby bindings for OpenGL - 4.6, OpenGL ES - 3.2 and all extensions using
|
14
|
+
Fiddle (For MRI >= 2.4.0). GLFW/GLUT/GLU bindings are also available.
|
15
|
+
|
16
|
+
'
|
17
|
+
email:
|
18
|
+
- vaiorabbit@gmail.com
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- ChangeLog
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.md
|
26
|
+
- lib/glfw.rb
|
27
|
+
- lib/glu.rb
|
28
|
+
- lib/glut.rb
|
29
|
+
- lib/opengl.rb
|
30
|
+
- lib/opengl_command.rb
|
31
|
+
- lib/opengl_common.rb
|
32
|
+
- lib/opengl_enum.rb
|
33
|
+
- lib/opengl_es.rb
|
34
|
+
- lib/opengl_es_command.rb
|
35
|
+
- lib/opengl_es_enum.rb
|
36
|
+
- lib/opengl_es_ext.rb
|
37
|
+
- lib/opengl_es_ext_command.rb
|
38
|
+
- lib/opengl_es_ext_enum.rb
|
39
|
+
- lib/opengl_ext.rb
|
40
|
+
- lib/opengl_ext_command.rb
|
41
|
+
- lib/opengl_ext_common.rb
|
42
|
+
- lib/opengl_ext_enum.rb
|
43
|
+
- lib/opengl_linux.rb
|
44
|
+
- lib/opengl_macosx.rb
|
45
|
+
- lib/opengl_platform.rb
|
46
|
+
- lib/opengl_windows.rb
|
47
|
+
- sample/README.md
|
48
|
+
- sample/glfw_get.bat
|
49
|
+
- sample/glfw_get.sh
|
50
|
+
- sample/report_env.rb
|
51
|
+
- sample/simple.rb
|
52
|
+
homepage: https://github.com/vaiorabbit/ruby-opengl
|
53
|
+
licenses:
|
54
|
+
- Zlib
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.4.0
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.3.1
|
70
|
+
requirements: []
|
71
|
+
rubygems_version: 3.2.29
|
72
|
+
signing_key:
|
73
|
+
specification_version: 4
|
74
|
+
summary: Bindings for OpenGL -4.6, ES - 3.2 and extensions (For MRI >= 2.4.0)
|
75
|
+
test_files: []
|