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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/rays/bounds.cpp +1 -1
  3. data/.doc/ext/rays/font.cpp +23 -5
  4. data/.doc/ext/rays/image.cpp +1 -1
  5. data/.doc/ext/rays/native.cpp +1 -5
  6. data/.doc/ext/rays/painter.cpp +1 -1
  7. data/.doc/ext/rays/polygon.cpp +1 -1
  8. data/.github/workflows/release-gem.yml +1 -1
  9. data/.github/workflows/test.yml +4 -4
  10. data/CLAUDE.md +25 -0
  11. data/ChangeLog.md +17 -0
  12. data/Gemfile.lock +6 -5
  13. data/Rakefile +4 -2
  14. data/VERSION +1 -1
  15. data/ext/rays/bounds.cpp +1 -1
  16. data/ext/rays/extconf.rb +4 -3
  17. data/ext/rays/font.cpp +27 -7
  18. data/ext/rays/image.cpp +1 -1
  19. data/ext/rays/native.cpp +1 -5
  20. data/ext/rays/painter.cpp +1 -1
  21. data/ext/rays/polygon.cpp +1 -1
  22. data/include/rays/font.h +5 -1
  23. data/include/rays/painter.h +1 -1
  24. data/lib/rays/ext.rb +1 -1
  25. data/lib/rays/image.rb +5 -0
  26. data/rays.gemspec +2 -2
  27. data/src/bitmap.h +6 -1
  28. data/src/color_space.cpp +1 -41
  29. data/src/font.cpp +17 -1
  30. data/src/image.cpp +0 -1
  31. data/src/ios/bitmap.mm +20 -35
  32. data/src/ios/rays.mm +3 -3
  33. data/src/opengl/bitmap.cpp +41 -0
  34. data/src/opengl/color_space.cpp +51 -0
  35. data/src/{color_space.h → opengl/color_space.h} +2 -2
  36. data/src/{frame_buffer.cpp → opengl/frame_buffer.cpp} +1 -1
  37. data/src/{frame_buffer.h → opengl/frame_buffer.h} +2 -2
  38. data/src/{ios → opengl/ios}/opengl.mm +3 -3
  39. data/src/{opengl.h → opengl/opengl.h} +3 -7
  40. data/src/{osx → opengl/osx}/opengl.mm +3 -3
  41. data/src/opengl/painter.cpp +756 -0
  42. data/src/{render_buffer.h → opengl/render_buffer.h} +2 -2
  43. data/src/opengl/sdl/opengl.cpp +103 -0
  44. data/src/{shader.cpp → opengl/shader.cpp} +1 -2
  45. data/src/{shader.h → opengl/shader.h} +2 -2
  46. data/src/{shader_program.cpp → opengl/shader_program.cpp} +3 -3
  47. data/src/{shader_program.h → opengl/shader_program.h} +2 -2
  48. data/src/{shader_source.h → opengl/shader_source.h} +2 -2
  49. data/src/{texture.cpp → opengl/texture.cpp} +2 -3
  50. data/src/opengl/texture.h +21 -0
  51. data/src/{win32 → opengl/win32}/opengl.cpp +4 -4
  52. data/src/osx/bitmap.mm +20 -36
  53. data/src/osx/rays.mm +3 -3
  54. data/src/painter.cpp +28 -910
  55. data/src/painter.h +210 -11
  56. data/src/polygon.cpp +38 -13
  57. data/src/renderer.h +22 -0
  58. data/src/sdl/bitmap.cpp +304 -0
  59. data/src/sdl/camera.cpp +119 -0
  60. data/src/sdl/font.cpp +93 -0
  61. data/src/sdl/rays.cpp +50 -0
  62. data/src/texture.h +0 -3
  63. data/src/win32/bitmap.cpp +8 -35
  64. data/src/win32/rays.cpp +3 -3
  65. data/test/test_image.rb +1 -0
  66. metadata +34 -35
  67. /data/src/{opengl.cpp → opengl/opengl.cpp} +0 -0
  68. /data/src/{render_buffer.cpp → opengl/render_buffer.cpp} +0 -0
  69. /data/src/{shader_source.cpp → opengl/shader_source.cpp} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ca6bcfcc699588e0e6a3028ed839cfa9bec07bd42a4c3759e53ea73640efcc1
