rays 0.3.11 → 0.3.12
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.
- checksums.yaml +4 -4
- data/.doc/ext/rays/image.cpp +10 -0
- data/.doc/ext/rays/painter.cpp +49 -1
- data/.doc/ext/rays/shader.cpp +8 -6
- data/.github/workflows/release-gem.yml +3 -0
- data/.github/workflows/utils.rb +88 -17
- data/ChangeLog.md +17 -0
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/ext/rays/extconf.rb +3 -4
- data/ext/rays/image.cpp +11 -0
- data/ext/rays/painter.cpp +53 -1
- data/ext/rays/shader.cpp +8 -6
- data/include/rays/coord.h +6 -6
- data/include/rays/defs.h +2 -0
- data/include/rays/image.h +11 -1
- data/include/rays/painter.h +19 -0
- data/include/rays/ruby.h +2 -2
- data/include/rays/shader.h +5 -3
- data/include/rays.h +2 -2
- data/lib/rays/extension.rb +8 -2
- data/lib/rays/image.rb +2 -1
- data/lib/rays/shader.rb +13 -4
- data/rays.gemspec +3 -4
- data/src/color_space.cpp +1 -1
- data/src/coord.h +10 -0
- data/src/font.cpp +1 -1
- data/src/image.cpp +85 -10
- data/src/opengl/painter.cpp +388 -124
- data/src/opengl/render_buffer.cpp +1 -1
- data/src/opengl/sdl/opengl.cpp +6 -0
- data/src/opengl/shader.cpp +68 -51
- data/src/opengl/shader.h +10 -6
- data/src/opengl/shader_program.cpp +21 -7
- data/src/opengl/shader_program.h +2 -1
- data/src/opengl/shader_source.cpp +2 -4
- data/src/opengl/texture.cpp +18 -6
- data/src/osx/bitmap.mm +1 -1
- data/src/painter.cpp +79 -24
- data/src/painter.h +15 -2
- data/src/sdl/font.cpp +358 -9
- data/src/sdl/rays.cpp +5 -0
- data/src/texture.h +6 -0
- data/test/test_painter.rb +36 -25
- data/test/test_painter_batch.rb +254 -0
- metadata +8 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b820979b1e5f5cc65ad457a6614bf068a15f03f0351709367e007a5046b02747
|
|
4
|
+
data.tar.gz: b80a61f404fb951e609cc449cc155450aaaf2c7d0f6a2eab39001d5bd8cdc8aa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9fa68f150b09b3ac24e47d8cb36c6deb4f68047755b9d5da8daccd44b568655650e6b96b4043d3c1d148bb61fc782f0a39f01dfd0ea950e078f866c0b4d1ad8c
|
|
7
|
+
data.tar.gz: b83ee77854124708af2d926de0f354e01263362fa385feb0d30a8ad3c88c522fda44d1537ba9df73c9b07570a8e6214300c858c44584535d68b3bc10a8cdfb02
|
data/.doc/ext/rays/image.cpp
CHANGED
|
@@ -122,6 +122,15 @@ VALUE get_smooth(VALUE self)
|
|
|
122
122
|
return value(THIS->smooth());
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
static
|
|
126
|
+
VALUE compare(VALUE self, VALUE other)
|
|
127
|
+
{
|
|
128
|
+
CHECK;
|
|
129
|
+
auto* a = THIS->self.get();
|
|
130
|
+
auto* b = to<const Rays::Image*>(other)->self.get();
|
|
131
|
+
return value(a < b ? -1 : a > b ? 1 : 0);
|
|
132
|
+
}
|
|
133
|
+
|
|
125
134
|
static
|
|
126
135
|
VALUE load(VALUE self, VALUE path)
|
|
127
136
|
{
|
|
@@ -149,6 +158,7 @@ Init_rays_image ()
|
|
|
149
158
|
rb_define_private_method(cImage, "get_bitmap", RUBY_METHOD_FUNC(get_bitmap), 1);
|
|
150
159
|
rb_define_method(cImage, "smooth=", RUBY_METHOD_FUNC(set_smooth), 1);
|
|
151
160
|
rb_define_method(cImage, "smooth", RUBY_METHOD_FUNC(get_smooth), 0);
|
|
161
|
+
cImage.define_method("<=>", compare);
|
|
152
162
|
cImage.define_module_function("load!", load);
|
|
153
163
|
}
|
|
154
164
|
|
data/.doc/ext/rays/painter.cpp
CHANGED
|
@@ -250,7 +250,17 @@ VALUE image(VALUE self)
|
|
|
250
250
|
CHECK;
|
|
251
251
|
check_arg_count(__FILE__, __LINE__, "Painter#image", argc, 1, 3, 5, 7, 9);
|
|
252
252
|
|
|
253
|
-
|
|
253
|
+
RUCY_SYM(to_image);
|
|
254
|
+
std::unique_ptr<Rays::Image> pimage;
|
|
255
|
+
|
|
256
|
+
const Rays::Image* image = NULL;
|
|
257
|
+
if (argv[0].is_a(Rays::image_class()))
|
|
258
|
+
image = to<Rays::Image*>(argv[0]);
|
|
259
|
+
else if (argv[0].respond_to(to_image))
|
|
260
|
+
{
|
|
261
|
+
pimage.reset(new Rays::Image(to<const Rays::Image&>(argv[0].call(to_image))));
|
|
262
|
+
image = pimage.get();
|
|
263
|
+
}
|
|
254
264
|
if (!image)
|
|
255
265
|
argument_error(__FILE__, __LINE__, "%s is not an image.", argv[0].inspect().c_str());
|
|
256
266
|
|
|
@@ -742,6 +752,38 @@ VALUE pop_matrix(VALUE self)
|
|
|
742
752
|
}
|
|
743
753
|
|
|
744
754
|
|
|
755
|
+
static
|
|
756
|
+
VALUE set_debug(VALUE self, VALUE debug)
|
|
757
|
+
{
|
|
758
|
+
CHECK;
|
|
759
|
+
if (debug)
|
|
760
|
+
THIS->remove_flag(Rays::Painter::FLAG_BATCHING);
|
|
761
|
+
else
|
|
762
|
+
THIS-> add_flag(Rays::Painter::FLAG_BATCHING);
|
|
763
|
+
return debug;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
static
|
|
767
|
+
VALUE get_debug(VALUE self)
|
|
768
|
+
{
|
|
769
|
+
CHECK;
|
|
770
|
+
return value(!THIS->has_flag(Rays::Painter::FLAG_BATCHING));
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
static
|
|
774
|
+
VALUE set_global_debug(VALUE self, VALUE debug)
|
|
775
|
+
{
|
|
776
|
+
Rays::Painter::set_debug(debug);
|
|
777
|
+
return debug;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
static
|
|
781
|
+
VALUE get_global_debug(VALUE self)
|
|
782
|
+
{
|
|
783
|
+
return value(Rays::Painter::debug());
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
|
|
745
787
|
static Class cPainter;
|
|
746
788
|
|
|
747
789
|
void
|
|
@@ -822,6 +864,12 @@ Init_rays_painter ()
|
|
|
822
864
|
rb_define_method(cPainter, "matrix", RUBY_METHOD_FUNC(get_matrix), 0);
|
|
823
865
|
rb_define_method(cPainter, "push_matrix", RUBY_METHOD_FUNC(push_matrix), 0);
|
|
824
866
|
rb_define_method(cPainter, "pop_matrix", RUBY_METHOD_FUNC(pop_matrix), 0);
|
|
867
|
+
|
|
868
|
+
rb_define_method(cPainter, "debug=", RUBY_METHOD_FUNC(set_debug), 1);
|
|
869
|
+
cPainter.define_method("debug?", get_debug);
|
|
870
|
+
|
|
871
|
+
rb_define_singleton_method(cPainter, "debug=", RUBY_METHOD_FUNC(set_global_debug), 1);
|
|
872
|
+
cPainter.define_singleton_method("debug?", get_global_debug);
|
|
825
873
|
}
|
|
826
874
|
|
|
827
875
|
|
data/.doc/ext/rays/shader.cpp
CHANGED
|
@@ -66,15 +66,17 @@ make_env (const Value& names, const Value& ignore_no_uniform_location_error)
|
|
|
66
66
|
to_name_list(names, 0),
|
|
67
67
|
to_name_list(names, 1),
|
|
68
68
|
to_name_list(names, 2),
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
to_name_list(names, 3),
|
|
70
|
+
to_name_list(names, 4),
|
|
71
71
|
to_name( names, 5),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
to_name( names, 6),
|
|
73
|
+
to_name( names, 7),
|
|
74
|
+
to_name( names, 8),
|
|
75
|
+
to_name( names, 9),
|
|
76
76
|
to_name_list(names, 10),
|
|
77
77
|
to_name_list(names, 11),
|
|
78
|
+
to_name_list(names, 12),
|
|
79
|
+
to_name_list(names, 13),
|
|
78
80
|
flags);
|
|
79
81
|
}
|
|
80
82
|
|
data/.github/workflows/utils.rb
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
require 'shellwords'
|
|
2
|
+
|
|
3
|
+
ALL_REPO = 'xord/all'
|
|
4
|
+
ALL_DIR = '../all'
|
|
5
|
+
ALL_FETCH_DEPTH = 100
|
|
6
|
+
|
|
1
7
|
RENAMES = {reflex: 'reflexion'}
|
|
2
8
|
|
|
3
9
|
def sh(cmd)
|
|
@@ -5,7 +11,7 @@ def sh(cmd)
|
|
|
5
11
|
system cmd
|
|
6
12
|
end
|
|
7
13
|
|
|
8
|
-
def setup_dependencies(
|
|
14
|
+
def setup_dependencies(only: nil)
|
|
9
15
|
gemspec_path = `git ls-files`.lines(chomp: true).find {|l| l =~ /\.gemspec$/}
|
|
10
16
|
return unless gemspec_path
|
|
11
17
|
|
|
@@ -13,44 +19,109 @@ def setup_dependencies(build: true, only: nil)
|
|
|
13
19
|
name = File.basename gemspec_path, '.gemspec'
|
|
14
20
|
|
|
15
21
|
exts = File.readlines('Rakefile')
|
|
16
|
-
.map {|l| l[%r|^\s*require\W+(\w+)/extension\W+$|, 1]}
|
|
22
|
+
.map {|l| l[%r|^\s*require\W+([\w\-\_]+)/extension\W+$|, 1]}
|
|
17
23
|
.compact
|
|
18
24
|
.reject {|ext| ext == name}
|
|
19
25
|
exts = exts & [only].flatten.map(&:to_s) if only
|
|
26
|
+
return if exts.empty?
|
|
27
|
+
|
|
28
|
+
unless setup_dependencies_via_monorepo(exts)
|
|
29
|
+
setup_dependencies_via_each_repo_by_version(gemspec, exts)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
exts.each {|ext| sh %( cd ../#{ext} && rake ext )}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def setup_dependencies_via_monorepo(exts)
|
|
36
|
+
return false unless checkout_monorepo
|
|
37
|
+
exts.each {|ext| sh %( ln -snf all/#{ext} ../#{ext} )}
|
|
38
|
+
true
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def checkout_monorepo()
|
|
42
|
+
uuid = `git log -1 --format=%B`[/^\[\[([0-9a-fA-F-]+)\]\]$/, 1]
|
|
43
|
+
return false unless uuid
|
|
44
|
+
|
|
45
|
+
commit = setup_monorepo uuid
|
|
46
|
+
return false unless commit
|
|
47
|
+
|
|
48
|
+
Dir.chdir(ALL_DIR) {sh %( git checkout -q #{commit} )}
|
|
49
|
+
true
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def setup_monorepo(uuid)
|
|
53
|
+
unless File.directory? ALL_DIR
|
|
54
|
+
url = "https://github.com/#{ALL_REPO}.git"
|
|
55
|
+
sh %( git clone --no-tags --depth #{ALL_FETCH_DEPTH} #{url} #{ALL_DIR} )
|
|
56
|
+
end
|
|
57
|
+
loop do
|
|
58
|
+
commit = find_monorepo_commit uuid
|
|
59
|
+
return commit if commit
|
|
60
|
+
|
|
61
|
+
deepened = Dir.chdir ALL_DIR do
|
|
62
|
+
before = `git rev-list --count HEAD`.to_i
|
|
63
|
+
sh %( git fetch --deepen #{ALL_FETCH_DEPTH} )
|
|
64
|
+
`git rev-list --count HEAD`.to_i > before
|
|
65
|
+
end
|
|
66
|
+
return nil unless deepened
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def find_monorepo_commit(uuid)
|
|
71
|
+
Dir.chdir ALL_DIR do
|
|
72
|
+
out = `git log origin/HEAD -F --grep="[[#{uuid}]]" --format=%H -1`.strip
|
|
73
|
+
out.empty? ? nil : out
|
|
74
|
+
end
|
|
75
|
+
end
|
|
20
76
|
|
|
77
|
+
def setup_dependencies_via_each_repo_by_version(gemspec, exts)
|
|
21
78
|
exts.each do |ext|
|
|
22
79
|
gem = RENAMES[ext.to_sym].then {|s| s || ext}
|
|
23
|
-
ver = gemspec[/add_dependency.*['"]#{gem}['"].*['"]\s
|
|
80
|
+
ver = gemspec[/add_dependency.*['"]#{gem}['"].*['"]\s*~>\s*([\d\.]+)\s*['"]/, 1]
|
|
24
81
|
opts = '-c advice.detachedHead=false --depth 1'
|
|
25
82
|
clone = "git clone #{opts} https://github.com/xord/#{ext}.git ../#{ext}"
|
|
26
83
|
|
|
27
84
|
# 'rake subtree:push' pushes all subrepos, so cloning by new tag
|
|
28
85
|
# often fails before tagging each new tag
|
|
29
86
|
sh %( #{clone} --branch v#{ver} || #{clone} )
|
|
30
|
-
sh %( cd ../#{ext} && rake ext )
|
|
31
87
|
end
|
|
32
88
|
end
|
|
33
89
|
|
|
34
90
|
def tag_versions()
|
|
35
|
-
|
|
36
|
-
|
|
91
|
+
changes = changelogs
|
|
92
|
+
tags = `git tag`.lines chomp: true
|
|
93
|
+
vers = `git log --oneline ./VERSION`
|
|
37
94
|
.lines(chomp: true)
|
|
38
95
|
.map {|line| line.split.first[/^\w+$/]}
|
|
39
|
-
.map {|
|
|
40
|
-
.select {|ver,
|
|
96
|
+
.map {|sha| [`git cat-file -p #{sha}:./VERSION 2>/dev/null`[/[\d\.]+/], sha]}
|
|
97
|
+
.select {|ver, sha| ver && sha}
|
|
41
98
|
.reverse
|
|
42
99
|
.to_h
|
|
43
100
|
|
|
44
|
-
|
|
45
|
-
.split(/^\s*##\s*\[\s*v([\d\.]+)\s*\].*$/)
|
|
46
|
-
.slice(1..-1)
|
|
47
|
-
.each_slice(2)
|
|
48
|
-
.to_h
|
|
49
|
-
.transform_values(&:strip!)
|
|
50
|
-
|
|
51
|
-
vers.to_a.reverse.each do |ver, hash|
|
|
101
|
+
vers.to_a.reverse.each do |ver, sha|
|
|
52
102
|
tag = "v#{ver}"
|
|
53
103
|
break if tags.include?(tag)
|
|
54
|
-
sh %( git tag -a -m \"#{changes[
|
|
104
|
+
sh %( git tag -a -m \"#{changes[tag]&.gsub '"', '\\"'}\" #{tag} #{sha} )
|
|
55
105
|
end
|
|
56
106
|
end
|
|
107
|
+
|
|
108
|
+
def release(*paths)
|
|
109
|
+
tag = ENV['GITHUB_REF']&.sub(%r|^refs/tags/|, '') || raise('GITHUB_REF tag not set')
|
|
110
|
+
notes = (changelogs[tag] || '').shellescape
|
|
111
|
+
paths = paths.flatten.join ' '
|
|
112
|
+
|
|
113
|
+
sh(%( gh release create #{tag} #{paths} --notes #{notes} )) ||
|
|
114
|
+
sh(%( gh release upload #{tag} #{paths} --clobber )) ||
|
|
115
|
+
raise('failed to upload to releases')
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def changelogs()
|
|
119
|
+
File.read('ChangeLog.md')
|
|
120
|
+
.split(/^\s*##\s*\[\s*(v[\d\.]+)\s*\].*$/)
|
|
121
|
+
.slice(1..)
|
|
122
|
+
.each_slice(2)
|
|
123
|
+
.to_h
|
|
124
|
+
.transform_values(&:strip!)
|
|
125
|
+
rescue Errno::ENOENT
|
|
126
|
+
raise 'failed to get changelogs'
|
|
127
|
+
end
|
data/ChangeLog.md
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
# rays ChangeLog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [v0.3.12] - 2026-05-10
|
|
5
|
+
|
|
6
|
+
- Support WebAssembly
|
|
7
|
+
- Implement batch rendering
|
|
8
|
+
- Implement WASM font rendering via HTMLCanvasElement
|
|
9
|
+
- Implement SDL_ttf font rendering for SDL backend
|
|
10
|
+
- Use GL_DEPTH_COMPONENT16 on WASM builds
|
|
11
|
+
- Rename texcoord_offset to texcoord_pixel
|
|
12
|
+
- Pin external library versions
|
|
13
|
+
- Add Image and Texture comparison operators
|
|
14
|
+
- Add Painter::set_debug / debug singleton API
|
|
15
|
+
- Pin position attribute to location 0 on macOS
|
|
16
|
+
- Simplify Painter_draw_image to fill-only
|
|
17
|
+
- Add libsdl2-ttf-dev to CI apt packages
|
|
18
|
+
- Remove deprecated has_rdoc= from gemspecs
|
|
19
|
+
|
|
20
|
+
|
|
4
21
|
## [v0.3.11] - 2026-04-17
|
|
5
22
|
|
|
6
23
|
- Move OpenGL code into src/opengl/ and introduce Renderer abstraction
|
data/Rakefile
CHANGED
|
@@ -16,7 +16,7 @@ TESTS_ALONE = ['test/test_rays_init.rb']
|
|
|
16
16
|
|
|
17
17
|
install_packages(
|
|
18
18
|
mingw: %w[MINGW_PACKAGE_PREFIX-glew],
|
|
19
|
-
apt: %w[libglew-dev libsdl2-dev])
|
|
19
|
+
apt: %w[libglew-dev libsdl2-dev libsdl2-ttf-dev])
|
|
20
20
|
|
|
21
21
|
use_external_library 'https://github.com/g-truc/glm',
|
|
22
22
|
tag: '1.0.1',
|
|
@@ -29,7 +29,7 @@ use_external_library 'https://github.com/skyrpex/clipper',
|
|
|
29
29
|
excludes: 'clipper/cpp/cpp_'
|
|
30
30
|
|
|
31
31
|
use_external_library 'https://github.com/mapbox/earcut.hpp',
|
|
32
|
-
|
|
32
|
+
commit: '365be263bfed498f9d3d3bf065bcb39b0d0e4ba6',
|
|
33
33
|
incdirs: 'include/mapbox',
|
|
34
34
|
srcdirs: 'NOSRC'
|
|
35
35
|
|
|
@@ -44,7 +44,7 @@ use_external_library 'https://github.com/andrewwillmott/splines-lib',
|
|
|
44
44
|
end
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
if win32? || linux?
|
|
47
|
+
if win32? || linux? || wasm?
|
|
48
48
|
use_external_library 'https://github.com/nothings/stb',
|
|
49
49
|
commit: 'ae721c50eaf761660b4f90cc590453cdb0c2acd0',
|
|
50
50
|
srcdirs: 'NOSRC'
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.12
|
data/ext/rays/extconf.rb
CHANGED
|
@@ -13,11 +13,10 @@ Xot::ExtConf.new Xot, Rucy, Rays do
|
|
|
13
13
|
setup do
|
|
14
14
|
headers << 'ruby.h'
|
|
15
15
|
libs.unshift 'gdi32', 'opengl32', 'glew32' if win32?
|
|
16
|
-
libs.unshift 'SDL2', 'GLEW', 'GL'
|
|
16
|
+
libs.unshift 'SDL2', 'SDL2_ttf', 'GLEW', 'GL' if linux? || wasm?
|
|
17
17
|
frameworks << 'AppKit' << 'OpenGL' << 'AVFoundation' if osx?
|
|
18
|
-
|
|
19
|
-
$
|
|
20
|
-
$LDFLAGS << ' -Wl,--out-implib=rays_ext.dll.a' if mingw? || cygwin?
|
|
18
|
+
$CPPFLAGS << ' -DRAYS_32BIT_PIXELS_STRING' if RUBY_PLATFORM == 'x64-mingw-ucrt'
|
|
19
|
+
$LDFLAGS << ' -Wl,--out-implib=librays.dll.a' if mingw? || cygwin?
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
create_makefile 'rays_ext'
|
data/ext/rays/image.cpp
CHANGED
|
@@ -134,6 +134,16 @@ RUCY_DEF0(get_smooth)
|
|
|
134
134
|
}
|
|
135
135
|
RUCY_END
|
|
136
136
|
|
|
137
|
+
static
|
|
138
|
+
RUCY_DEF1(compare, other)
|
|
139
|
+
{
|
|
140
|
+
CHECK;
|
|
141
|
+
auto* a = THIS->self.get();
|
|
142
|
+
auto* b = to<const Rays::Image*>(other)->self.get();
|
|
143
|
+
return value(a < b ? -1 : a > b ? 1 : 0);
|
|
144
|
+
}
|
|
145
|
+
RUCY_END
|
|
146
|
+
|
|
137
147
|
static
|
|
138
148
|
RUCY_DEF1(load, path)
|
|
139
149
|
{
|
|
@@ -162,6 +172,7 @@ Init_rays_image ()
|
|
|
162
172
|
cImage.define_private_method("get_bitmap", get_bitmap);
|
|
163
173
|
cImage.define_method("smooth=", set_smooth);
|
|
164
174
|
cImage.define_method("smooth", get_smooth);
|
|
175
|
+
cImage.define_method("<=>", compare);
|
|
165
176
|
cImage.define_module_function("load!", load);
|
|
166
177
|
}
|
|
167
178
|
|
data/ext/rays/painter.cpp
CHANGED
|
@@ -266,7 +266,17 @@ RUCY_DEFN(image)
|
|
|
266
266
|
CHECK;
|
|
267
267
|
check_arg_count(__FILE__, __LINE__, "Painter#image", argc, 1, 3, 5, 7, 9);
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
RUCY_SYM(to_image);
|
|
270
|
+
std::unique_ptr<Rays::Image> pimage;
|
|
271
|
+
|
|
272
|
+
const Rays::Image* image = NULL;
|
|
273
|
+
if (argv[0].is_a(Rays::image_class()))
|
|
274
|
+
image = to<Rays::Image*>(argv[0]);
|
|
275
|
+
else if (argv[0].respond_to(to_image))
|
|
276
|
+
{
|
|
277
|
+
pimage.reset(new Rays::Image(to<const Rays::Image&>(argv[0].call(to_image))));
|
|
278
|
+
image = pimage.get();
|
|
279
|
+
}
|
|
270
280
|
if (!image)
|
|
271
281
|
argument_error(__FILE__, __LINE__, "%s is not an image.", argv[0].inspect().c_str());
|
|
272
282
|
|
|
@@ -810,6 +820,42 @@ RUCY_DEF0(pop_matrix)
|
|
|
810
820
|
RUCY_END
|
|
811
821
|
|
|
812
822
|
|
|
823
|
+
static
|
|
824
|
+
RUCY_DEF1(set_debug, debug)
|
|
825
|
+
{
|
|
826
|
+
CHECK;
|
|
827
|
+
if (debug)
|
|
828
|
+
THIS->remove_flag(Rays::Painter::FLAG_BATCHING);
|
|
829
|
+
else
|
|
830
|
+
THIS-> add_flag(Rays::Painter::FLAG_BATCHING);
|
|
831
|
+
return debug;
|
|
832
|
+
}
|
|
833
|
+
RUCY_END
|
|
834
|
+
|
|
835
|
+
static
|
|
836
|
+
RUCY_DEF0(get_debug)
|
|
837
|
+
{
|
|
838
|
+
CHECK;
|
|
839
|
+
return value(!THIS->has_flag(Rays::Painter::FLAG_BATCHING));
|
|
840
|
+
}
|
|
841
|
+
RUCY_END
|
|
842
|
+
|
|
843
|
+
static
|
|
844
|
+
RUCY_DEF1(set_global_debug, debug)
|
|
845
|
+
{
|
|
846
|
+
Rays::Painter::set_debug(debug);
|
|
847
|
+
return debug;
|
|
848
|
+
}
|
|
849
|
+
RUCY_END
|
|
850
|
+
|
|
851
|
+
static
|
|
852
|
+
RUCY_DEF0(get_global_debug)
|
|
853
|
+
{
|
|
854
|
+
return value(Rays::Painter::debug());
|
|
855
|
+
}
|
|
856
|
+
RUCY_END
|
|
857
|
+
|
|
858
|
+
|
|
813
859
|
static Class cPainter;
|
|
814
860
|
|
|
815
861
|
void
|
|
@@ -890,6 +936,12 @@ Init_rays_painter ()
|
|
|
890
936
|
cPainter.define_method("matrix", get_matrix);
|
|
891
937
|
cPainter.define_method("push_matrix", push_matrix);
|
|
892
938
|
cPainter.define_method( "pop_matrix", pop_matrix);
|
|
939
|
+
|
|
940
|
+
cPainter.define_method("debug=", set_debug);
|
|
941
|
+
cPainter.define_method("debug?", get_debug);
|
|
942
|
+
|
|
943
|
+
cPainter.define_singleton_method("debug=", set_global_debug);
|
|
944
|
+
cPainter.define_singleton_method("debug?", get_global_debug);
|
|
893
945
|
}
|
|
894
946
|
|
|
895
947
|
|
data/ext/rays/shader.cpp
CHANGED
|
@@ -67,15 +67,17 @@ make_env (const Value& names, const Value& ignore_no_uniform_location_error)
|
|
|
67
67
|
to_name_list(names, 0),
|
|
68
68
|
to_name_list(names, 1),
|
|
69
69
|
to_name_list(names, 2),
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
to_name_list(names, 3),
|
|
71
|
+
to_name_list(names, 4),
|
|
72
72
|
to_name( names, 5),
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
to_name( names, 6),
|
|
74
|
+
to_name( names, 7),
|
|
75
|
+
to_name( names, 8),
|
|
76
|
+
to_name( names, 9),
|
|
77
77
|
to_name_list(names, 10),
|
|
78
78
|
to_name_list(names, 11),
|
|
79
|
+
to_name_list(names, 12),
|
|
80
|
+
to_name_list(names, 13),
|
|
79
81
|
flags);
|
|
80
82
|
}
|
|
81
83
|
|
data/include/rays/coord.h
CHANGED
|
@@ -25,9 +25,9 @@ namespace Rays
|
|
|
25
25
|
coord array[SIZE];
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
This& reset (coord value = 0);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
This& reset (coord x, coord y);
|
|
31
31
|
|
|
32
32
|
size_t size () const;
|
|
33
33
|
|
|
@@ -58,9 +58,9 @@ namespace Rays
|
|
|
58
58
|
|
|
59
59
|
This& operator = (const Coord2& rhs);
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
This& reset (coord value = 0);
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
This& reset (coord x, coord y, coord z = 0);
|
|
64
64
|
|
|
65
65
|
size_t size () const;
|
|
66
66
|
|
|
@@ -93,9 +93,9 @@ namespace Rays
|
|
|
93
93
|
|
|
94
94
|
This& operator = (const Coord3& rhs);
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
This& reset (coord value = 0);
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
This& reset (coord x, coord y, coord z = 0, coord w = 1);
|
|
99
99
|
|
|
100
100
|
size_t size () const;
|
|
101
101
|
|
data/include/rays/defs.h
CHANGED
data/include/rays/image.h
CHANGED
|
@@ -61,10 +61,20 @@ namespace Rays
|
|
|
61
61
|
|
|
62
62
|
bool operator ! () const;
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
friend bool operator == (const This& lhs, const This& rhs);
|
|
65
|
+
|
|
66
|
+
friend bool operator != (const This& lhs, const This& rhs);
|
|
67
|
+
|
|
68
|
+
struct Data
|
|
69
|
+
{
|
|
70
|
+
virtual ~Data ();
|
|
71
|
+
virtual void preprocess (const Image* image) const;
|
|
72
|
+
};
|
|
65
73
|
|
|
66
74
|
Xot::PSharedImpl<Data> self;
|
|
67
75
|
|
|
76
|
+
Image (Data* data);
|
|
77
|
+
|
|
68
78
|
};// Image
|
|
69
79
|
|
|
70
80
|
|
data/include/rays/painter.h
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
#include <xot/pimpl.h>
|
|
8
|
+
#include <xot/util.h>
|
|
8
9
|
#include <rays/defs.h>
|
|
9
10
|
#include <rays/point.h>
|
|
10
11
|
|
|
@@ -29,6 +30,15 @@ namespace Rays
|
|
|
29
30
|
|
|
30
31
|
public:
|
|
31
32
|
|
|
33
|
+
enum Flag
|
|
34
|
+
{
|
|
35
|
+
|
|
36
|
+
FLAG_BATCHING = Xot::bit(0),
|
|
37
|
+
|
|
38
|
+
FLAG_LAST = FLAG_BATCHING
|
|
39
|
+
|
|
40
|
+
};// Flag
|
|
41
|
+
|
|
32
42
|
Painter ();
|
|
33
43
|
|
|
34
44
|
~Painter ();
|
|
@@ -322,10 +332,19 @@ namespace Rays
|
|
|
322
332
|
void pop_matrix ();
|
|
323
333
|
|
|
324
334
|
|
|
335
|
+
void add_flag (uint flags);
|
|
336
|
+
|
|
337
|
+
void remove_flag (uint flags);
|
|
338
|
+
|
|
339
|
+
bool has_flag (uint flags) const;
|
|
340
|
+
|
|
325
341
|
operator bool () const;
|
|
326
342
|
|
|
327
343
|
bool operator ! () const;
|
|
328
344
|
|
|
345
|
+
static void set_debug (bool debug);
|
|
346
|
+
|
|
347
|
+
static bool debug ();
|
|
329
348
|
|
|
330
349
|
struct Data;
|
|
331
350
|
|
data/include/rays/ruby.h
CHANGED
data/include/rays/shader.h
CHANGED
|
@@ -98,15 +98,17 @@ namespace Rays
|
|
|
98
98
|
ShaderEnv (
|
|
99
99
|
const NameList& attribute_position_names = {},
|
|
100
100
|
const NameList& attribute_texcoord_names = {},
|
|
101
|
+
const NameList& attribute_texcoord_min_names = {},
|
|
102
|
+
const NameList& attribute_texcoord_max_names = {},
|
|
101
103
|
const NameList& attribute_color_names = {},
|
|
102
104
|
const char* varying_position_name = NULL,
|
|
103
105
|
const char* varying_texcoord_name = NULL,
|
|
106
|
+
const char* varying_texcoord_min_name = NULL,
|
|
107
|
+
const char* varying_texcoord_max_name = NULL,
|
|
104
108
|
const char* varying_color_name = NULL,
|
|
105
109
|
const NameList& uniform_position_matrix_names = {},
|
|
106
110
|
const NameList& uniform_texcoord_matrix_names = {},
|
|
107
|
-
const NameList&
|
|
108
|
-
const NameList& uniform_texcoord_max_names = {},
|
|
109
|
-
const NameList& uniform_texcoord_offset_names = {},
|
|
111
|
+
const NameList& uniform_texcoord_pixel_names = {},
|
|
110
112
|
const NameList& uniform_texture_names = {},
|
|
111
113
|
uint flags = 0);
|
|
112
114
|
|
data/include/rays.h
CHANGED
data/lib/rays/extension.rb
CHANGED
|
@@ -5,8 +5,10 @@ module Rays
|
|
|
5
5
|
|
|
6
6
|
module_function
|
|
7
7
|
|
|
8
|
-
def name()
|
|
9
|
-
super.split('::')[-2]
|
|
8
|
+
def name(downcase = false)
|
|
9
|
+
super().split('::')[-2].then {|s|
|
|
10
|
+
downcase ? s.gsub(/([a-z])([A-Z])/) {"#{$1}-#{$2}"}.downcase : s
|
|
11
|
+
}
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
def version()
|
|
@@ -29,6 +31,10 @@ module Rays
|
|
|
29
31
|
root_dir 'ext'
|
|
30
32
|
end
|
|
31
33
|
|
|
34
|
+
def lib_name()
|
|
35
|
+
"#{name true}.dll" if /mswin|ming|cygwin/.match? RUBY_PLATFORM
|
|
36
|
+
end
|
|
37
|
+
|
|
32
38
|
end# Extension
|
|
33
39
|
|
|
34
40
|
|