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
data/lib/rays/shader.rb
CHANGED
|
@@ -17,10 +17,19 @@ module Rays
|
|
|
17
17
|
setup(
|
|
18
18
|
fragment_shader_source, vertex_shader_source,
|
|
19
19
|
builtin_variable_names&.values_at(
|
|
20
|
-
:attribute_position,
|
|
21
|
-
|
|
22
|
-
:
|
|
23
|
-
:
|
|
20
|
+
:attribute_position,
|
|
21
|
+
:attribute_texcoord,
|
|
22
|
+
:attribute_texcoord_min,
|
|
23
|
+
:attribute_texcoord_max,
|
|
24
|
+
:attribute_color,
|
|
25
|
+
:varying_position,
|
|
26
|
+
:varying_texcoord,
|
|
27
|
+
:varying_texcoord_min,
|
|
28
|
+
:varying_texcoord_max,
|
|
29
|
+
:varying_color,
|
|
30
|
+
:uniform_position_matrix,
|
|
31
|
+
:uniform_texcoord_matrix,
|
|
32
|
+
:uniform_texcoord_pixel,
|
|
24
33
|
:uniform_texture),
|
|
25
34
|
ignore_no_uniform_location_error)
|
|
26
35
|
|
data/rays.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
ext = Rays::Extension
|
|
13
|
-
name = ext.name
|
|
13
|
+
name = ext.name true
|
|
14
14
|
rdocs = glob.call *%w[README .doc/ext/**/*.cpp]
|
|
15
15
|
|
|
16
16
|
s.name = name
|
|
@@ -25,14 +25,13 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
s.platform = Gem::Platform::RUBY
|
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
|
27
27
|
|
|
28
|
-
s.add_dependency 'xot', '~> 0.3.
|
|
29
|
-
s.add_dependency 'rucy', '~> 0.3.
|
|
28
|
+
s.add_dependency 'xot', '~> 0.3.12'
|
|
29
|
+
s.add_dependency 'rucy', '~> 0.3.12'
|
|
30
30
|
|
|
31
31
|
s.files = `git ls-files`.split $/
|
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
|
33
33
|
s.test_files = s.files.grep %r{^(test|spec|features)/}
|
|
34
34
|
s.extra_rdoc_files = rdocs.to_a
|
|
35
|
-
s.has_rdoc = true
|
|
36
35
|
|
|
37
36
|
s.metadata['msys2_mingw_dependencies'] = 'glew'
|
|
38
37
|
|
data/src/color_space.cpp
CHANGED
|
@@ -133,7 +133,7 @@ namespace Rays
|
|
|
133
133
|
ColorSpace::has_alpha () const
|
|
134
134
|
{
|
|
135
135
|
return
|
|
136
|
-
(ALPHA_FIRST <= type_ && type_ <= ALPHA_LAST) ||
|
|
136
|
+
(ALPHA_FIRST <= (int) type_ && (int) type_ <= ALPHA_LAST) ||
|
|
137
137
|
type_ == RGBA_8888 || type_ == ARGB_8888 ||
|
|
138
138
|
type_ == BGRA_8888 || type_ == ABGR_8888 ||
|
|
139
139
|
type_ == RGBA_float || type_ == ARGB_float ||
|
data/src/coord.h
CHANGED
|
@@ -21,12 +21,22 @@ namespace Rays
|
|
|
21
21
|
|
|
22
22
|
inline const Vec3& to_glm (const Coord3& val) {return *(const Vec3*) &val;}
|
|
23
23
|
|
|
24
|
+
inline Vec4& to_glm ( Coord4& val) {return *( Vec4*) &val;}
|
|
25
|
+
|
|
26
|
+
inline const Vec4& to_glm (const Coord4& val) {return *(const Vec4*) &val;}
|
|
27
|
+
|
|
24
28
|
template <typename T>
|
|
25
29
|
inline T& to_rays ( Vec3& val) {return *( T*) &val;}
|
|
26
30
|
|
|
27
31
|
template <typename T>
|
|
28
32
|
inline const T& to_rays (const Vec3& val) {return *(const T*) &val;}
|
|
29
33
|
|
|
34
|
+
template <typename T>
|
|
35
|
+
inline T& to_rays ( Vec4& val) {return *( T*) &val;}
|
|
36
|
+
|
|
37
|
+
template <typename T>
|
|
38
|
+
inline const T& to_rays (const Vec4& val) {return *(const T*) &val;}
|
|
39
|
+
|
|
30
40
|
|
|
31
41
|
}// Rays
|
|
32
42
|
|
data/src/font.cpp
CHANGED
data/src/image.cpp
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
#if 0
|
|
13
|
-
#define PRINT_MODIFIED_FLAGS(message)
|
|
13
|
+
#define PRINT_MODIFIED_FLAGS(message) get_data(this)->print_modified_flags(message)
|
|
14
14
|
#else
|
|
15
15
|
#define PRINT_MODIFIED_FLAGS(message)
|
|
16
16
|
#endif
|
|
@@ -20,16 +20,16 @@ namespace Rays
|
|
|
20
20
|
{
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
struct Image::Data
|
|
23
|
+
struct ImageData : Image::Data
|
|
24
24
|
{
|
|
25
25
|
|
|
26
26
|
int width = 0, height = 0;
|
|
27
27
|
|
|
28
|
-
ColorSpace color_space;
|
|
29
|
-
|
|
30
28
|
float pixel_density = 1;
|
|
31
29
|
|
|
32
|
-
bool smooth
|
|
30
|
+
bool smooth = false;
|
|
31
|
+
|
|
32
|
+
ColorSpace color_space;
|
|
33
33
|
|
|
34
34
|
mutable Bitmap bitmap;
|
|
35
35
|
|
|
@@ -48,10 +48,23 @@ namespace Rays
|
|
|
48
48
|
};// Image::Data
|
|
49
49
|
|
|
50
50
|
|
|
51
|
+
static ImageData*
|
|
52
|
+
get_data (Image* image)
|
|
53
|
+
{
|
|
54
|
+
return (ImageData*) image->self.get();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static const ImageData*
|
|
58
|
+
get_data (const Image* image)
|
|
59
|
+
{
|
|
60
|
+
return (const ImageData*) image->self.get();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
51
64
|
static void
|
|
52
65
|
clear_modified_flags (Image* image)
|
|
53
66
|
{
|
|
54
|
-
|
|
67
|
+
ImageData* self = get_data(image);
|
|
55
68
|
|
|
56
69
|
if (self->bitmap) Bitmap_set_modified(&self->bitmap, false);
|
|
57
70
|
if (self->texture) self->texture.set_modified(false);
|
|
@@ -61,7 +74,7 @@ namespace Rays
|
|
|
61
74
|
invalidate_texture (Image* image)
|
|
62
75
|
{
|
|
63
76
|
image->bitmap();// update bitmap
|
|
64
|
-
image->
|
|
77
|
+
get_data(image)->texture = Texture();
|
|
65
78
|
}
|
|
66
79
|
|
|
67
80
|
static Bitmap&
|
|
@@ -69,7 +82,7 @@ namespace Rays
|
|
|
69
82
|
{
|
|
70
83
|
assert(image);
|
|
71
84
|
|
|
72
|
-
|
|
85
|
+
ImageData* self = get_data(image);
|
|
73
86
|
|
|
74
87
|
if (!*image)
|
|
75
88
|
{
|
|
@@ -112,7 +125,7 @@ namespace Rays
|
|
|
112
125
|
Texture&
|
|
113
126
|
Image_get_texture (Image& image)
|
|
114
127
|
{
|
|
115
|
-
|
|
128
|
+
ImageData* self = get_data(&image);
|
|
116
129
|
|
|
117
130
|
if (!image)
|
|
118
131
|
{
|
|
@@ -171,17 +184,30 @@ namespace Rays
|
|
|
171
184
|
}
|
|
172
185
|
|
|
173
186
|
|
|
187
|
+
Image::Data::~Data ()
|
|
188
|
+
{
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
void
|
|
192
|
+
Image::Data::preprocess (const Image*) const
|
|
193
|
+
{
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
174
197
|
Image::Image ()
|
|
198
|
+
: self(new ImageData())
|
|
175
199
|
{
|
|
176
200
|
}
|
|
177
201
|
|
|
178
202
|
Image::Image (
|
|
179
203
|
int width, int height, const ColorSpace& cs,
|
|
180
204
|
float pixel_density, bool smooth)
|
|
205
|
+
: self(new ImageData())
|
|
181
206
|
{
|
|
182
207
|
if (pixel_density <= 0)
|
|
183
208
|
argument_error(__FILE__, __LINE__, "invalid pixel_density.");
|
|
184
209
|
|
|
210
|
+
ImageData* self = get_data(this);
|
|
185
211
|
self->width = (int) (width * pixel_density);
|
|
186
212
|
self->height = (int) (height * pixel_density);
|
|
187
213
|
self->color_space = cs;
|
|
@@ -190,10 +216,12 @@ namespace Rays
|
|
|
190
216
|
}
|
|
191
217
|
|
|
192
218
|
Image::Image (const Bitmap& bitmap, float pixel_density, bool smooth)
|
|
219
|
+
: self(new ImageData())
|
|
193
220
|
{
|
|
194
221
|
if (pixel_density <= 0)
|
|
195
222
|
argument_error(__FILE__, __LINE__, "invalid pixel_density.");
|
|
196
223
|
|
|
224
|
+
ImageData* self = get_data(this);
|
|
197
225
|
self->bitmap = bitmap;
|
|
198
226
|
self->width = bitmap.width();
|
|
199
227
|
self->height = bitmap.height();
|
|
@@ -202,6 +230,11 @@ namespace Rays
|
|
|
202
230
|
self->smooth = smooth;
|
|
203
231
|
}
|
|
204
232
|
|
|
233
|
+
Image::Image (Data* data)
|
|
234
|
+
: self(data)
|
|
235
|
+
{
|
|
236
|
+
}
|
|
237
|
+
|
|
205
238
|
Image::~Image ()
|
|
206
239
|
{
|
|
207
240
|
}
|
|
@@ -209,12 +242,16 @@ namespace Rays
|
|
|
209
242
|
Image
|
|
210
243
|
Image::dup () const
|
|
211
244
|
{
|
|
245
|
+
self->preprocess(this);
|
|
246
|
+
|
|
212
247
|
return Image(bitmap().dup(), pixel_density());
|
|
213
248
|
}
|
|
214
249
|
|
|
215
250
|
void
|
|
216
251
|
Image::save (const char* path)
|
|
217
252
|
{
|
|
253
|
+
self->preprocess(this);
|
|
254
|
+
|
|
218
255
|
if (!*this)
|
|
219
256
|
invalid_state_error(__FILE__, __LINE__);
|
|
220
257
|
|
|
@@ -224,32 +261,47 @@ namespace Rays
|
|
|
224
261
|
coord
|
|
225
262
|
Image::width () const
|
|
226
263
|
{
|
|
264
|
+
self->preprocess(this);
|
|
265
|
+
|
|
266
|
+
const ImageData* self = get_data(this);
|
|
227
267
|
return self->width / self->pixel_density;
|
|
228
268
|
}
|
|
229
269
|
|
|
230
270
|
coord
|
|
231
271
|
Image::height () const
|
|
232
272
|
{
|
|
273
|
+
self->preprocess(this);
|
|
274
|
+
|
|
275
|
+
const ImageData* self = get_data(this);
|
|
233
276
|
return self->height / self->pixel_density;
|
|
234
277
|
}
|
|
235
278
|
|
|
236
279
|
const ColorSpace&
|
|
237
280
|
Image::color_space () const
|
|
238
281
|
{
|
|
282
|
+
self->preprocess(this);
|
|
283
|
+
|
|
284
|
+
const ImageData* self = get_data(this);
|
|
239
285
|
return self->color_space;
|
|
240
286
|
}
|
|
241
287
|
|
|
242
288
|
float
|
|
243
289
|
Image::pixel_density () const
|
|
244
290
|
{
|
|
291
|
+
self->preprocess(this);
|
|
292
|
+
|
|
293
|
+
const ImageData* self = get_data(this);
|
|
245
294
|
return self->pixel_density;
|
|
246
295
|
}
|
|
247
296
|
|
|
248
297
|
void
|
|
249
298
|
Image::set_smooth (bool smooth)
|
|
250
299
|
{
|
|
251
|
-
|
|
300
|
+
self->preprocess(this);
|
|
301
|
+
|
|
302
|
+
ImageData* self = get_data(this);
|
|
252
303
|
|
|
304
|
+
if (smooth == self->smooth) return;
|
|
253
305
|
self->smooth = smooth;
|
|
254
306
|
invalidate_texture(this);
|
|
255
307
|
}
|
|
@@ -257,12 +309,17 @@ namespace Rays
|
|
|
257
309
|
bool
|
|
258
310
|
Image::smooth () const
|
|
259
311
|
{
|
|
312
|
+
self->preprocess(this);
|
|
313
|
+
|
|
314
|
+
const ImageData* self = get_data(this);
|
|
260
315
|
return self->smooth;
|
|
261
316
|
}
|
|
262
317
|
|
|
263
318
|
Painter
|
|
264
319
|
Image::painter ()
|
|
265
320
|
{
|
|
321
|
+
self->preprocess(this);
|
|
322
|
+
|
|
266
323
|
Painter p;
|
|
267
324
|
p.bind(*this);
|
|
268
325
|
return p;
|
|
@@ -271,6 +328,9 @@ namespace Rays
|
|
|
271
328
|
Bitmap&
|
|
272
329
|
Image::bitmap (bool modify)
|
|
273
330
|
{
|
|
331
|
+
self->preprocess(this);
|
|
332
|
+
|
|
333
|
+
ImageData* self = get_data(this);
|
|
274
334
|
if (modify)
|
|
275
335
|
{
|
|
276
336
|
if (!self->bitmap) get_bitmap(this);
|
|
@@ -287,6 +347,9 @@ namespace Rays
|
|
|
287
347
|
|
|
288
348
|
Image::operator bool () const
|
|
289
349
|
{
|
|
350
|
+
self->preprocess(this);
|
|
351
|
+
|
|
352
|
+
const ImageData* self = get_data(this);
|
|
290
353
|
return
|
|
291
354
|
self->width > 0 &&
|
|
292
355
|
self->height > 0 &&
|
|
@@ -300,5 +363,17 @@ namespace Rays
|
|
|
300
363
|
return !operator bool();
|
|
301
364
|
}
|
|
302
365
|
|
|
366
|
+
bool
|
|
367
|
+
operator == (const Image& lhs, const Image& rhs)
|
|
368
|
+
{
|
|
369
|
+
return lhs.self == rhs.self;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
bool
|
|
373
|
+
operator != (const Image& lhs, const Image& rhs)
|
|
374
|
+
{
|
|
375
|
+
return !operator==(lhs, rhs);
|
|
376
|
+
}
|
|
377
|
+
|
|
303
378
|
|
|
304
379
|
}// Rays
|