rays 0.3.9 → 0.3.11
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/bounds.cpp +1 -1
- data/.doc/ext/rays/font.cpp +23 -5
- data/.doc/ext/rays/image.cpp +1 -1
- data/.doc/ext/rays/native.cpp +1 -5
- data/.doc/ext/rays/painter.cpp +1 -1
- data/.doc/ext/rays/polygon.cpp +1 -1
- data/.github/workflows/release-gem.yml +1 -1
- data/.github/workflows/test.yml +4 -4
- data/CLAUDE.md +25 -0
- data/ChangeLog.md +17 -0
- data/Gemfile.lock +6 -5
- data/Rakefile +4 -2
- data/VERSION +1 -1
- data/ext/rays/bounds.cpp +1 -1
- data/ext/rays/extconf.rb +4 -3
- data/ext/rays/font.cpp +27 -7
- data/ext/rays/image.cpp +1 -1
- data/ext/rays/native.cpp +1 -5
- data/ext/rays/painter.cpp +1 -1
- data/ext/rays/polygon.cpp +1 -1
- data/include/rays/font.h +5 -1
- data/include/rays/painter.h +1 -1
- data/lib/rays/ext.rb +1 -1
- data/lib/rays/image.rb +5 -0
- data/rays.gemspec +2 -2
- data/src/bitmap.h +6 -1
- data/src/color_space.cpp +1 -41
- data/src/font.cpp +17 -1
- data/src/image.cpp +0 -1
- data/src/ios/bitmap.mm +20 -35
- data/src/ios/rays.mm +3 -3
- data/src/opengl/bitmap.cpp +41 -0
- data/src/opengl/color_space.cpp +51 -0
- data/src/{color_space.h → opengl/color_space.h} +2 -2
- data/src/{frame_buffer.cpp → opengl/frame_buffer.cpp} +1 -1
- data/src/{frame_buffer.h → opengl/frame_buffer.h} +2 -2
- data/src/{ios → opengl/ios}/opengl.mm +3 -3
- data/src/{opengl.h → opengl/opengl.h} +3 -7
- data/src/{osx → opengl/osx}/opengl.mm +3 -3
- data/src/opengl/painter.cpp +756 -0
- data/src/{render_buffer.h → opengl/render_buffer.h} +2 -2
- data/src/opengl/sdl/opengl.cpp +103 -0
- data/src/{shader.cpp → opengl/shader.cpp} +1 -2
- data/src/{shader.h → opengl/shader.h} +2 -2
- data/src/{shader_program.cpp → opengl/shader_program.cpp} +3 -3
- data/src/{shader_program.h → opengl/shader_program.h} +2 -2
- data/src/{shader_source.h → opengl/shader_source.h} +2 -2
- data/src/{texture.cpp → opengl/texture.cpp} +2 -3
- data/src/opengl/texture.h +21 -0
- data/src/{win32 → opengl/win32}/opengl.cpp +4 -4
- data/src/osx/bitmap.mm +20 -36
- data/src/osx/rays.mm +3 -3
- data/src/painter.cpp +28 -910
- data/src/painter.h +210 -11
- data/src/polygon.cpp +38 -13
- data/src/renderer.h +22 -0
- data/src/sdl/bitmap.cpp +304 -0
- data/src/sdl/camera.cpp +119 -0
- data/src/sdl/font.cpp +93 -0
- data/src/sdl/rays.cpp +50 -0
- data/src/texture.h +0 -3
- data/src/win32/bitmap.cpp +8 -35
- data/src/win32/rays.cpp +3 -3
- data/test/test_image.rb +1 -0
- metadata +34 -35
- /data/src/{opengl.cpp → opengl/opengl.cpp} +0 -0
- /data/src/{render_buffer.cpp → opengl/render_buffer.cpp} +0 -0
- /data/src/{shader_source.cpp → opengl/shader_source.cpp} +0 -0
data/src/ios/bitmap.mm
CHANGED
|
@@ -6,10 +6,8 @@
|
|
|
6
6
|
#import <MobileCoreServices/UTCoreTypes.h>
|
|
7
7
|
#include <xot/util.h>
|
|
8
8
|
#include "rays/exception.h"
|
|
9
|
-
#include "../color_space.h"
|
|
10
9
|
#include "../font.h"
|
|
11
10
|
#include "../texture.h"
|
|
12
|
-
#include "../frame_buffer.h"
|
|
13
11
|
|
|
14
12
|
|
|
15
13
|
namespace Rays
|
|
@@ -76,7 +74,7 @@ namespace Rays
|
|
|
76
74
|
clear();
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
CGContextRef get_context ()
|
|
77
|
+
CGContextRef get_context (bool smooth = true)
|
|
80
78
|
{
|
|
81
79
|
if (context) return context;
|
|
82
80
|
|
|
@@ -95,6 +93,17 @@ namespace Rays
|
|
|
95
93
|
context = CGBitmapContextCreate(
|
|
96
94
|
pixels, width, height, bpc, pitch, cgcs, make_bitmapinfo(color_space));
|
|
97
95
|
CGColorSpaceRelease(cgcs);
|
|
96
|
+
|
|
97
|
+
if (!smooth)
|
|
98
|
+
{
|
|
99
|
+
CGContextSetShouldAntialias( context, false);
|
|
100
|
+
CGContextSetShouldSmoothFonts( context, false);
|
|
101
|
+
CGContextSetInterpolationQuality( context, kCGInterpolationNone);
|
|
102
|
+
CGContextSetAllowsFontSmoothing( context, false);
|
|
103
|
+
CGContextSetShouldSubpixelPositionFonts(context, false);
|
|
104
|
+
CGContextSetShouldSubpixelQuantizeFonts(context, true);
|
|
105
|
+
}
|
|
106
|
+
|
|
98
107
|
return context;
|
|
99
108
|
}
|
|
100
109
|
|
|
@@ -120,11 +129,10 @@ namespace Rays
|
|
|
120
129
|
};// Bitmap::Data
|
|
121
130
|
|
|
122
131
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
Bitmap* bitmap,
|
|
126
|
-
|
|
127
|
-
const void* pixels = NULL, bool clear_pixels = true)
|
|
132
|
+
void
|
|
133
|
+
Bitmap_setup (
|
|
134
|
+
Bitmap* bitmap, int w, int h, const ColorSpace& cs,
|
|
135
|
+
const void* pixels, bool clear_pixels)
|
|
128
136
|
{
|
|
129
137
|
if (w <= 0)
|
|
130
138
|
argument_error(__FILE__, __LINE__);
|
|
@@ -151,30 +159,6 @@ namespace Rays
|
|
|
151
159
|
memset(self->pixels, 0, size);
|
|
152
160
|
}
|
|
153
161
|
|
|
154
|
-
Bitmap
|
|
155
|
-
Bitmap_from (const Texture& tex)
|
|
156
|
-
{
|
|
157
|
-
if (!tex)
|
|
158
|
-
argument_error(__FILE__, __LINE__);
|
|
159
|
-
|
|
160
|
-
Bitmap bmp;
|
|
161
|
-
setup_bitmap(
|
|
162
|
-
&bmp, tex.width(), tex.height(), tex.color_space(), NULL, false);
|
|
163
|
-
|
|
164
|
-
GLenum format, type;
|
|
165
|
-
ColorSpace_get_gl_format_and_type(&format, &type, tex.color_space());
|
|
166
|
-
|
|
167
|
-
FrameBuffer fb(tex);
|
|
168
|
-
FrameBufferBinder binder(fb.id());
|
|
169
|
-
|
|
170
|
-
for (int y = 0; y < bmp.height(); ++y)
|
|
171
|
-
{
|
|
172
|
-
GLvoid* ptr = (GLvoid*) bmp.at<uchar>(0, y);
|
|
173
|
-
glReadPixels(0, y, bmp.width(), 1, format, type, ptr);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return bmp;
|
|
177
|
-
}
|
|
178
162
|
|
|
179
163
|
void
|
|
180
164
|
Bitmap_draw_image (
|
|
@@ -201,7 +185,8 @@ namespace Rays
|
|
|
201
185
|
|
|
202
186
|
void
|
|
203
187
|
Bitmap_draw_string (
|
|
204
|
-
Bitmap* bitmap, const RawFont& font,
|
|
188
|
+
Bitmap* bitmap, const RawFont& font,
|
|
189
|
+
const char* str, coord x, coord y, bool smooth)
|
|
205
190
|
{
|
|
206
191
|
if (!bitmap)
|
|
207
192
|
argument_error(__FILE__, __LINE__);
|
|
@@ -214,7 +199,7 @@ namespace Rays
|
|
|
214
199
|
|
|
215
200
|
if (*str == '\0') return;
|
|
216
201
|
|
|
217
|
-
font.draw_string(bitmap->self->get_context(), bitmap->height(), str, x, y);
|
|
202
|
+
font.draw_string(bitmap->self->get_context(smooth), bitmap->height(), str, x, y);
|
|
218
203
|
Bitmap_set_modified(bitmap);
|
|
219
204
|
}
|
|
220
205
|
|
|
@@ -306,7 +291,7 @@ namespace Rays
|
|
|
306
291
|
Bitmap::Bitmap (
|
|
307
292
|
int width, int height, const ColorSpace& color_space, const void* pixels)
|
|
308
293
|
{
|
|
309
|
-
|
|
294
|
+
Bitmap_setup(this, width, height, color_space, pixels);
|
|
310
295
|
}
|
|
311
296
|
|
|
312
297
|
Bitmap::~Bitmap ()
|
data/src/ios/rays.mm
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
#import <Foundation/Foundation.h>
|
|
6
6
|
#include "rays/exception.h"
|
|
7
|
-
#include "../
|
|
7
|
+
#include "../renderer.h"
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
namespace Rays
|
|
@@ -29,7 +29,7 @@ namespace Rays
|
|
|
29
29
|
|
|
30
30
|
global::pool = [[NSAutoreleasePool alloc] init];
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Renderer_init();
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
void
|
|
@@ -38,7 +38,7 @@ namespace Rays
|
|
|
38
38
|
if (!global::pool)
|
|
39
39
|
rays_error(__FILE__, __LINE__, "not initialized.");
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
Renderer_fin();
|
|
42
42
|
|
|
43
43
|
[global::pool release];
|
|
44
44
|
global::pool = nil;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#include "../bitmap.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include "rays/exception.h"
|
|
5
|
+
#include "../texture.h"
|
|
6
|
+
#include "opengl.h"
|
|
7
|
+
#include "color_space.h"
|
|
8
|
+
#include "frame_buffer.h"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
namespace Rays
|
|
12
|
+
{
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Bitmap
|
|
16
|
+
Bitmap_from (const Texture& tex)
|
|
17
|
+
{
|
|
18
|
+
if (!tex)
|
|
19
|
+
argument_error(__FILE__, __LINE__);
|
|
20
|
+
|
|
21
|
+
Bitmap bmp;
|
|
22
|
+
Bitmap_setup(
|
|
23
|
+
&bmp, tex.width(), tex.height(), tex.color_space(), NULL, false);
|
|
24
|
+
|
|
25
|
+
GLenum format, type;
|
|
26
|
+
ColorSpace_get_gl_format_and_type(&format, &type, tex.color_space());
|
|
27
|
+
|
|
28
|
+
FrameBuffer fb(tex);
|
|
29
|
+
FrameBufferBinder binder(fb.id());
|
|
30
|
+
|
|
31
|
+
for (int y = 0; y < bmp.height(); ++y)
|
|
32
|
+
{
|
|
33
|
+
GLvoid* ptr = (GLvoid*) bmp.at<uchar>(0, y);
|
|
34
|
+
glReadPixels(0, y, bmp.width(), 1, format, type, ptr);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return bmp;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
}// Rays
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#include "color_space.h"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#include "rays/exception.h"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
namespace Rays
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
void
|
|
12
|
+
ColorSpace_get_gl_format_and_type (
|
|
13
|
+
GLenum* format, GLenum* type, const ColorSpace& cs)
|
|
14
|
+
{
|
|
15
|
+
if (!format && !type)
|
|
16
|
+
argument_error(__FILE__, __LINE__);
|
|
17
|
+
|
|
18
|
+
if (!cs)
|
|
19
|
+
invalid_state_error(__FILE__, __LINE__);
|
|
20
|
+
|
|
21
|
+
if (format)
|
|
22
|
+
{
|
|
23
|
+
if (cs.is_rgb()) *format = cs.has_alpha() ? GL_RGBA : GL_RGB;
|
|
24
|
+
#ifndef IOS
|
|
25
|
+
else if (cs.is_bgr()) *format = cs.has_alpha() ? GL_BGRA : GL_BGR;
|
|
26
|
+
#endif
|
|
27
|
+
else if (cs.is_gray()) *format = GL_LUMINANCE;
|
|
28
|
+
else if (cs.is_alpha()) *format = GL_ALPHA;
|
|
29
|
+
else
|
|
30
|
+
rays_error(__FILE__, __LINE__, "invalid color space.");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (type)
|
|
34
|
+
{
|
|
35
|
+
if (cs.is_float())
|
|
36
|
+
*type = GL_FLOAT;
|
|
37
|
+
else switch (cs.bpc())
|
|
38
|
+
{
|
|
39
|
+
case 8: *type = GL_UNSIGNED_BYTE; break;
|
|
40
|
+
case 16: *type = GL_UNSIGNED_SHORT; break;
|
|
41
|
+
#ifndef IOS
|
|
42
|
+
case 32: *type = GL_UNSIGNED_INT; break;
|
|
43
|
+
#endif
|
|
44
|
+
default:
|
|
45
|
+
rays_error(__FILE__, __LINE__, "invalid bpc.");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
}// Rays
|
|
@@ -105,7 +105,7 @@ namespace Rays
|
|
|
105
105
|
FrameBufferBinder binder(id());
|
|
106
106
|
|
|
107
107
|
glFramebufferTexture2D(
|
|
108
|
-
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture
|
|
108
|
+
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, Texture_get_id(texture), 0);
|
|
109
109
|
OpenGL_check_error(__FILE__, __LINE__);
|
|
110
110
|
|
|
111
111
|
self->texture = texture;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// -*- objc -*-
|
|
2
|
-
#include "
|
|
2
|
+
#include "../../renderer.h"
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
#import <OpenGLES/EAGL.h>
|
|
@@ -22,13 +22,13 @@ namespace Rays
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
void
|
|
25
|
-
|
|
25
|
+
Renderer_init ()
|
|
26
26
|
{
|
|
27
27
|
activate_offscreen_context();
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
void
|
|
31
|
-
|
|
31
|
+
Renderer_fin ()
|
|
32
32
|
{
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// -*- c++ -*-
|
|
2
2
|
#pragma once
|
|
3
|
-
#ifndef
|
|
4
|
-
#define
|
|
3
|
+
#ifndef __RAYS_SRC_OPENGL_OPENGL_H__
|
|
4
|
+
#define __RAYS_SRC_OPENGL_OPENGL_H__
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
#if defined(OSX)
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
#elif defined(IOS)
|
|
11
11
|
#include <OpenGLES/ES3/gl.h>
|
|
12
12
|
#include <OpenGLES/ES3/glext.h>
|
|
13
|
-
#
|
|
13
|
+
#else
|
|
14
14
|
#include <GL/glew.h>
|
|
15
15
|
#endif
|
|
16
16
|
|
|
@@ -21,10 +21,6 @@ namespace Rays
|
|
|
21
21
|
{
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
void OpenGL_init ();
|
|
25
|
-
|
|
26
|
-
void OpenGL_fin ();
|
|
27
|
-
|
|
28
24
|
bool OpenGL_has_error ();
|
|
29
25
|
|
|
30
26
|
void OpenGL_check_error (const char* file, int line);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// -*- objc -*-
|
|
2
|
-
#include "
|
|
2
|
+
#include "../../renderer.h"
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
#import <AppKit/AppKit.h>
|
|
@@ -39,13 +39,13 @@ namespace Rays
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
void
|
|
42
|
-
|
|
42
|
+
Renderer_init ()
|
|
43
43
|
{
|
|
44
44
|
activate_offscreen_context();
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
void
|
|
48
|
-
|
|
48
|
+
Renderer_fin ()
|
|
49
49
|
{
|
|
50
50
|
}
|
|
51
51
|
|