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
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/* Shared method bodies for every render target (Window, RenderTexture).
|
|
2
|
+
Included from two translation units; each defines RT_FN, RT_METHOD and
|
|
3
|
+
RT_HANDLE before including this file, then undefines them after. Generating
|
|
4
|
+
concrete methods per class keeps the compiler's type checks on the handle and
|
|
5
|
+
on every sf* call, which a runtime dispatch through void* would not.
|
|
6
|
+
|
|
7
|
+
CSFML gives sfRenderWindow and sfRenderTexture identical render-target
|
|
8
|
+
surfaces under two name prefixes, so RT_FN is the only thing that differs.
|
|
9
|
+
SFML::Target still exists for the runtime-dispatch case (Drawable#draw); this
|
|
10
|
+
file is about the methods each concrete target owns directly. */
|
|
11
|
+
|
|
12
|
+
#include "graphics/enums.h"
|
|
13
|
+
#include "graphics/render_state.h"
|
|
14
|
+
#include "graphics/vertex.h"
|
|
15
|
+
#include "graphics/vertex_buffer.h"
|
|
16
|
+
#include "graphics/view.h"
|
|
17
|
+
#include "graphics/color.h"
|
|
18
|
+
#include "graphics/rect.h"
|
|
19
|
+
#include "system/vec2.h"
|
|
20
|
+
#include "core/exceptions.h"
|
|
21
|
+
#include "core/macros.h"
|
|
22
|
+
|
|
23
|
+
/* A nil view means "the target's current view", which is what CSFML's NULL
|
|
24
|
+
means for every one of these. */
|
|
25
|
+
static const sfView *RT_METHOD(view_arg)(VALUE rb_view) {
|
|
26
|
+
if (NIL_P(rb_view)) {
|
|
27
|
+
return NULL;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!rb_obj_is_kind_of(rb_view, Get_Klass_View())) {
|
|
31
|
+
raise_invalid_argument_class(Get_Klass_View());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return Get_View_Struct(rb_view);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static const sfRenderStates *RT_METHOD(state_arg)(VALUE rb_state) {
|
|
38
|
+
if (NIL_P(rb_state)) {
|
|
39
|
+
return NULL;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!rb_obj_is_kind_of(rb_state, Get_Klass_RenderState())) {
|
|
43
|
+
raise_invalid_argument_class(Get_Klass_RenderState());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return Get_RenderState_Struct(rb_state);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE RT_METHOD(is_srgb)(VALUE self) {
|
|
50
|
+
return BOOL2RB(RT_FN(isSrgb)(RT_HANDLE(self)));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static VALUE RT_METHOD(clear_stencil)(VALUE self, VALUE rb_value) {
|
|
54
|
+
sfStencilValue value = {.value = (unsigned int) NUM2UINT(rb_value)};
|
|
55
|
+
|
|
56
|
+
RT_FN(clearStencil)(RT_HANDLE(self), value);
|
|
57
|
+
|
|
58
|
+
return self;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static VALUE RT_METHOD(clear_color_and_stencil)(VALUE self, VALUE rb_color, VALUE rb_stencil) {
|
|
62
|
+
sfStencilValue value = {.value = (unsigned int) NUM2UINT(rb_stencil)};
|
|
63
|
+
|
|
64
|
+
RT_FN(clearColorAndStencil)(RT_HANDLE(self), color_from_rb(rb_color), value);
|
|
65
|
+
|
|
66
|
+
return self;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static VALUE RT_METHOD(get_viewport)(int argc, VALUE *argv, VALUE self) {
|
|
70
|
+
VALUE rb_view;
|
|
71
|
+
|
|
72
|
+
rb_scan_args(argc, argv, "01", &rb_view);
|
|
73
|
+
|
|
74
|
+
return int_rect_to_rb(RT_FN(getViewport)(RT_HANDLE(self), RT_METHOD(view_arg)(rb_view)));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static VALUE RT_METHOD(get_scissor)(int argc, VALUE *argv, VALUE self) {
|
|
78
|
+
VALUE rb_view;
|
|
79
|
+
|
|
80
|
+
rb_scan_args(argc, argv, "01", &rb_view);
|
|
81
|
+
|
|
82
|
+
return int_rect_to_rb(RT_FN(getScissor)(RT_HANDLE(self), RT_METHOD(view_arg)(rb_view)));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Pixel -> world. The inverse of the view transform, so a zoomed, rotated or
|
|
86
|
+
viewport-shifted view still turns a mouse position into scene coordinates. */
|
|
87
|
+
static VALUE RT_METHOD(map_pixel_to_coords)(int argc, VALUE *argv, VALUE self) {
|
|
88
|
+
VALUE rb_point, rb_view;
|
|
89
|
+
|
|
90
|
+
rb_scan_args(argc, argv, "11", &rb_point, &rb_view);
|
|
91
|
+
|
|
92
|
+
return vec2f_to_rb(RT_FN(mapPixelToCoords)(RT_HANDLE(self),
|
|
93
|
+
vec2i_from_rb(rb_point),
|
|
94
|
+
RT_METHOD(view_arg)(rb_view)));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* World -> pixel. Returns integer pixel coordinates. */
|
|
98
|
+
static VALUE RT_METHOD(map_coords_to_pixel)(int argc, VALUE *argv, VALUE self) {
|
|
99
|
+
VALUE rb_point, rb_view;
|
|
100
|
+
sfVector2i pixel;
|
|
101
|
+
|
|
102
|
+
rb_scan_args(argc, argv, "11", &rb_point, &rb_view);
|
|
103
|
+
|
|
104
|
+
pixel = RT_FN(mapCoordsToPixel)(RT_HANDLE(self),
|
|
105
|
+
vec2f_from_rb(rb_point),
|
|
106
|
+
RT_METHOD(view_arg)(rb_view));
|
|
107
|
+
|
|
108
|
+
return VEC2_C2RB(pixel);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
static VALUE RT_METHOD(push_gl_states)(VALUE self) {
|
|
112
|
+
RT_FN(pushGLStates)(RT_HANDLE(self));
|
|
113
|
+
return self;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static VALUE RT_METHOD(pop_gl_states)(VALUE self) {
|
|
117
|
+
RT_FN(popGLStates)(RT_HANDLE(self));
|
|
118
|
+
return self;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static VALUE RT_METHOD(reset_gl_states)(VALUE self) {
|
|
122
|
+
RT_FN(resetGLStates)(RT_HANDLE(self));
|
|
123
|
+
return self;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* draw_primitives(vertices, primitive, state = nil) */
|
|
127
|
+
static VALUE RT_METHOD(draw_primitives)(int argc, VALUE *argv, VALUE self) {
|
|
128
|
+
VALUE rb_vertices, rb_primitive, rb_state;
|
|
129
|
+
sfPrimitiveType type;
|
|
130
|
+
const sfRenderStates *states;
|
|
131
|
+
sfVertex *vertices;
|
|
132
|
+
size_t count;
|
|
133
|
+
|
|
134
|
+
rb_scan_args(argc, argv, "21", &rb_vertices, &rb_primitive, &rb_state);
|
|
135
|
+
|
|
136
|
+
/* Every argument is converted before the array is allocated, so a bad
|
|
137
|
+
vertex raises without leaking it. */
|
|
138
|
+
type = primitive_type_from_rb(rb_primitive);
|
|
139
|
+
states = RT_METHOD(state_arg)(rb_state);
|
|
140
|
+
vertices = vertices_from_rb(rb_vertices, &count);
|
|
141
|
+
|
|
142
|
+
RT_FN(drawPrimitives)(RT_HANDLE(self), vertices, count, type, states);
|
|
143
|
+
|
|
144
|
+
xfree(vertices);
|
|
145
|
+
|
|
146
|
+
return self;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* draw_vertex_buffer_range(buffer, first, count, state = nil) */
|
|
150
|
+
static VALUE RT_METHOD(draw_vertex_buffer_range)(int argc, VALUE *argv, VALUE self) {
|
|
151
|
+
VALUE rb_buffer, rb_first, rb_count, rb_state;
|
|
152
|
+
|
|
153
|
+
rb_scan_args(argc, argv, "31", &rb_buffer, &rb_first, &rb_count, &rb_state);
|
|
154
|
+
|
|
155
|
+
if (!rb_obj_is_kind_of(rb_buffer, Get_Klass_VertexBuffer())) {
|
|
156
|
+
raise_invalid_argument_class(Get_Klass_VertexBuffer());
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
RT_FN(drawVertexBufferRange)(RT_HANDLE(self),
|
|
160
|
+
Get_VertexBuffer_Struct(rb_buffer),
|
|
161
|
+
NUM2SIZET(rb_first),
|
|
162
|
+
NUM2SIZET(rb_count),
|
|
163
|
+
RT_METHOD(state_arg)(rb_state));
|
|
164
|
+
|
|
165
|
+
return self;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static void RT_METHOD(define_render_target_methods)(VALUE klass) {
|
|
169
|
+
rb_define_method(klass, "srgb?", RT_METHOD(is_srgb), 0);
|
|
170
|
+
rb_define_method(klass, "clear_stencil", RT_METHOD(clear_stencil), 1);
|
|
171
|
+
rb_define_method(klass, "clear_color_and_stencil", RT_METHOD(clear_color_and_stencil), 2);
|
|
172
|
+
rb_define_method(klass, "viewport", RT_METHOD(get_viewport), -1);
|
|
173
|
+
rb_define_method(klass, "scissor", RT_METHOD(get_scissor), -1);
|
|
174
|
+
rb_define_method(klass, "map_pixel_to_coords", RT_METHOD(map_pixel_to_coords), -1);
|
|
175
|
+
rb_define_method(klass, "map_coords_to_pixel", RT_METHOD(map_coords_to_pixel), -1);
|
|
176
|
+
rb_define_method(klass, "push_gl_states", RT_METHOD(push_gl_states), 0);
|
|
177
|
+
rb_define_method(klass, "pop_gl_states", RT_METHOD(pop_gl_states), 0);
|
|
178
|
+
rb_define_method(klass, "reset_gl_states", RT_METHOD(reset_gl_states), 0);
|
|
179
|
+
rb_define_method(klass, "draw_primitives", RT_METHOD(draw_primitives), -1);
|
|
180
|
+
rb_define_method(klass, "draw_vertex_buffer_range", RT_METHOD(draw_vertex_buffer_range), -1);
|
|
181
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#include "graphics/render_texture.h"
|
|
2
|
+
|
|
3
|
+
#include <ruby.h>
|
|
4
|
+
|
|
5
|
+
#include "graphics/target.h"
|
|
6
|
+
#include "graphics/render_state.h"
|
|
7
|
+
#include "graphics/view.h"
|
|
8
|
+
#include "graphics/texture.h"
|
|
9
|
+
#include "graphics/color.h"
|
|
10
|
+
#include "graphics/rect.h"
|
|
11
|
+
#include "system/vec2.h"
|
|
12
|
+
#include "core/exceptions.h"
|
|
13
|
+
#include "core/macros.h"
|
|
14
|
+
|
|
15
|
+
static VALUE rb_cRenderTexture;
|
|
16
|
+
|
|
17
|
+
static void RenderTexture_free(void* ptr) {
|
|
18
|
+
sfRenderTexture_destroy(ptr);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static const rb_data_type_t RenderTexture_data_type = {
|
|
22
|
+
.wrap_struct_name = "SFML::RenderTexture",
|
|
23
|
+
.function = {.dmark = NULL, .dfree = RenderTexture_free, .dsize = NULL},
|
|
24
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY};
|
|
25
|
+
|
|
26
|
+
sfRenderTexture* Get_RenderTexture_Struct(VALUE self) {
|
|
27
|
+
sfRenderTexture* ptr;
|
|
28
|
+
TypedData_Get_Struct(self, sfRenderTexture, &RenderTexture_data_type, ptr);
|
|
29
|
+
return ptr;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static VALUE RenderTexture_wrap(VALUE klass, sfRenderTexture* render_texture) {
|
|
33
|
+
if (render_texture == NULL) {
|
|
34
|
+
rb_raise(rb_eRuntimeError, "failed to create render texture");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return TypedData_Wrap_Struct(klass, &RenderTexture_data_type, render_texture);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static VALUE RenderTexture_new(int argc, VALUE* argv, VALUE klass) {
|
|
41
|
+
VALUE rb_size, rb_settings;
|
|
42
|
+
|
|
43
|
+
rb_scan_args(argc, argv, "11", &rb_size, &rb_settings);
|
|
44
|
+
|
|
45
|
+
(void)rb_settings;
|
|
46
|
+
|
|
47
|
+
return RenderTexture_wrap(klass, sfRenderTexture_create(vec2u_from_rb(rb_size), NULL));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static VALUE RenderTexture_get_size(VALUE self) {
|
|
51
|
+
sfVector2u size = sfRenderTexture_getSize(Get_RenderTexture_Struct(self));
|
|
52
|
+
|
|
53
|
+
return vec2f_to_rb((sfVector2f){(float)size.x, (float)size.y});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static VALUE RenderTexture_set_active(VALUE self, VALUE rb_active) {
|
|
57
|
+
return BOOL2RB(sfRenderTexture_setActive(Get_RenderTexture_Struct(self), RTEST(rb_active)));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static VALUE RenderTexture_display(VALUE self) {
|
|
61
|
+
sfRenderTexture_display(Get_RenderTexture_Struct(self));
|
|
62
|
+
return self;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static VALUE RenderTexture_clear(int argc, VALUE* argv, VALUE self) {
|
|
66
|
+
VALUE rb_color;
|
|
67
|
+
sfColor color = sfBlack;
|
|
68
|
+
|
|
69
|
+
rb_scan_args(argc, argv, "01", &rb_color);
|
|
70
|
+
|
|
71
|
+
if (!NIL_P(rb_color)) {
|
|
72
|
+
color = color_from_rb(rb_color);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
sfRenderTexture_clear(Get_RenderTexture_Struct(self), color);
|
|
76
|
+
|
|
77
|
+
return self;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static VALUE RenderTexture_set_view(VALUE self, VALUE rb_view) {
|
|
81
|
+
if (!rb_obj_is_kind_of(rb_view, Get_Klass_View())) {
|
|
82
|
+
raise_invalid_argument_class(Get_Klass_View());
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
sfRenderTexture_setView(Get_RenderTexture_Struct(self), Get_View_Struct(rb_view));
|
|
86
|
+
|
|
87
|
+
return self;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static VALUE RenderTexture_get_view(VALUE self) {
|
|
91
|
+
return Get_Casting_View(sfView_copy(sfRenderTexture_getView(Get_RenderTexture_Struct(self))));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static VALUE RenderTexture_get_default_view(VALUE self) {
|
|
95
|
+
return Get_Casting_View(
|
|
96
|
+
sfView_copy(sfRenderTexture_getDefaultView(Get_RenderTexture_Struct(self))));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static VALUE RenderTexture_get_texture(VALUE self) {
|
|
100
|
+
return texture_from_borrowed(sfRenderTexture_getTexture(Get_RenderTexture_Struct(self)));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static VALUE RenderTexture_set_smooth(VALUE self, VALUE rb_smooth) {
|
|
104
|
+
sfRenderTexture_setSmooth(Get_RenderTexture_Struct(self), RTEST(rb_smooth));
|
|
105
|
+
return rb_smooth;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static VALUE RenderTexture_is_smooth(VALUE self) {
|
|
109
|
+
return BOOL2RB(sfRenderTexture_isSmooth(Get_RenderTexture_Struct(self)));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static VALUE RenderTexture_set_repeated(VALUE self, VALUE rb_repeated) {
|
|
113
|
+
sfRenderTexture_setRepeated(Get_RenderTexture_Struct(self), RTEST(rb_repeated));
|
|
114
|
+
return rb_repeated;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static VALUE RenderTexture_is_repeated(VALUE self) {
|
|
118
|
+
return BOOL2RB(sfRenderTexture_isRepeated(Get_RenderTexture_Struct(self)));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static VALUE RenderTexture_generate_mipmap(VALUE self) {
|
|
122
|
+
return BOOL2RB(sfRenderTexture_generateMipmap(Get_RenderTexture_Struct(self)));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static VALUE RenderTexture_draw(int argc, VALUE* argv, VALUE self) {
|
|
126
|
+
VALUE rb_drawable, rb_state;
|
|
127
|
+
|
|
128
|
+
if (argc == 0 || argc > 2) {
|
|
129
|
+
raise_invalid_arguments_excepted(-1, argc);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
rb_drawable = argv[0];
|
|
133
|
+
rb_state = (argc == 2) ? argv[1] : Get_New_RenderState();
|
|
134
|
+
|
|
135
|
+
rb_funcall(Get_New_Target_From_RenderTexture(self), rb_intern("draw"), 2, rb_drawable,
|
|
136
|
+
rb_state);
|
|
137
|
+
|
|
138
|
+
return self;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static VALUE RenderTexture_maximum_antialiasing_level(VALUE klass) {
|
|
142
|
+
return UINT2NUM(sfRenderTexture_getMaximumAntiAliasingLevel());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
#define RT_FN(name) sfRenderTexture_##name
|
|
146
|
+
#define RT_METHOD(name) RenderTexture_##name
|
|
147
|
+
#define RT_HANDLE(self) Get_RenderTexture_Struct(self)
|
|
148
|
+
#include "graphics/render_target.inc"
|
|
149
|
+
#undef RT_FN
|
|
150
|
+
#undef RT_METHOD
|
|
151
|
+
#undef RT_HANDLE
|
|
152
|
+
|
|
153
|
+
void Init_RenderTexture(VALUE rb_module) {
|
|
154
|
+
rb_cRenderTexture = rb_define_class_under(rb_module, "RenderTexture", rb_cObject);
|
|
155
|
+
|
|
156
|
+
rb_define_singleton_method(rb_cRenderTexture, "new", RenderTexture_new, -1);
|
|
157
|
+
rb_define_singleton_method(rb_cRenderTexture, "maximum_antialiasing_level",
|
|
158
|
+
RenderTexture_maximum_antialiasing_level, 0);
|
|
159
|
+
|
|
160
|
+
rb_define_method(rb_cRenderTexture, "size", RenderTexture_get_size, 0);
|
|
161
|
+
rb_define_method(rb_cRenderTexture, "display", RenderTexture_display, 0);
|
|
162
|
+
rb_define_method(rb_cRenderTexture, "clear", RenderTexture_clear, -1);
|
|
163
|
+
rb_define_method(rb_cRenderTexture, "view", RenderTexture_get_view, 0);
|
|
164
|
+
rb_define_method(rb_cRenderTexture, "default_view", RenderTexture_get_default_view, 0);
|
|
165
|
+
rb_define_method(rb_cRenderTexture, "texture", RenderTexture_get_texture, 0);
|
|
166
|
+
rb_define_method(rb_cRenderTexture, "smooth?", RenderTexture_is_smooth, 0);
|
|
167
|
+
rb_define_method(rb_cRenderTexture, "repeated?", RenderTexture_is_repeated, 0);
|
|
168
|
+
rb_define_method(rb_cRenderTexture, "generate_mipmap", RenderTexture_generate_mipmap, 0);
|
|
169
|
+
|
|
170
|
+
rb_define_method(rb_cRenderTexture, "view=", RenderTexture_set_view, 1);
|
|
171
|
+
rb_define_method(rb_cRenderTexture, "active=", RenderTexture_set_active, 1);
|
|
172
|
+
rb_define_method(rb_cRenderTexture, "smooth=", RenderTexture_set_smooth, 1);
|
|
173
|
+
rb_define_method(rb_cRenderTexture, "repeated=", RenderTexture_set_repeated, 1);
|
|
174
|
+
|
|
175
|
+
rb_define_method(rb_cRenderTexture, "draw", RenderTexture_draw, -1);
|
|
176
|
+
|
|
177
|
+
RenderTexture_define_render_target_methods(rb_cRenderTexture);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
VALUE Get_Klass_RenderTexture(void) {
|
|
181
|
+
return rb_cRenderTexture;
|
|
182
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#ifndef SFML_RB_GRAPHICS_RENDER_TEXTURE_H
|
|
2
|
+
#define SFML_RB_GRAPHICS_RENDER_TEXTURE_H
|
|
3
|
+
|
|
4
|
+
#include <ruby.h>
|
|
5
|
+
|
|
6
|
+
#include "core/sfml.h"
|
|
7
|
+
|
|
8
|
+
void Init_RenderTexture(VALUE rb_module);
|
|
9
|
+
|
|
10
|
+
VALUE Get_Klass_RenderTexture(void);
|
|
11
|
+
|
|
12
|
+
sfRenderTexture *Get_RenderTexture_Struct(VALUE self);
|
|
13
|
+
|
|
14
|
+
#endif //SFML_RB_GRAPHICS_RENDER_TEXTURE_H
|