rays 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/.doc/ext/rays/bitmap.cpp +70 -233
  3. data/.doc/ext/rays/bounds.cpp +339 -57
  4. data/.doc/ext/rays/color.cpp +58 -48
  5. data/.doc/ext/rays/color_space.cpp +174 -0
  6. data/.doc/ext/rays/font.cpp +31 -53
  7. data/.doc/ext/rays/image.cpp +64 -67
  8. data/.doc/ext/rays/matrix.cpp +22 -50
  9. data/.doc/ext/rays/native.cpp +9 -2
  10. data/.doc/ext/rays/painter.cpp +276 -259
  11. data/.doc/ext/rays/point.cpp +186 -52
  12. data/.doc/ext/rays/rays.cpp +25 -20
  13. data/.doc/ext/rays/shader.cpp +61 -0
  14. data/.doc/ext/rays/texture.cpp +47 -59
  15. data/{README → README.md} +0 -0
  16. data/Rakefile +6 -5
  17. data/VERSION +1 -1
  18. data/ext/rays/bitmap.cpp +88 -248
  19. data/ext/rays/bounds.cpp +437 -141
  20. data/ext/rays/color.cpp +79 -69
  21. data/ext/rays/color_space.cpp +185 -0
  22. data/ext/rays/extconf.rb +14 -63
  23. data/ext/rays/font.cpp +44 -65
  24. data/ext/rays/image.cpp +82 -81
  25. data/ext/rays/matrix.cpp +32 -60
  26. data/ext/rays/native.cpp +9 -2
  27. data/ext/rays/painter.cpp +345 -321
  28. data/ext/rays/point.cpp +212 -69
  29. data/ext/rays/rays.cpp +29 -23
  30. data/ext/rays/shader.cpp +63 -0
  31. data/ext/rays/texture.cpp +64 -74
  32. data/include/rays/bitmap.h +21 -12
  33. data/include/rays/bounds.h +67 -9
  34. data/include/rays/color.h +23 -7
  35. data/include/rays/{colorspace.h → color_space.h} +6 -3
  36. data/include/rays/exception.h +17 -11
  37. data/include/rays/font.h +4 -3
  38. data/include/rays/image.h +11 -6
  39. data/include/rays/matrix.h +15 -12
  40. data/include/rays/opengl.h +54 -1
  41. data/include/rays/painter.h +98 -108
  42. data/include/rays/point.h +45 -5
  43. data/include/rays/rays.h +2 -2
  44. data/include/rays/ruby/bitmap.h +2 -16
  45. data/include/rays/ruby/bounds.h +4 -16
  46. data/include/rays/ruby/color.h +3 -16
  47. data/include/rays/ruby/color_space.h +27 -0
  48. data/include/rays/ruby/font.h +2 -16
  49. data/include/rays/ruby/image.h +2 -16
  50. data/include/rays/ruby/matrix.h +2 -16
  51. data/include/rays/ruby/painter.h +2 -16
  52. data/include/rays/ruby/point.h +3 -16
  53. data/include/rays/ruby/shader.h +27 -0
  54. data/include/rays/ruby/texture.h +2 -16
  55. data/include/rays/ruby.h +1 -0
  56. data/include/rays/shader.h +48 -0
  57. data/include/rays/texture.h +13 -2
  58. data/include/rays.h +2 -1
  59. data/lib/rays/bitmap.rb +20 -11
  60. data/lib/rays/bounds.rb +29 -68
  61. data/lib/rays/color.rb +39 -0
  62. data/lib/rays/color_space.rb +33 -0
  63. data/lib/rays/font.rb +29 -0
  64. data/lib/rays/image.rb +22 -0
  65. data/lib/rays/module.rb +11 -7
  66. data/lib/rays/painter.rb +103 -40
  67. data/lib/rays/point.rb +19 -36
  68. data/lib/rays/shader.rb +13 -0
  69. data/lib/rays/texture.rb +9 -0
  70. data/lib/rays.rb +4 -0
  71. data/rays.gemspec +3 -4
  72. data/src/bounds.cpp +272 -63
  73. data/src/color.cpp +168 -21
  74. data/src/{colorspace.cpp → color_space.cpp} +38 -1
  75. data/src/exception.cpp +24 -15
  76. data/src/frame_buffer.cpp +275 -0
  77. data/src/frame_buffer.h +79 -0
  78. data/src/image.cpp +80 -36
  79. data/src/ios/bitmap.mm +340 -0
  80. data/src/ios/font.mm +206 -0
  81. data/src/{cocoa → ios}/helper.h +2 -2
  82. data/src/{cocoa → ios}/helper.mm +0 -0
  83. data/src/ios/opengl.mm +21 -0
  84. data/src/ios/program.cpp +122 -0
  85. data/src/{cocoa → ios}/rays.mm +8 -7
  86. data/src/matrix.cpp +10 -22
  87. data/src/opengl.cpp +64 -0
  88. data/src/{cocoa → osx}/bitmap.mm +121 -70
  89. data/src/{cocoa → osx}/font.mm +32 -24
  90. data/src/osx/helper.h +26 -0
  91. data/src/osx/helper.mm +25 -0
  92. data/src/osx/opengl.mm +103 -0
  93. data/src/osx/rays.mm +43 -0
  94. data/src/painter.cpp +596 -422
  95. data/src/point.cpp +154 -11
  96. data/src/program.cpp +513 -0
  97. data/src/program.h +73 -0
  98. data/src/render_buffer.cpp +120 -0
  99. data/src/render_buffer.h +47 -0
  100. data/src/shader.cpp +117 -0
  101. data/src/texture.cpp +104 -134
  102. data/test/helper.rb +10 -3
  103. data/test/test_bitmap.rb +18 -0
  104. data/test/test_bounds.rb +81 -35
  105. data/test/test_color.rb +29 -2
  106. data/test/test_image.rb +63 -0
  107. data/test/test_painter.rb +120 -0
  108. data/test/test_point.rb +30 -9
  109. data/test/test_shader.rb +37 -0
  110. data/test/test_texture.rb +18 -0
  111. metadata +75 -58
  112. data/.gitignore +0 -14
  113. data/ChangeLog +0 -8