4
- data.tar.gz: 5e7d38c01624e04fed64c4520cabea6fd2716b24a1c79f8aa87b3e44a4c09493
3
+ metadata.gz: 9ccc3b9eda8d2da41df31850e7ab6a6e480936ad80dfff07adaf35e5d12c8eee
4
+ data.tar.gz: 46785a8507b11be71d877a87fb8f7a42478d19190086701e748978e040a16ad3
5
5
  SHA512:
6
- metadata.gz: ec77cfefeac3f8db0c4861c313f9614d70abbfc1f90d635b8b9e2d296ada2a900a12a6d49528870f438e454eab6ae38c65e25b29d4d2c452309575640727d5c4
7
- data.tar.gz: f061fbab93220c413ef09f93b79d8ab22fc887a77025a7ec8390e357dbc0b26cfa610c7a1da7917b418e2aabc70fc6dfeaf4dfe6d53ab30d5299a98e6dc4c906
6
+ metadata.gz: 505a1f2e9a2e3a1aea29b4e69528c4741ce0ad956f9c2e7fafa67bf528b6b25c51e6d7371624d52f3a4a8e0e8fa8aab1388d76775b03445f4882af49dd3b18d0
7
+ data.tar.gz: 51d70c57b927a3b8564718170962d41d36ca7f9a5b209f71c6d72e23bcd6278b8bbf73181909084bb973d2fb72aa4d7172e8ee218407ebf7236c74bb46530e6f
@@ -58,7 +58,7 @@ VALUE include(VALUE self)
58
58
  CHECK;
59
59
  check_arg_count(__FILE__, __LINE__, "Bounds#include?", argc, 1, 2);
60
60
 
61
- const Rays::Point& point = to<Rays::Point&>(argv[0]);
61
+ const Rays::Point& point = to<Rays::Point>(argv[0]);
62
62
  int dimension = argc >= 2 ? to<int>(argv[1]) : 2;
63
63
 
64
64
  return value(THIS->is_include(point, dimension));
@@ -22,7 +22,7 @@ static
22
22
  VALUE initialize(VALUE self)
23
23
  {
24
24
  RUCY_CHECK_OBJ(Rays::Font, self);
25
- check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2);
25
+ check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2, 3);
26
26
 
27
27
  *THIS = to<Rays::Font>(argc, argv);
28
28
  return self;
@@ -59,6 +59,21 @@ VALUE size(VALUE self)
59
59
  return value(THIS->size());
60
60
  }
61
61
 
62
+ static
63
+ VALUE set_smooth(VALUE self, VALUE smooth)
64
+ {
65
+ CHECK;
66
+ THIS->set_smooth(to<bool>(smooth));
67
+ return smooth;
68
+ }
69
+
70
+ static
71
+ VALUE smooth(VALUE self)
72
+ {
73
+ CHECK;
74
+ return value(THIS->smooth());
75
+ }
76
+
62
77
  static
63
78
  VALUE width(VALUE self, VALUE str)
