rays 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.doc/ext/rays/bitmap.cpp +70 -233
- data/.doc/ext/rays/bounds.cpp +339 -57
- data/.doc/ext/rays/color.cpp +58 -48
- data/.doc/ext/rays/color_space.cpp +174 -0
- data/.doc/ext/rays/font.cpp +31 -53
- data/.doc/ext/rays/image.cpp +64 -67
- data/.doc/ext/rays/matrix.cpp +22 -50
- data/.doc/ext/rays/native.cpp +9 -2
- data/.doc/ext/rays/painter.cpp +276 -259
- data/.doc/ext/rays/point.cpp +186 -52
- data/.doc/ext/rays/rays.cpp +25 -20
- data/.doc/ext/rays/shader.cpp +61 -0
- data/.doc/ext/rays/texture.cpp +47 -59
- data/{README → README.md} +0 -0
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +88 -248
- data/ext/rays/bounds.cpp +437 -141
- data/ext/rays/color.cpp +79 -69
- data/ext/rays/color_space.cpp +185 -0
- data/ext/rays/extconf.rb +14 -63
- data/ext/rays/font.cpp +44 -65
- data/ext/rays/image.cpp +82 -81
- data/ext/rays/matrix.cpp +32 -60
- data/ext/rays/native.cpp +9 -2
- data/ext/rays/painter.cpp +345 -321
- data/ext/rays/point.cpp +212 -69
- data/ext/rays/rays.cpp +29 -23
- data/ext/rays/shader.cpp +63 -0
- data/ext/rays/texture.cpp +64 -74
- data/include/rays/bitmap.h +21 -12
- data/include/rays/bounds.h +67 -9
- data/include/rays/color.h +23 -7
- data/include/rays/{colorspace.h → color_space.h} +6 -3
- data/include/rays/exception.h +17 -11
- data/include/rays/font.h +4 -3
- data/include/rays/image.h +11 -6
- data/include/rays/matrix.h +15 -12
- data/include/rays/opengl.h +54 -1
- data/include/rays/painter.h +98 -108
- data/include/rays/point.h +45 -5
- data/include/rays/rays.h +2 -2
- data/include/rays/ruby/bitmap.h +2 -16
- data/include/rays/ruby/bounds.h +4 -16
- data/include/rays/ruby/color.h +3 -16
- data/include/rays/ruby/color_space.h +27 -0
- data/include/rays/ruby/font.h +2 -16
- data/include/rays/ruby/image.h +2 -16
- data/include/rays/ruby/matrix.h +2 -16
- data/include/rays/ruby/painter.h +2 -16
- data/include/rays/ruby/point.h +3 -16
- data/include/rays/ruby/shader.h +27 -0
- data/include/rays/ruby/texture.h +2 -16
- data/include/rays/ruby.h +1 -0
- data/include/rays/shader.h +48 -0
- data/include/rays/texture.h +13 -2
- data/include/rays.h +2 -1
- data/lib/rays/bitmap.rb +20 -11
- data/lib/rays/bounds.rb +29 -68
- data/lib/rays/color.rb +39 -0
- data/lib/rays/color_space.rb +33 -0
- data/lib/rays/font.rb +29 -0
- data/lib/rays/image.rb +22 -0
- data/lib/rays/module.rb +11 -7
- data/lib/rays/painter.rb +103 -40
- data/lib/rays/point.rb +19 -36
- data/lib/rays/shader.rb +13 -0
- data/lib/rays/texture.rb +9 -0
- data/lib/rays.rb +4 -0
- data/rays.gemspec +3 -4
- data/src/bounds.cpp +272 -63
- data/src/color.cpp +168 -21
- data/src/{colorspace.cpp → color_space.cpp} +38 -1
- data/src/exception.cpp +24 -15
- data/src/frame_buffer.cpp +275 -0
- data/src/frame_buffer.h +79 -0
- data/src/image.cpp +80 -36
- data/src/ios/bitmap.mm +340 -0
- data/src/ios/font.mm +206 -0
- data/src/{cocoa → ios}/helper.h +2 -2
- data/src/{cocoa → ios}/helper.mm +0 -0
- data/src/ios/opengl.mm +21 -0
- data/src/ios/program.cpp +122 -0
- data/src/{cocoa → ios}/rays.mm +8 -7
- data/src/matrix.cpp +10 -22
- data/src/opengl.cpp +64 -0
- data/src/{cocoa → osx}/bitmap.mm +121 -70
- data/src/{cocoa → osx}/font.mm +32 -24
- data/src/osx/helper.h +26 -0
- data/src/osx/helper.mm +25 -0
- data/src/osx/opengl.mm +103 -0
- data/src/osx/rays.mm +43 -0
- data/src/painter.cpp +596 -422
- data/src/point.cpp +154 -11
- data/src/program.cpp +513 -0
- data/src/program.h +73 -0
- data/src/render_buffer.cpp +120 -0
- data/src/render_buffer.h +47 -0
- data/src/shader.cpp +117 -0
- data/src/texture.cpp +104 -134
- data/test/helper.rb +10 -3
- data/test/test_bitmap.rb +18 -0
- data/test/test_bounds.rb +81 -35
- data/test/test_color.rb +29 -2
- data/test/test_image.rb +63 -0
- data/test/test_painter.rb +120 -0
- data/test/test_point.rb +30 -9
- data/test/test_shader.rb +37 -0
- data/test/test_texture.rb +18 -0
- metadata +75 -58
- data/.gitignore +0 -14
- 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
|