data/src/osx/opengl.mm ADDED
@@ -0,0 +1,103 @@
1
+ // -*- objc -*-
2
+ #include "rays/opengl.h"
3
+
4
+
5
+ #include <vector>
6
+ #import <Cocoa/Cocoa.h>
7
+ #import <AppKit/NSApplication.h>
8
+ #import <AppKit/NSWindow.h>
9
+ #import <AppKit/NSOpenGLView.h>
10
+ #import <OpenGL/OpenGL.h>
11
+
12
+
13
+ static NSOpenGLPixelFormat*
14
+ make_pixelformat ()
15
+ {
16
+ static const NSOpenGLPixelFormatAttribute DEFAULT[] =
17
+ {
18
+ NSOpenGLPFAWindow,
19
+ //NSOpenGLPFAAccelerated,
20
+ NSOpenGLPFADoubleBuffer,
21
+ //NSOpenGLPFAColorSize, 24,
22
+ //NSOpenGLPFAAlphaSize, 8,
23
+ NSOpenGLPFADepthSize, 24,
24
+ //NSOpenGLPFANoRecovery,
25
+ };
26
+ static const size_t DEFAULT_SIZE = sizeof(DEFAULT) / sizeof(DEFAULT[0]);
27
+
28
+ std::vector<NSOpenGLPixelFormatAttribute> attr(
29
+ DEFAULT, DEFAULT + DEFAULT_SIZE);
30
+ attr.push_back(0);
31
+
32
+ return [[[NSOpenGLPixelFormat alloc] initWithAttributes: &attr[0]] autorelease];
33
+ }
34
+
35
+
36
+ @interface OffscreenGLView : NSOpenGLView
37
+ @end// OffscreenGLView
38
+
39
+
40
+ @implementation OffscreenGLView
41
+
42
+ - (id) init
43
+ {
44
+ self = [super
45
+ initWithFrame: NSMakeRect(0, 0, 0, 0)
46
+ pixelFormat: make_pixelformat()];
47
+ if (!self) return nil;
48
+
49
+ [[self openGLContext] makeCurrentContext];
50
+ return self;
51
+ }
52
+
53
+ @end// OffscreenGLView
54
+
55
+
56
+ @interface OffscreenWindow : NSWindow
57
+
58
+ {
59
+ @private
60
+ OffscreenGLView* view;
61
+ }
62
+
63
+ @end// OffscreenWindow
64
+
65
+
66
+ @implementation OffscreenWindow
67
+
68
+ - (id) init
69
+ {
70
+ self = [super
71
+ initWithContentRect: NSMakeRect(0, 0, 0, 0)
72
+ styleMask: 0
73
+ backing: NSBackingStoreBuffered
74
+ defer: NO];
75
+ if (!self) return nil;
76
+
77
+ view = [[OffscreenGLView alloc] init];
78
+ [self setContentView: view];
79
+ return self;
80
+ }
81
+
82
+ - (void) dealloc
83
+ {
84
+ if (view) [view release];
85
+ [super dealloc];
86
+ }
87
+
88
+ @end// OffscreenWindow
89
+
90
+
91
+ namespace Rays
92
+ {
93
+
94
+
95
+ void
96
+ init_offscreen_context ()
97
+ {
98
+ [NSApplication sharedApplication];
99
+ [[[OffscreenWindow alloc] init] autorelease];
100
+ }
101
+
102
+
103
+ }// Rays
data/src/osx/rays.mm ADDED
@@ -0,0 +1,43 @@
1
+ // -*- objc -*-
2
+ #include "rays/rays.h"
3
+
4
+
5
+ #import <Foundation/Foundation.h>
6
+ #include "rays/exception.h"
7
+
8
+
9
+ namespace Rays
10
+ {
11
+
12
+
13
+ namespace global
14
+ {
15
+
16
+
17
+ static NSAutoreleasePool* pool = nil;
18
+
19
+
20
+ }// global
21
+
22
+
23
+ void
24
+ init ()
25
+ {
26
+ if (global::pool)
27
+ rays_error(__FILE__, __LINE__, "Rays::init(): already initialized.");
28
+
29
+ global::pool = [[NSAutoreleasePool alloc] init];
30
+ }
31
+
32
+ void
33
+ fin ()
34
+ {
35
+ if (!global::pool)
36
+ rays_error(__FILE__, __LINE__, "Rays::fin(): not initialized.");
37
+
38
+ [global::pool release];
39
+ global::pool = nil;
40
+ }
41
+
42
+
43
+ }// Rays