64
79
  {
@@ -142,6 +157,8 @@ Init_rays_font ()
142
157
  rb_define_method(cFont, "name", RUBY_METHOD_FUNC(name), 0);
143
158
  rb_define_method(cFont, "size=", RUBY_METHOD_FUNC(set_size), 1);
144
159
  rb_define_method(cFont, "size", RUBY_METHOD_FUNC(size), 0);
160
+ rb_define_method(cFont, "smooth=", RUBY_METHOD_FUNC(set_smooth), 1);
161
+ rb_define_method(cFont, "smooth", RUBY_METHOD_FUNC(smooth), 0);
145
162
  rb_define_method(cFont, "width", RUBY_METHOD_FUNC(width), 1);
146
163
  rb_define_method(cFont, "height", RUBY_METHOD_FUNC(height), 0);
147
164
  rb_define_method(cFont, "ascent", RUBY_METHOD_FUNC(ascent), 0);
@@ -172,12 +189,13 @@ namespace Rucy
172
189
  if (argc == 0)
173
190
  return Rays::get_default_font();
174
191
 
175
- coord size =
176
- argc >= 2 ? to<coord>(argv[1]) : (coord) Rays::Font::DEFAULT_SIZE;
192
+ coord size = argc >= 2 ? to<coord>(argv[1]) : (coord) Rays::Font::DEFAULT_SIZE;
193
+ bool smooth = argc >= 3 ? to<bool>(argv[2]) : true;
194
+
177
195
  if (argv->is_nil())
178
- return Rays::Font(NULL, size);
196
+ return Rays::Font(NULL, size, smooth);
179
197
  else if (argv->is_s() || argv->is_sym())
180
- return Rays::Font(argv[0].c_str(), size);
198
+ return Rays::Font(argv[0].c_str(), size, smooth);
181
199
  }
182
200
 
183
201
  if (argc != 1)
@@ -149,7 +149,7 @@ Init_rays_image ()
149
149
  rb_define_private_method(cImage, "get_bitmap", RUBY_METHOD_FUNC(get_bitmap), 1);
150
150
  rb_define_method(cImage, "smooth=", RUBY_METHOD_FUNC(set_smooth), 1);
151
151
  rb_define_method(cImage, "smooth", RUBY_METHOD_FUNC(get_smooth), 0);
152
- rb_define_module_function(cImage, "load", RUBY_METHOD_FUNC(load), 1);
152
+ cImage.define_module_function("load!", load);
153
153
  }
154
154
 
155
155
 
@@ -23,11 +23,7 @@ void Init_rays_util ();
23
23
 
24
24
 
25
25
  extern "C" void
26
- #ifdef COCOAPODS
27
- Init_rays_native ()
28
- #else
29
- Init_native ()
30
- #endif
26
+ Init_rays_ext ()
31
27
  {
32
28
  RUCY_TRY
33
29
 
@@ -540,7 +540,7 @@ static
540
540
  VALUE set_font(VALUE self)
541
541
  {
542
542
  CHECK;
543
- check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2);
543
+ check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2, 3);
544
544
 
545
545
  THIS->set_font(to<Rays::Font>(argc, argv));
546
546
  return self;
