rays 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/ChangeLog +8 -0
  2. data/README +4 -0
  3. data/Rakefile +72 -0
  4. data/VERSION +1 -0
  5. data/ext/rays/bitmap.cpp +322 -0
  6. data/ext/rays/extconf.rb +61 -0
  7. data/ext/rays/font.cpp +125 -0
  8. data/ext/rays/image.cpp +166 -0
  9. data/ext/rays/native.cpp +24 -0
  10. data/ext/rays/painter.cpp +573 -0
  11. data/ext/rays/rays.cpp +61 -0
  12. data/ext/rays/rays.h +39 -0
  13. data/ext/rays/texture.cpp +130 -0
  14. data/include/rays.h +20 -0
  15. data/include/rays/bitmap.h +80 -0
  16. data/include/rays/colorspace.h +101 -0
  17. data/include/rays/defs.h +33 -0
  18. data/include/rays/font.h +49 -0
  19. data/include/rays/helpers.h +37 -0
  20. data/include/rays/image.h +68 -0
  21. data/include/rays/opengl.h +15 -0
  22. data/include/rays/painter.h +179 -0
  23. data/include/rays/rays.h +19 -0
  24. data/include/rays/ruby.h +15 -0
  25. data/include/rays/ruby/bitmap.h +39 -0
  26. data/include/rays/ruby/font.h +39 -0
  27. data/include/rays/ruby/image.h +39 -0
  28. data/include/rays/ruby/painter.h +39 -0
  29. data/include/rays/ruby/rays.h +21 -0
  30. data/include/rays/ruby/texture.h +39 -0
  31. data/include/rays/texture.h +56 -0
  32. data/include/rays/transform.h +35 -0
  33. data/lib/rays.rb +9 -0
  34. data/lib/rays/autoinit.rb +10 -0
  35. data/lib/rays/bitmap.rb +25 -0
  36. data/lib/rays/image.rb +15 -0
  37. data/lib/rays/module.rb +30 -0
  38. data/lib/rays/painter.rb +99 -0
  39. data/lib/rays/texture.rb +15 -0
  40. data/rays.gemspec +54 -0
  41. data/src/cocoa/bitmap.mm +286 -0
  42. data/src/cocoa/font.mm +193 -0
  43. data/src/cocoa/helpers.h +26 -0
  44. data/src/cocoa/helpers.mm +25 -0
  45. data/src/cocoa/rays.mm +40 -0
  46. data/src/colorspace.cpp +183 -0
  47. data/src/helpers.cpp +22 -0
  48. data/src/image.cpp +133 -0
  49. data/src/painter.cpp +769 -0
  50. data/src/texture.cpp +360 -0
  51. data/src/transform.cpp +88 -0
  52. data/src/win32/bitmap.cpp +212 -0
  53. data/src/win32/font.cpp +99 -0
  54. data/src/win32/gdi.cpp +771 -0
  55. data/src/win32/gdi.h +226 -0
  56. data/src/win32/rays.cpp +36 -0
  57. data/support.rb +58 -0
  58. data/task/ext.rake +41 -0
  59. data/task/gem.rake +33 -0
  60. data/task/git.rake +22 -0
  61. data/task/lib.rake +54 -0
  62. data/test/helpers.rb +15 -0
  63. data/test/test_painter.rb +11 -0
  64. data/test/test_rays.rb +19 -0
  65. data/test/test_texture.rb +11 -0
  66. metadata +153 -0
