sfml3-rb 0.0.1 → 0.2.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +342 -0
- data/README.md +51 -14
- data/TODO.md +199 -0
- data/ext/audio/audio_enums.c +131 -0
- data/ext/audio/audio_enums.h +18 -0
- data/ext/audio/effect_processor.c +233 -0
- data/ext/audio/effect_processor.h +25 -0
- data/ext/audio/listener.c +83 -0
- data/ext/audio/listener.h +8 -0
- data/ext/audio/music.c +174 -0
- data/ext/audio/music.h +14 -0
- data/ext/audio/sound.c +139 -0
- data/ext/audio/sound.h +14 -0
- data/ext/audio/sound_buffer.c +274 -0
- data/ext/audio/sound_buffer.h +18 -0
- data/ext/audio/sound_buffer_recorder.c +109 -0
- data/ext/audio/sound_buffer_recorder.h +14 -0
- data/ext/audio/sound_recorder.c +268 -0
- data/ext/audio/sound_recorder.h +14 -0
- data/ext/audio/sound_source.h +13 -0
- data/ext/audio/sound_source.inc +271 -0
- data/ext/audio/sound_source_cone.c +138 -0
- data/ext/audio/sound_source_cone.h +20 -0
- data/ext/audio/sound_stream.c +294 -0
- data/ext/audio/sound_stream.h +14 -0
- data/ext/{exceptions.c → core/exceptions.c} +10 -8
- data/ext/{ext → core}/exceptions.h +3 -3
- data/ext/core/foreign_thread.c +149 -0
- data/ext/core/foreign_thread.h +31 -0
- data/ext/core/macros.h +8 -0
- data/ext/{ext → core}/sfml.h +5 -3
- data/ext/core/unicode.c +46 -0
- data/ext/core/unicode.h +25 -0
- data/ext/ext.c +125 -14
- data/ext/extconf.rb +51 -6
- data/ext/graphics/blend_mode.c +261 -0
- data/ext/graphics/blend_mode.h +18 -0
- data/ext/graphics/circle.c +319 -0
- data/ext/{ext/klass/drawable → graphics}/circle.h +3 -3
- data/ext/graphics/color.c +318 -0
- data/ext/graphics/color.h +37 -0
- data/ext/{drawable.c → graphics/drawable.c} +11 -11
- data/ext/graphics/drawable.h +10 -0
- data/ext/graphics/enums.c +123 -0
- data/ext/graphics/enums.h +20 -0
- data/ext/graphics/font.c +148 -0
- data/ext/graphics/font.h +14 -0
- data/ext/graphics/glyph.c +60 -0
- data/ext/graphics/glyph.h +14 -0
- data/ext/graphics/image.c +205 -0
- data/ext/graphics/image.h +16 -0
- data/ext/graphics/polygon.c +300 -0
- data/ext/graphics/polygon.h +10 -0
- data/ext/graphics/rect.c +287 -0
- data/ext/graphics/rect.h +30 -0
- data/ext/graphics/rectangle.c +302 -0
- data/ext/graphics/rectangle.h +10 -0
- data/ext/graphics/render_state.c +204 -0
- data/ext/graphics/render_state.h +18 -0
- data/ext/graphics/render_target.inc +181 -0
- data/ext/graphics/render_texture.c +182 -0
- data/ext/graphics/render_texture.h +14 -0
- data/ext/graphics/shader.c +540 -0
- data/ext/graphics/shader.h +14 -0
- data/ext/graphics/shape.c +311 -0
- data/ext/graphics/shape.h +10 -0
- data/ext/graphics/sprite.c +249 -0
- data/ext/graphics/sprite.h +10 -0
- data/ext/graphics/stencil_mode.c +211 -0
- data/ext/graphics/stencil_mode.h +18 -0
- data/ext/graphics/target.c +133 -0
- data/ext/graphics/target.h +40 -0
- data/ext/graphics/text.c +344 -0
- data/ext/graphics/text.h +10 -0
- data/ext/graphics/texture.c +379 -0
- data/ext/graphics/texture.h +16 -0
- data/ext/graphics/transform.c +372 -0
- data/ext/graphics/transform.h +35 -0
- data/ext/{transformable.c → graphics/transformable.c} +168 -144
- data/ext/{ext/klass → graphics}/transformable.h +3 -3
- data/ext/graphics/vertex.c +179 -0
- data/ext/graphics/vertex.h +23 -0
- data/ext/graphics/vertex_array.c +127 -0
- data/ext/graphics/vertex_array.h +10 -0
- data/ext/graphics/vertex_buffer.c +211 -0
- data/ext/graphics/vertex_buffer.h +14 -0
- data/ext/{view.c → graphics/view.c} +168 -169
- data/ext/{ext/klass → graphics}/view.h +3 -3
- data/ext/network/ftp.c +405 -0
- data/ext/network/ftp.h +20 -0
- data/ext/network/http.c +243 -0
- data/ext/network/http.h +18 -0
- data/ext/network/ip_address.c +164 -0
- data/ext/network/ip_address.h +20 -0
- data/ext/network/network_enums.c +298 -0
- data/ext/network/network_enums.h +26 -0
- data/ext/network/packet.c +189 -0
- data/ext/network/packet.h +14 -0
- data/ext/network/socket_selector.c +142 -0
- data/ext/network/socket_selector.h +14 -0
- data/ext/network/tcp_listener.c +115 -0
- data/ext/network/tcp_listener.h +14 -0
- data/ext/network/tcp_socket.c +199 -0
- data/ext/network/tcp_socket.h +17 -0
- data/ext/network/udp_socket.c +190 -0
- data/ext/network/udp_socket.h +14 -0
- data/ext/ports.rb +97 -21
- data/ext/system/buffer.c +77 -0
- data/ext/system/buffer.h +14 -0
- data/ext/system/clock.c +100 -0
- data/ext/{ext/klass → system}/clock.h +3 -3
- data/ext/system/input_stream.c +229 -0
- data/ext/system/input_stream.h +23 -0
- data/ext/system/sleep.c +16 -0
- data/ext/system/sleep.h +8 -0
- data/ext/system/time.c +218 -0
- data/ext/system/time.h +18 -0
- data/ext/system/vec2.c +251 -0
- data/ext/system/vec2.h +55 -0
- data/ext/system/vec3.c +219 -0
- data/ext/system/vec3.h +18 -0
- data/ext/window/clipboard.c +89 -0
- data/ext/window/clipboard.h +8 -0
- data/ext/window/context.c +70 -0
- data/ext/window/context.h +8 -0
- data/ext/window/context_settings.c +220 -0
- data/ext/window/context_settings.h +18 -0
- data/ext/window/cursor.c +56 -0
- data/ext/window/cursor.h +14 -0
- data/ext/window/event.c +216 -0
- data/ext/window/event.h +14 -0
- data/ext/{event_name.c → window/event_name.c} +2 -2
- data/ext/window/event_name.h +8 -0
- data/ext/window/input_enums.c +261 -0
- data/ext/window/input_enums.h +36 -0
- data/ext/window/joystick.c +60 -0
- data/ext/window/joystick.h +8 -0
- data/ext/{keyboard.c → window/keyboard.c} +74 -2
- data/ext/window/keyboard.h +12 -0
- data/ext/window/mouse.c +70 -0
- data/ext/window/mouse.h +8 -0
- data/ext/window/sensor.c +30 -0
- data/ext/window/sensor.h +8 -0
- data/ext/window/touch.c +49 -0
- data/ext/window/touch.h +8 -0
- data/ext/window/video_mode.c +133 -0
- data/ext/window/video_mode.h +14 -0
- data/ext/window/vulkan.c +44 -0
- data/ext/window/vulkan.h +8 -0
- data/ext/window/window.c +414 -0
- data/ext/{ext/klass → window}/window.h +3 -3
- data/lib/sfml/version.rb +4 -2
- data/lib/sfml.rb +2 -0
- metadata +163 -56
- data/ext/circle.c +0 -198
- data/ext/clock.c +0 -65
- data/ext/color.c +0 -43
- data/ext/event.c +0 -148
- data/ext/ext/klass/color.h +0 -26
- data/ext/ext/klass/drawable/image.h +0 -4
- data/ext/ext/klass/drawable/polygon.h +0 -4
- data/ext/ext/klass/drawable/rectangle.h +0 -4
- data/ext/ext/klass/drawable/sprite.h +0 -4
- data/ext/ext/klass/drawable/texture.h +0 -4
- data/ext/ext/klass/event/event_name.h +0 -8
- data/ext/ext/klass/event.h +0 -12
- data/ext/ext/klass/keyboard.h +0 -8
- data/ext/ext/klass/render_state.h +0 -16
- data/ext/ext/klass/target.h +0 -18
- data/ext/ext/klass/transform.h +0 -17
- data/ext/ext/klass/video_mode.h +0 -12
- data/ext/ext/module/drawable/drawable.h +0 -10
- data/ext/ext/module/transform.h +0 -18
- data/ext/ext/module.h +0 -10
- data/ext/ext/rect.h +0 -16
- data/ext/ext/style_name.h +0 -11
- data/ext/ext/vec2.h +0 -38
- data/ext/image.c +0 -5
- data/ext/polygon.c +0 -5
- data/ext/rect.c +0 -26
- data/ext/rectangle.c +0 -5
- data/ext/render_state.c +0 -109
- data/ext/sprite.c +0 -5
- data/ext/style_name.c +0 -15
- data/ext/target.c +0 -106
- data/ext/texture.c +0 -5
- data/ext/transform.c +0 -107
- data/ext/vec2.c +0 -42
- data/ext/video_mode.c +0 -78
- data/ext/window.c +0 -274
data/ext/event.c
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
#include "ext/klass/event.h"
|
|
2
|
-
|
|
3
|
-
#include <ruby.h>
|
|
4
|
-
#include <stdio.h>
|
|
5
|
-
|
|
6
|
-
#include "ext/klass/event/event_name.h"
|
|
7
|
-
#include "ext/klass/keyboard.h"
|
|
8
|
-
#include "ext/klass/video_mode.h"
|
|
9
|
-
#include "ext/vec2.h"
|
|
10
|
-
#include "ext/module.h"
|
|
11
|
-
#include "ext/sfml.h"
|
|
12
|
-
|
|
13
|
-
static VALUE rb_cEvent;
|
|
14
|
-
|
|
15
|
-
static sfEvent *Event_create() {
|
|
16
|
-
return malloc(sizeof(sfEvent));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static void Event_free(void *ptr) {
|
|
20
|
-
free(ptr);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static VALUE Event_new(VALUE klass) {
|
|
24
|
-
VALUE self;
|
|
25
|
-
sfEvent *event;
|
|
26
|
-
|
|
27
|
-
VALUE argv[] = {};
|
|
28
|
-
|
|
29
|
-
event = Event_create();
|
|
30
|
-
self = Data_Wrap_Struct(klass, 0, Event_free, event);
|
|
31
|
-
|
|
32
|
-
rb_obj_call_init(self, 0, argv);
|
|
33
|
-
|
|
34
|
-
return self;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static VALUE Event_init(VALUE self) {
|
|
38
|
-
return self;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static VALUE Event_type(VALUE self) {
|
|
42
|
-
sfEvent *event = Get_Event_Struct(self);
|
|
43
|
-
return rb_str_new2(get_event_name(event->type));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static VALUE Event_key(VALUE self) {
|
|
47
|
-
VALUE arr;
|
|
48
|
-
VALUE hash;
|
|
49
|
-
sfEvent *event = Get_Event_Struct(self);
|
|
50
|
-
|
|
51
|
-
const char *key_name = get_key_event(event->key.code);
|
|
52
|
-
|
|
53
|
-
/*
|
|
54
|
-
event->key.system;
|
|
55
|
-
event->key.alt;
|
|
56
|
-
event->key.control;
|
|
57
|
-
event->key.shift;
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
arr = rb_ary_new();
|
|
61
|
-
rb_ary_push(arr, rb_str_new2(key_name));
|
|
62
|
-
rb_ary_push(arr, INT2NUM((int) event->key.system));
|
|
63
|
-
rb_ary_push(arr, INT2NUM((int) event->key.alt));
|
|
64
|
-
rb_ary_push(arr, INT2NUM((int) event->key.control));
|
|
65
|
-
rb_ary_push(arr, INT2NUM((int) event->key.shift));
|
|
66
|
-
|
|
67
|
-
return arr;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static VALUE Event_size(VALUE self) {
|
|
71
|
-
sfEvent *event = Get_Event_Struct(self);
|
|
72
|
-
|
|
73
|
-
return vec2_new(event->size.size.x, event->size.size.y);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static VALUE Event_text(VALUE self) {
|
|
77
|
-
return Qnil;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static VALUE Event_mouse_move(VALUE self) {
|
|
81
|
-
return Qnil;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
static VALUE Event_mouse_button(VALUE self) {
|
|
85
|
-
return Qnil;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
static VALUE Event_mouse_wheel(VALUE self) {
|
|
89
|
-
return Qnil;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
static VALUE Event_mouse_wheel_scroll(VALUE self) {
|
|
93
|
-
return Qnil;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
static VALUE Event_joystick_move(VALUE self) {
|
|
97
|
-
return Qnil;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
static VALUE Event_joystick_button(VALUE self) {
|
|
101
|
-
return Qnil;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
static VALUE Event_joystick_connect(VALUE self) {
|
|
105
|
-
return Qnil;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
static VALUE Event_touch(VALUE self) {
|
|
109
|
-
return Qnil;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
static VALUE Event_sensor(VALUE self) {
|
|
113
|
-
return Qnil;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
void Init_Event(VALUE rb_module) {
|
|
117
|
-
rb_cEvent = rb_define_class_under(rb_module, "Event", rb_cObject);
|
|
118
|
-
|
|
119
|
-
rb_define_singleton_method(rb_cEvent, "new", Event_new, 0);
|
|
120
|
-
|
|
121
|
-
// methods
|
|
122
|
-
rb_define_method(rb_cEvent, "initialize", Event_init, 0);
|
|
123
|
-
|
|
124
|
-
// getters
|
|
125
|
-
rb_define_method(rb_cEvent, "type", Event_type, 0);
|
|
126
|
-
rb_define_method(rb_cEvent, "key", Event_key, 0);
|
|
127
|
-
rb_define_method(rb_cEvent, "size", Event_size, 0);
|
|
128
|
-
rb_define_method(rb_cEvent, "text", Event_text, 0);
|
|
129
|
-
rb_define_method(rb_cEvent, "mouse_move", Event_mouse_move, 0);
|
|
130
|
-
rb_define_method(rb_cEvent, "mouse_button", Event_mouse_button, 0);
|
|
131
|
-
rb_define_method(rb_cEvent, "mouse_wheel", Event_mouse_wheel, 0);
|
|
132
|
-
rb_define_method(rb_cEvent, "mouse_wheel_scroll", Event_mouse_wheel_scroll, 0);
|
|
133
|
-
rb_define_method(rb_cEvent, "joystick_move", Event_joystick_move, 0);
|
|
134
|
-
rb_define_method(rb_cEvent, "joystick_button", Event_joystick_button, 0);
|
|
135
|
-
rb_define_method(rb_cEvent, "joystick_connect", Event_joystick_connect, 0);
|
|
136
|
-
rb_define_method(rb_cEvent, "touch", Event_touch, 0);
|
|
137
|
-
rb_define_method(rb_cEvent, "sensor", Event_sensor, 0);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
void *Get_Event_Struct(VALUE self) {
|
|
141
|
-
sfEvent *ptr;
|
|
142
|
-
Data_Get_Struct(self, sfEvent, ptr);
|
|
143
|
-
return ptr;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
VALUE Get_Klass_Event() {
|
|
147
|
-
return rb_cEvent;
|
|
148
|
-
}
|
data/ext/ext/klass/color.h
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#ifndef SFML_RB_COLOR_H
|
|
2
|
-
#define SFML_RB_COLOR_H
|
|
3
|
-
|
|
4
|
-
#include <ruby.h>
|
|
5
|
-
|
|
6
|
-
#include "ext/sfml.h"
|
|
7
|
-
|
|
8
|
-
#define VALID_LENGTH_COLOR 4
|
|
9
|
-
|
|
10
|
-
#define UNPACK_COLOR(c_color) (unsigned char) c_color.r, (unsigned char) c_color.g, (unsigned char) c_color.b, (unsigned char) c_color.a
|
|
11
|
-
|
|
12
|
-
#define COLOR_C2RB(c_color) color_new(c_color.r, c_color.g, c_color.b, c_color.a)
|
|
13
|
-
|
|
14
|
-
#define COLOR_RB2C(rb_arr) { NUM2INT(rb_ary_entry(rb_arr, 0)), NUM2INT(rb_ary_entry(rb_arr, 1)), NUM2INT(rb_ary_entry(rb_arr, 2)), NUM2INT(rb_ary_entry(rb_arr, 3)) }
|
|
15
|
-
|
|
16
|
-
VALUE color_new(int r, int g, int b, int a);
|
|
17
|
-
|
|
18
|
-
void color_check(VALUE rb_arr);
|
|
19
|
-
|
|
20
|
-
void color_swap(sfColor *color_a, sfColor *color_b);
|
|
21
|
-
|
|
22
|
-
sfColor color_new_from_rb(VALUE rb_arr);
|
|
23
|
-
|
|
24
|
-
VALUE color_new_from_c(sfColor color);
|
|
25
|
-
|
|
26
|
-
#endif //SFML_RB_COLOR_H
|
data/ext/ext/klass/event.h
DELETED
data/ext/ext/klass/keyboard.h
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#ifndef SFML_RB_RENDER_STATE_H
|
|
2
|
-
#define SFML_RB_RENDER_STATE_H
|
|
3
|
-
|
|
4
|
-
#include <ruby.h>
|
|
5
|
-
|
|
6
|
-
#define DefaultMatrix3x3() {1, 0, 0, 0, 1, 0, 0, 0, 1}
|
|
7
|
-
|
|
8
|
-
void Init_RenderState(VALUE rb_module);
|
|
9
|
-
|
|
10
|
-
void *Get_RenderState_Struct(VALUE self);
|
|
11
|
-
|
|
12
|
-
VALUE Get_Klass_RenderState(void);
|
|
13
|
-
|
|
14
|
-
VALUE Get_New_RenderState(void);
|
|
15
|
-
|
|
16
|
-
#endif //SFML_RB_RENDER_STATE_H
|
data/ext/ext/klass/target.h
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#ifndef SFML_RB_TARGET_H
|
|
2
|
-
#define SFML_RB_TARGET_H
|
|
3
|
-
|
|
4
|
-
#include <ruby.h>
|
|
5
|
-
|
|
6
|
-
typedef struct {
|
|
7
|
-
void *window;
|
|
8
|
-
} Target;
|
|
9
|
-
|
|
10
|
-
void Init_Target(VALUE rb_module);
|
|
11
|
-
|
|
12
|
-
VALUE Get_Klass_Target(void);
|
|
13
|
-
|
|
14
|
-
void *Get_Target_Struct(VALUE self);
|
|
15
|
-
|
|
16
|
-
VALUE Get_New_Target(VALUE rb_window);
|
|
17
|
-
|
|
18
|
-
#endif //SFML_RB_TARGET_H
|
data/ext/ext/klass/transform.h
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#ifndef SFML_RB_TRANSFORM_H
|
|
2
|
-
#define SFML_RB_TRANSFORM_H
|
|
3
|
-
|
|
4
|
-
#include <ruby.h>
|
|
5
|
-
|
|
6
|
-
#define MATRIX_LENGTH 9 // 3x3
|
|
7
|
-
#define MATRIX_GL_LENGTH 16 // 4x4
|
|
8
|
-
|
|
9
|
-
static VALUE rb_cTransform;
|
|
10
|
-
|
|
11
|
-
void Init_Transform(VALUE rb_module);
|
|
12
|
-
|
|
13
|
-
void *Get_Transform_Struct(VALUE self);
|
|
14
|
-
|
|
15
|
-
VALUE To_Transform_Struct(void *ptr);
|
|
16
|
-
|
|
17
|
-
#endif //SFML_RB_TRANSFORM_H
|
data/ext/ext/klass/video_mode.h
DELETED
data/ext/ext/module/transform.h
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#ifndef CANDY2D_EXT_TRANSFORM_H
|
|
2
|
-
#define CANDY2D_EXT_TRANSFORM_H
|
|
3
|
-
|
|
4
|
-
#include <ruby.h>
|
|
5
|
-
|
|
6
|
-
#include "ext/sfml.h"
|
|
7
|
-
|
|
8
|
-
#define MATRIX_LENGTH 9 // 3x3
|
|
9
|
-
|
|
10
|
-
void Init_Transform(VALUE rb_module);
|
|
11
|
-
|
|
12
|
-
VALUE Transform_MatrixToArray(float *c_matrix);
|
|
13
|
-
|
|
14
|
-
void Transform_ArrayToMatrix(VALUE rb_matrix, float *c_matrix);
|
|
15
|
-
|
|
16
|
-
void Transform_SwapMatrix(const float *c_matrix_a, float *c_matrix_b);
|
|
17
|
-
|
|
18
|
-
#endif //CANDY2D_EXT_TRANSFORM_H
|
data/ext/ext/module.h
DELETED
data/ext/ext/rect.h
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#ifndef SFML_RB_EXT_RECT_H
|
|
2
|
-
#define SFML_RB_EXT_RECT_H
|
|
3
|
-
|
|
4
|
-
#include <ruby.h>
|
|
5
|
-
|
|
6
|
-
#define RECT_UNPACK(c_rect) c_rect.position.x, c_rect.position.y, c_rect.size.x, c_rect.size.y
|
|
7
|
-
|
|
8
|
-
#define RECT_C2RB(c_rect) Rect_new(RECT_UNPACK(c_rect))
|
|
9
|
-
|
|
10
|
-
#define RECT_RB2C(rb_arr) { {NUM2DBL(rb_ary_entry(rb_arr, 0)), NUM2DBL(rb_ary_entry(rb_arr, 1))}, {NUM2DBL(rb_ary_entry(rb_arr, 2)), NUM2DBL(rb_ary_entry(rb_arr, 3))} }
|
|
11
|
-
|
|
12
|
-
VALUE Rect_new(float x, float y, float width, float height);
|
|
13
|
-
|
|
14
|
-
void Rect_check(VALUE rb_arr);
|
|
15
|
-
|
|
16
|
-
#endif //SFML_RB_EXT_RECT_H
|
data/ext/ext/style_name.h
DELETED
data/ext/ext/vec2.h
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#ifndef SFML_RB_VEC2_H
|
|
2
|
-
#define SFML_RB_VEC2_H
|
|
3
|
-
|
|
4
|
-
#include <ruby.h>
|
|
5
|
-
|
|
6
|
-
#include "ext/sfml.h"
|
|
7
|
-
|
|
8
|
-
#define UNPACK_VEC2(c_type, c_vec) (c_type) c_vec.x, (c_type) c_vec.y
|
|
9
|
-
|
|
10
|
-
#define VEC2_C2RB(c_vec) vec2_new((float) c_vec.x, (float) c_vec.y)
|
|
11
|
-
|
|
12
|
-
#define VEC2_C2RB_T(c_type, c_vec) vec2_new((c_type) c_vec.x, (c_type) c_vec.y)
|
|
13
|
-
|
|
14
|
-
#define VEC2_RB2C(rb_arr) { NUM2DBL(rb_ary_entry(rb_arr, 0)), NUM2DBL(rb_ary_entry(rb_arr, 1)) }
|
|
15
|
-
|
|
16
|
-
#define VEC2_RB2C_T(c_type, rb_arr) { (c_type) NUM2DBL(rb_ary_entry(rb_arr, 0)), (c_type) NUM2DBL(rb_ary_entry(rb_arr, 1)) }
|
|
17
|
-
|
|
18
|
-
#define VEC2_SET_X(rb_arr, x) rb_ary_store(rb_arr, 0, DBL2NUM(x))
|
|
19
|
-
|
|
20
|
-
#define VEC2_SET_Y(rb_arr, x) rb_ary_store(rb_arr, 1, DBL2NUM(y))
|
|
21
|
-
|
|
22
|
-
#define VEC2_GET_X(rb_arr) NUM2DBL(rb_ary_entry(rb_arr, 0))
|
|
23
|
-
|
|
24
|
-
#define VEC2_GET_Y(rb_arr) NUM2DBL(rb_ary_entry(rb_arr, 1))
|
|
25
|
-
|
|
26
|
-
VALUE vec2_new(float x, float y);
|
|
27
|
-
|
|
28
|
-
void vec2_check(VALUE rb_arr);
|
|
29
|
-
|
|
30
|
-
VALUE vec2f_new_from_c(sfVector2f c_vec);
|
|
31
|
-
|
|
32
|
-
sfVector2i vec2i_new_from_ruby(VALUE rb_arr);
|
|
33
|
-
|
|
34
|
-
sfVector2u vec2u_new_from_ruby(VALUE rb_arr);
|
|
35
|
-
|
|
36
|
-
sfVector2f vec2f_new_from_ruby(VALUE rb_arr);
|
|
37
|
-
|
|
38
|
-
#endif //SFML_RB_VEC2_H
|
data/ext/image.c
DELETED
data/ext/polygon.c
DELETED
data/ext/rect.c
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#include "ext/rect.h"
|
|
2
|
-
|
|
3
|
-
#include <stdio.h>
|
|
4
|
-
#include <stdlib.h>
|
|
5
|
-
|
|
6
|
-
#include <ext/sfml.h>
|
|
7
|
-
#include <ext/module.h>
|
|
8
|
-
|
|
9
|
-
VALUE Rect_new(float x, float y, float width, float height) {
|
|
10
|
-
VALUE arr;
|
|
11
|
-
|
|
12
|
-
arr = rb_ary_new();
|
|
13
|
-
|
|
14
|
-
rb_ary_store(arr, 0, DBL2NUM(x));
|
|
15
|
-
rb_ary_store(arr, 1, DBL2NUM(y));
|
|
16
|
-
rb_ary_store(arr, 2, DBL2NUM(width));
|
|
17
|
-
rb_ary_store(arr, 3, DBL2NUM(height));
|
|
18
|
-
|
|
19
|
-
return arr;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
void Rect_check(VALUE rb_arr) {
|
|
23
|
-
if (rb_array_len(rb_arr) != 4) {
|
|
24
|
-
rb_raise(rb_eArgError, "invalid length of array");
|
|
25
|
-
}
|
|
26
|
-
}
|
data/ext/rectangle.c
DELETED
data/ext/render_state.c
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
#include "ext/klass/render_state.h"
|
|
2
|
-
|
|
3
|
-
#include <ruby.h>
|
|
4
|
-
#include <stdio.h>
|
|
5
|
-
|
|
6
|
-
#include "ext/module/transform.h"
|
|
7
|
-
#include "ext/klass/transformable.h"
|
|
8
|
-
#include "ext/vec2.h"
|
|
9
|
-
#include "ext/rect.h"
|
|
10
|
-
#include "ext/module.h"
|
|
11
|
-
#include "ext/sfml.h"
|
|
12
|
-
|
|
13
|
-
static VALUE rb_cRenderState;
|
|
14
|
-
|
|
15
|
-
static sfRenderStates *RenderStates_create(sfTransform transform) {
|
|
16
|
-
sfRenderStates *states = malloc(sizeof(sfRenderStates));
|
|
17
|
-
|
|
18
|
-
states->transform = transform;
|
|
19
|
-
states->blendMode = sfBlendAlpha;
|
|
20
|
-
states->texture = NULL;
|
|
21
|
-
states->shader = NULL;
|
|
22
|
-
|
|
23
|
-
return states;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static void RenderStates_free(void *ptr) {
|
|
27
|
-
free(ptr);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static VALUE RenderStates_new(int argc, VALUE *argv, VALUE klass) {
|
|
31
|
-
float c_matrix[MATRIX_LENGTH] = DefaultMatrix3x3();
|
|
32
|
-
sfRenderStates *states;
|
|
33
|
-
sfTransform transform;
|
|
34
|
-
VALUE self;
|
|
35
|
-
|
|
36
|
-
if (argc > 1) {
|
|
37
|
-
rb_raise(rb_eArgError, "invalid number of arguments");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (argc == 1) {
|
|
41
|
-
VALUE rb_arr = argv[0];
|
|
42
|
-
|
|
43
|
-
if (TYPE(rb_arr) == T_ARRAY) {
|
|
44
|
-
if (rb_array_len(rb_arr) != 9) {
|
|
45
|
-
rb_raise(rb_eArgError, "invalid length array");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
Transform_ArrayToMatrix(rb_arr, c_matrix);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
Transform_SwapMatrix(c_matrix, transform.matrix);
|
|
53
|
-
|
|
54
|
-
states = RenderStates_create(transform);
|
|
55
|
-
self = Data_Wrap_Struct(klass, 0, RenderStates_free, states);
|
|
56
|
-
|
|
57
|
-
rb_obj_call_init(self, argc, argv);
|
|
58
|
-
|
|
59
|
-
return self;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static VALUE RenderStates_init(int argc, VALUE *argv, VALUE self) {
|
|
63
|
-
return self;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
static VALUE RenderStates_set_matrix(VALUE self, VALUE rb_matrix) {
|
|
67
|
-
float c_matrix[MATRIX_LENGTH];
|
|
68
|
-
sfRenderStates *states;
|
|
69
|
-
|
|
70
|
-
states = Get_RenderState_Struct(self);
|
|
71
|
-
|
|
72
|
-
Transform_ArrayToMatrix(rb_matrix, c_matrix);
|
|
73
|
-
Transform_SwapMatrix(c_matrix, states->transform.matrix);
|
|
74
|
-
|
|
75
|
-
return self;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static VALUE RenderStates_get_matrix(VALUE self) {
|
|
79
|
-
return Transform_MatrixToArray(((sfRenderStates *) Get_RenderState_Struct(self))->transform.matrix);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
void Init_RenderState(VALUE rb_module) {
|
|
83
|
-
rb_cRenderState = rb_define_class_under(rb_module, "RenderState", rb_cObject);
|
|
84
|
-
|
|
85
|
-
rb_define_singleton_method(rb_cRenderState, "new", RenderStates_new, -1);
|
|
86
|
-
|
|
87
|
-
// methods
|
|
88
|
-
rb_define_method(rb_cRenderState, "initialize", RenderStates_init, -1);
|
|
89
|
-
|
|
90
|
-
// setters
|
|
91
|
-
rb_define_method(rb_cRenderState, "matrix=", RenderStates_set_matrix, 1);
|
|
92
|
-
|
|
93
|
-
// getters
|
|
94
|
-
rb_define_method(rb_cRenderState, "matrix", RenderStates_get_matrix, 0);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
void *Get_RenderState_Struct(VALUE self) {
|
|
98
|
-
sfRenderStates *states;
|
|
99
|
-
Data_Get_Struct(self, sfRenderStates, states);
|
|
100
|
-
return states;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
VALUE Get_Klass_RenderState(void) {
|
|
104
|
-
return rb_cRenderState;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
VALUE Get_New_RenderState(void) {
|
|
108
|
-
return RenderStates_new(0, NULL, Get_Klass_RenderState());
|
|
109
|
-
}
|
data/ext/sprite.c
DELETED
data/ext/style_name.c
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#include "ext/style_name.h"
|
|
2
|
-
|
|
3
|
-
const char *styles[STYLES_LENGTH] = {"none", "titlebar", "resize", "close", "fullscreen", "default"};
|
|
4
|
-
|
|
5
|
-
int search_style_name(const char *style) {
|
|
6
|
-
int i;
|
|
7
|
-
|
|
8
|
-
for (i = 0; i < STYLES_LENGTH; i++) {
|
|
9
|
-
if (strcmp(styles[i], style) != 0) {
|
|
10
|
-
return i;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return -1;
|
|
15
|
-
}
|