@@ -26,7 +26,7 @@ VALUE setup(VALUE self, VALUE args, VALUE loop, VALUE colors, VALUE texcoords)
26
26
  {
27
27
  CHECK;
28
28
 
29
- if (args[0].is_a(Rays::polyline_class()))
29
+ if (args.size() >= 1 && args[0].is_a(Rays::polyline_class()))
30
30
  *THIS = to<Rays::Polygon>(args.size(), args.as_array());
31
31
  else
32
32
  {
@@ -24,7 +24,7 @@ jobs:
24
24
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
25
25
 
26
26
  - name: test
27
- run: bundle exec rake quiet packages test
27
+ run: bundle exec rake packages test
28
28
 
29
29
  - name: create gem
30
30
  id: gem
@@ -25,13 +25,13 @@ jobs:
25
25
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
26
26
 
27
27
  - name: packages
28
- run: bundle exec rake packages
28
+ run: bundle exec rake verbose packages
29
29
 
30
30
  - name: lib
31
- run: bundle exec rake lib
31
+ run: bundle exec rake verbose lib
32
32
 
33
33
  - name: ext
34
- run: bundle exec rake ext
34
+ run: bundle exec rake verbose ext
35
35
 
36
36
  - name: test
37
- run: bundle exec rake test
37
+ run: bundle exec rake verbose test
data/CLAUDE.md ADDED
@@ -0,0 +1,25 @@
1
+ # Rays
2
+
3
+ OpenGL-based 2D drawing engine.
4
+
5
+ ## External Libraries
6
+
7
+ Automatically fetched at build time:
8
+ - GLM 1.0.1 — Math library
9
+ - Clipper 6.4.2 — Polygon clipping
10
+ - Earcut.hpp v2.2.4 — Polygon triangulation
11
+ - Splines-lib — Filtering
12
+ - STB (Windows/Linux only) — Image loading
13
+
14
+ ## Platform-Specific Code
15
+
16
+ Platform implementations under `src/`:
17
+ - `src/osx/` — macOS (AppKit, OpenGL)
18
+ - `src/ios/` — iOS
19
+ - `src/win32/` — Windows (GDI32, OpenGL32)
20
+ - `src/sdl/` — Linux (SDL2, GLEW)
21
+
22
+ ## Testing
23
+
24
+ - `test_rays_init.rb` must run alone (`TESTS_ALONE`)
25
+ - `assert_equal_color` — Custom color comparison assertion
data/ChangeLog.md CHANGED
@@ -1,6 +1,23 @@
1
1
  # rays ChangeLog
2
2
 
3
3
 
4
+ ## [v0.3.11] - 2026-04-17
5
+
6
+ - Move OpenGL code into src/opengl/ and introduce Renderer abstraction
7
+
8
+ - Fix Polygon#initialize crash on empty args
9
+
10
+
11
+ ## [v0.3.10] - 2026-04-09
12
+
13
+ - Add Font::smooth
14
+ - Add minimal support for SDL2
15
+ - Add 'apt' for install_packages()
16
+ - Image.load raises Errno::ENOENT when the file does not exist
17
+ - Change C-Extension name from 'native.so' to 'rays_ext.so'
18
+ - Update dependencies
19
+
20
+
4
21
  ## [v0.3.9] - 2025-07-06
5
22
 
6
23
  - Add deepwiki badge
data/Gemfile.lock CHANGED
@@ -1,15 +1,16 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- power_assert (2.0.3)
5
- rake (13.1.0)
6
- test-unit (3.6.1)
4
+ power_assert (3.0.1)
5
+ rake (13.3.1)
6
+ test-unit (3.7.7)
7
7
  power_assert
8
- yard (0.9.34)
8
+ yard (0.9.39)
9
9
 
10
10
  PLATFORMS
11
11
  arm64-darwin-21
12
12
  arm64-darwin-23
13
+ arm64-darwin-24
13
14
 
14
15
  DEPENDENCIES
15
16
  rake
@@ -17,4 +18,4 @@ DEPENDENCIES
17
18
  yard
18
19
 
19
20
  BUNDLED WITH
20
- 2.4.13
21
+ 2.4.19
data/Rakefile CHANGED
@@ -14,7 +14,9 @@ require 'rays/extension'
14
14
  EXTENSIONS = [Xot, Rucy, Rays]
15
15
  TESTS_ALONE = ['test/test_rays_init.rb']
16
16
 
17
- install_packages win32: %w[MINGW_PACKAGE_PREFIX-glew]
17
+ install_packages(
18
+ mingw: %w[MINGW_PACKAGE_PREFIX-glew],
19
+ apt: %w[libglew-dev libsdl2-dev])
18
20
 
19
21
  use_external_library 'https://github.com/g-truc/glm',
20
22
  tag: '1.0.1',
@@ -42,7 +44,7 @@ use_external_library 'https://github.com/andrewwillmott/splines-lib',
42
44
  end
43
45
  }
44
46
 
45
- if win32?
47
+ if win32? || linux?
46
48
  use_external_library 'https://github.com/nothings/stb',
47
49
  commit: 'ae721c50eaf761660b4f90cc590453cdb0c2acd0',
48
50
  srcdirs: 'NOSRC'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.9
1
+ 0.3.11
data/ext/rays/bounds.cpp CHANGED
@@ -62,7 +62,7 @@ RUCY_DEFN(include)
62
62
  CHECK;
63
63
  check_arg_count(__FILE__, __LINE__, "Bounds#include?", argc, 1, 2);
64
64
 
65
- const Rays::Point& point = to<Rays::Point&>(argv[0]);
65
+ const Rays::Point& point = to<Rays::Point>(argv[0]);
66
66
  int dimension = argc >= 2 ? to<int>(argv[1]) : 2;
67
67
 
68
68
  return value(THIS->is_include(point, dimension));
data/ext/rays/extconf.rb CHANGED
@@ -13,11 +13,12 @@ Xot::ExtConf.new Xot, Rucy, Rays do
13
13
  setup do
14
14
  headers << 'ruby.h'
15
15
  libs.unshift 'gdi32', 'opengl32', 'glew32' if win32?
16
+ libs.unshift 'SDL2', 'GLEW', 'GL' if linux?
16
17
  frameworks << 'AppKit' << 'OpenGL' << 'AVFoundation' if osx?
17
- $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if mingw? || cygwin?
18
18
 
19
- $CPPFLAGS << ' -DRAYS_32BIT_PIXELS_STRING' if RUBY_PLATFORM == 'x64-mingw-ucrt'
19
+ $CPPFLAGS << ' -DRAYS_32BIT_PIXELS_STRING' if RUBY_PLATFORM == 'x64-mingw-ucrt'
20
+ $LDFLAGS << ' -Wl,--out-implib=rays_ext.dll.a' if mingw? || cygwin?
20
21
  end
21
22
 
22
- create_makefile 'rays/native'
23
+ create_makefile 'rays_ext'
23
24
  end
data/ext/rays/font.cpp CHANGED
@@ -23,7 +23,7 @@ static
23
23
  RUCY_DEFN(initialize)
24
24
  {
25
25
  RUCY_CHECK_OBJ(Rays::Font, self);
26
- check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2);
26
+ check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2, 3);
27
27
 
