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/program.h
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_PROGRAM_H__
|
4
|
+
#define __RAYS_PROGRAM_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <xot/pimpl.h>
|
8
|
+
#include <rays/opengl.h>
|
9
|
+
|
10
|
+
|
11
|
+
namespace Rays
|
12
|
+
{
|
13
|
+
|
14
|
+
|
15
|
+
class Shader;
|
16
|
+
|
17
|
+
|
18
|
+
class Program
|
19
|
+
{
|
20
|
+
|
21
|
+
typedef Program This;
|
22
|
+
|
23
|
+
public:
|
24
|
+
|
25
|
+
Program ();
|
26
|
+
|
27
|
+
~Program ();
|
28
|
+
|
29
|
+
void attach (const Shader& shader);
|
30
|
+
|
31
|
+
void detach (const Shader& shader);
|
32
|
+
|
33
|
+
void set_uniform (const char* name, int arg1);
|
34
|
+
|
35
|
+
void set_uniform (const char* name, int arg1, int arg2);
|
36
|
+
|
37
|
+
void set_uniform (const char* name, int arg1, int arg2, int arg3);
|
38
|
+
|
39
|
+
void set_uniform (const char* name, int arg1, int arg2, int arg3, int arg4);
|
40
|
+
|
41
|
+
void set_uniform (const char* name, const int* args, size_t size);
|
42
|
+
|
43
|
+
void set_uniform (const char* name, float arg1);
|
44
|
+
|
45
|
+
void set_uniform (const char* name, float arg1, float arg2);
|
46
|
+
|
47
|
+
void set_uniform (const char* name, float arg1, float arg2, float arg3);
|
48
|
+
|
49
|
+
void set_uniform (const char* name, float arg1, float arg2, float arg3, float arg4);
|
50
|
+
|
51
|
+
void set_uniform (const char* name, const float* args, size_t size);
|
52
|
+
|
53
|
+
void push ();
|
54
|
+
|
55
|
+
void pop ();
|
56
|
+
|
57
|
+
GLuint id () const;
|
58
|
+
|
59
|
+
operator bool () const;
|
60
|
+
|
61
|
+
bool operator ! () const;
|
62
|
+
|
63
|
+
struct Data;
|
64
|
+
|
65
|
+
Xot::PImpl<Data, true> self;
|
66
|
+
|
67
|
+
};// Program
|
68
|
+
|
69
|
+
|
70
|
+
}// Rays
|
71
|
+
|
72
|
+
|
73
|
+
#endif//EOH
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#include "render_buffer.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include "rays/exception.h"
|
5
|
+
|
6
|
+
|
7
|
+
namespace Rays
|
8
|
+
{
|
9
|
+
|
10
|
+
|
11
|
+
struct RenderBuffer::Data
|
12
|
+
{
|
13
|
+
|
14
|
+
int id, width, height;
|
15
|
+
|
16
|
+
Data ()
|
17
|
+
: id(-1), width(0), height(0)
|
18
|
+
{
|
19
|
+
}
|
20
|
+
|
21
|
+
~Data ()
|
22
|
+
{
|
23
|
+
clear();
|
24
|
+
}
|
25
|
+
|
26
|
+
void create (int width_, int height_)
|
27
|
+
{
|
28
|
+
if (width_ <= 0 || height_ <= 0)
|
29
|
+
argument_error(__FILE__, __LINE__);
|
30
|
+
|
31
|
+
if (is_valid())
|
32
|
+
{
|
33
|
+
if (width != width_ || height == height_)
|
34
|
+
{
|
35
|
+
argument_error(__FILE__, __LINE__,
|
36
|
+
"RenderBuffer is already created and "
|
37
|
+
"width/height parameters is not same as current width/height.");
|
38
|
+
}
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
|
42
|
+
GLuint id_ = 0;
|
43
|
+
glGenRenderbuffers(1, &id_);
|
44
|
+
check_error(__FILE__, __LINE__);
|
45
|
+
|
46
|
+
id = id_;
|
47
|
+
glBindRenderbuffer(GL_RENDERBUFFER, id_);
|
48
|
+
check_error(__FILE__, __LINE__);
|
49
|
+
|
50
|
+
glRenderbufferStorage(
|
51
|
+
GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
|
52
|
+
check_error(__FILE__, __LINE__);
|
53
|
+
|
54
|
+
width = width_;
|
55
|
+
height = height_;
|
56
|
+
}
|
57
|
+
|
58
|
+
void clear ()
|
59
|
+
{
|
60
|
+
if (id >= 0)
|
61
|
+
{
|
62
|
+
GLenum id_ = id;
|
63
|
+
glDeleteRenderbuffers(1, &id_);
|
64
|
+
}
|
65
|
+
|
66
|
+
id = -1;
|
67
|
+
}
|
68
|
+
|
69
|
+
bool is_valid () const
|
70
|
+
{
|
71
|
+
return id >= 0;
|
72
|
+
}
|
73
|
+
|
74
|
+
};// RenderBuffer::Data
|
75
|
+
|
76
|
+
|
77
|
+
RenderBuffer::RenderBuffer ()
|
78
|
+
{
|
79
|
+
}
|
80
|
+
|
81
|
+
RenderBuffer::RenderBuffer (int width, int height)
|
82
|
+
{
|
83
|
+
self->create(width, height);
|
84
|
+
}
|
85
|
+
|
86
|
+
RenderBuffer::~RenderBuffer ()
|
87
|
+
{
|
88
|
+
}
|
89
|
+
|
90
|
+
GLuint
|
91
|
+
RenderBuffer::id () const
|
92
|
+
{
|
93
|
+
return self->id;
|
94
|
+
}
|
95
|
+
|
96
|
+
int
|
97
|
+
RenderBuffer::width () const
|
98
|
+
{
|
99
|
+
return self->width;
|
100
|
+
}
|
101
|
+
|
102
|
+
int
|
103
|
+
RenderBuffer::height () const
|
104
|
+
{
|
105
|
+
return self->height;
|
106
|
+
}
|
107
|
+
|
108
|
+
RenderBuffer::operator bool () const
|
109
|
+
{
|
110
|
+
return self && self->is_valid();
|
111
|
+
}
|
112
|
+
|
113
|
+
bool
|
114
|
+
RenderBuffer::operator ! () const
|
115
|
+
{
|
116
|
+
return !operator bool();
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
}// Rays
|
data/src/render_buffer.h
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_RENDER_BUFFER_H__
|
4
|
+
#define __RAYS_RENDER_BUFFER_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <xot/pimpl.h>
|
8
|
+
#include <rays/defs.h>
|
9
|
+
#include <rays/opengl.h>
|
10
|
+
|
11
|
+
|
12
|
+
namespace Rays
|
13
|
+
{
|
14
|
+
|
15
|
+
|
16
|
+
class RenderBuffer
|
17
|
+
{
|
18
|
+
|
19
|
+
public:
|
20
|
+
|
21
|
+
RenderBuffer ();
|
22
|
+
|
23
|
+
RenderBuffer (int width, int height);
|
24
|
+
|
25
|
+
~RenderBuffer ();
|
26
|
+
|
27
|
+
GLuint id () const;
|
28
|
+
|
29
|
+
int width () const;
|
30
|
+
|
31
|
+
int height () const;
|
32
|
+
|
33
|
+
operator bool () const;
|
34
|
+
|
35
|
+
bool operator ! () const;
|
36
|
+
|
37
|
+
struct Data;
|
38
|
+
|
39
|
+
Xot::PImpl<Data, true> self;
|
40
|
+
|
41
|
+
};// RenderBuffer
|
42
|
+
|
43
|
+
|
44
|
+
}// Rays
|
45
|
+
|
46
|
+
|
47
|
+
#endif//EOH
|
data/src/shader.cpp
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
#include "rays/shader.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <boost/scoped_array.hpp>
|
5
|
+
#include "rays/exception.h"
|
6
|
+
|
7
|
+
|
8
|
+
namespace Rays
|
9
|
+
{
|
10
|
+
|
11
|
+
|
12
|
+
struct Shader::Data
|
13
|
+
{
|
14
|
+
|
15
|
+
int id;
|
16
|
+
|
17
|
+
Data ()
|
18
|
+
: id(-1)
|
19
|
+
{
|
20
|
+
}
|
21
|
+
|
22
|
+
~Data ()
|
23
|
+
{
|
24
|
+
clear();
|
25
|
+
}
|
26
|
+
|
27
|
+
void clear ()
|
28
|
+
{
|
29
|
+
if (id >= 0) glDeleteShader((GLuint) id);
|
30
|
+
|
31
|
+
id = -1;
|
32
|
+
}
|
33
|
+
|
34
|
+
bool is_valid () const
|
35
|
+
{
|
36
|
+
return id >= 0;
|
37
|
+
}
|
38
|
+
|
39
|
+
};// Shader::Data
|
40
|
+
|
41
|
+
|
42
|
+
void
|
43
|
+
compile_shader (Shader* this_, const char* source)
|
44
|
+
{
|
45
|
+
if (!this_ || !source)
|
46
|
+
argument_error(__FILE__, __LINE__);
|
47
|
+
|
48
|
+
Shader::Data* self = this_->self.get();
|
49
|
+
if (self->is_valid())
|
50
|
+
invalid_state_error(__FILE__, __LINE__);
|
51
|
+
|
52
|
+
self->id = glCreateShader(GL_FRAGMENT_SHADER);
|
53
|
+
glShaderSource(self->id, 1, &source, NULL);
|
54
|
+
glCompileShader(self->id);
|
55
|
+
|
56
|
+
GLint status = GL_FALSE;
|
57
|
+
glGetShaderiv(self->id, GL_COMPILE_STATUS, &status);
|
58
|
+
if (status == GL_FALSE)
|
59
|
+
{
|
60
|
+
int len = 0;
|
61
|
+
glGetShaderiv(self->id, GL_INFO_LOG_LENGTH, &len);
|
62
|
+
|
63
|
+
boost::scoped_array<char> buffer(new char[len]);
|
64
|
+
int written = 0;
|
65
|
+
glGetShaderInfoLog(self->id, len, &written, &buffer[0]);
|
66
|
+
|
67
|
+
opengl_error(__FILE__, __LINE__, &buffer[0]);
|
68
|
+
}
|
69
|
+
|
70
|
+
check_error(__FILE__, __LINE__);
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
Shader::Shader ()
|
75
|
+
{
|
76
|
+
}
|
77
|
+
|
78
|
+
Shader::Shader (const char* source)
|
79
|
+
{
|
80
|
+
compile_shader(this, source);
|
81
|
+
}
|
82
|
+
|
83
|
+
Shader::~Shader ()
|
84
|
+
{
|
85
|
+
}
|
86
|
+
|
87
|
+
GLuint
|
88
|
+
Shader::id () const
|
89
|
+
{
|
90
|
+
return self->id;
|
91
|
+
}
|
92
|
+
|
93
|
+
bool
|
94
|
+
Shader::operator == (const Shader& rhs) const
|
95
|
+
{
|
96
|
+
return self->id == rhs.self->id;
|
97
|
+
}
|
98
|
+
|
99
|
+
bool
|
100
|
+
Shader::operator != (const Shader& rhs) const
|
101
|
+
{
|
102
|
+
return !operator==(rhs);
|
103
|
+
}
|
104
|
+
|
105
|
+
Shader::operator bool () const
|
106
|
+
{
|
107
|
+
return self->is_valid();
|
108
|
+
}
|
109
|
+
|
110
|
+
bool
|
111
|
+
Shader::operator ! () const
|
112
|
+
{
|
113
|
+
return !operator bool();
|
114
|
+
}
|
115
|
+
|
116
|
+
|
117
|
+
}// Rays
|