rays 0.2 → 0.3
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 +100 -33
- data/.doc/ext/rays/bounds.cpp +2 -2
- data/.doc/ext/rays/camera.cpp +2 -2
- data/.doc/ext/rays/color.cpp +2 -2
- data/.doc/ext/rays/color_space.cpp +3 -3
- data/.doc/ext/rays/font.cpp +5 -4
- data/.doc/ext/rays/image.cpp +1 -1
- data/.doc/ext/rays/matrix.cpp +4 -4
- data/.doc/ext/rays/painter.cpp +1 -1
- data/.doc/ext/rays/point.cpp +2 -2
- data/.doc/ext/rays/polygon.cpp +3 -3
- data/.doc/ext/rays/polyline.cpp +3 -3
- data/.doc/ext/rays/rays.cpp +10 -10
- data/.doc/ext/rays/shader.cpp +2 -2
- data/.github/workflows/release-gem.yml +2 -2
- data/.github/workflows/tag.yml +1 -1
- data/.github/workflows/test.yml +10 -1
- data/ChangeLog.md +14 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +17 -2
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +100 -33
- data/ext/rays/bounds.cpp +2 -2
- data/ext/rays/camera.cpp +2 -2
- data/ext/rays/color.cpp +2 -2
- data/ext/rays/color_space.cpp +3 -3
- data/ext/rays/defs.h +2 -0
- data/ext/rays/extconf.rb +4 -2
- data/ext/rays/font.cpp +5 -4
- data/ext/rays/image.cpp +1 -1
- data/ext/rays/matrix.cpp +4 -4
- data/ext/rays/painter.cpp +1 -1
- data/ext/rays/point.cpp +2 -2
- data/ext/rays/polygon.cpp +3 -3
- data/ext/rays/polyline.cpp +3 -3
- data/ext/rays/rays.cpp +10 -10
- data/ext/rays/shader.cpp +2 -2
- data/include/rays/color_space.h +4 -4
- data/include/rays/defs.h +7 -0
- data/include/rays/rays.h +8 -0
- 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/include/rays/ruby.h +3 -1
- data/include/rays.h +3 -0
- data/lib/rays/bitmap.rb +7 -0
- data/lib/rays/extension.rb +4 -0
- data/rays.gemspec +2 -2
- data/src/coord.h +2 -2
- data/src/font.cpp +1 -0
- data/src/image.cpp +0 -29
- data/src/ios/bitmap.mm +23 -30
- data/src/ios/font.mm +4 -1
- data/src/ios/opengl.mm +23 -10
- data/src/ios/rays.mm +5 -3
- data/src/matrix.h +1 -1
- data/src/opengl.h +7 -8
- data/src/osx/bitmap.mm +23 -30
- data/src/osx/font.mm +4 -1
- data/src/osx/opengl.mm +31 -19
- data/src/osx/rays.mm +5 -3
- data/src/painter.cpp +1 -0
- data/src/shader.cpp +3 -0
- data/src/texture.cpp +3 -25
- data/src/texture.h +0 -2
- data/src/win32/bitmap.cpp +167 -65
- data/src/win32/camera.cpp +119 -0
- data/src/win32/font.cpp +179 -40
- data/src/win32/gdi.cpp +2 -4
- 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 -5
- data/test/test_bitmap.rb +3 -1
- data/test/test_image.rb +8 -14
- data/test/test_painter.rb +4 -4
- metadata +8 -8
- data/include/rays/opengl.h +0 -20
- 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/include/rays/ruby.h
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
#define __RAYS_RUBY_H__
|
5
5
|
|
6
6
|
|
7
|
-
#include <rays/ruby/rays.h>
|
8
7
|
#include <rays/ruby/defs.h>
|
8
|
+
#include <rays/ruby/rays.h>
|
9
9
|
#include <rays/ruby/exception.h>
|
10
10
|
|
11
11
|
#include <rays/ruby/point.h>
|
@@ -23,5 +23,7 @@
|
|
23
23
|
|
24
24
|
#include <rays/ruby/painter.h>
|
25
25
|
|
26
|
+
#include <rays/ruby/camera.h>
|
27
|
+
|
26
28
|
|
27
29
|
#endif//EOH
|
data/include/rays.h
CHANGED
data/lib/rays/bitmap.rb
CHANGED
data/lib/rays/extension.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'
|
29
|
+
s.add_runtime_dependency 'rucy', '~> 0.3'
|
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/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
@@ -56,33 +56,6 @@ namespace Rays
|
|
56
56
|
if (self->texture) self->texture.set_modified(false);
|
57
57
|
}
|
58
58
|
|
59
|
-
static void
|
60
|
-
invalidate_texture (Image* image)
|
61
|
-
{
|
62
|
-
image->bitmap();// update bitmap
|
63
|
-
image->self->texture = Texture();
|
64
|
-
}
|
65
|
-
|
66
|
-
static void
|
67
|
-
invalidate_texture_for_another_context (Image* image)
|
68
|
-
{
|
69
|
-
assert(image);
|
70
|
-
|
71
|
-
const Texture& tex = image->self->texture;
|
72
|
-
if (!tex) return;
|
73
|
-
|
74
|
-
Context tex_context = tex.context();
|
75
|
-
if (!tex_context) return;
|
76
|
-
|
77
|
-
Context current_context = OpenGL_get_context();
|
78
|
-
if (tex_context == current_context)
|
79
|
-
return;
|
80
|
-
|
81
|
-
OpenGL_set_context(tex_context);
|
82
|
-
invalidate_texture(image);
|
83
|
-
OpenGL_set_context(current_context);
|
84
|
-
}
|
85
|
-
|
86
59
|
static Bitmap&
|
87
60
|
get_bitmap (Image* image)
|
88
61
|
{
|
@@ -139,8 +112,6 @@ namespace Rays
|
|
139
112
|
return self->texture;
|
140
113
|
}
|
141
114
|
|
142
|
-
invalidate_texture_for_another_context(&image);
|
143
|
-
|
144
115
|
if (!self->texture)
|
145
116
|
{
|
146
117
|
if (self->bitmap)
|
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,40 @@ 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 || h <= 0 || !cs)
|
131
130
|
argument_error(__FILE__, __LINE__);
|
132
131
|
|
133
|
-
|
132
|
+
Bitmap::Data* self = bitmap->self.get();
|
134
133
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
134
|
+
self->clear();
|
135
|
+
|
136
|
+
self->width = w;
|
137
|
+
self->height = h;
|
138
|
+
self->color_space = cs;
|
139
|
+
self->modified = true;
|
139
140
|
|
140
141
|
size_t size = w * h * cs.Bpp();
|
141
|
-
|
142
|
+
self->pixels = new uchar[size];
|
142
143
|
|
143
|
-
if (
|
144
|
-
memcpy(
|
144
|
+
if (pixels)
|
145
|
+
memcpy(self->pixels, pixels, size);
|
145
146
|
else if (clear_pixels)
|
146
|
-
memset(
|
147
|
+
memset(self->pixels, 0, size);
|
147
148
|
}
|
148
149
|
|
149
|
-
|
150
|
-
|
150
|
+
Bitmap
|
151
|
+
Bitmap_from (const Texture& tex)
|
151
152
|
{
|
152
|
-
if (!
|
153
|
+
if (!tex)
|
153
154
|
argument_error(__FILE__, __LINE__);
|
154
155
|
|
156
|
+
Bitmap bmp;
|
155
157
|
setup_bitmap(
|
156
|
-
|
158
|
+
&bmp, tex.width(), tex.height(), tex.color_space(), NULL, false);
|
157
159
|
|
158
160
|
GLenum format, type;
|
159
161
|
ColorSpace_get_gl_format_and_type(&format, &type, tex.color_space());
|
@@ -161,18 +163,12 @@ namespace Rays
|
|
161
163
|
FrameBuffer fb(tex);
|
162
164
|
FrameBufferBinder binder(fb.id());
|
163
165
|
|
164
|
-
for (int y = 0; y <
|
166
|
+
for (int y = 0; y < bmp.height(); ++y)
|
165
167
|
{
|
166
|
-
GLvoid* ptr = (GLvoid*)
|
167
|
-
glReadPixels(0, y,
|
168
|
+
GLvoid* ptr = (GLvoid*) bmp.at<uchar>(0, y);
|
169
|
+
glReadPixels(0, y, bmp.width(), 1, format, type, ptr);
|
168
170
|
}
|
169
|
-
}
|
170
171
|
|
171
|
-
Bitmap
|
172
|
-
Bitmap_from (const Texture& texture)
|
173
|
-
{
|
174
|
-
Bitmap bmp;
|
175
|
-
setup_bitmap(&bmp, texture);
|
176
172
|
return bmp;
|
177
173
|
}
|
178
174
|
|
@@ -207,15 +203,12 @@ namespace Rays
|
|
207
203
|
if (*str == '\0') return;
|
208
204
|
|
209
205
|
font.draw_string(bitmap->self->get_context(), bitmap->height(), str, x, y);
|
210
|
-
|
211
206
|
Bitmap_set_modified(bitmap);
|
212
207
|
}
|
213
208
|
|
214
209
|
void
|
215
210
|
Bitmap_set_modified (Bitmap* bitmap, bool modified)
|
216
211
|
{
|
217
|
-
assert(bitmap);
|
218
|
-
|
219
212
|
bitmap->self->modified = modified;
|
220
213
|
}
|
221
214
|
|
data/src/ios/font.mm
CHANGED
@@ -152,11 +152,14 @@ namespace Rays
|
|
152
152
|
{
|
153
153
|
CGContextRef context = (CGContextRef) context_;
|
154
154
|
|
155
|
-
if (
|
155
|
+
if (!context || !str)
|
156
156
|
argument_error(__FILE__, __LINE__);
|
157
157
|
|
158
158
|
if (*str == '\0') return;
|
159
159
|
|
160
|
+
if (!*this)
|
161
|
+
invalid_state_error(__FILE__, __LINE__);
|
162
|
+
|
160
163
|
CTLinePtr line = make_line(self->font, str);
|
161
164
|
if (!line)
|
162
165
|
rays_error(__FILE__, __LINE__, "creating CTLineRef failed.");
|
data/src/ios/opengl.mm
CHANGED
@@ -2,34 +2,47 @@
|
|
2
2
|
#include "../opengl.h"
|
3
3
|
|
4
4
|
|
5
|
-
#include <vector>
|
6
5
|
#import <OpenGLES/EAGL.h>
|
6
|
+
#include "rays/rays.h"
|
7
|
+
#include "rays/exception.h"
|
7
8
|
|
8
9
|
|
9
10
|
namespace Rays
|
10
11
|
{
|
11
12
|
|
12
13
|
|
14
|
+
static EAGLContext*
|
15
|
+
get_opengl_offscreen_context ()
|
16
|
+
{
|
17
|
+
static EAGLContext* context = nil;
|
18
|
+
if (!context)
|
19
|
+
context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES3];
|
20
|
+
return context;
|
21
|
+
}
|
22
|
+
|
23
|
+
|
13
24
|
void
|
14
|
-
|
25
|
+
OpenGL_init ()
|
15
26
|
{
|
16
|
-
|
27
|
+
activate_offscreen_context();
|
17
28
|
}
|
18
29
|
|
19
|
-
|
20
|
-
|
30
|
+
void
|
31
|
+
OpenGL_fin ()
|
21
32
|
{
|
22
|
-
return [EAGLContext currentContext];
|
23
33
|
}
|
24
34
|
|
25
35
|
|
26
36
|
Context
|
27
37
|
get_offscreen_context ()
|
28
38
|
{
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
39
|
+
return get_opengl_offscreen_context();
|
40
|
+
}
|
41
|
+
|
42
|
+
void
|
43
|
+
activate_offscreen_context ()
|
44
|
+
{
|
45
|
+
[EAGLContext setCurrentContext: get_opengl_offscreen_context()];
|
33
46
|
}
|
34
47
|
|
35
48
|
|
data/src/ios/rays.mm
CHANGED
@@ -25,18 +25,20 @@ 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
|
|
32
|
-
|
32
|
+
OpenGL_init();
|
33
33
|
}
|
34
34
|
|
35
35
|
void
|
36
36
|
fin ()
|
37
37
|
{
|
38
38
|
if (!global::pool)
|
39
|
-
rays_error(__FILE__, __LINE__, "
|
39
|
+
rays_error(__FILE__, __LINE__, "not initialized.");
|
40
|
+
|
41
|
+
OpenGL_fin();
|
40
42
|
|
41
43
|
[global::pool release];
|
42
44
|
global::pool = nil;
|
data/src/matrix.h
CHANGED
data/src/opengl.h
CHANGED
@@ -11,26 +11,25 @@
|
|
11
11
|
#include <OpenGLES/ES3/gl.h>
|
12
12
|
#include <OpenGLES/ES3/glext.h>
|
13
13
|
#elif defined(WIN32)
|
14
|
-
#include <GL/
|
15
|
-
#include <GL/glext.h>
|
14
|
+
#include <GL/glew.h>
|
16
15
|
#endif
|
17
16
|
|
18
|
-
#include "rays/
|
17
|
+
#include "rays/defs.h"
|
19
18
|
|
20
19
|
|
21
20
|
namespace Rays
|
22
21
|
{
|
23
22
|
|
24
23
|
|
25
|
-
void
|
24
|
+
void OpenGL_init ();
|
26
25
|
|
27
|
-
|
26
|
+
void OpenGL_fin ();
|
28
27
|
|
29
|
-
bool
|
28
|
+
bool OpenGL_has_error ();
|
30
29
|
|
31
|
-
void
|
30
|
+
void OpenGL_check_error (const char* file, int line);
|
32
31
|
|
33
|
-
void
|
32
|
+
void OpenGL_check_error (const char* file, int line, const char* format, ...);
|
34
33
|
|
35
34
|
|
36
35
|
}// Rays
|