28
28
  *THIS = to<Rays::Font>(argc, argv);
29
29
  return self;
@@ -65,6 +65,23 @@ RUCY_DEF0(size)
65
65
  }
66
66
  RUCY_END
67
67
 
68
+ static
69
+ RUCY_DEF1(set_smooth, smooth)
70
+ {
71
+ CHECK;
72
+ THIS->set_smooth(to<bool>(smooth));
73
+ return smooth;
74
+ }
75
+ RUCY_END
76
+
77
+ static
78
+ RUCY_DEF0(smooth)
79
+ {
80
+ CHECK;
81
+ return value(THIS->smooth());
82
+ }
83
+ RUCY_END
84
+
68
85
  static
69
86
  RUCY_DEF1(width, str)
70
87
  {
@@ -153,8 +170,10 @@ Init_rays_font ()
153
170
  cFont.define_private_method("initialize", initialize);
154
171
  cFont.define_private_method("initialize_copy", initialize_copy);
155
172
  cFont.define_method("name", name);
156
- cFont.define_method("size=", set_size);
157
- cFont.define_method("size", size);
173
+ cFont.define_method("size=", set_size);
174
+ cFont.define_method("size", size);
175
+ cFont.define_method("smooth=", set_smooth);
176
+ cFont.define_method("smooth", smooth);
158
177
  cFont.define_method("width", width);
159
178
  cFont.define_method("height", height);
160
179
  cFont.define_method("ascent", ascent);
@@ -185,12 +204,13 @@ namespace Rucy
185
204
  if (argc == 0)
186
205
  return Rays::get_default_font();
187
206
 
188
- coord size =
189
- argc >= 2 ? to<coord>(argv[1]) : (coord) Rays::Font::DEFAULT_SIZE;
207
+ coord size = argc >= 2 ? to<coord>(argv[1]) : (coord) Rays::Font::DEFAULT_SIZE;
208
+ bool smooth = argc >= 3 ? to<bool>(argv[2]) : true;
209
+
190
210
  if (argv->is_nil())
191
- return Rays::Font(NULL, size);
211
+ return Rays::Font(NULL, size, smooth);
192
212
  else if (argv->is_s() || argv->is_sym())
193
- return Rays::Font(argv[0].c_str(), size);
213
+ return Rays::Font(argv[0].c_str(), size, smooth);
194
214
  }
195
215
 
196
216
  if (argc != 1)
