ray 0.1.1 → 0.2.0
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.
- data/README.md +9 -6
- data/Rakefile +1 -5
- data/ext/audio.c +25 -19
- data/ext/audio_source.c +67 -39
- data/ext/color.c +19 -19
- data/ext/drawable.c +190 -31
- data/ext/extconf.rb +16 -14
- data/ext/gl.c +310 -30
- data/ext/gl_buffer.c +223 -2
- data/ext/gl_index_buffer.c +11 -0
- data/ext/gl_int_array.c +24 -22
- data/ext/gl_vertex.c +84 -49
- data/ext/image.c +115 -51
- data/ext/image_target.c +58 -10
- data/ext/input.c +73 -6
- data/ext/mo.c +583 -0
- data/ext/mo.h +189 -0
- data/ext/music.c +9 -8
- data/ext/pixel_bus.c +349 -0
- data/ext/polygon.c +68 -45
- data/ext/ray.c +1 -0
- data/ext/ray.h +19 -1
- data/ext/rect.c +9 -47
- data/ext/say.h +1 -2
- data/ext/say_all.h +6 -0
- data/ext/say_audio.h +3 -0
- data/ext/say_audio_context.c +1 -4
- data/ext/say_basic_type.c +24 -0
- data/ext/say_basic_type.h +4 -0
- data/ext/say_buffer.c +217 -88
- data/ext/say_buffer.h +20 -5
- data/ext/say_buffer_renderer.c +10 -7
- data/ext/say_buffer_renderer.h +1 -1
- data/ext/say_buffer_slice.c +70 -76
- data/ext/say_context.c +109 -22
- data/ext/say_context.h +14 -0
- data/ext/say_drawable.c +113 -25
- data/ext/say_drawable.h +23 -2
- data/ext/say_error.c +7 -2
- data/ext/say_font.c +30 -27
- data/ext/say_font.h +3 -6
- data/ext/say_get_proc.c +35 -0
- data/ext/say_image.c +102 -27
- data/ext/say_image.h +11 -4
- data/ext/say_image_target.c +88 -34
- data/ext/say_image_target.h +3 -2
- data/ext/say_index_buffer.c +31 -19
- data/ext/say_index_buffer.h +4 -2
- data/ext/say_index_buffer_slice.c +78 -70
- data/ext/say_music.c +4 -2
- data/ext/say_osx.h +3 -2
- data/ext/say_osx_context.h +37 -4
- data/ext/say_osx_window.h +32 -37
- data/ext/say_pixel_bus.c +163 -0
- data/ext/say_pixel_bus.h +44 -0
- data/ext/say_polygon.c +2 -2
- data/ext/say_shader.c +66 -62
- data/ext/say_shader.h +2 -0
- data/ext/say_sprite.c +1 -2
- data/ext/say_target.c +14 -23
- data/ext/say_target.h +3 -1
- data/ext/say_text.c +45 -7
- data/ext/say_text.h +12 -3
- data/ext/say_thread.c +13 -6
- data/ext/say_thread.h +1 -1
- data/ext/say_thread_variable.c +5 -5
- data/ext/say_vertex_type.c +79 -41
- data/ext/say_vertex_type.h +6 -2
- data/ext/say_view.c +10 -31
- data/ext/say_view.h +1 -5
- data/ext/say_win.h +2 -2
- data/ext/say_win_context.h +49 -11
- data/ext/say_win_window.h +30 -27
- data/ext/say_window.c +3 -3
- data/ext/say_x11.h +3 -1
- data/ext/say_x11_context.h +64 -10
- data/ext/say_x11_window.h +22 -17
- data/ext/shader.c +9 -0
- data/ext/sprite.c +7 -1
- data/ext/target.c +80 -28
- data/ext/text.c +43 -1
- data/ext/view.c +53 -1
- data/ext/window.c +4 -0
- data/lib/ray/animation_list.rb +17 -2
- data/lib/ray/audio_source.rb +11 -0
- data/lib/ray/color.rb +14 -0
- data/lib/ray/drawable.rb +23 -0
- data/lib/ray/dsl/event.rb +1 -9
- data/lib/ray/dsl/event_runner.rb +3 -4
- data/lib/ray/dsl/matcher.rb +20 -1
- data/lib/ray/effect.rb +116 -0
- data/lib/ray/effect/black_and_white.rb +38 -0
- data/lib/ray/effect/color_inversion.rb +16 -0
- data/lib/ray/effect/generator.rb +145 -0
- data/lib/ray/effect/grayscale.rb +32 -0
- data/lib/ray/game.rb +25 -5
- data/lib/ray/gl/vertex.rb +105 -26
- data/lib/ray/helper.rb +5 -0
- data/lib/ray/image.rb +54 -13
- data/lib/ray/image_target.rb +7 -0
- data/lib/ray/matrix.rb +26 -0
- data/lib/ray/music.rb +4 -0
- data/lib/ray/pixel_bus.rb +22 -0
- data/lib/ray/polygon.rb +17 -0
- data/lib/ray/pp.rb +28 -0
- data/lib/ray/ray.rb +7 -1
- data/lib/ray/rect.rb +7 -13
- data/lib/ray/scene.rb +24 -5
- data/lib/ray/scene_list.rb +9 -0
- data/lib/ray/shader.rb +11 -2
- data/lib/ray/sound.rb +4 -0
- data/lib/ray/sprite.rb +23 -62
- data/lib/ray/target.rb +25 -0
- data/lib/ray/text.rb +10 -0
- data/lib/ray/turtle.rb +9 -3
- data/lib/ray/vector.rb +18 -0
- data/lib/ray/vertex.rb +6 -0
- data/lib/ray/view.rb +22 -0
- data/samples/animation/sprite_motion.rb +0 -60
- data/samples/audio/{spacial.rb → spatial.rb} +1 -1
- data/samples/buffer/buffer.rb +1 -0
- data/samples/buffer/index_buffer.rb +2 -0
- data/samples/cptn_ruby/cptn_ruby.rb +6 -7
- data/samples/effects/effect.rb +39 -0
- data/samples/effects/grayscale.rb +27 -0
- data/samples/opengl/image.rb +7 -5
- data/samples/opengl/instancing.rb +159 -0
- data/samples/opengl/instancing.rbc +3231 -0
- data/samples/opengl/obj_loader.rb +9 -8
- data/samples/opengl/shader.rb +1 -3
- data/samples/shaders/geometry.rb +108 -38
- data/samples/shaders/geometry.rbc +2074 -0
- data/samples/shaders/shape.rb +2 -2
- data/samples/starfighter/starfighter.rb +5 -5
- data/samples/window/get_pixel.rb +1 -1
- data/test/animation_list_test.rb +18 -4
- data/test/drawable_test.rb +70 -1
- data/test/effect_generator_test.rb +63 -0
- data/test/effect_test.rb +61 -0
- data/test/game_test.rb +18 -0
- data/test/gl_buffer_test.rb +43 -1
- data/test/gl_index_buffer_test.rb +5 -0
- data/test/gl_vertex_test.rb +28 -1
- data/test/image_test.rb +5 -5
- data/test/input_test.rb +49 -0
- data/test/pixel_bus_test.rb +28 -0
- data/test/rect_test.rb +4 -0
- data/{samples/_media → test/res}/Beep.wav +0 -0
- data/samples/_media/CptnRuby Gem.png b/data/test/res/CptnRuby → Gem.png +0 -0
- data/samples/_media/CptnRuby Map.txt b/data/test/res/CptnRuby → Map.txt +0 -0
- data/samples/_media/CptnRuby Tileset.png b/data/test/res/CptnRuby → Tileset.png +0 -0
- data/{samples/_media → test/res}/CptnRuby.png +0 -0
- data/{samples/_media → test/res}/Space.png +0 -0
- data/{samples/_media → test/res}/Star.png +0 -0
- data/{samples/_media → test/res}/Starfighter.png +0 -0
- data/test/res/cube.obj +28 -0
- data/test/res/light3d.c +2 -2
- data/test/res/stone.png +0 -0
- data/test/scene_test.rb +3 -0
- data/test/sprite_test.rb +10 -0
- data/test/text_test.rb +31 -2
- data/test/view_test.rb +13 -1
- metadata +38 -17
- data/ext/say_array.c +0 -124
- data/ext/say_array.h +0 -34
- data/ext/say_table.c +0 -86
- data/ext/say_table.h +0 -24
data/ext/say_image_target.h
CHANGED
data/ext/say_index_buffer.c
CHANGED
@@ -11,7 +11,7 @@ static void say_ibo_make_current(GLuint ibo) {
|
|
11
11
|
say_current_ibo = ibo;
|
12
12
|
say_ibo_last_context = context;
|
13
13
|
|
14
|
-
|
14
|
+
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
|
15
15
|
}
|
16
16
|
}
|
17
17
|
|
@@ -26,15 +26,15 @@ say_index_buffer *say_index_buffer_create(GLenum type, size_t size) {
|
|
26
26
|
|
27
27
|
say_index_buffer *buf = malloc(sizeof(say_index_buffer));
|
28
28
|
|
29
|
-
|
29
|
+
glGenBuffers(1, &buf->ibo);
|
30
30
|
buf->type = type;
|
31
31
|
|
32
|
-
buf->buffer
|
33
|
-
|
32
|
+
mo_array_init(&buf->buffer, sizeof(GLuint));
|
33
|
+
mo_array_resize(&buf->buffer, size);
|
34
34
|
|
35
35
|
say_ibo_make_current(buf->ibo);
|
36
|
-
|
37
|
-
|
36
|
+
glBufferData(GL_ELEMENT_ARRAY_BUFFER, size * sizeof(GLuint),
|
37
|
+
NULL, type);
|
38
38
|
|
39
39
|
return buf;
|
40
40
|
}
|
@@ -43,8 +43,8 @@ void say_index_buffer_free(say_index_buffer *buf) {
|
|
43
43
|
say_context_ensure();
|
44
44
|
|
45
45
|
say_ibo_will_delete(buf->ibo);
|
46
|
-
|
47
|
-
|
46
|
+
glDeleteBuffers(1, &buf->ibo);
|
47
|
+
mo_array_release(&buf->buffer);
|
48
48
|
free(buf);
|
49
49
|
}
|
50
50
|
|
@@ -53,38 +53,50 @@ void say_index_buffer_bind(say_index_buffer *buf) {
|
|
53
53
|
say_ibo_make_current(buf->ibo);
|
54
54
|
}
|
55
55
|
|
56
|
-
void say_index_buffer_unbind(
|
56
|
+
void say_index_buffer_unbind() {
|
57
57
|
say_context_ensure();
|
58
58
|
say_ibo_make_current(0);
|
59
59
|
}
|
60
60
|
|
61
|
+
void say_index_buffer_rebind() {
|
62
|
+
if (say_ibo_last_context == say_context_current())
|
63
|
+
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, say_current_ibo);
|
64
|
+
}
|
65
|
+
|
61
66
|
void say_index_buffer_update_part(say_index_buffer *buf, size_t index,
|
62
67
|
size_t size) {
|
63
68
|
say_context_ensure();
|
64
69
|
|
65
70
|
say_index_buffer_bind(buf);
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
71
|
+
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER,
|
72
|
+
index * sizeof(GLuint),
|
73
|
+
size * sizeof(GLuint),
|
74
|
+
mo_array_at(&buf->buffer, index));
|
70
75
|
}
|
71
76
|
|
72
77
|
void say_index_buffer_update(say_index_buffer *buf) {
|
73
|
-
say_index_buffer_update_part(buf, 0,
|
78
|
+
say_index_buffer_update_part(buf, 0, buf->buffer.size);
|
74
79
|
}
|
75
80
|
|
76
81
|
size_t say_index_buffer_get_size(say_index_buffer *buf) {
|
77
|
-
return
|
82
|
+
return buf->buffer.size;
|
78
83
|
}
|
79
84
|
|
80
85
|
void say_index_buffer_resize(say_index_buffer *buf, size_t size) {
|
81
86
|
say_context_ensure();
|
82
87
|
|
83
|
-
|
84
|
-
|
85
|
-
|
88
|
+
mo_array_resize(&buf->buffer, size);
|
89
|
+
mo_array_shrink(&buf->buffer);
|
90
|
+
|
91
|
+
say_index_buffer_bind(buf);
|
92
|
+
glBufferData(GL_ELEMENT_ARRAY_BUFFER, size * sizeof(GLuint),
|
93
|
+
mo_array_at(&buf->buffer, 0), buf->type);
|
86
94
|
}
|
87
95
|
|
88
96
|
GLuint *say_index_buffer_get(say_index_buffer *buf, size_t i) {
|
89
|
-
return
|
97
|
+
return mo_array_get_ptr(&buf->buffer, i, GLuint);
|
98
|
+
}
|
99
|
+
|
100
|
+
GLuint say_index_buffer_get_ibo(say_index_buffer *buf) {
|
101
|
+
return buf->ibo;
|
90
102
|
}
|
data/ext/say_index_buffer.h
CHANGED
@@ -2,13 +2,12 @@
|
|
2
2
|
#define SAY_INDEX_BUFFER_H_
|
3
3
|
|
4
4
|
#include "say_basic_type.h"
|
5
|
-
#include "say_array.h"
|
6
5
|
|
7
6
|
typedef struct {
|
8
7
|
GLuint ibo;
|
9
8
|
GLenum type;
|
10
9
|
|
11
|
-
|
10
|
+
mo_array buffer;
|
12
11
|
} say_index_buffer;
|
13
12
|
|
14
13
|
say_index_buffer *say_index_buffer_create(GLenum type, size_t size);
|
@@ -16,6 +15,7 @@ void say_index_buffer_free(say_index_buffer *buf);
|
|
16
15
|
|
17
16
|
void say_index_buffer_bind(say_index_buffer *buf);
|
18
17
|
void say_index_buffer_unbind();
|
18
|
+
void say_index_buffer_rebind();
|
19
19
|
|
20
20
|
void say_index_buffer_update_part(say_index_buffer *buf, size_t index,
|
21
21
|
size_t size);
|
@@ -26,4 +26,6 @@ void say_index_buffer_resize(say_index_buffer *buf, size_t size);
|
|
26
26
|
|
27
27
|
GLuint *say_index_buffer_get(say_index_buffer *buf, size_t i);
|
28
28
|
|
29
|
+
GLuint say_index_buffer_get_ibo(say_index_buffer *buf);
|
30
|
+
|
29
31
|
#endif
|
@@ -12,15 +12,15 @@ typedef struct {
|
|
12
12
|
|
13
13
|
typedef struct {
|
14
14
|
say_index_buffer *buf;
|
15
|
-
|
15
|
+
mo_list *ranges;
|
16
16
|
} say_global_ibo;
|
17
17
|
|
18
|
-
static
|
18
|
+
static mo_array *say_index_buffers = NULL;
|
19
19
|
|
20
20
|
static say_global_ibo say_global_ibo_create(size_t size) {
|
21
21
|
say_global_ibo ret;
|
22
22
|
ret.buf = say_index_buffer_create(SAY_STREAM, size);
|
23
|
-
ret.ranges =
|
23
|
+
ret.ranges = NULL;
|
24
24
|
|
25
25
|
return ret;
|
26
26
|
}
|
@@ -29,90 +29,95 @@ static void say_global_ibo_free(void *data) {
|
|
29
29
|
say_global_ibo *ibo = (say_global_ibo*)data;
|
30
30
|
|
31
31
|
say_index_buffer_free(ibo->buf);
|
32
|
-
|
32
|
+
if (ibo->ranges) mo_list_free(ibo->ranges);
|
33
33
|
}
|
34
34
|
|
35
35
|
static say_global_ibo *say_global_ibo_at(size_t index) {
|
36
36
|
if (!say_index_buffers)
|
37
37
|
return NULL;
|
38
|
-
return
|
38
|
+
return mo_array_at(say_index_buffers, index);
|
39
39
|
}
|
40
40
|
|
41
|
-
static
|
41
|
+
static bool say_global_ibo_fit_into(say_global_ibo *ibo, size_t used,
|
42
42
|
size_t size) {
|
43
|
-
|
44
|
-
|
43
|
+
size_t buffer_size = say_index_buffer_get_size(ibo->buf);
|
44
|
+
|
45
|
+
if (used + size < buffer_size)
|
46
|
+
return true;
|
47
|
+
else if (used + size < SAY_BUFFER_MAX_SIZE &&
|
48
|
+
buffer_size <= SAY_BUFFER_MAX_SIZE) {
|
49
|
+
size_t sought_size = used + size;
|
50
|
+
size_t right_size = buffer_size;
|
45
51
|
|
46
|
-
|
52
|
+
while (right_size < sought_size) right_size *= 2;
|
47
53
|
|
48
|
-
|
49
|
-
|
50
|
-
range->loc = prev->loc + prev->size;
|
54
|
+
say_index_buffer_resize(ibo->buf, right_size);
|
55
|
+
return true;
|
51
56
|
}
|
57
|
+
else
|
58
|
+
return false;
|
59
|
+
}
|
60
|
+
|
61
|
+
static size_t say_global_ibo_prepend(say_global_ibo *ibo, size_t size) {
|
62
|
+
say_range range = say_make_range(0, size);
|
63
|
+
ibo->ranges = mo_list_prepend(ibo->ranges, &range);
|
64
|
+
return 0;
|
65
|
+
}
|
66
|
+
|
67
|
+
static size_t say_global_ibo_insert(mo_list *list, size_t size) {
|
68
|
+
say_range *range = mo_list_data_ptr(list, say_range);
|
69
|
+
say_range tmp = say_make_range(range->loc + range->size, size);
|
52
70
|
|
53
|
-
|
71
|
+
mo_list_insert(list, &tmp);
|
72
|
+
return tmp.loc;
|
54
73
|
}
|
55
74
|
|
56
75
|
static size_t say_global_ibo_find_in(say_global_ibo *ibo, size_t size) {
|
57
|
-
|
76
|
+
if (!ibo->ranges && say_global_ibo_fit_into(ibo, 0, size)) {
|
77
|
+
ibo->ranges = mo_list_create(sizeof(say_range));
|
78
|
+
say_range *range = mo_list_data_ptr(ibo->ranges, say_range);
|
79
|
+
*range = say_make_range(0, size);
|
80
|
+
return 0;
|
81
|
+
}
|
58
82
|
|
59
|
-
|
60
|
-
say_range *first = say_array_get(ibo->ranges, 0);
|
83
|
+
say_range *first = mo_list_data_ptr(ibo->ranges, say_range);
|
61
84
|
|
62
85
|
/* There's room at the begin of the buffer */
|
63
|
-
if (
|
64
|
-
return
|
86
|
+
if (first->loc >= size) {
|
87
|
+
return say_global_ibo_prepend(ibo, size);
|
65
88
|
}
|
66
89
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
next
|
90
|
+
mo_list *it = ibo->ranges;
|
91
|
+
for (; it->next; it = it->next) {
|
92
|
+
say_range *current = mo_list_data_ptr(it, say_range);
|
93
|
+
say_range *next = mo_list_data_ptr(it->next, say_range);
|
71
94
|
|
72
95
|
size_t begin = current->loc + current->size;
|
73
96
|
size_t end = next->loc;
|
74
97
|
|
75
98
|
/* There's enough room between those two elements */
|
76
|
-
if (end - begin >= size)
|
77
|
-
return say_global_ibo_insert(
|
78
|
-
}
|
79
|
-
|
80
|
-
current = next;
|
99
|
+
if (end - begin >= size)
|
100
|
+
return say_global_ibo_insert(it, size);
|
81
101
|
}
|
82
102
|
|
83
|
-
say_range *last =
|
103
|
+
say_range *last = mo_list_data_ptr(it, say_range);
|
84
104
|
|
85
105
|
/* There's enough room at the end of the buffer */
|
86
|
-
if ((last->loc + last->size
|
87
|
-
return say_global_ibo_insert(
|
88
|
-
}
|
89
|
-
|
90
|
-
/* Not enough room here. But perhaps we can make some? */
|
91
|
-
if (buffer_size < SAY_BUFFER_MAX_SIZE && size <= SAY_BUFFER_MAX_SIZE) {
|
92
|
-
size_t sought_size = last->loc + last->size + size;
|
93
|
-
size_t right_size = say_index_buffer_get_size(ibo->buf);
|
94
|
-
|
95
|
-
while (right_size < sought_size)
|
96
|
-
right_size *= 2;
|
97
|
-
|
98
|
-
say_index_buffer_resize(ibo->buf, right_size);
|
99
|
-
return say_global_ibo_insert(ibo, ary_size, size);
|
100
|
-
}
|
106
|
+
if (say_global_ibo_fit_into(ibo, last->loc + last->size, size))
|
107
|
+
return say_global_ibo_insert(it, size);
|
101
108
|
else
|
102
109
|
return SAY_MAX_SIZE;
|
103
110
|
}
|
104
111
|
|
105
112
|
static size_t say_global_ibo_find(size_t size, size_t *buf_id) {
|
106
113
|
if (!say_index_buffers) {
|
107
|
-
say_index_buffers =
|
108
|
-
|
109
|
-
NULL);
|
114
|
+
say_index_buffers = mo_array_create(sizeof(say_global_ibo));
|
115
|
+
say_index_buffers->release = say_global_ibo_free;
|
110
116
|
}
|
111
117
|
|
112
|
-
size_t i = 0;
|
113
|
-
|
114
|
-
|
115
|
-
say_array_next(say_index_buffers, (void**)&ibo)) {
|
118
|
+
for (size_t i = 0; i < say_index_buffers->size; i++) {
|
119
|
+
say_global_ibo *ibo = mo_array_at(say_index_buffers, 0);
|
120
|
+
|
116
121
|
size_t loc;
|
117
122
|
if ((loc = say_global_ibo_find_in(ibo, size)) != SAY_MAX_SIZE) {
|
118
123
|
*buf_id = i;
|
@@ -132,34 +137,35 @@ static size_t say_global_ibo_find(size_t size, size_t *buf_id) {
|
|
132
137
|
}
|
133
138
|
|
134
139
|
say_global_ibo ibo = say_global_ibo_create(buf_size);
|
135
|
-
|
140
|
+
mo_array_push(say_index_buffers, &ibo);
|
136
141
|
|
137
|
-
*buf_id =
|
142
|
+
*buf_id = say_index_buffers->size - 1;
|
138
143
|
return say_global_ibo_find_in(say_global_ibo_at(*buf_id), size);
|
139
144
|
}
|
140
145
|
|
141
|
-
static void say_global_ibo_delete_at(say_global_ibo *ibo, size_t loc
|
146
|
+
static void say_global_ibo_delete_at(say_global_ibo *ibo, size_t loc,
|
147
|
+
size_t range_size) {
|
142
148
|
if (!ibo)
|
143
149
|
return;
|
144
150
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
}
|
151
|
+
for (mo_list *it = ibo->ranges; it; it = it->next) {
|
152
|
+
say_range *range = mo_list_data_ptr(it, say_range);
|
153
|
+
if (range->loc == loc && range->size == range_size) {
|
154
|
+
mo_list *next = it->next;
|
155
|
+
mo_list_delete(it);
|
151
156
|
|
152
|
-
|
153
|
-
return; /* Element could not be found */
|
157
|
+
if (it == ibo->ranges) ibo->ranges = next;
|
154
158
|
|
155
|
-
|
159
|
+
return;
|
160
|
+
}
|
161
|
+
}
|
156
162
|
}
|
157
163
|
|
158
164
|
static void say_global_ibo_reduce_size(say_global_ibo *ibo, size_t loc,
|
159
|
-
size_t size) {
|
160
|
-
for (
|
161
|
-
|
162
|
-
if (range->loc == loc) {
|
165
|
+
size_t old_size, size_t size) {
|
166
|
+
for (mo_list *it = ibo->ranges; it; it = it->next) {
|
167
|
+
say_range *range = mo_list_data_ptr(it, say_range);
|
168
|
+
if (range->loc == loc && range->size == old_size) {
|
163
169
|
range->size = size;
|
164
170
|
return;
|
165
171
|
}
|
@@ -180,19 +186,21 @@ say_index_buffer_slice *say_index_buffer_slice_create(size_t size) {
|
|
180
186
|
}
|
181
187
|
|
182
188
|
void say_index_buffer_slice_free(say_index_buffer_slice *slice) {
|
183
|
-
say_global_ibo_delete_at(say_global_ibo_at(slice->buf_id), slice->loc
|
189
|
+
say_global_ibo_delete_at(say_global_ibo_at(slice->buf_id), slice->loc,
|
190
|
+
slice->size);
|
184
191
|
free(slice);
|
185
192
|
}
|
186
193
|
|
187
194
|
void say_index_buffer_slice_recreate(say_index_buffer_slice *slice,
|
188
195
|
size_t size) {
|
189
196
|
if (size > slice->size) {
|
190
|
-
say_global_ibo_delete_at(say_global_ibo_at(slice->buf_id), slice->loc
|
197
|
+
say_global_ibo_delete_at(say_global_ibo_at(slice->buf_id), slice->loc,
|
198
|
+
slice->size);
|
191
199
|
slice->loc = say_global_ibo_find(size, &slice->buf_id);
|
192
200
|
}
|
193
201
|
else {
|
194
202
|
say_global_ibo_reduce_size(say_global_ibo_at(slice->buf_id),
|
195
|
-
|
203
|
+
slice->loc, slice->size, size);
|
196
204
|
}
|
197
205
|
|
198
206
|
slice->size = size;
|
@@ -221,7 +229,7 @@ void say_index_buffer_slice_bind(say_index_buffer_slice *slice) {
|
|
221
229
|
|
222
230
|
void say_index_buffer_slice_clean_up() {
|
223
231
|
if (say_index_buffers) {
|
224
|
-
|
232
|
+
mo_array_free(say_index_buffers);
|
225
233
|
say_index_buffers = NULL;
|
226
234
|
}
|
227
235
|
}
|
data/ext/say_music.c
CHANGED
@@ -78,12 +78,12 @@ static void *say_music_playback_thread(say_music *music) {
|
|
78
78
|
}
|
79
79
|
}
|
80
80
|
}
|
81
|
-
|
81
|
+
|
82
82
|
/* sleep for 0.25s */
|
83
83
|
#ifdef SAY_WIN
|
84
84
|
Sleep(250);
|
85
85
|
#else
|
86
|
-
usleep(250 * 1000);
|
86
|
+
usleep(250 * 1000);
|
87
87
|
#endif
|
88
88
|
}
|
89
89
|
|
@@ -116,7 +116,9 @@ say_music *say_music_create() {
|
|
116
116
|
void say_music_free(say_music *music) {
|
117
117
|
music->continue_running = false;
|
118
118
|
|
119
|
+
#ifndef SAY_WIN
|
119
120
|
say_thread_join(music->thread);
|
121
|
+
#endif
|
120
122
|
say_thread_free(music->thread);
|
121
123
|
|
122
124
|
alSourceStop(music->src->src);
|
data/ext/say_osx.h
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
#import <Cocoa/Cocoa.h>
|
4
4
|
|
5
|
+
#include "mo.h"
|
6
|
+
|
5
7
|
struct say_event;
|
6
|
-
struct say_array;
|
7
8
|
struct say_image;
|
8
9
|
|
9
10
|
void say_osx_flip_pool();
|
@@ -31,7 +32,7 @@ void say_osx_flip_pool();
|
|
31
32
|
NSWindow *window;
|
32
33
|
NSOpenGLView *view;
|
33
34
|
|
34
|
-
|
35
|
+
mo_array events;
|
35
36
|
|
36
37
|
BOOL allow_close;
|
37
38
|
|
data/ext/say_osx_context.h
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
static NSOpenGLPixelFormat *format = nil;
|
9
9
|
|
10
10
|
if (!format) {
|
11
|
+
say_context_config *conf = say_context_get_config();
|
12
|
+
|
11
13
|
NSOpenGLPixelFormatAttribute attr[] = {
|
12
14
|
NSOpenGLPFAClosestPolicy,
|
13
15
|
NSOpenGLPFADoubleBuffer,
|
@@ -16,11 +18,43 @@
|
|
16
18
|
NSOpenGLPFAColorSize, 24,
|
17
19
|
NSOpenGLPFAAlphaSize, 8,
|
18
20
|
|
19
|
-
|
21
|
+
/*
|
22
|
+
* Next elements must be set depending on user configuration.
|
23
|
+
*/
|
24
|
+
|
25
|
+
0, 0, /* depth */
|
26
|
+
0, 0, /* stencil */
|
27
|
+
|
28
|
+
0, 0, /* profile */
|
20
29
|
|
21
|
-
0
|
30
|
+
0 /* terminator */
|
22
31
|
};
|
23
32
|
|
33
|
+
size_t i = 7;
|
34
|
+
|
35
|
+
if (conf->depth_size) {
|
36
|
+
attr[i + 0] = NSOpenGLPFADepthSize;
|
37
|
+
attr[i + 1] = conf->depth_size;
|
38
|
+
|
39
|
+
i += 2;
|
40
|
+
}
|
41
|
+
|
42
|
+
if (conf->stencil_size) {
|
43
|
+
attr[i + 0] = NSOpenGLPFAStencilSize;
|
44
|
+
attr[i + 1] = conf->stencil_size;
|
45
|
+
|
46
|
+
i += 2;
|
47
|
+
}
|
48
|
+
|
49
|
+
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
50
|
+
if (conf->core_profile) { /* OpenGL 3.2! */
|
51
|
+
attr[i + 0] = NSOpenGLPFAOpenGLProfile;
|
52
|
+
attr[i + 1] = NSOpenGLProfileVersion3_2Core;
|
53
|
+
|
54
|
+
i += 2;
|
55
|
+
}
|
56
|
+
#endif
|
57
|
+
|
24
58
|
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
|
25
59
|
}
|
26
60
|
|
@@ -62,10 +96,9 @@
|
|
62
96
|
}
|
63
97
|
|
64
98
|
- (void)dealloc {
|
65
|
-
|
99
|
+
say_osx_flip_pool();
|
66
100
|
[context release];
|
67
101
|
[super dealloc];
|
68
|
-
[pool drain];
|
69
102
|
}
|
70
103
|
|
71
104
|
@end
|