@@ -0,0 +1,49 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_FONT_H__
4
+ #define __RAYS_FONT_H__
5
+
6
+
7
+ #include <rays/defs.h>
8
+ #include <rays/helpers.h>
9
+
10
+
11
+ namespace Rays
12
+ {
13
+
14
+
15
+ class Font
16
+ {
17
+
18
+ public:
19
+
20
+ Font ();
21
+
22
+ Font (const char* name, coord size = 0);
23
+
24
+ ~Font ();
25
+
26
+ String name () const;
27
+
28
+ coord size () const;
29
+
30
+ bool get_extent (coord* width, coord* height, const char* str) const;
31
+
32
+ operator bool () const;
33
+
34
+ bool operator ! () const;
35
+
36
+ struct Data;
37
+
38
+ Impl<Data> self;
39
+
40
+ };// Font
41
+
42
+
43
+ const Font& default_font ();
44
+
45
+
46
+ }// Rays
47
+
48
+
49
+ #endif//EOH
@@ -0,0 +1,37 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_HELPERS_H__
4
+ #define __RAYS_HELPERS_H__
5
+
6
+
7
+ #include <boost/shared_ptr.hpp>
8
+
9
+
10
+ namespace Rays
11
+ {
12
+
13
+
14
+ template <typename T>
15
+ class Impl : public boost::shared_ptr<T>
16
+ {
17
+
18
+ typedef boost::shared_ptr<T> Super;
19
+
20
+ public:
21
+
22
+ Impl () : Super(new T) {}
23
+
24
+ Impl (T* p) : Super(p) {}
25
+
26
+ };// Impl
27
+
28
+
29
+ int bit2byte (int bits);
30
+
31
+ int byte2bit (int bytes);
32
+
33
+
34
+ }// Rays
35
+
36
+
37
+ #endif//EOH
@@ -0,0 +1,68 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_IMAGE_H__
4
+ #define __RAYS_IMAGE_H__
5
+
6
+
7
+ #include <rays/colorspace.h>
8
+ #include <rays/helpers.h>
9
+
10
+
11
+ namespace Rays
12
+ {
13
+
14
+
15
+ class Bitmap;
16
+
17
+ class Texture;
18
+
19
+
20
+ class Image
21
+ {
22
+
23
+ public:
24
+
25
+ Image ();
26
+
27
+ Image (
28
+ int width, int height, const ColorSpace& cs = RGBA,
29
+ bool alphatexture = false);
30
+
31
+ Image (const Bitmap& bitmap, bool alphatexture = false);
32
+
33
+ ~Image ();
34
+
35
+ int width () const;
36
+
37
+ int height () const;
38
+
39
+ const ColorSpace& color_space () const;
40
+
41
+ bool alpha_texture () const;
42
+
43
+ Bitmap& bitmap ();
44
+
45
+ const Bitmap& bitmap () const;
46
+
47
+ Texture& texture ();
48
+
49
+ const Texture& texture () const;
50
+
51
+ operator bool () const;
52
+
53
+ bool operator ! () const;
54
+
55
+ struct Data;
56
+
57
+ Impl<Data> self;
58
+
59
+ };// Image
60
+
61
+
62
+ bool load_image (Image* image, const char* path, bool alphatexture = false);
63
+
64
+
65
+ }// Rays
66
+
67
+
68
+ #endif//EOH
@@ -0,0 +1,15 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_GL_H__
4
+ #define __RAYS_GL_H__
5
+
6
+
7
+ #if defined(COCOA)
8
+ #include <OpenGL/OpenGL.h>
9
+ #elif defined(WIN32)
10
+ #include <GL/gl.h>
11
+ #include <GL/glext.h>
12
+ #endif
13
+
14
+
15
+ #endif//EOH
@@ -0,0 +1,179 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_PAINTER_H__
4
+ #define __RAYS_PAINTER_H__
5
+
6
+
7
+ #include <rays/defs.h>
8
+ #include <rays/opengl.h>
9
+ #include <rays/font.h>
10
+ #include <rays/helpers.h>
11
+
12
+
13
+ namespace Rays
14
+ {
15
+
16
+
17
+ enum ShapeType
18
+ {
19
+
20
+ SHAPE_UNKNOWN = UNKNOWN,
21
+
22
+ POINTS = GL_POINTS,
23
+
24
+ LINES = GL_LINES,
25
+
26
+ LINE_STRIP = GL_LINE_STRIP,
27
+
28
+ LINE_LOOP = GL_LINE_LOOP,
29
+
30
+ TRIANGLES = GL_TRIANGLES,
31
+
32
+ TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
33
+
34
+ TRIANGLE_FAN = GL_TRIANGLE_FAN,
35
+
36
+ QUADS = GL_QUADS,
37
+
38
+ QUAD_STRIP = GL_QUAD_STRIP,
39
+
40
+ POLYGON = GL_POLYGON,
41
+
42
+ };// ShapeType
43
+
44
+
45
+ class Texture;
46
+
47
+ class Image;
48
+
49
+
50
+ class Painter
51
+ {
52
+
53
+ public:
54
+
55
+ Painter ();
56
+
57
+ ~Painter ();
58
+
59
+ bool canvas (coord x, coord y, coord width, coord height);
60
+
61
+ bool begin ();
62
+
63
+ bool end ();
64
+
65
+ bool push ();
66
+
67
+ bool pop ();
68
+
69
+ //
70
+ // high level drawing methods
71
+ //
72
+ bool line (coord x1, coord y1, coord x2, coord y2);
73
+
74
+ bool rect (coord x, coord y, coord width, coord height);
75
+
76
+ bool ellipse (
77
+ coord x, coord y, coord width, coord height = 0, coord radius_min = 0,
78
+ uint nsegment = 0);
79
+
80
+ bool arc (
81
+ coord x, coord y, coord width, coord height = 0,
82
+ float angle_from = 0, float angle_to = 360, coord radius_min = 0,
83
+ uint nsegment = 0);
84
+
85
+ bool image (
86
+ const Image& image, coord x = 0, coord y = 0);
87
+
88
+ bool image (
89
+ const Image& image, coord x, coord y, coord width, coord height);
90
+
91
+ bool image (
92
+ const Image& image,
93
+ coord src_x, coord src_y, coord src_width, coord src_height,
94
+ coord dest_x, coord dest_y);
95
+
96
+ bool image (
97
+ const Image& image,
98
+ coord src_x, coord src_y, coord src_width, coord src_height,
99
+ coord dest_x, coord dest_y, coord dest_width, coord dest_height);
100
+
101
+ bool text (
102
+ const char* str, coord x = 0, coord y = 0,
103
+ const Font& font = default_font());
104
+
105
+ bool text (
106
+ const char* str, coord x, coord y, coord width, coord height,
107
+ const Font& font = default_font());
108
+
109
+ bool clear ();
110
+
111
+ bool get_clear (
112
+ float* red, float* green = NULL, float* blue = NULL,
113
+ float* alpha = NULL);
114
+
115
+ bool set_clear (
116
+ float red, float green, float blue, float alpha = 1);
117
+
118
+ bool no_clear ();
119
+
120
+ bool get_fill (
121
+ float* red, float* green = NULL, float* blue = NULL,
122
+ float* alpha = NULL);
123
+
124
+ bool set_fill (float red, float green, float blue, float alpha = 1);
125
+
126
+ bool no_fill ();
127
+
128
+ bool get_stroke (
129
+ float* red, float* green = NULL, float* blue = NULL,
130
+ float* alpha = NULL);
131
+
132
+ bool set_stroke (float red, float green, float blue, float alpha = 1);
133
+
134
+ bool no_stroke ();
135
+
136
+ bool get_clip (
137
+ coord* x, coord* y = NULL,
138
+ coord* width = NULL, coord* height = NULL);
139
+
140
+ bool set_clip (coord x, coord y, coord width, coord height);
141
+
142
+ bool no_clip ();
143
+
144
+ //
145
+ // low level drawing methods
146
+ //
147
+ bool begin_shape (ShapeType type);
148
+
149
+ bool end_shape ();
150
+
151
+ bool color (float red, float green, float blue, float alpha = 1);
152
+
153
+ bool texture (const Texture& tex);
154
+
155
+ bool no_texture ();
156
+
157
+ bool vertex (coord x, coord y);
158
+
159
+ bool vertex (coord x, coord y, coord z);
160
+
161
+ bool vertex (coord x, coord y, coord texture_s, coord texture_t);
162
+
163
+ bool vertex (coord x, coord y, coord z, coord texture_s, coord texture_t);
164
+
165
+ operator bool () const;
166
+
167
+ bool operator ! () const;
168
+
169
+ struct Data;
170
+
171
+ Impl<Data> self;
172
+
173
+ };// Painter
174
+
175
+
176
+ }// Rays
177
+
178
+
179
+ #endif//EOH
@@ -0,0 +1,19 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_RAYS_H__
4
+ #define __RAYS_RAYS_H__
5
+
6
+
7
+ namespace Rays
8
+ {
9
+
10
+
11
+ bool init ();
12
+
13
+ bool fin ();
14
+
15
+
16
+ }// Rays
17
+
18
+
19
+ #endif//EOH
@@ -0,0 +1,15 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_RUBY_H__
4
+ #define __RAYS_RUBY_H__
5
+
6
+
7
+ #include <rays/ruby/rays.h>
8
+ #include <rays/ruby/bitmap.h>
9
+ #include <rays/ruby/texture.h>
10
+ #include <rays/ruby/image.h>
11
+ #include <rays/ruby/font.h>
12
+ #include <rays/ruby/painter.h>
13
+
14
+
15
+ #endif//EOH
@@ -0,0 +1,39 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_RUBY_BITMAP_H__
4
+ #define __RAYS_RUBY_BITMAP_H__
5
+
6
+
7
+ #include <rucy/rucy.h>
8
+ #include <rucy/class.h>
9
+ #include <rays/bitmap.h>
10
+
11
+
12
+ namespace Rays
13
+ {
14
+
15
+
16
+ Rucy::Class bitmap_class ();
17
+ // class Rays::Bitmap
18
+
19
+
20
+ }// Rays
21
+
22
+
23
+ namespace Rucy
24
+ {
25
+
26
+
27
+ Value value (const Rays::Bitmap& bitmap);
28
+
29
+ template <> inline Rays::Bitmap*
30
+ value_to<Rays::Bitmap*> (Value obj, bool convert)
31
+ {
32
+ return get_type<Rays::Bitmap>(obj, Rays::bitmap_class());
33
+ }
34
+
35
+
36
+ }// Rucy
37
+
38
+
39
+ #endif//EOH
@@ -0,0 +1,39 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_RUBY_FONT_H__
4
+ #define __RAYS_RUBY_FONT_H__
5
+
6
+
7
+ #include <rucy/rucy.h>
8
+ #include <rucy/class.h>
9
+ #include <rays/font.h>
10
+
11
+
12
+ namespace Rays
13
+ {
14
+
15
+
16
+ Rucy::Class font_class ();
17
+ // class Rays::Font
18
+
19
+
20
+ }// Rays
21
+
22
+
23
+ namespace Rucy
24
+ {
25
+
26
+
27
+ Value value (const Rays::Font& font);
28
+
29
+ template <> inline Rays::Font*
30
+ value_to<Rays::Font*> (Value obj, bool convert)
31
+ {
32
+ return get_type<Rays::Font>(obj, Rays::font_class());
33
+ }
34
+
35
+
36
+ }// Rucy
37
+
38
+
39
+ #endif//EOH