data/ext/rays/image.cpp CHANGED
@@ -162,7 +162,7 @@ Init_rays_image ()
162
162
  cImage.define_private_method("get_bitmap", get_bitmap);
163
163
  cImage.define_method("smooth=", set_smooth);
164
164
  cImage.define_method("smooth", get_smooth);
165
- cImage.define_module_function("load", load);
165
+ cImage.define_module_function("load!", load);
166
166
  }
167
167
 
168
168
 
data/ext/rays/native.cpp CHANGED
@@ -23,11 +23,7 @@ void Init_rays_util ();
23
23
 
24
24
 
25
25
  extern "C" void
26
- #ifdef COCOAPODS
27
- Init_rays_native ()
28
- #else
29
- Init_native ()
30
- #endif
26
+ Init_rays_ext ()
31
27
  {
32
28
  RUCY_TRY
33
29
 
data/ext/rays/painter.cpp CHANGED
@@ -587,7 +587,7 @@ static
587
587
  RUCY_DEFN(set_font)
588
588
  {
589
589
  CHECK;
590
- check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2);
590
+ check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2, 3);
591
591
 
592
592
  THIS->set_font(to<Rays::Font>(argc, argv));
593
593
  return self;
data/ext/rays/polygon.cpp CHANGED
@@ -27,7 +27,7 @@ RUCY_DEF4(setup, args, loop, colors, texcoords)
27
27
  {
28
28
  CHECK;
29
29
 
30
- if (args[0].is_a(Rays::polyline_class()))
30
+ if (args.size() >= 1 && args[0].is_a(Rays::polyline_class()))
31
31
  *THIS = to<Rays::Polygon>(args.size(), args.as_array());
32
32
  else
33
33
  {
data/include/rays/font.h CHANGED
@@ -23,7 +23,7 @@ namespace Rays
23
23
 
24
24
  Font ();
25
25
 
26
- Font (const char* name, coord size = DEFAULT_SIZE);
26
+ Font (const char* name, coord size = DEFAULT_SIZE, bool smooth = true);
27
27
 
28
28
  ~Font ();
29
29
 
@@ -35,6 +35,10 @@ namespace Rays
35
35
 
36
36
  coord size () const;
37
37
 
38
+ void set_smooth (bool smooth);
39
+
40
+ bool smooth () const;
41
+
38
42
  coord get_width (const char* str) const;
39
43
 
40
44
  coord get_height (
@@ -257,7 +257,7 @@ namespace Rays
257
257
 
258
258
  const Bounds& clip () const;
259
259
 
260
- void set_font (const char* name, coord size = 0);
260
+ void set_font (const char* name, coord size = 0, bool smooth = true);
261
261
 
262
262
  void set_font (const Font& font);
263
263
 
data/lib/rays/ext.rb CHANGED
@@ -1 +1 @@
1
- require 'rays/native'
1
+ require 'rays_ext'
data/lib/rays/image.rb CHANGED
@@ -38,6 +38,11 @@ module Rays
38
38
  get_bitmap true
39
39
  end
40
40
 
41
+ def self.load(path)
42
+ raise Errno::ENOENT, "no such file: '#{path}'" unless File.exist? path
43
+ load! path
44
+ end
45
+
41
46
  end# Image
42
47
 
43
48
 
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_dependency 'xot', '~> 0.3.9', '>= 0.3.9'
29
- s.add_dependency 'rucy', '~> 0.3.9', '>= 0.3.9'
28
+ s.add_dependency 'xot', '~> 0.3.11'
29
+ s.add_dependency 'rucy', '~> 0.3.11'
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/bitmap.h CHANGED
@@ -16,10 +16,15 @@ namespace Rays
16
16
  class RawFont;
17
17
 
18
18
 
19
+ void Bitmap_setup (
20
+ Bitmap* bitmap, int w, int h, const ColorSpace& cs,
21
+ const void* pixels = NULL, bool clear_pixels = true);
22
+
19
23
  Bitmap Bitmap_from (const Texture& texture);
20
24
 
21
25
  void Bitmap_draw_string (
22
- Bitmap* bitmap, const RawFont& font, const char* str, coord x, coord y);
26
+ Bitmap* bitmap, const RawFont& font,
27
+ const char* str, coord x, coord y, bool smooth);
23
28
 
24
29
  void Bitmap_set_modified (Bitmap* bitmap, bool modified = true);
25
30
 
data/src/color_space.cpp CHANGED
@@ -1,4 +1,4 @@
1
- #include "color_space.h"
1
+ #include "rays/color_space.h"
2
2
 
3
3
 
4
4
  #include <xot/util.h>
@@ -194,44 +194,4 @@ namespace Rays
194
194
  }
195
195
 
196
196
 
197
- void
198
- ColorSpace_get_gl_format_and_type (
199
- GLenum* format, GLenum* type, const ColorSpace& cs)
200
- {
201
- if (!format && !type)
202
- argument_error(__FILE__, __LINE__);
203
-
204
- if (!cs)
205
- invalid_state_error(__FILE__, __LINE__);
206
-
207
- if (format)
208
- {
209
- if (cs.is_rgb()) *format = cs.has_alpha() ? GL_RGBA : GL_RGB;
210
- #ifndef IOS
211
- else if (cs.is_bgr()) *format = cs.has_alpha() ? GL_BGRA : GL_BGR;
212
- #endif
213
- else if (cs.is_gray()) *format = GL_LUMINANCE;
214
- else if (cs.is_alpha()) *format = GL_ALPHA;
215
- else
216
- rays_error(__FILE__, __LINE__, "invalid color space.");
217
- }
218
-
219
- if (type)
220
- {
221
- if (cs.is_float())
222
- *type = GL_FLOAT;
223
- else switch (cs.bpc())
224
- {
225
- case 8: *type = GL_UNSIGNED_BYTE; break;
226
- case 16: *type = GL_UNSIGNED_SHORT; break;
227
- #ifndef IOS
228
- case 32: *type = GL_UNSIGNED_INT; break;
229
- #endif
230
- default:
231
- rays_error(__FILE__, __LINE__, "invalid bpc.");
232
- }
233
- }
234
- }
235
-
236
-
237
197
  }// Rays
