rays 0.2.1 → 0.3.1
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/bitmap.cpp +99 -32
- data/.doc/ext/rays/bounds.cpp +16 -12
- data/.doc/ext/rays/camera.cpp +1 -1
- data/.doc/ext/rays/color.cpp +2 -2
- data/.doc/ext/rays/color_space.cpp +3 -3
- data/.doc/ext/rays/defs.cpp +4 -4
- data/.doc/ext/rays/font.cpp +4 -3
- data/.doc/ext/rays/image.cpp +32 -18
- data/.doc/ext/rays/matrix.cpp +6 -6
- data/.doc/ext/rays/painter.cpp +1 -1
- data/.doc/ext/rays/point.cpp +10 -6
- data/.doc/ext/rays/polygon.cpp +11 -9
- data/.doc/ext/rays/polyline.cpp +6 -4
- data/.doc/ext/rays/rays.cpp +25 -15
- data/.doc/ext/rays/shader.cpp +3 -3
- data/.github/workflows/release-gem.yml +1 -1
- data/.github/workflows/test.yml +3 -0
- data/ChangeLog.md +11 -0
- data/Gemfile.lock +1 -1
- data/LICENSE +1 -1
- data/Rakefile +17 -3
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +99 -32
- data/ext/rays/bounds.cpp +16 -12
- data/ext/rays/camera.cpp +1 -1
- data/ext/rays/color.cpp +2 -2
- data/ext/rays/color_space.cpp +3 -3
- data/ext/rays/defs.cpp +4 -4
- data/ext/rays/defs.h +2 -0
- data/ext/rays/extconf.rb +4 -2
- data/ext/rays/font.cpp +4 -3
- data/ext/rays/image.cpp +34 -18
- data/ext/rays/matrix.cpp +6 -6
- data/ext/rays/painter.cpp +1 -1
- data/ext/rays/point.cpp +10 -6
- data/ext/rays/polygon.cpp +11 -9
- data/ext/rays/polyline.cpp +6 -4
- data/ext/rays/rays.cpp +25 -15
- data/ext/rays/shader.cpp +3 -3
- data/include/rays/defs.h +7 -0
- data/include/rays/image.h +8 -2
- data/include/rays/ruby/bitmap.h +2 -2
- data/include/rays/ruby/bounds.h +2 -2
- data/include/rays/ruby/camera.h +2 -2
- data/include/rays/ruby/color.h +2 -2
- data/include/rays/ruby/color_space.h +2 -2
- data/include/rays/ruby/exception.h +3 -3
- data/include/rays/ruby/font.h +2 -2
- data/include/rays/ruby/image.h +2 -2
- data/include/rays/ruby/matrix.h +2 -2
- data/include/rays/ruby/painter.h +2 -2
- data/include/rays/ruby/point.h +2 -2
- data/include/rays/ruby/polygon.h +2 -2
- data/include/rays/ruby/polyline.h +2 -2
- data/include/rays/ruby/rays.h +6 -6
- data/include/rays/ruby/shader.h +2 -2
- data/lib/rays/bitmap.rb +7 -0
- data/lib/rays/extension.rb +4 -0
- data/lib/rays/image.rb +4 -0
- data/rays.gemspec +2 -2
- data/src/bounds.cpp +6 -2
- data/src/color.cpp +12 -4
- data/src/coord.h +2 -2
- data/src/font.cpp +1 -0
- data/src/image.cpp +32 -4
- data/src/ios/bitmap.mm +40 -33
- data/src/ios/font.mm +6 -1
- data/src/ios/rays.mm +2 -2
- data/src/matrix.h +1 -1
- data/src/opengl.h +1 -2
- data/src/osx/bitmap.mm +40 -33
- data/src/osx/font.mm +6 -1
- data/src/osx/rays.mm +2 -2
- data/src/painter.cpp +4 -1
- data/src/point.cpp +15 -3
- data/src/polygon.cpp +3 -5
- data/src/render_buffer.cpp +11 -3
- data/src/shader.cpp +3 -0
- data/src/shader_program.cpp +19 -9
- data/src/shader_source.cpp +5 -1
- data/src/texture.cpp +33 -11
- data/src/texture.h +6 -2
- data/src/win32/bitmap.cpp +178 -66
- data/src/win32/camera.cpp +119 -0
- data/src/win32/font.cpp +181 -40
- data/src/win32/gdi.h +1 -1
- data/src/win32/opengl.cpp +127 -0
- data/src/win32/rays.cpp +16 -9
- data/test/helper.rb +2 -0
- data/test/test_bitmap.rb +3 -1
- data/test/test_image.rb +8 -14
- data/test/test_painter.rb +4 -4
- data/test/test_painter_shape.rb +6 -5
- metadata +8 -7
- data/src/win32/font.h +0 -24
data/include/rays/ruby/color.h
CHANGED
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/color.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Color)
|
12
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Color)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class color_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class color_class ();
|
20
20
|
// class Rays::Color
|
21
21
|
|
22
22
|
|
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/color_space.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::ColorSpace)
|
12
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::ColorSpace)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class color_space_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class color_space_class ();
|
20
20
|
// class Rays::ColorSpace
|
21
21
|
|
22
22
|
|
@@ -12,13 +12,13 @@ namespace Rays
|
|
12
12
|
{
|
13
13
|
|
14
14
|
|
15
|
-
Rucy::Class rays_error_class ();
|
15
|
+
RAYS_EXPORT Rucy::Class rays_error_class ();
|
16
16
|
// class Rays::RaysError
|
17
17
|
|
18
|
-
Rucy::Class opengl_error_class ();
|
18
|
+
RAYS_EXPORT Rucy::Class opengl_error_class ();
|
19
19
|
// class Rays::OpenGLError
|
20
20
|
|
21
|
-
Rucy::Class shader_error_class ();
|
21
|
+
RAYS_EXPORT Rucy::Class shader_error_class ();
|
22
22
|
// class Rays::ShaderError
|
23
23
|
|
24
24
|
|
data/include/rays/ruby/font.h
CHANGED
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/font.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Font)
|
12
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Font)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class font_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class font_class ();
|
20
20
|
// class Rays::Font
|
21
21
|
|
22
22
|
|
data/include/rays/ruby/image.h
CHANGED
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/image.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_FROM_TO(Rays::Image)
|
12
|
+
RUCY_DECLARE_VALUE_FROM_TO(RAYS_EXPORT, Rays::Image)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class image_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class image_class ();
|
20
20
|
// class Rays::Image
|
21
21
|
|
22
22
|
|
data/include/rays/ruby/matrix.h
CHANGED
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/matrix.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Matrix)
|
12
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Matrix)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class matrix_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class matrix_class ();
|
20
20
|
// class Rays::Matrix
|
21
21
|
|
22
22
|
|
data/include/rays/ruby/painter.h
CHANGED
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/painter.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_FROM_TO(Rays::Painter)
|
12
|
+
RUCY_DECLARE_VALUE_FROM_TO(RAYS_EXPORT, Rays::Painter)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class painter_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class painter_class ();
|
20
20
|
// class Rays::Painter
|
21
21
|
|
22
22
|
|
data/include/rays/ruby/point.h
CHANGED
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/point.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Point)
|
12
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Point)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class point_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class point_class ();
|
20
20
|
// class Rays::Point
|
21
21
|
|
22
22
|
|
data/include/rays/ruby/polygon.h
CHANGED
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/polygon.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polygon)
|
12
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Polygon)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class polygon_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class polygon_class ();
|
20
20
|
// class Rays::Polygon
|
21
21
|
|
22
22
|
|
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/polyline.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polyline)
|
12
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Polyline)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class polyline_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class polyline_class ();
|
20
20
|
// class Rays::Polyline
|
21
21
|
|
22
22
|
|
data/include/rays/ruby/rays.h
CHANGED
@@ -9,22 +9,22 @@
|
|
9
9
|
#include <rays/rays.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_CONVERT_TO(Rays::CapType)
|
12
|
+
RUCY_DECLARE_CONVERT_TO(RAYS_EXPORT, Rays::CapType)
|
13
13
|
|
14
|
-
RUCY_DECLARE_CONVERT_TO(Rays::JoinType)
|
14
|
+
RUCY_DECLARE_CONVERT_TO(RAYS_EXPORT, Rays::JoinType)
|
15
15
|
|
16
|
-
RUCY_DECLARE_CONVERT_TO(Rays::BlendMode)
|
16
|
+
RUCY_DECLARE_CONVERT_TO(RAYS_EXPORT, Rays::BlendMode)
|
17
17
|
|
18
|
-
RUCY_DECLARE_CONVERT_TO(Rays::TexCoordMode)
|
18
|
+
RUCY_DECLARE_CONVERT_TO(RAYS_EXPORT, Rays::TexCoordMode)
|
19
19
|
|
20
|
-
RUCY_DECLARE_CONVERT_TO(Rays::TexCoordWrap)
|
20
|
+
RUCY_DECLARE_CONVERT_TO(RAYS_EXPORT, Rays::TexCoordWrap)
|
21
21
|
|
22
22
|
|
23
23
|
namespace Rays
|
24
24
|
{
|
25
25
|
|
26
26
|
|
27
|
-
Rucy::Module rays_module ();
|
27
|
+
RAYS_EXPORT Rucy::Module rays_module ();
|
28
28
|
// module Rays
|
29
29
|
|
30
30
|
|
data/include/rays/ruby/shader.h
CHANGED
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/shader.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Shader)
|
12
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Shader)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class shader_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class shader_class ();
|
20
20
|
// class Rays::Shader
|
21
21
|
|
22
22
|
|
data/lib/rays/bitmap.rb
CHANGED
data/lib/rays/extension.rb
CHANGED
data/lib/rays/image.rb
CHANGED
data/rays.gemspec
CHANGED
@@ -25,8 +25,8 @@ 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_runtime_dependency 'xot', '~> 0.
|
29
|
-
s.add_runtime_dependency 'rucy', '~> 0.
|
28
|
+
s.add_runtime_dependency 'xot', '~> 0.3.1'
|
29
|
+
s.add_runtime_dependency 'rucy', '~> 0.3.1'
|
30
30
|
|
31
31
|
s.files = `git ls-files`.split $/
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/src/bounds.cpp
CHANGED
@@ -50,7 +50,9 @@ namespace Rays
|
|
50
50
|
bool
|
51
51
|
Bounds::is_intersect (const Bounds& other, int dimension) const
|
52
52
|
{
|
53
|
-
if (dimension < 1
|
53
|
+
if (dimension < 1)
|
54
|
+
argument_error(__FILE__, __LINE__);
|
55
|
+
if (dimension > 3)
|
54
56
|
argument_error(__FILE__, __LINE__);
|
55
57
|
|
56
58
|
Point size = (*this & other).size();
|
@@ -69,7 +71,9 @@ namespace Rays
|
|
69
71
|
bool
|
70
72
|
Bounds::is_include (const Point& point, int dimension) const
|
71
73
|
{
|
72
|
-
if (dimension < 1
|
74
|
+
if (dimension < 1)
|
75
|
+
argument_error(__FILE__, __LINE__);
|
76
|
+
if (dimension > 3)
|
73
77
|
argument_error(__FILE__, __LINE__);
|
74
78
|
|
75
79
|
const Point &pos = position(), &size_ = size();
|
data/src/color.cpp
CHANGED
@@ -117,7 +117,9 @@ namespace Rays
|
|
117
117
|
Color&
|
118
118
|
Color::reset (const void* pixel, const ColorSpace& cs)
|
119
119
|
{
|
120
|
-
if (!pixel
|
120
|
+
if (!pixel)
|
121
|
+
argument_error(__FILE__, __LINE__);
|
122
|
+
if (!cs)
|
121
123
|
argument_error(__FILE__, __LINE__);
|
122
124
|
|
123
125
|
if (cs.is_float())
|
@@ -175,7 +177,9 @@ namespace Rays
|
|
175
177
|
static void
|
176
178
|
get_rgba (float* red, float* green, float* blue, float* alpha, const float* c)
|
177
179
|
{
|
178
|
-
if (
|
180
|
+
if (!red && !green && !blue && !alpha)
|
181
|
+
argument_error(__FILE__, __LINE__);
|
182
|
+
if (!c)
|
179
183
|
argument_error(__FILE__, __LINE__);
|
180
184
|
|
181
185
|
if (red) *red = c[0];
|
@@ -187,7 +191,9 @@ namespace Rays
|
|
187
191
|
static void
|
188
192
|
get_rgba (uchar* red, uchar* green, uchar* blue, uchar* alpha, const float* c)
|
189
193
|
{
|
190
|
-
if (
|
194
|
+
if (!red && !green && !blue && !alpha)
|
195
|
+
argument_error(__FILE__, __LINE__);
|
196
|
+
if (!c)
|
191
197
|
argument_error(__FILE__, __LINE__);
|
192
198
|
|
193
199
|
if (red) *red = Color::float2uchar(c[0]);
|
@@ -199,7 +205,9 @@ namespace Rays
|
|
199
205
|
void
|
200
206
|
Color::get (void* pixel, const ColorSpace& cs) const
|
201
207
|
{
|
202
|
-
if (!pixel
|
208
|
+
if (!pixel)
|
209
|
+
argument_error(__FILE__, __LINE__);
|
210
|
+
if (!cs)
|
203
211
|
argument_error(__FILE__, __LINE__);
|
204
212
|
|
205
213
|
const float* c = array;
|
data/src/coord.h
CHANGED
@@ -13,9 +13,9 @@ namespace Rays
|
|
13
13
|
{
|
14
14
|
|
15
15
|
|
16
|
-
typedef glm::
|
16
|
+
typedef glm::vec<3, coord, glm::defaultp> Vec3;
|
17
17
|
|
18
|
-
typedef glm::
|
18
|
+
typedef glm::vec<4, coord, glm::defaultp> Vec4;
|
19
19
|
|
20
20
|
|
21
21
|
inline Vec3& to_glm ( Coord3& val) {return *( Vec3*) &val;}
|
data/src/font.cpp
CHANGED
data/src/image.cpp
CHANGED
@@ -30,6 +30,8 @@ namespace Rays
|
|
30
30
|
|
31
31
|
float pixel_density = 1;
|
32
32
|
|
33
|
+
bool smooth = false;
|
34
|
+
|
33
35
|
mutable Bitmap bitmap;
|
34
36
|
|
35
37
|
mutable Texture texture;
|
@@ -56,6 +58,13 @@ namespace Rays
|
|
56
58
|
if (self->texture) self->texture.set_modified(false);
|
57
59
|
}
|
58
60
|
|
61
|
+
static void
|
62
|
+
invalidate_texture (Image* image)
|
63
|
+
{
|
64
|
+
image->bitmap();// update bitmap
|
65
|
+
image->self->texture = Texture();
|
66
|
+
}
|
67
|
+
|
59
68
|
static Bitmap&
|
60
69
|
get_bitmap (Image* image)
|
61
70
|
{
|
@@ -117,12 +126,13 @@ namespace Rays
|
|
117
126
|
if (self->bitmap)
|
118
127
|
{
|
119
128
|
PRINT_MODIFIED_FLAGS("new texture from bitmap");
|
120
|
-
self->texture = Texture(self->bitmap);
|
129
|
+
self->texture = Texture(self->bitmap, self->smooth);
|
121
130
|
}
|
122
131
|
else
|
123
132
|
{
|
124
133
|
PRINT_MODIFIED_FLAGS("new texture");
|
125
|
-
self->texture = Texture(
|
134
|
+
self->texture = Texture(
|
135
|
+
self->width, self->height, self->color_space, self->smooth);
|
126
136
|
|
127
137
|
Painter p = image.painter();
|
128
138
|
p.begin();
|
@@ -167,7 +177,8 @@ namespace Rays
|
|
167
177
|
}
|
168
178
|
|
169
179
|
Image::Image (
|
170
|
-
int width, int height, const ColorSpace& cs,
|
180
|
+
int width, int height, const ColorSpace& cs,
|
181
|
+
float pixel_density, bool smooth)
|
171
182
|
{
|
172
183
|
if (pixel_density <= 0)
|
173
184
|
argument_error(__FILE__, __LINE__, "invalid pixel_density.");
|
@@ -176,9 +187,10 @@ namespace Rays
|
|
176
187
|
self->height = (int) (height * pixel_density);
|
177
188
|
self->color_space = cs;
|
178
189
|
self->pixel_density = pixel_density;
|
190
|
+
self->smooth = smooth;
|
179
191
|
}
|
180
192
|
|
181
|
-
Image::Image (const Bitmap& bitmap, float pixel_density)
|
193
|
+
Image::Image (const Bitmap& bitmap, float pixel_density, bool smooth)
|
182
194
|
{
|
183
195
|
if (pixel_density <= 0)
|
184
196
|
argument_error(__FILE__, __LINE__, "invalid pixel_density.");
|
@@ -188,6 +200,7 @@ namespace Rays
|
|
188
200
|
self->height = bitmap.height();
|
189
201
|
self->color_space = bitmap.color_space();
|
190
202
|
self->pixel_density = pixel_density;
|
203
|
+
self->smooth = smooth;
|
191
204
|
}
|
192
205
|
|
193
206
|
Image::~Image ()
|
@@ -233,6 +246,21 @@ namespace Rays
|
|
233
246
|
return self->pixel_density;
|
234
247
|
}
|
235
248
|
|
249
|
+
void
|
250
|
+
Image::set_smooth (bool smooth)
|
251
|
+
{
|
252
|
+
if (smooth == self->smooth) return;
|
253
|
+
|
254
|
+
self->smooth = smooth;
|
255
|
+
invalidate_texture(this);
|
256
|
+
}
|
257
|
+
|
258
|
+
bool
|
259
|
+
Image::smooth () const
|
260
|
+
{
|
261
|
+
return self->smooth;
|
262
|
+
}
|
263
|
+
|
236
264
|
Painter
|
237
265
|
Image::painter ()
|
238
266
|
{
|
data/src/ios/bitmap.mm
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
#import "bitmap.h"
|
3
3
|
|
4
4
|
|
5
|
-
#include <assert.h>
|
6
5
|
#import <ImageIO/CGImageDestination.h>
|
7
6
|
#import <MobileCoreServices/UTCoreTypes.h>
|
8
7
|
#include "rays/exception.h"
|
@@ -61,7 +60,7 @@ namespace Rays
|
|
61
60
|
|
62
61
|
ColorSpace color_space;
|
63
62
|
|
64
|
-
void* pixels
|
63
|
+
void* pixels = NULL;
|
65
64
|
|
66
65
|
CGContextRef context = NULL;
|
67
66
|
|
@@ -123,37 +122,44 @@ namespace Rays
|
|
123
122
|
|
124
123
|
static void
|
125
124
|
setup_bitmap (
|
126
|
-
Bitmap*
|
125
|
+
Bitmap* bitmap,
|
127
126
|
int w, int h, const ColorSpace& cs,
|
128
|
-
const void*
|
127
|
+
const void* pixels = NULL, bool clear_pixels = true)
|
129
128
|
{
|
130
|
-
if (
|
129
|
+
if (w <= 0)
|
131
130
|
argument_error(__FILE__, __LINE__);
|
131
|
+
if (h <= 0)
|
132
|
+
argument_error(__FILE__, __LINE__);
|
133
|
+
if (!cs)
|
134
|
+
argument_error(__FILE__, __LINE__);
|
135
|
+
|
136
|
+
Bitmap::Data* self = bitmap->self.get();
|
132
137
|
|
133
|
-
|
138
|
+
self->clear();
|
134
139
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
140
|
+
self->width = w;
|
141
|
+
self->height = h;
|
142
|
+
self->color_space = cs;
|
143
|
+
self->modified = true;
|
139
144
|
|
140
145
|
size_t size = w * h * cs.Bpp();
|
141
|
-
|
146
|
+
self->pixels = new uchar[size];
|
142
147
|
|
143
|
-
if (
|
144
|
-
memcpy(
|
148
|
+
if (pixels)
|
149
|
+
memcpy(self->pixels, pixels, size);
|
145
150
|
else if (clear_pixels)
|
146
|
-
memset(
|
151
|
+
memset(self->pixels, 0, size);
|
147
152
|
}
|
148
153
|
|
149
|
-
|
150
|
-
|
154
|
+
Bitmap
|
155
|
+
Bitmap_from (const Texture& tex)
|
151
156
|
{
|
152
|
-
if (!
|
157
|
+
if (!tex)
|
153
158
|
argument_error(__FILE__, __LINE__);
|
154
159
|
|
160
|
+
Bitmap bmp;
|
155
161
|
setup_bitmap(
|
156
|
-
|
162
|
+
&bmp, tex.width(), tex.height(), tex.color_space(), NULL, false);
|
157
163
|
|
158
164
|
GLenum format, type;
|
159
165
|
ColorSpace_get_gl_format_and_type(&format, &type, tex.color_space());
|
@@ -161,18 +167,12 @@ namespace Rays
|
|
161
167
|
FrameBuffer fb(tex);
|
162
168
|
FrameBufferBinder binder(fb.id());
|
163
169
|
|
164
|
-
for (int y = 0; y <
|
170
|
+
for (int y = 0; y < bmp.height(); ++y)
|
165
171
|
{
|
166
|
-
GLvoid* ptr = (GLvoid*)
|
167
|
-
glReadPixels(0, y,
|
172
|
+
GLvoid* ptr = (GLvoid*) bmp.at<uchar>(0, y);
|
173
|
+
glReadPixels(0, y, bmp.width(), 1, format, type, ptr);
|
168
174
|
}
|
169
|
-
}
|
170
175
|
|
171
|
-
Bitmap
|
172
|
-
Bitmap_from (const Texture& texture)
|
173
|
-
{
|
174
|
-
Bitmap bmp;
|
175
|
-
setup_bitmap(&bmp, texture);
|
176
176
|
return bmp;
|
177
177
|
}
|
178
178
|
|
@@ -183,7 +183,9 @@ namespace Rays
|
|
183
183
|
{
|
184
184
|
if (width == 0 || height == 0) return;
|
185
185
|
|
186
|
-
if (!bitmap
|
186
|
+
if (!bitmap)
|
187
|
+
argument_error(__FILE__, __LINE__);
|
188
|
+
if (!image)
|
187
189
|
argument_error(__FILE__, __LINE__);
|
188
190
|
|
189
191
|
CGContextRef context = bitmap->self->get_context();
|
@@ -201,21 +203,24 @@ namespace Rays
|
|
201
203
|
Bitmap_draw_string (
|
202
204
|
Bitmap* bitmap, const RawFont& font, const char* str, coord x, coord y)
|
203
205
|
{
|
204
|
-
if (!bitmap
|
206
|
+
if (!bitmap)
|
207
|
+
argument_error(__FILE__, __LINE__);
|
208
|
+
if (!*bitmap)
|
209
|
+
argument_error(__FILE__, __LINE__);
|
210
|
+
if (!font)
|
211
|
+
argument_error(__FILE__, __LINE__);
|
212
|
+
if (!str)
|
205
213
|
argument_error(__FILE__, __LINE__);
|
206
214
|
|
207
215
|
if (*str == '\0') return;
|
208
216
|
|
209
217
|
font.draw_string(bitmap->self->get_context(), bitmap->height(), str, x, y);
|
210
|
-
|
211
218
|
Bitmap_set_modified(bitmap);
|
212
219
|
}
|
213
220
|
|
214
221
|
void
|
215
222
|
Bitmap_set_modified (Bitmap* bitmap, bool modified)
|
216
223
|
{
|
217
|
-
assert(bitmap);
|
218
|
-
|
219
224
|
bitmap->self->modified = modified;
|
220
225
|
}
|
221
226
|
|
@@ -268,7 +273,9 @@ namespace Rays
|
|
268
273
|
Bitmap
|
269
274
|
Bitmap_load (const char* path_)
|
270
275
|
{
|
271
|
-
if (!path_
|
276
|
+
if (!path_)
|
277
|
+
argument_error(__FILE__, __LINE__);
|
278
|
+
if (path_[0] == '\0')
|
272
279
|
argument_error(__FILE__, __LINE__);
|
273
280
|
|
274
281
|
NSString* path = [NSString stringWithUTF8String: path_];
|
data/src/ios/font.mm
CHANGED
@@ -152,11 +152,16 @@ namespace Rays
|
|
152
152
|
{
|
153
153
|
CGContextRef context = (CGContextRef) context_;
|
154
154
|
|
155
|
-
if (
|
155
|
+
if (!context)
|
156
|
+
argument_error(__FILE__, __LINE__);
|
157
|
+
if (!str)
|
156
158
|
argument_error(__FILE__, __LINE__);
|
157
159
|
|
158
160
|
if (*str == '\0') return;
|
159
161
|
|
162
|
+
if (!*this)
|
163
|
+
invalid_state_error(__FILE__, __LINE__);
|
164
|
+
|
160
165
|
CTLinePtr line = make_line(self->font, str);
|
161
166
|
if (!line)
|
162
167
|
rays_error(__FILE__, __LINE__, "creating CTLineRef failed.");
|
data/src/ios/rays.mm
CHANGED
@@ -25,7 +25,7 @@ namespace Rays
|
|
25
25
|
init ()
|
26
26
|
{
|
27
27
|
if (global::pool)
|
28
|
-
rays_error(__FILE__, __LINE__, "
|
28
|
+
rays_error(__FILE__, __LINE__, "already initialized.");
|
29
29
|
|
30
30
|
global::pool = [[NSAutoreleasePool alloc] init];
|
31
31
|
|
@@ -36,7 +36,7 @@ namespace Rays
|
|
36
36
|
fin ()
|
37
37
|
{
|
38
38
|
if (!global::pool)
|
39
|
-
rays_error(__FILE__, __LINE__, "
|
39
|
+
rays_error(__FILE__, __LINE__, "not initialized.");
|
40
40
|
|
41
41
|
OpenGL_fin();
|
42
42
|
|
data/src/matrix.h
CHANGED