rays 0.1.29 → 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 +1 -1
- 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 -35
- 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 +1 -1
- 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/exception.cpp +1 -1
- 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 -35
- 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 +1 -1
- data/rays.gemspec +3 -3
- data/src/opengl.cpp +2 -3
- data/src/painter.cpp +53 -91
- data/src/shader.cpp +4 -4
- data/src/texture.cpp +11 -6
- data/test/helper.rb +1 -1
- metadata +7 -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
data/.doc/ext/rays/exception.cpp
CHANGED
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,25 +2,25 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
void Init_rays ();
|
5
|
-
void
|
5
|
+
void Init_rays_exception ();
|
6
6
|
|
7
|
-
void
|
8
|
-
void
|
9
|
-
void
|
10
|
-
void
|
11
|
-
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 ();
|
12
12
|
|
13
|
-
void
|
14
|
-
void
|
15
|
-
void
|
16
|
-
void
|
17
|
-
void
|
18
|
-
void
|
19
|
-
void
|
20
|
-
void
|
21
|
-
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 ();
|
22
22
|
|
23
|
-
void
|
23
|
+
void Init_rays_noise ();
|
24
24
|
|
25
25
|
|
26
26
|
extern "C" void
|
@@ -35,25 +35,25 @@ extern "C" void
|
|
35
35
|
Rucy::init();
|
36
36
|
|
37
37
|
Init_rays();
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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();
|
57
57
|
|
58
58
|
RUCY_CATCH
|
59
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
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/exception.cpp
CHANGED
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,25 +2,25 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
void Init_rays ();
|
5
|
-
void
|
5
|
+
void Init_rays_exception ();
|
6
6
|
|
7
|
-
void
|
8
|
-
void
|
9
|
-
void
|
10
|
-
void
|
11
|
-
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 ();
|
12
12
|
|
13
|
-
void
|
14
|
-
void
|
15
|
-
void
|
16
|
-
void
|
17
|
-
void
|
18
|
-
void
|
19
|
-
void
|
20
|
-
void
|
21
|
-
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 ();
|
22
22
|
|
23
|
-
void
|
23
|
+
void Init_rays_noise ();
|
24
24
|
|
25
25
|
|
26
26
|
extern "C" void
|
@@ -35,25 +35,25 @@ extern "C" void
|
|
35
35
|
Rucy::init();
|
36
36
|
|
37
37
|
Init_rays();
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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();
|
57
57
|
|
58
58
|
RUCY_CATCH
|
59
59
|
}
|
data/ext/rays/noise.cpp
CHANGED
data/ext/rays/painter.cpp
CHANGED
data/ext/rays/point.cpp
CHANGED
data/ext/rays/polygon.cpp
CHANGED
data/ext/rays/polygon_line.cpp
CHANGED
data/ext/rays/polyline.cpp
CHANGED
data/ext/rays/shader.cpp
CHANGED
data/rays.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- mode: ruby; coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
-
File.expand_path('
|
4
|
+
File.expand_path('lib', __dir__)
|
5
5
|
.tap {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
|
6
6
|
|
7
7
|
require 'rays/module'
|
@@ -28,8 +28,8 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.platform = Gem::Platform::RUBY
|
29
29
|
s.required_ruby_version = '>= 2.6.0'
|
30
30
|
|
31
|
-
s.add_runtime_dependency 'xot', '~> 0.1.
|
32
|
-
s.add_runtime_dependency 'rucy', '~> 0.1.
|
31
|
+
s.add_runtime_dependency 'xot', '~> 0.1.30'
|
32
|
+
s.add_runtime_dependency 'rucy', '~> 0.1.30'
|
33
33
|
|
34
34
|
s.files = `git ls-files`.split $/
|
35
35
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/src/opengl.cpp
CHANGED
@@ -24,7 +24,7 @@ namespace Rays
|
|
24
24
|
case GL_INVALID_VALUE: return "GL_INVALID_VALUE";
|
25
25
|
case GL_INVALID_OPERATION: return "GL_INVALID_OPERATION";
|
26
26
|
case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY";
|
27
|
-
#if !defined(GL_VERSION_3_0)
|
27
|
+
#if !defined(GL_VERSION_3_0) && !defined(GL_ES_VERSION_2_0)
|
28
28
|
case GL_STACK_OVERFLOW: return "GL_STACK_OVERFLOW";
|
29
29
|
case GL_STACK_UNDERFLOW: return "GL_STACK_UNDERFLOW";
|
30
30
|
case GL_INVALID_FRAMEBUFFER_OPERATION: return "GL_INVALID_FRAMEBUFFER_OPERATION";
|
@@ -45,11 +45,10 @@ namespace Rays
|
|
45
45
|
void
|
46
46
|
OpenGL_check_error (const char* file, int line, const char* format, ...)
|
47
47
|
{
|
48
|
-
XOT_STRINGF(format, s);
|
49
|
-
|
50
48
|
GLenum e = glGetError();
|
51
49
|
if (e != GL_NO_ERROR)
|
52
50
|
{
|
51
|
+
XOT_STRINGF(format, s);
|
53
52
|
opengl_error(
|
54
53
|
file, line,
|
55
54
|
"OpenGL error %s: %s", get_error_name(e).c_str(), s.c_str());
|
data/src/painter.cpp
CHANGED
@@ -329,16 +329,18 @@ namespace Rays
|
|
329
329
|
|
330
330
|
const auto& names = Shader_get_builtin_variable_names(shader);
|
331
331
|
apply_builtin_uniforms(*program, names, texinfo);
|
332
|
-
apply_attributes(*program, names, points, npoints, texcoords, color
|
333
|
-
|
334
|
-
|
332
|
+
apply_attributes(*program, names, points, npoints, texcoords, color);
|
333
|
+
draw_indices(mode, indices, nindices, npoints);
|
334
|
+
cleanup();
|
335
335
|
|
336
336
|
ShaderProgram_deactivate();
|
337
337
|
}
|
338
338
|
|
339
339
|
private:
|
340
340
|
|
341
|
-
|
341
|
+
std::vector<GLint> locations;
|
342
|
+
|
343
|
+
std::vector<GLuint> buffers;
|
342
344
|
|
343
345
|
void apply_builtin_uniforms (
|
344
346
|
const ShaderProgram& program, const ShaderBuiltinVariableNames& names,
|
@@ -406,21 +408,16 @@ namespace Rays
|
|
406
408
|
|
407
409
|
void apply_attributes (
|
408
410
|
const ShaderProgram& program, const ShaderBuiltinVariableNames& names,
|
409
|
-
const Coord3* points, size_t npoints, const Coord3* texcoords,
|
410
|
-
|
411
|
+
const Coord3* points, size_t npoints, const Coord3* texcoords,
|
412
|
+
const Color& color)
|
411
413
|
{
|
412
414
|
assert(points && npoints > 0);
|
413
415
|
|
414
|
-
std::vector<GLuint> buffers;
|
415
|
-
LocationList locations;
|
416
|
-
|
417
416
|
apply_attribute(
|
418
|
-
&buffers, &locations,
|
419
417
|
program, names.attribute_position_names,
|
420
418
|
points, npoints);
|
421
419
|
|
422
420
|
apply_attribute(
|
423
|
-
&buffers, &locations,
|
424
421
|
program, names.attribute_texcoord_names,
|
425
422
|
texcoords ? texcoords : points, npoints);
|
426
423
|
|
@@ -429,54 +426,44 @@ namespace Rays
|
|
429
426
|
// with specific glsl 'attribute' name.
|
430
427
|
std::vector<Color> colors(npoints, color);
|
431
428
|
apply_attribute(
|
432
|
-
&buffers, &locations,
|
433
429
|
program, names.attribute_color_names,
|
434
430
|
(const Coord4*) &colors[0], npoints);
|
435
431
|
#else
|
436
432
|
for (const auto& name : names.attribute_color_names)
|
437
433
|
{
|
438
|
-
apply_attribute(
|
434
|
+
apply_attribute(program, name, [&](GLint loc) {
|
439
435
|
glVertexAttrib4fv(loc, color.array);
|
440
436
|
});
|
441
437
|
}
|
442
438
|
#endif
|
443
|
-
|
444
|
-
draw_fun();
|
445
|
-
|
446
|
-
for (auto loc : locations)
|
447
|
-
{
|
448
|
-
glDisableVertexAttribArray(loc);
|
449
|
-
OpenGL_check_error(__FILE__, __LINE__);
|
450
|
-
}
|
451
|
-
|
452
|
-
glDeleteBuffers((GLsizei) buffers.size(), &buffers[0]);
|
453
|
-
OpenGL_check_error(__FILE__, __LINE__);
|
454
439
|
}
|
455
440
|
|
456
441
|
template <typename CoordN>
|
457
442
|
void apply_attribute(
|
458
|
-
auto* buffers, LocationList* locations,
|
459
443
|
const ShaderProgram& program, const auto& names,
|
460
444
|
const CoordN* values, size_t nvalues)
|
461
445
|
{
|
462
|
-
assert(buffers);
|
463
|
-
|
464
446
|
GLuint buffer = 0;
|
465
447
|
for (const auto& name : names)
|
466
448
|
{
|
467
|
-
|
449
|
+
#ifndef IOS
|
468
450
|
if (buffer == 0)
|
469
451
|
{
|
470
|
-
buffer =
|
471
|
-
|
452
|
+
buffer = create_and_bind_buffer(
|
453
|
+
GL_ARRAY_BUFFER, values, sizeof(CoordN) * nvalues);
|
454
|
+
values = 0;
|
472
455
|
}
|
456
|
+
#endif
|
473
457
|
|
458
|
+
apply_attribute(program, name, [&](GLint loc) {
|
474
459
|
glEnableVertexAttribArray(loc);
|
475
|
-
OpenGL_check_error(
|
460
|
+
OpenGL_check_error(
|
461
|
+
__FILE__, __LINE__, "loc: %d %s\n", loc, name.c_str());
|
476
462
|
|
477
463
|
glVertexAttribPointer(
|
478
|
-
loc, CoordN::SIZE, get_gl_type<coord>(),
|
479
|
-
|
464
|
+
loc, CoordN::SIZE, get_gl_type<coord>(), GL_FALSE, 0, values);
|
465
|
+
|
466
|
+
locations.push_back(loc);
|
480
467
|
});
|
481
468
|
}
|
482
469
|
|
@@ -485,26 +472,24 @@ namespace Rays
|
|
485
472
|
}
|
486
473
|
|
487
474
|
void apply_attribute (
|
488
|
-
|
489
|
-
std::function<void(GLint)>
|
475
|
+
const ShaderProgram& program, const char* name,
|
476
|
+
std::function<void(GLint)> apply_fun)
|
490
477
|
{
|
491
478
|
GLint loc = glGetAttribLocation(program.id(), name);
|
492
479
|
if (loc < 0) return;
|
493
480
|
|
494
|
-
|
481
|
+
apply_fun(loc);
|
495
482
|
OpenGL_check_error(__FILE__, __LINE__);
|
496
|
-
|
497
|
-
if (locations) locations->push_back(loc);
|
498
483
|
}
|
499
484
|
|
500
485
|
void apply_uniform (
|
501
486
|
const ShaderProgram& program, const char* name,
|
502
|
-
std::function<void(GLint)>
|
487
|
+
std::function<void(GLint)> apply_fun)
|
503
488
|
{
|
504
489
|
GLint loc = glGetUniformLocation(program.id(), name);
|
505
490
|
if (loc < 0) return;
|
506
491
|
|
507
|
-
|
492
|
+
apply_fun(loc);
|
508
493
|
OpenGL_check_error(__FILE__, __LINE__);
|
509
494
|
}
|
510
495
|
|
@@ -518,75 +503,52 @@ namespace Rays
|
|
518
503
|
nindices = npoints;
|
519
504
|
}
|
520
505
|
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, indices, GL_STREAM_DRAW);
|
528
|
-
OpenGL_check_error(__FILE__, __LINE__);
|
506
|
+
#ifdef IOS
|
507
|
+
glDrawElements(mode, (GLsizei) nindices, GL_UNSIGNED_INT, indices);
|
508
|
+
OpenGL_check_error(__FILE__, __LINE__);
|
509
|
+
#else
|
510
|
+
create_and_bind_buffer(
|
511
|
+
GL_ELEMENT_ARRAY_BUFFER, indices, sizeof(uint) * nindices);
|
529
512
|
|
530
|
-
|
531
|
-
|
513
|
+
glDrawElements(mode, (GLsizei) nindices, GL_UNSIGNED_INT, 0);
|
514
|
+
OpenGL_check_error(__FILE__, __LINE__);
|
532
515
|
|
533
|
-
|
534
|
-
|
516
|
+
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
517
|
+
OpenGL_check_error(__FILE__, __LINE__);
|
518
|
+
#endif
|
535
519
|
}
|
536
520
|
|
537
|
-
|
538
|
-
|
521
|
+
GLuint create_and_bind_buffer (
|
522
|
+
GLenum target, const void* data, GLsizeiptr size)
|
539
523
|
{
|
540
|
-
GLuint id
|
541
|
-
|
542
|
-
|
543
|
-
glBindBuffer(GL_ARRAY_BUFFER, id);
|
524
|
+
GLuint id = 0;
|
525
|
+
glGenBuffers(1, &id);
|
544
526
|
OpenGL_check_error(__FILE__, __LINE__);
|
545
527
|
|
546
|
-
|
547
|
-
OpenGL_check_error(__FILE__, __LINE__);
|
528
|
+
buffers.push_back(id);
|
548
529
|
|
549
|
-
|
550
|
-
|
530
|
+
glBindBuffer(target, id);
|
531
|
+
OpenGL_check_error(__FILE__, __LINE__);
|
551
532
|
|
552
|
-
|
553
|
-
{
|
554
|
-
GLuint id;
|
555
|
-
glGenBuffers(1, &id);
|
533
|
+
glBufferData(target, size, data, GL_STREAM_DRAW);
|
556
534
|
OpenGL_check_error(__FILE__, __LINE__);
|
535
|
+
|
557
536
|
return id;
|
558
537
|
}
|
559
538
|
|
560
|
-
void
|
539
|
+
void cleanup ()
|
561
540
|
{
|
562
|
-
|
541
|
+
for (auto loc : locations)
|
563
542
|
{
|
564
|
-
|
565
|
-
|
543
|
+
glDisableVertexAttribArray(loc);
|
544
|
+
OpenGL_check_error(__FILE__, __LINE__);
|
566
545
|
}
|
567
546
|
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
GLuint id = texture->id();
|
572
|
-
if (id != get_current_texture_id())
|
573
|
-
glBindTexture(GL_TEXTURE_2D, id);
|
574
|
-
|
575
|
-
glEnable(GL_TEXTURE_2D);
|
576
|
-
}
|
577
|
-
|
578
|
-
GLuint get_current_texture_id ()
|
579
|
-
{
|
580
|
-
GLint id = 0;
|
581
|
-
glGetIntegerv(GL_TEXTURE_BINDING_2D, &id);
|
582
|
-
return (GLuint) id;
|
583
|
-
}
|
584
|
-
|
585
|
-
void deactivate_texture (const Texture* texture)
|
586
|
-
{
|
587
|
-
if (!texture) return;
|
547
|
+
glDeleteBuffers((GLsizei) buffers.size(), &buffers[0]);
|
548
|
+
OpenGL_check_error(__FILE__, __LINE__);
|
588
549
|
|
589
|
-
|
550
|
+
locations.clear();
|
551
|
+
buffers.clear();
|
590
552
|
}
|
591
553
|
|
592
554
|
};// Painter::Data
|
data/src/shader.cpp
CHANGED
@@ -67,7 +67,7 @@ namespace Rays
|
|
67
67
|
ShaderSource make_fragment_shader_source (const char* source)
|
68
68
|
{
|
69
69
|
#ifdef IOS
|
70
|
-
static const String SHARED_HEADER = "precision
|
70
|
+
static const String SHARED_HEADER = "precision highp float;\n";
|
71
71
|
static const std::regex PRECISION(R"(^\s*precision\s+\w+p\s+float\s*;)");
|
72
72
|
|
73
73
|
if (!std::regex_search(source, PRECISION))
|
@@ -128,7 +128,7 @@ namespace Rays
|
|
128
128
|
"void main ()\n"
|
129
129
|
"{\n"
|
130
130
|
" vec4 col__ = texture2D(" + U_TEXTURE + ", " + V_TEXCOORD + ".xy);\n"
|
131
|
-
#
|
131
|
+
#if defined(OSX) || defined(IOS)
|
132
132
|
// restore premultiplied rgb values
|
133
133
|
" vec3 rgb__ = col__.a != 0.0 ? col__.rgb / col__.a : col__.rgb;\n"
|
134
134
|
" gl_FragColor = " + V_COLOR + " * vec4(rgb__, col__.a);\n"
|
@@ -386,8 +386,8 @@ namespace Rays
|
|
386
386
|
"uniform mat4 " + U_TEXCOORD_MATRIX + ";\n"
|
387
387
|
"void main ()\n"
|
388
388
|
"{\n"
|
389
|
-
" vec4 pos__
|
390
|
-
" vec4 texcoord__
|
389
|
+
" vec4 pos__ = vec4(" + A_POSITION + ", 1.0);\n"
|
390
|
+
" vec4 texcoord__ = vec4(" + A_TEXCOORD + ", 1.0);\n"
|
391
391
|
" " + V_POSITION + " = pos__;\n"
|
392
392
|
" " + V_TEXCOORD + " = " + U_TEXCOORD_MATRIX + " * texcoord__;\n"
|
393
393
|
" " + V_COLOR + " = " + A_COLOR + ";\n"
|
data/src/texture.cpp
CHANGED
@@ -181,7 +181,7 @@ namespace Rays
|
|
181
181
|
static void
|
182
182
|
setup_texture (
|
183
183
|
Texture::Data* self, int width, int height, const ColorSpace& cs,
|
184
|
-
const Bitmap* bitmap = NULL)
|
184
|
+
const Bitmap* bitmap = NULL, bool npot = false)
|
185
185
|
{
|
186
186
|
assert(self && !self->has_id());
|
187
187
|
|
@@ -205,11 +205,16 @@ namespace Rays
|
|
205
205
|
GLenum format, type;
|
206
206
|
ColorSpace_get_gl_format_and_type(&format, &type, cs);
|
207
207
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
208
|
+
if (npot)
|
209
|
+
{
|
210
|
+
// create non-power-of-two texture
|
211
|
+
glTexImage2D(
|
212
|
+
GL_TEXTURE_2D, 0, format, width, height, 0, format, type,
|
213
|
+
bitmap ? bitmap->pixels() : NULL);
|
214
|
+
npot = OpenGL_has_error();
|
215
|
+
}
|
216
|
+
|
217
|
+
if (!npot)
|
213
218
|
{
|
214
219
|
// create power-of-two texture
|
215
220
|
int width_pow2 = min_pow2(width);
|
data/test/helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.30
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.
|
26
|
+
version: 0.1.30
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rucy
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
33
|
+
version: 0.1.30
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.
|
40
|
+
version: 0.1.30
|
41
41
|
description: This library helps you to develop graphics application with OpenGL.
|
42
42
|
email: xordog@gmail.com
|
43
43
|
executables: []
|
@@ -257,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
257
|
- !ruby/object:Gem::Version
|
258
258
|
version: '0'
|
259
259
|
requirements: []
|
260
|
-
rubygems_version: 3.
|
260
|
+
rubygems_version: 3.4.1
|
261
261
|
signing_key:
|
262
262
|
specification_version: 4
|
263
263
|
summary: A Drawing Engine using OpenGL.
|