data/src/font.cpp CHANGED
@@ -14,6 +14,8 @@ namespace Rays
14
14
 
15
15
  RawFont rawfont;
16
16
 
17
+ bool smooth = true;
18
+
17
19
  mutable RawFont rawfont_for_pixel_density;
18
20
 
19
21
  mutable float for_pixel_density = 1;
@@ -64,9 +66,10 @@ namespace Rays
64
66
  {
65
67
  }
66
68
 
67
- Font::Font (const char* name, coord size)
69
+ Font::Font (const char* name, coord size, bool smooth)
68
70
  {
69
71
  self->rawfont = RawFont(name, size);
72
+ self->smooth = smooth;
70
73
  }
71
74
 
72
75
  Font::~Font ()
@@ -78,6 +81,7 @@ namespace Rays
78
81
  {
79
82
  Font f;
80
83
  f.self->rawfont = RawFont(self->rawfont, self->rawfont.size());
84
+ f.self->smooth = self->smooth;
81
85
  return f;
82
86
  }
83
87
 
@@ -99,6 +103,18 @@ namespace Rays
99
103
  return self->rawfont.size();
100
104
  }
101
105
 
106
+ void
107
+ Font::set_smooth (bool smooth)
108
+ {
109
+ self->smooth = smooth;
110
+ }
111
+
112
+ bool
113
+ Font::smooth () const
114
+ {
115
+ return self->smooth;
116
+ }
117
+
102
118
  coord
103
119
  Font::get_width (const char* str) const
104
120
  {
data/src/image.cpp CHANGED
@@ -5,7 +5,6 @@
5
5
  #include <assert.h>
6
6
  #include "rays/exception.h"
7
7
  #include "rays/debug.h"
8
- #include "opengl.h"
9
8
  #include "bitmap.h"
10
9
  #include "texture.h"
11
10