rays 0.1.28 → 0.1.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/rays/bitmap.cpp +1 -1
- data/.doc/ext/rays/bounds.cpp +1 -1
- data/.doc/ext/rays/camera.cpp +1 -1
- data/.doc/ext/rays/color.cpp +1 -1
- data/.doc/ext/rays/color_space.cpp +1 -1
- data/.doc/ext/rays/exception.cpp +45 -0
- data/.doc/ext/rays/font.cpp +1 -1
- data/.doc/ext/rays/image.cpp +1 -1
- data/.doc/ext/rays/matrix.cpp +1 -1
- data/.doc/ext/rays/native.cpp +35 -33
- data/.doc/ext/rays/noise.cpp +1 -1
- data/.doc/ext/rays/painter.cpp +1 -1
- data/.doc/ext/rays/point.cpp +1 -1
- data/.doc/ext/rays/polygon.cpp +1 -1
- data/.doc/ext/rays/polygon_line.cpp +1 -1
- data/.doc/ext/rays/polyline.cpp +1 -1
- data/.doc/ext/rays/shader.cpp +101 -7
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +1 -1
- data/ext/rays/bounds.cpp +1 -1
- data/ext/rays/camera.cpp +1 -1
- data/ext/rays/color.cpp +1 -1
- data/ext/rays/color_space.cpp +1 -1
- data/ext/rays/defs.h +1 -0
- data/ext/rays/exception.cpp +45 -0
- data/ext/rays/extconf.rb +1 -1
- data/ext/rays/font.cpp +1 -1
- data/ext/rays/image.cpp +1 -1
- data/ext/rays/matrix.cpp +1 -1
- data/ext/rays/native.cpp +35 -33
- data/ext/rays/noise.cpp +1 -1
- data/ext/rays/painter.cpp +1 -1
- data/ext/rays/point.cpp +1 -1
- data/ext/rays/polygon.cpp +1 -1
- data/ext/rays/polygon_line.cpp +1 -1
- data/ext/rays/polyline.cpp +1 -1
- data/ext/rays/shader.cpp +102 -6
- data/include/rays/exception.h +11 -0
- data/include/rays/ruby/bitmap.h +0 -1
- data/include/rays/ruby/bounds.h +0 -2
- data/include/rays/ruby/camera.h +0 -1
- data/include/rays/ruby/color.h +0 -2
- data/include/rays/ruby/color_space.h +0 -1
- data/include/rays/ruby/defs.h +30 -0
- data/include/rays/ruby/exception.h +28 -0
- data/include/rays/ruby/font.h +0 -1
- data/include/rays/ruby/image.h +0 -1
- data/include/rays/ruby/matrix.h +0 -1
- data/include/rays/ruby/painter.h +0 -1
- data/include/rays/ruby/point.h +0 -2
- data/include/rays/ruby/polygon.h +0 -1
- data/include/rays/ruby/polyline.h +0 -1
- data/include/rays/ruby/rays.h +0 -1
- data/include/rays/ruby/shader.h +0 -1
- data/include/rays/ruby.h +2 -0
- data/include/rays/shader.h +48 -1
- data/lib/rays/painter.rb +6 -5
- data/lib/rays/point.rb +1 -0
- data/lib/rays/shader.rb +18 -5
- data/rays.gemspec +3 -3
- data/src/exception.cpp +13 -0
- data/src/image.cpp +6 -4
- data/src/opengl.cpp +20 -7
- data/src/opengl.h +5 -3
- data/src/osx/font.mm +0 -2
- data/src/osx/opengl.mm +17 -2
- data/src/painter.cpp +181 -148
- data/src/shader.cpp +333 -53
- data/src/shader.h +53 -14
- data/src/shader_program.cpp +53 -27
- data/src/shader_program.h +8 -1
- data/src/shader_source.cpp +2 -2
- data/src/texture.cpp +80 -63
- data/test/helper.rb +1 -1
- data/test/test_point.rb +6 -5
- data/test/test_rays.rb +2 -2
- data/test/test_shader.rb +151 -14
- metadata +12 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88387a7d63567dd0f87d5c28708d1c666b7bd41df31ae34d676a9fcfeb4b19b5
|
4
|
+
data.tar.gz: 6a05891d8c4aee2b2ffbdc11fd9d6acc9dee8678f7e98180d399f6a64b04383b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14ec81d1d115983f66e39432af1f98d29efe759bf891412fb67e85b09801c89fa6702e4970fd56fcb29cc1d2dfacbeb7d5edc8fb43aaa17accf964bca2b4df30
|
7
|
+
data.tar.gz: 4d07ba7e7280e7aba01eed8b483978e750a6bfc5201a345e062977cf379c10f12ca1d75b38ef00677bc0bd0798245050cc14c5f0aa33e70fd93dcca5aa58d920
|
data/.doc/ext/rays/bitmap.cpp
CHANGED
data/.doc/ext/rays/bounds.cpp
CHANGED
data/.doc/ext/rays/camera.cpp
CHANGED
data/.doc/ext/rays/color.cpp
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
#include "rays/ruby/exception.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include "defs.h"
|
5
|
+
|
6
|
+
|
7
|
+
static Class cRaysError;
|
8
|
+
static Class cOpenGLError;
|
9
|
+
static Class cShaderError;
|
10
|
+
|
11
|
+
void
|
12
|
+
Init_rays_exception ()
|
13
|
+
{
|
14
|
+
Module mRays = rb_define_module("Rays");
|
15
|
+
|
16
|
+
cRaysError = rb_define_class_under(mRays, "RaysError", rb_eRuntimeError);
|
17
|
+
cOpenGLError = rb_define_class_under(mRays, "OpenGLError", cRaysError);
|
18
|
+
cShaderError = rb_define_class_under(mRays, "ShaderError", cOpenGLError);
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
namespace Rays
|
23
|
+
{
|
24
|
+
|
25
|
+
|
26
|
+
Class
|
27
|
+
rays_error_class ()
|
28
|
+
{
|
29
|
+
return cRaysError;
|
30
|
+
}
|
31
|
+
|
32
|
+
Class
|
33
|
+
opengl_error_class ()
|
34
|
+
{
|
35
|
+
return cOpenGLError;
|
36
|
+
}
|
37
|
+
|
38
|
+
Class
|
39
|
+
shader_error_class ()
|
40
|
+
{
|
41
|
+
return cShaderError;
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
}// Rays
|
data/.doc/ext/rays/font.cpp
CHANGED
data/.doc/ext/rays/image.cpp
CHANGED
data/.doc/ext/rays/matrix.cpp
CHANGED
data/.doc/ext/rays/native.cpp
CHANGED
@@ -2,24 +2,25 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
void Init_rays ();
|
5
|
+
void Init_rays_exception ();
|
5
6
|
|
6
|
-
void
|
7
|
-
void
|
8
|
-
void
|
9
|
-
void
|
10
|
-
void
|
7
|
+
void Init_rays_point ();
|
8
|
+
void Init_rays_bounds ();
|
9
|
+
void Init_rays_color ();
|
10
|
+
void Init_rays_color_space ();
|
11
|
+
void Init_rays_matrix ();
|
11
12
|
|
12
|
-
void
|
13
|
-
void
|
14
|
-
void
|
15
|
-
void
|
16
|
-
void
|
17
|
-
void
|
18
|
-
void
|
19
|
-
void
|
20
|
-
void
|
13
|
+
void Init_rays_painter ();
|
14
|
+
void Init_rays_polyline ();
|
15
|
+
void Init_rays_polygon_line ();
|
16
|
+
void Init_rays_polygon ();
|
17
|
+
void Init_rays_bitmap ();
|
18
|
+
void Init_rays_image ();
|
19
|
+
void Init_rays_font ();
|
20
|
+
void Init_rays_shader ();
|
21
|
+
void Init_rays_camera ();
|
21
22
|
|
22
|
-
void
|
23
|
+
void Init_rays_noise ();
|
23
24
|
|
24
25
|
|
25
26
|
extern "C" void
|
@@ -34,24 +35,25 @@ extern "C" void
|
|
34
35
|
Rucy::init();
|
35
36
|
|
36
37
|
Init_rays();
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
38
|
+
Init_rays_exception();
|
39
|
+
|
40
|
+
Init_rays_point();
|
41
|
+
Init_rays_bounds();
|
42
|
+
Init_rays_color();
|
43
|
+
Init_rays_color_space();
|
44
|
+
Init_rays_matrix();
|
45
|
+
|
46
|
+
Init_rays_painter();
|
47
|
+
Init_rays_polyline();
|
48
|
+
Init_rays_polygon_line();
|
49
|
+
Init_rays_polygon();
|
50
|
+
Init_rays_bitmap();
|
51
|
+
Init_rays_image();
|
52
|
+
Init_rays_font();
|
53
|
+
Init_rays_shader();
|
54
|
+
Init_rays_camera();
|
55
|
+
|
56
|
+
Init_rays_noise();
|
55
57
|
|
56
58
|
RUCY_CATCH
|
57
59
|
}
|
data/.doc/ext/rays/noise.cpp
CHANGED
data/.doc/ext/rays/painter.cpp
CHANGED
data/.doc/ext/rays/point.cpp
CHANGED
data/.doc/ext/rays/polygon.cpp
CHANGED
data/.doc/ext/rays/polyline.cpp
CHANGED
data/.doc/ext/rays/shader.cpp
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "rays/ruby/shader.h"
|
2
2
|
|
3
3
|
|
4
|
+
#include "rays/ruby/image.h"
|
4
5
|
#include "defs.h"
|
5
6
|
|
6
7
|
|
@@ -17,12 +18,83 @@ VALUE alloc(VALUE klass)
|
|
17
18
|
return new_type<Rays::Shader>(klass);
|
18
19
|
}
|
19
20
|
|
21
|
+
static const char*
|
22
|
+
to_name (const Value& names, size_t index)
|
23
|
+
{
|
24
|
+
if (!names || !names.is_array() || index >= names.size())
|
25
|
+
return NULL;
|
26
|
+
|
27
|
+
const auto& name = names[index];
|
28
|
+
if (!name) return NULL;
|
29
|
+
|
30
|
+
return name.c_str();
|
31
|
+
}
|
32
|
+
|
33
|
+
static Rays::ShaderEnv::NameList
|
34
|
+
to_name_list (const Value& names, size_t index)
|
35
|
+
{
|
36
|
+
if (!names || !names.is_array() || index >= names.size())
|
37
|
+
return {};
|
38
|
+
|
39
|
+
const auto& name_or_array = names[index];
|
40
|
+
if (name_or_array.is_array())
|
41
|
+
{
|
42
|
+
Rays::ShaderEnv::NameList list;
|
43
|
+
for (size_t i = 0; i < name_or_array.size(); ++i)
|
44
|
+
list.emplace_back(name_or_array[i].c_str());
|
45
|
+
return list;
|
46
|
+
}
|
47
|
+
else if (name_or_array.is_s() || name_or_array.is_sym())
|
48
|
+
return {Xot::String(name_or_array.c_str())};
|
49
|
+
else
|
50
|
+
return {};
|
51
|
+
}
|
52
|
+
|
53
|
+
static std::shared_ptr<Rays::ShaderEnv>
|
54
|
+
make_env (const Value& names, const Value& ignore_no_uniform_location_error)
|
55
|
+
{
|
56
|
+
bool has_names = names && names.is_array() && !names.empty();
|
57
|
+
if (!has_names && !ignore_no_uniform_location_error)
|
58
|
+
return NULL;
|
59
|
+
|
60
|
+
uint flags = 0;
|
61
|
+
if (ignore_no_uniform_location_error)
|
62
|
+
flags |= Rays::ShaderEnv::IGNORE_NO_UNIFORM_LOCATION_ERROR;
|
63
|
+
|
64
|
+
return std::make_shared<Rays::ShaderEnv>(
|
65
|
+
to_name_list(names, 0),
|
66
|
+
to_name_list(names, 1),
|
67
|
+
to_name_list(names, 2),
|
68
|
+
to_name( names, 3),
|
69
|
+
to_name( names, 4),
|
70
|
+
to_name( names, 5),
|
71
|
+
to_name_list(names, 6),
|
72
|
+
to_name_list(names, 7),
|
73
|
+
to_name_list(names, 8),
|
74
|
+
to_name_list(names, 9),
|
75
|
+
to_name_list(names, 10),
|
76
|
+
to_name_list(names, 11),
|
77
|
+
flags);
|
78
|
+
}
|
79
|
+
|
20
80
|
static
|
21
|
-
VALUE setup(VALUE self, VALUE
|
81
|
+
VALUE setup(VALUE self, VALUE
|
82
|
+
fragment_shader_source, VALUE vertex_shader_source, VALUE
|
83
|
+
builtin_variable_names, VALUE ignore_no_uniform_location_error)
|
22
84
|
{
|
23
85
|
RUCY_CHECK_OBJ(Rays::Shader, self);
|
24
86
|
|
25
|
-
|
87
|
+
if (fragment_shader_source.is_nil())
|
88
|
+
argument_error(__FILE__, __LINE__);
|
89
|
+
|
90
|
+
const char* fs = fragment_shader_source.c_str();
|
91
|
+
const char* vs = vertex_shader_source ? vertex_shader_source.c_str() : NULL;
|
92
|
+
|
93
|
+
auto env = make_env(builtin_variable_names, ignore_no_uniform_location_error);
|
94
|
+
if (env)
|
95
|
+
*THIS = Rays::Shader(fs, vs, *env);
|
96
|
+
else
|
97
|
+
*THIS = Rays::Shader(fs, vs);
|
26
98
|
}
|
27
99
|
|
28
100
|
static
|
@@ -31,9 +103,6 @@ VALUE set_uniform(VALUE self)
|
|
31
103
|
CHECK;
|
32
104
|
check_arg_count(__FILE__, __LINE__, "Painter#set_uniform", argc, 2, 3, 4, 5);
|
33
105
|
|
34
|
-
#define Ai(n) (argv[n].as_i())
|
35
|
-
#define Af(n) ((float) argv[n].as_f())
|
36
|
-
|
37
106
|
const char* name = argv[0].c_str();
|
38
107
|
if (argv[1].is_array())
|
39
108
|
{
|
@@ -46,6 +115,9 @@ VALUE set_uniform(VALUE self)
|
|
46
115
|
argv += 1;
|
47
116
|
}
|
48
117
|
|
118
|
+
#define Ai(n) (argv[n].as_i())
|
119
|
+
#define Af(n) ((float) argv[n].as_f())
|
120
|
+
|
49
121
|
if (argv[0].is_i())
|
50
122
|
{
|
51
123
|
switch (argc)
|
@@ -66,6 +138,8 @@ VALUE set_uniform(VALUE self)
|
|
66
138
|
case 4: THIS->set_uniform(name, Af(0), Af(1), Af(2), Af(3)); break;
|
67
139
|
}
|
68
140
|
}
|
141
|
+
else if (argv[0].is_kind_of(Rays::image_class()))
|
142
|
+
THIS->set_uniform(name, to<Rays::Image&>(argv[0]));
|
69
143
|
else
|
70
144
|
argument_error(__FILE__, __LINE__);
|
71
145
|
|
@@ -75,18 +149,38 @@ VALUE set_uniform(VALUE self)
|
|
75
149
|
return self;
|
76
150
|
}
|
77
151
|
|
152
|
+
static
|
153
|
+
VALUE get_vertex_shader_source(VALUE self)
|
154
|
+
{
|
155
|
+
CHECK;
|
156
|
+
|
157
|
+
const char* source = THIS->vertex_shader_source();
|
158
|
+
return source ? value(source) : nil();
|
159
|
+
}
|
160
|
+
|
161
|
+
static
|
162
|
+
VALUE get_fragment_shader_source(VALUE self)
|
163
|
+
{
|
164
|
+
CHECK;
|
165
|
+
|
166
|
+
const char* source = THIS->fragment_shader_source();
|
167
|
+
return source ? value(source) : nil();
|
168
|
+
}
|
169
|
+
|
78
170
|
|
79
171
|
static Class cShader;
|
80
172
|
|
81
173
|
void
|
82
|
-
|
174
|
+
Init_rays_shader ()
|
83
175
|
{
|
84
176
|
Module mRays = rb_define_module("Rays");
|
85
177
|
|
86
178
|
cShader = rb_define_class_under(mRays, "Shader", rb_cObject);
|
87
179
|
rb_define_alloc_func(cShader, alloc);
|
88
|
-
rb_define_private_method(cShader, "setup", RUBY_METHOD_FUNC(setup),
|
180
|
+
rb_define_private_method(cShader, "setup", RUBY_METHOD_FUNC(setup), 4);
|
89
181
|
rb_define_private_method(cShader, "set_uniform", RUBY_METHOD_FUNC(set_uniform), -1);
|
182
|
+
rb_define_method(cShader, "vertex_shader_source", RUBY_METHOD_FUNC(get_vertex_shader_source), 0);
|
183
|
+
rb_define_method(cShader, "fragment_shader_source", RUBY_METHOD_FUNC(get_fragment_shader_source), 0);
|
90
184
|
}
|
91
185
|
|
92
186
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.30
|
data/ext/rays/bitmap.cpp
CHANGED
data/ext/rays/bounds.cpp
CHANGED
data/ext/rays/camera.cpp
CHANGED
data/ext/rays/color.cpp
CHANGED
data/ext/rays/color_space.cpp
CHANGED
data/ext/rays/defs.h
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
#include "rays/ruby/exception.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include "defs.h"
|
5
|
+
|
6
|
+
|
7
|
+
static Class cRaysError;
|
8
|
+
static Class cOpenGLError;
|
9
|
+
static Class cShaderError;
|
10
|
+
|
11
|
+
void
|
12
|
+
Init_rays_exception ()
|
13
|
+
{
|
14
|
+
Module mRays = define_module("Rays");
|
15
|
+
|
16
|
+
cRaysError = mRays.define_class("RaysError", rb_eRuntimeError);
|
17
|
+
cOpenGLError = mRays.define_class("OpenGLError", cRaysError);
|
18
|
+
cShaderError = mRays.define_class("ShaderError", cOpenGLError);
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
namespace Rays
|
23
|
+
{
|
24
|
+
|
25
|
+
|
26
|
+
Class
|
27
|
+
rays_error_class ()
|
28
|
+
{
|
29
|
+
return cRaysError;
|
30
|
+
}
|
31
|
+
|
32
|
+
Class
|
33
|
+
opengl_error_class ()
|
34
|
+
{
|
35
|
+
return cOpenGLError;
|
36
|
+
}
|
37
|
+
|
38
|
+
Class
|
39
|
+
shader_error_class ()
|
40
|
+
{
|
41
|
+
return cShaderError;
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
}// Rays
|
data/ext/rays/extconf.rb
CHANGED
data/ext/rays/font.cpp
CHANGED
data/ext/rays/image.cpp
CHANGED
data/ext/rays/matrix.cpp
CHANGED
data/ext/rays/native.cpp
CHANGED
@@ -2,24 +2,25 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
void Init_rays ();
|
5
|
+
void Init_rays_exception ();
|
5
6
|
|
6
|
-
void
|
7
|
-
void
|
8
|
-
void
|
9
|
-
void
|
10
|
-
void
|
7
|
+
void Init_rays_point ();
|
8
|
+
void Init_rays_bounds ();
|
9
|
+
void Init_rays_color ();
|
10
|
+
void Init_rays_color_space ();
|
11
|
+
void Init_rays_matrix ();
|
11
12
|
|
12
|
-
void
|
13
|
-
void
|
14
|
-
void
|
15
|
-
void
|
16
|
-
void
|
17
|
-
void
|
18
|
-
void
|
19
|
-
void
|
20
|
-
void
|
13
|
+
void Init_rays_painter ();
|
14
|
+
void Init_rays_polyline ();
|
15
|
+
void Init_rays_polygon_line ();
|
16
|
+
void Init_rays_polygon ();
|
17
|
+
void Init_rays_bitmap ();
|
18
|
+
void Init_rays_image ();
|
19
|
+
void Init_rays_font ();
|
20
|
+
void Init_rays_shader ();
|
21
|
+
void Init_rays_camera ();
|
21
22
|
|
22
|
-
void
|
23
|
+
void Init_rays_noise ();
|
23
24
|
|
24
25
|
|
25
26
|
extern "C" void
|
@@ -34,24 +35,25 @@ extern "C" void
|
|
34
35
|
Rucy::init();
|
35
36
|
|
36
37
|
Init_rays();
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
38
|
+
Init_rays_exception();
|
39
|
+
|
40
|
+
Init_rays_point();
|
41
|
+
Init_rays_bounds();
|
42
|
+
Init_rays_color();
|
43
|
+
Init_rays_color_space();
|
44
|
+
Init_rays_matrix();
|
45
|
+
|
46
|
+
Init_rays_painter();
|
47
|
+
Init_rays_polyline();
|
48
|
+
Init_rays_polygon_line();
|
49
|
+
Init_rays_polygon();
|
50
|
+
Init_rays_bitmap();
|
51
|
+
Init_rays_image();
|
52
|
+
Init_rays_font();
|
53
|
+
Init_rays_shader();
|
54
|
+
Init_rays_camera();
|
55
|
+
|
56
|
+
Init_rays_noise();
|
55
57
|
|
56
58
|
RUCY_CATCH
|
57
59
|
}
|