rubygl 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.travis/push-rdoc-to-gh-pages.sh +22 -0
- data/.travis.yml +18 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +12 -0
- data/LICENSE +21 -21
- data/README.md +40 -0
- data/Rakefile +98 -83
- data/bin/ffi_code_gen.rb +166 -166
- data/bin/gl_code_gen.rb +458 -458
- data/examples/faceted_example.rb +71 -64
- data/examples/instanced_example.rb +135 -127
- data/examples/phong_example.rb +80 -71
- data/ext/windows/RubyGL.so +0 -0
- data/lib/rubygl/event.rb +64 -0
- data/lib/{RubyGL → rubygl}/geometry.rb +216 -211
- data/lib/{RubyGL → rubygl}/math.rb +300 -300
- data/lib/{RubyGL → rubygl}/memory.rb +125 -121
- data/lib/rubygl/native/all_enums.rb +641 -0
- data/lib/{RubyGL/Native → rubygl/native}/glcontext.rb +23 -47
- data/lib/{RubyGL/Native → rubygl/native}/include/GLContext.h +36 -36
- data/lib/{RubyGL/Native → rubygl/native}/include/Input.h +15 -15
- data/lib/{RubyGL/Native → rubygl/native}/include/Window.h +27 -27
- data/lib/rubygl/native/input.rb +247 -0
- data/lib/{RubyGL/Native → rubygl/native}/opengl.rb +2808 -2032
- data/lib/{RubyGL/Native → rubygl/native}/src/GLContext.c +72 -72
- data/lib/{RubyGL/Native → rubygl/native}/src/Input.c +25 -25
- data/lib/{RubyGL/Native → rubygl/native}/src/Window.c +57 -57
- data/lib/{RubyGL/Native → rubygl/native}/window.rb +24 -24
- data/lib/{RubyGL → rubygl}/setup.rb +50 -50
- data/lib/{RubyGL → rubygl}/shader.rb +203 -203
- data/lib/{RubyGL → rubygl}/util.rb +77 -77
- data/lib/rubygl.rb +49 -48
- data/{RubyGL.gemspec → rubygl.gemspec} +20 -23
- data/test/test_util.rb +19 -0
- metadata +36 -33
- data/lib/RubyGL/Native/input.rb +0 -13
- data/lib/RubyGL/callback.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZWE2NTJjYThmM2M2MGM0MmUwNmE5NTk1YmQxOTFiMTI5YTZkZjEzYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDRmMDFhZmI3MjJkZDEwZTgwMDg2N2I4NGI2YmFmOGRjOTg5MjUxYQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjA1NWMzYzI1YTZiM2E2ZWEyYWI0NDUxYmM5ZmVlY2UyYThkOGU5M2RlN2Nk
|
10
|
+
NDlhZjA3NGUwMWQ1ZTMzOTE4M2Q2MmI3OTg0NDM1ZWYyNTVmMzgyY2I2NjJk
|
11
|
+
ODUzNGU0YTE5ZjFhYzY4OTFlYWJlYzgyYzI5YjQ0NWY0N2Q2OGI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODNkNTRmZmUxMTVmODU4OWUxMmMwZGNiM2Q1YzBlNjE5NGJiZjc4MmRjODk1
|
14
|
+
NjNlMTMxYTlhNzQ3OWZkZGEzOWNjZWE1ZjE0ZDFmODk0OWYyZTFhYmYyNDcx
|
15
|
+
MDhmZGFhNWY1ODA5OTNhN2JkMTgyMmIyY2Y0MjMxZDllNmMzNzY=
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
if [ "$TRAVIS_REPO_SLUG" == "GGist/RubyGL" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
|
4
|
+
echo -e "Publishing rdoc to gh-pages...\n"
|
5
|
+
|
6
|
+
mkdir $HOME/rdoc-latest
|
7
|
+
rake doc
|
8
|
+
cp -r doc/* $HOME/rdoc-latest/.
|
9
|
+
|
10
|
+
cd $HOME
|
11
|
+
git config --global user.email "travis@travis-ci.org"
|
12
|
+
git config --global user.name "travis-ci"
|
13
|
+
git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/GGist/RubyGL gh-pages > /dev/null
|
14
|
+
|
15
|
+
cd gh-pages
|
16
|
+
cp -rf $HOME/rdoc-latest/* .
|
17
|
+
git add -A
|
18
|
+
git commit -m "Latest rdoc on successful travis build $TRAVIS_BUILD_NUMBER auto-pushed to gh-pages"
|
19
|
+
git push -fq origin gh-pages > /dev/null
|
20
|
+
|
21
|
+
echo -e "Published rdoc to gh-pages.\n"
|
22
|
+
fi
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
script:
|
4
|
+
- bundle exec rake test
|
5
|
+
|
6
|
+
env:
|
7
|
+
global:
|
8
|
+
- secure: qt435BABTrF0JP6PwK5WyyaMYMdDatHDT4yQcJq9BEfhMrhyY+Xdwzpkhq2UVkJ1r+g+ML5C7oNFQxUkDFS7PY4H7YhaPZHKCBbCpp9YH7yzMH7eWq4FtjGUt357kdGVhLietfqTiBl/pnxgAdUmvXxcjvZGHd2OORUymxRucIw=
|
9
|
+
|
10
|
+
after_success:
|
11
|
+
- chmod +x .travis/push-rdoc-to-gh-pages.sh
|
12
|
+
- .travis/push-rdoc-to-gh-pages.sh
|
13
|
+
|
14
|
+
deploy:
|
15
|
+
provider: rubygems
|
16
|
+
api_key:
|
17
|
+
- secure: ohBwl2E3XI6eP3O35SiJU5hnnh6/fah0yCtAHcs30PJaDuHHoCB/RfwhsiNHWAvs7jJGg261UD/Mz1t1vl3mpxx0KfTc1y/Px+5JbjHSlvd6OeVMu1fIZweYXofjQbhHjugbWmDKII5a1G+/4WEU6FTI0RGpGww1w+dh4nXjQj4=
|
18
|
+
gem: rubygl
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2014 Andrew
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Andrew
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
RubyGL - [![Build Status](https://travis-ci.org/GGist/RubyGL.svg)](https://travis-ci.org/GGist/RubyGL) [![Documentation](http://img.shields.io/badge/docs-in--progress-blue.svg)](http://ggist.github.io/RubyGL/index.html) [![License](http://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/GGist/RubyGL/master/LICENSE)
|
2
|
+
=======
|
3
|
+
A Complete Solution For Graphics Programming In Ruby.
|
4
|
+
|
5
|
+
Installing - [![Gem Version](https://badge.fury.io/rb/rubygl.svg)](http://badge.fury.io/rb/rubygl)
|
6
|
+
----------
|
7
|
+
```
|
8
|
+
gem install rubygl
|
9
|
+
```
|
10
|
+
|
11
|
+
Examples Gallery
|
12
|
+
----------------
|
13
|
+
<img src="https://cloud.githubusercontent.com/assets/5248583/5156041/53eeb3ce-725b-11e4-908b-0b5aa7b37e2e.gif">
|
14
|
+
<img align="right" src="https://cloud.githubusercontent.com/assets/5248583/5156042/55d1ee0e-725b-11e4-9edf-b240051a41b7.gif">
|
15
|
+
|
16
|
+
Frequently Asked Questions
|
17
|
+
--------------------------
|
18
|
+
**Q: Why are my shaders not working?**
|
19
|
+
A: You probably have an older version of GLSL (1.2 or earler) so your version of GLSL may not support the ```in``` and ```out```
|
20
|
+
variables (the shaders in ShaderGenerator use these). To work around this, you can change the ```in``` qualifiers in the
|
21
|
+
vertex shader to ```attribute``` qualifiers and the ```out``` qualifiers to ```varying``` qualifiers. In the fragment
|
22
|
+
shader change the ```in``` qualifiers to ```varying``` qualifiers and remove any ```out``` variables; you should use the
|
23
|
+
built-in ```gl_FragColor``` variable to assign the output fragment color. Lastly, make sure to update the ```#version XXX```
|
24
|
+
tag for the version of GLSL your GPU can support (Ex: ```#version 120``` if running GLSL 1.2). You can check your
|
25
|
+
GLSL version by running ```puts RubyGL::Native::glGetString(RubyGL::Native::GL_SHADING_LANGUAGE_VERSION)```.
|
26
|
+
|
27
|
+
**Q: Why is my program giving a segmentation fault?**
|
28
|
+
A: You are most likely trying to call an OpenGL function that does not exist in your GPUs version of OpenGL. The offending
|
29
|
+
function should be given to you in the stack trace. I have compiled the rubygl shared library for the latest version of OpenGL
|
30
|
+
in compatibility mode to let users call any function that their version of OpenGL may support; the library will assume
|
31
|
+
that any OpenGL function you are calling is valid (I should probably change this), hence the segmentation fault. Go to
|
32
|
+
https://www.opengl.org/sdk/docs/man/ to see which functions are supported by each OpenGL version. You can run
|
33
|
+
```puts RubyGL::Native::glGetString(RubyGL::Native::GL_VERSION)``` to see what version of OpenGL you have.
|
34
|
+
|
35
|
+
Known Issues
|
36
|
+
------------
|
37
|
+
- Only supports Windows at the moment (OSX support coming soon)
|
38
|
+
- Not sure how to support Linux without requiring users to compile a shared library
|
39
|
+
- Windows does not guarantee that OpenGL functions loaded during context creation will be valid for other contexts
|
40
|
+
- Need to figure out how to efficiently swap these out if the user creates more than one context
|
data/Rakefile
CHANGED
@@ -1,83 +1,98 @@
|
|
1
|
-
require 'rake/task'
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'tmpdir'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
PROJ_INCLUDE = 'lib/
|
12
|
-
PROJ_SRC = 'lib/
|
13
|
-
|
14
|
-
# OS Detection
|
15
|
-
def os
|
16
|
-
@os ||= (
|
17
|
-
host_os = RbConfig::CONFIG['host_os']
|
18
|
-
|
19
|
-
case host_os
|
20
|
-
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
21
|
-
:windows
|
22
|
-
when /darwin|mac os/
|
23
|
-
:macosx
|
24
|
-
when /linux/
|
25
|
-
:linux
|
26
|
-
when /solaris|bsd/
|
27
|
-
:unix
|
28
|
-
else
|
29
|
-
raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
|
30
|
-
end
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
/---------------------------------RAKE JOBS-----------------------------------/
|
35
|
-
|
36
|
-
task :default
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
1
|
+
require 'rake/task'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
# Dependency Locations
|
6
|
+
SDL_INCLUDE = 'C:\Users\GG\Desktop\SDL2-2.0.3\i686-w64-mingw32\include\SDL2'
|
7
|
+
SDL_LIB = 'C:\Users\GG\Desktop\SDL2-2.0.3\i686-w64-mingw32\lib'
|
8
|
+
SDL_BIN = 'C:\Users\GG\Desktop\SDL2-2.0.3\i686-w64-mingw32\bin'
|
9
|
+
|
10
|
+
# C File Locations
|
11
|
+
PROJ_INCLUDE = 'lib/rubygl/native/include/'
|
12
|
+
PROJ_SRC = 'lib/rubygl/native/src/'
|
13
|
+
|
14
|
+
# OS Detection
|
15
|
+
def os
|
16
|
+
@os ||= (
|
17
|
+
host_os = RbConfig::CONFIG['host_os']
|
18
|
+
|
19
|
+
case host_os
|
20
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
21
|
+
:windows
|
22
|
+
when /darwin|mac os/
|
23
|
+
:macosx
|
24
|
+
when /linux/
|
25
|
+
:linux
|
26
|
+
when /solaris|bsd/
|
27
|
+
:unix
|
28
|
+
else
|
29
|
+
raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
|
30
|
+
end
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
/---------------------------------RAKE JOBS-----------------------------------/
|
35
|
+
|
36
|
+
task :default => [:bindings, :build, :clean]
|
37
|
+
|
38
|
+
# Builds The RubyGL Shared Library From C Source Files And SDL Library
|
39
|
+
task :build do
|
40
|
+
files = ['Window', 'GLContext', 'Input', 'OpenGL']
|
41
|
+
|
42
|
+
# Build Object Files
|
43
|
+
obj = "gcc -I#{SDL_INCLUDE} -I#{PROJ_INCLUDE} -c -fPIC REPLACE.c -o REPLACE.o"
|
44
|
+
files.each { |file|
|
45
|
+
sh (obj.gsub(/REPLACE/, PROJ_SRC + file))
|
46
|
+
file = file.prepend PROJ_SRC
|
47
|
+
}
|
48
|
+
|
49
|
+
# Build Shared Object File
|
50
|
+
bin = "gcc -L#{SDL_LIB} #{files.join('.o ') << '.o'} -lSDL2main -lSDL2 \
|
51
|
+
-lopengl32 -shared -o ext/#{os.to_s}/RubyGL.so"
|
52
|
+
sh bin
|
53
|
+
end
|
54
|
+
|
55
|
+
# Created The Documentation For The Library
|
56
|
+
task :doc do
|
57
|
+
sh "rdoc lib/*"
|
58
|
+
end
|
59
|
+
|
60
|
+
# Clean Out Generated Files Silently
|
61
|
+
task :clean do
|
62
|
+
FileUtils.rm_r('doc', {:secure => true, :force => true})
|
63
|
+
|
64
|
+
FileUtils.rm_f(PROJ_INCLUDE + '/OpenGL.h')
|
65
|
+
|
66
|
+
FileUtils.rm_f(PROJ_SRC + '/OpenGL.c')
|
67
|
+
|
68
|
+
FileUtils.rm_f Dir.glob(PROJ_SRC + '/*.o')
|
69
|
+
end
|
70
|
+
|
71
|
+
# Generate Updated OpenGL Bindings
|
72
|
+
task :bindings do
|
73
|
+
gl_api, gl_version, shared_lib = 'gl', '4.5C', 'RubyGL.so'
|
74
|
+
|
75
|
+
Dir.mktmpdir { |dir|
|
76
|
+
# Generates C Header And Source Files
|
77
|
+
sh "ruby bin/gl_code_gen.rb #{gl_api} #{gl_version} OpenGL #{dir}"
|
78
|
+
|
79
|
+
# Run Preprocessor On C Source File
|
80
|
+
sh "gcc -E -I#{SDL_INCLUDE} -o #{dir}/OpenGL.o #{dir}/OpenGL.c"
|
81
|
+
|
82
|
+
# Pipe Preprocessor(ed) File And Header File To Generate Bindings
|
83
|
+
sh "ruby bin/ffi_code_gen.rb #{dir}/OpenGL.o #{dir}/OpenGL.h \
|
84
|
+
#{dir}/opengl.rb #{shared_lib}"
|
85
|
+
|
86
|
+
# Move Files To Correct Folders
|
87
|
+
mv "#{dir}/OpenGL.h", PROJ_INCLUDE
|
88
|
+
mv "#{dir}/OpenGL.c", PROJ_SRC
|
89
|
+
mv "#{dir}/opengl.rb", "lib/rubygl/native/"
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
# Run All Tests In The tests Directory
|
94
|
+
Rake::TestTask.new do |t|
|
95
|
+
t.libs << 'test' << 'lib/rubygl'
|
96
|
+
t.test_files = FileList['test/test*.rb']
|
97
|
+
t.verbose = true
|
98
|
+
end
|