opengl3 0.0.1.pre3 → 0.0.1.pre4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/glut.rb +5 -1
- data/lib/glut/i386/freeglut.dll.gitkeep +0 -0
- data/lib/glut/x86_64/freeglut.dll.gitkeep +0 -0
- data/lib/opengl/platform/windows.rb +28 -0
- data/lib/opengl/type.rb +14 -1
- data/lib/opengl/type/default.yml +1 -0
- data/lib/opengl/version.rb +1 -1
- metadata +13 -32
- data/.gitignore +0 -21
- data/.yardopts +0 -6
- data/Gemfile +0 -8
- data/LICENSE.txt +0 -22
- data/README.md +0 -92
- data/Rakefile +0 -26
- data/examples/math3d.rb +0 -65
- data/examples/ogl-2_1-basic.rb +0 -115
- data/examples/ogl-3_2-attribute_less.rb +0 -119
- data/examples/ogl-3_2-basic.rb +0 -136
- data/examples/ogl-3_2-cube.rb +0 -204
- data/examples/ogl-3_2-texture.rb +0 -163
- data/examples/ogl-4_0-quad_tessellation.rb +0 -284
- data/examples/ogl-4_0-triangle_tessellation.rb +0 -263
- data/opengl.gemspec +0 -24
- data/spec/spec_helper.rb +0 -8
- data/test/test_helper.rb +0 -8
- data/yard/database.rb +0 -51
- data/yard/dsl_handler.rb +0 -76
- data/yard/wrapper_handler.rb +0 -24
data/lib/glut.rb
CHANGED
@@ -9,7 +9,11 @@ module GLUT
|
|
9
9
|
ffi_lib "/System/Library/Frameworks/GLUT.framework/GLUT"
|
10
10
|
when "linux"
|
11
11
|
ffi_lib "libglut.so.3"
|
12
|
-
|
12
|
+
when "windows"
|
13
|
+
path = File.expand_path("../glut/#{FFI::Platform::ARCH}", __FILE__)
|
14
|
+
ffi_lib ["freeglut.dll", "#{path}/freeglut.dll"]
|
15
|
+
else
|
16
|
+
raise RuntimeError, "GLUT: Unsupported OS"
|
13
17
|
end
|
14
18
|
|
15
19
|
# keyboard / mouse callback constants
|
File without changes
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module OpenGL::Platform
|
2
|
+
# @private
|
3
|
+
module Windows
|
4
|
+
extend Base
|
5
|
+
|
6
|
+
def self.current_context?
|
7
|
+
not OpenGL32.wglGetCurrentContext().null?
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.find_function_address(name)
|
11
|
+
return OpenGL32.lib.find_function(name.to_s) ||
|
12
|
+
OpenGL32.wglGetProcAddress(name.to_s)
|
13
|
+
end
|
14
|
+
|
15
|
+
module OpenGL32
|
16
|
+
extend FFI::Library
|
17
|
+
ffi_lib 'OpenGL32.dll'
|
18
|
+
callback :PROC, [], :void
|
19
|
+
def self.lib; ffi_libraries.last; end
|
20
|
+
attach_function :wglGetCurrentContext, [], :pointer
|
21
|
+
attach_function :wglGetProcAddress, [:string], :PROC
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.current
|
26
|
+
Windows
|
27
|
+
end
|
28
|
+
end
|
data/lib/opengl/type.rb
CHANGED
@@ -82,11 +82,24 @@ module OpenGL
|
|
82
82
|
#
|
83
83
|
def self.pointer(ptr)
|
84
84
|
if ptr.is_a? Integer
|
85
|
-
ptr = FFI::MemoryPointer(:pointer, n)
|
85
|
+
ptr = FFI::MemoryPointer.new(:pointer, n)
|
86
86
|
end
|
87
87
|
ptr.extend MemoryPointerInstanceMethods
|
88
88
|
ptr.null? ? nil : ptr
|
89
89
|
end
|
90
90
|
|
91
|
+
# Make sure offset is a pointer type
|
92
|
+
# @param [Integer, FFI::Pointer, nil] offset
|
93
|
+
# @return [FFI::Pointer]
|
94
|
+
#
|
95
|
+
def self.pointer_offset(offset)
|
96
|
+
case offset
|
97
|
+
when Integer then FFI::Pointer.new(offset)
|
98
|
+
when nil then FFI::Pointer.new(0)
|
99
|
+
when FFI::Pointer then offset
|
100
|
+
else raise ArgumentError, "Invalid type of 'offset'(=#{offset})"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
91
104
|
end
|
92
105
|
end
|
data/lib/opengl/type/default.yml
CHANGED
data/lib/opengl/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opengl3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.pre4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -66,23 +66,9 @@ executables: []
|
|
66
66
|
extensions: []
|
67
67
|
extra_rdoc_files: []
|
68
68
|
files:
|
69
|
-
- .
|
70
|
-
- .
|
71
|
-
- Gemfile
|
72
|
-
- LICENSE.txt
|
73
|
-
- README.md
|
74
|
-
- Rakefile
|
75
|
-
- examples/math3d.rb
|
76
|
-
- examples/ogl-2_1-basic.rb
|
77
|
-
- examples/ogl-3_2-attribute_less.rb
|
78
|
-
- examples/ogl-3_2-basic.rb
|
79
|
-
- examples/ogl-3_2-cube.rb
|
80
|
-
- examples/ogl-3_2-texture.rb
|
81
|
-
- examples/ogl-4_0-quad_tessellation.rb
|
82
|
-
- examples/ogl-4_0-triangle_tessellation.rb
|
69
|
+
- lib/glut/i386/freeglut.dll.gitkeep
|
70
|
+
- lib/glut/x86_64/freeglut.dll.gitkeep
|
83
71
|
- lib/glut.rb
|
84
|
-
- lib/opengl.rb
|
85
|
-
- lib/opengl/constants.rb
|
86
72
|
- lib/opengl/constants/core/2_x/GL_VERSION_1_1.yml
|
87
73
|
- lib/opengl/constants/core/2_x/GL_VERSION_1_2.yml
|
88
74
|
- lib/opengl/constants/core/2_x/GL_VERSION_1_3.yml
|
@@ -136,8 +122,8 @@ files:
|
|
136
122
|
- lib/opengl/constants/core/4_2/GL_ARB_shader_image_load_store.yml
|
137
123
|
- lib/opengl/constants/core/4_2/GL_ARB_texture_storage.yml
|
138
124
|
- lib/opengl/constants/core/4_2/GL_VERSION_4_2.yml
|
139
|
-
- lib/opengl/constants/core/4_3/GL_ARB_ES3_compatibility.yml
|
140
125
|
- lib/opengl/constants/core/4_3/GL_ARB_compute_shader.yml
|
126
|
+
- lib/opengl/constants/core/4_3/GL_ARB_ES3_compatibility.yml
|
141
127
|
- lib/opengl/constants/core/4_3/GL_ARB_explicit_uniform_location.yml
|
142
128
|
- lib/opengl/constants/core/4_3/GL_ARB_framebuffer_no_attachments.yml
|
143
129
|
- lib/opengl/constants/core/4_3/GL_ARB_internalformat_query2.yml
|
@@ -152,13 +138,14 @@ files:
|
|
152
138
|
- lib/opengl/constants/ext/GL_EXT_texture_compression_s3tc.yml
|
153
139
|
- lib/opengl/constants/ext/GL_EXT_texture_filter_anisotropic.yml
|
154
140
|
- lib/opengl/constants/ext/GL_EXT_texture_sRGB.yml
|
141
|
+
- lib/opengl/constants.rb
|
155
142
|
- lib/opengl/debugging.rb
|
156
143
|
- lib/opengl/gl.rb
|
157
|
-
- lib/opengl/platform.rb
|
158
144
|
- lib/opengl/platform/base.rb
|
159
145
|
- lib/opengl/platform/darwin.rb
|
160
146
|
- lib/opengl/platform/linux.rb
|
161
|
-
- lib/opengl/
|
147
|
+
- lib/opengl/platform/windows.rb
|
148
|
+
- lib/opengl/platform.rb
|
162
149
|
- lib/opengl/raw/core/2_x/GL_VERSION_1_0.yml
|
163
150
|
- lib/opengl/raw/core/2_x/GL_VERSION_1_1.yml
|
164
151
|
- lib/opengl/raw/core/2_x/GL_VERSION_1_2.yml
|
@@ -204,15 +191,15 @@ files:
|
|
204
191
|
- lib/opengl/raw/core/4_2/GL_ARB_texture_storage.yml
|
205
192
|
- lib/opengl/raw/core/4_2/GL_ARB_transform_feedback_instanced.yml
|
206
193
|
- lib/opengl/raw/core/4_2/GL_VERSION_4_2.yml
|
207
|
-
- lib/opengl/
|
194
|
+
- lib/opengl/raw.rb
|
208
195
|
- lib/opengl/type/default.yml
|
209
196
|
- lib/opengl/type/i386-linux.yml
|
210
197
|
- lib/opengl/type/i386-windows.yml
|
211
198
|
- lib/opengl/type/x86_64-darwin.yml
|
212
199
|
- lib/opengl/type/x86_64-linux.yml
|
213
200
|
- lib/opengl/type/x86_64-windows.yml
|
201
|
+
- lib/opengl/type.rb
|
214
202
|
- lib/opengl/version.rb
|
215
|
-
- lib/opengl/wrapper.rb
|
216
203
|
- lib/opengl/wrapper/base.rb
|
217
204
|
- lib/opengl/wrapper/core/2_x/GL_VERSION_1_0.rb
|
218
205
|
- lib/opengl/wrapper/core/2_x/GL_VERSION_1_1.rb
|
@@ -259,12 +246,8 @@ files:
|
|
259
246
|
- lib/opengl/wrapper/core/4_2/GL_ARB_texture_storage.rb
|
260
247
|
- lib/opengl/wrapper/core/4_2/GL_ARB_transform_feedback_instanced.rb
|
261
248
|
- lib/opengl/wrapper/core/4_2/GL_VERSION_4_2.rb
|
262
|
-
- opengl.
|
263
|
-
-
|
264
|
-
- test/test_helper.rb
|
265
|
-
- yard/database.rb
|
266
|
-
- yard/dsl_handler.rb
|
267
|
-
- yard/wrapper_handler.rb
|
249
|
+
- lib/opengl/wrapper.rb
|
250
|
+
- lib/opengl.rb
|
268
251
|
homepage: https://github.com/davll/ruby-opengl
|
269
252
|
licenses: []
|
270
253
|
post_install_message:
|
@@ -289,7 +272,5 @@ rubygems_version: 1.8.24
|
|
289
272
|
signing_key:
|
290
273
|
specification_version: 3
|
291
274
|
summary: OpenGL
|
292
|
-
test_files:
|
293
|
-
- spec/spec_helper.rb
|
294
|
-
- test/test_helper.rb
|
275
|
+
test_files: []
|
295
276
|
has_rdoc:
|
data/.gitignore
DELETED
data/.yardopts
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 David Lin
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
# OpenGL (opengl3)
|
2
|
-
|
3
|
-
OpenGL wrapper library for Ruby
|
4
|
-
|
5
|
-
* Pure Ruby, no C/C++/Java extension included (thanks to ffi gem)
|
6
|
-
* OpenGL 2.1 ~ 4.2
|
7
|
-
* automatic error checking each function call
|
8
|
-
* Ruby-style wrapper (not complete)
|
9
|
-
* Inspired by PyOpenGL
|
10
|
-
|
11
|
-
Tested on
|
12
|
-
|
13
|
-
* Mac OS X 10.8 (MRI 1.9.3, Rubinius)
|
14
|
-
* Linux (MRI 1.9.3, JRuby 1.7)
|
15
|
-
|
16
|
-
## Notice
|
17
|
-
|
18
|
-
Since the project is not complete, many functions are still C-style.
|
19
|
-
But don't worry, the gem makes use of `ffi` gem to import functions, and
|
20
|
-
therefore you can use ffi objects like `FFI::MemoryPointer` to work
|
21
|
-
with C-style OpenGL entrypoints.
|
22
|
-
|
23
|
-
## Ruby-Style OpenGL APIs
|
24
|
-
|
25
|
-
Please take a look at `lib/opengl/wrapper/**/*.rb`
|
26
|
-
to see if entrypoints are wrapped.
|
27
|
-
|
28
|
-
* glGetString(pname) -> String
|
29
|
-
* glGen__Objects__(count) -> Array<Integer>
|
30
|
-
* glDelete__Objects__(Array<Integer>) -> nil
|
31
|
-
* glGet__Value__fv(\*args, count) -> Array<Float>
|
32
|
-
* glGet__Value__iv(\*args, count) -> Array<Integer>
|
33
|
-
* glGet__Value__uiv(\*args, count) -> Array<Integer>
|
34
|
-
* glShaderSource(shader, Array<String>) -> nil
|
35
|
-
* glGetShaderInfoLog(shader) -> String
|
36
|
-
* glGetProgramInfoLog(program) -> String
|
37
|
-
* More Ruby-style functions coming soon
|
38
|
-
|
39
|
-
block-style glMapBuffer / glMapBufferRange:
|
40
|
-
|
41
|
-
```ruby
|
42
|
-
glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY) do |ptr|
|
43
|
-
ptr.put_array_of_GLfloat(offset_in_bytes, [ 1.0, 2.0, 3.0 ])
|
44
|
-
end
|
45
|
-
```
|
46
|
-
|
47
|
-
And helper functions
|
48
|
-
|
49
|
-
* glGetVersion() -> Array<Integer>
|
50
|
-
* glGetShadingLanguageVersion() -> Array<Integer>
|
51
|
-
* glGetAvailableExtensions() -> Array<String>
|
52
|
-
* glIsShaderCompiled?(shader) -> Boolean
|
53
|
-
* glIsProgramLinked?(program) -> Boolean
|
54
|
-
* More helper functions coming soon
|
55
|
-
|
56
|
-
## Installation
|
57
|
-
|
58
|
-
Add this line to your application's Gemfile:
|
59
|
-
|
60
|
-
gem 'opengl3', :require => 'opengl'
|
61
|
-
|
62
|
-
And then execute:
|
63
|
-
|
64
|
-
$ bundle
|
65
|
-
|
66
|
-
Or install it yourself as:
|
67
|
-
|
68
|
-
$ gem install opengl3
|
69
|
-
|
70
|
-
## Usage
|
71
|
-
|
72
|
-
```ruby
|
73
|
-
require 'opengl'
|
74
|
-
class App
|
75
|
-
include OpenGL::Constants
|
76
|
-
|
77
|
-
def initialize
|
78
|
-
# ... (window created)
|
79
|
-
self.extend OpenGL::GL.entrypoints
|
80
|
-
# OK, you can use OpenGL now
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
```
|
85
|
-
|
86
|
-
## Contributing
|
87
|
-
|
88
|
-
1. Fork it
|
89
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
90
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
91
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
92
|
-
5. Create new Pull Request
|
data/Rakefile
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rake/testtask"
|
3
|
-
|
4
|
-
Rake::TestTask.new :spec do |t|
|
5
|
-
t.libs << "spec"
|
6
|
-
t.pattern = "spec/**/*_spec.rb"
|
7
|
-
end
|
8
|
-
|
9
|
-
Rake::TestTask.new :test do |t|
|
10
|
-
t.libs << "test"
|
11
|
-
t.pattern = "test/**/*_test.rb"
|
12
|
-
end
|
13
|
-
|
14
|
-
desc "Open an irb session preloaded with this library"
|
15
|
-
task :console do
|
16
|
-
sh "irb -rubygems -I lib -r opengl"
|
17
|
-
end
|
18
|
-
|
19
|
-
begin
|
20
|
-
require "yard"
|
21
|
-
rescue LoadError => e
|
22
|
-
else
|
23
|
-
YARD::Rake::YardocTask.new
|
24
|
-
desc "Generate documentation"
|
25
|
-
task(:doc => :yard)
|
26
|
-
end
|
data/examples/math3d.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'matrix'
|
2
|
-
|
3
|
-
class Matrix
|
4
|
-
|
5
|
-
def self.perspective(fovy, aspect, z_near, z_far)
|
6
|
-
f, z_diff = Math.tan(Math::PI * 0.5 - fovy * 0.5), (z_near-z_far)
|
7
|
-
return self[
|
8
|
-
[ f/aspect, 0.0, 0.0, 0.0 ],
|
9
|
-
[ 0.0, f, 0.0, 0.0 ],
|
10
|
-
[ 0.0, 0.0, (z_far+z_near)/z_diff, (2.0*z_far*z_near)/z_diff ],
|
11
|
-
[ 0.0, 0.0, -1.0, 0.0 ]
|
12
|
-
]
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.translate(x, y, z)
|
16
|
-
x, y, z = Float(x), Float(y), Float(z)
|
17
|
-
return self[
|
18
|
-
[ 1.0, 0.0, 0.0, x ],
|
19
|
-
[ 0.0, 1.0, 0.0, y ],
|
20
|
-
[ 0.0, 0.0, 1.0, z ],
|
21
|
-
[ 0.0, 0.0, 0.0, 1.0 ]
|
22
|
-
]
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.scale(x, y, z)
|
26
|
-
x, y, z = Float(x), Float(y), Float(z)
|
27
|
-
return self[
|
28
|
-
[ x, 0.0, 0.0, 0.0 ],
|
29
|
-
[ 0.0, y, 0.0, 0.0 ],
|
30
|
-
[ 0.0, 0.0, z, 0.0 ],
|
31
|
-
[ 0.0, 0.0, 0.0, 1.0 ]
|
32
|
-
]
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.rotate_x(angle)
|
36
|
-
c, s = Math.cos(angle), Math.sin(angle)
|
37
|
-
return self[
|
38
|
-
[ 1.0, 0.0, 0.0, 0.0 ],
|
39
|
-
[ 0.0, c, -s, 0.0 ],
|
40
|
-
[ 0.0, s, c, 0.0 ],
|
41
|
-
[ 0.0, 0.0, 0.0, 1.0 ]
|
42
|
-
]
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.rotate_y(angle)
|
46
|
-
c, s = Math.cos(angle), Math.sin(angle)
|
47
|
-
return self[
|
48
|
-
[ c, 0.0, s, 0.0 ],
|
49
|
-
[ 0.0, 1.0, 0.0, 0.0 ],
|
50
|
-
[ -s, 0.0, c, 0.0 ],
|
51
|
-
[ 0.0, 0.0, 0.0, 1.0 ]
|
52
|
-
]
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.rotate_z(angle)
|
56
|
-
c, s = Math.cos(angle), Math.sin(angle)
|
57
|
-
return self[
|
58
|
-
[ c, -s, 0.0, 0.0 ],
|
59
|
-
[ s, c, 0.0, 0.0 ],
|
60
|
-
[ 0.0, 0.0, 1.0, 0.0 ],
|
61
|
-
[ 0.0, 0.0, 0.0, 1.0 ]
|
62
|
-
]
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|