ruby-sfml 3.0.0.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +101 -0
- data/LICENSE.txt +21 -0
- data/README.md +245 -0
- data/ext/ruby-sfml/extconf.rb +69 -0
- data/lib/sfml/assets/fonts/DejaVuSans.LICENSE.txt +78 -0
- data/lib/sfml/assets/fonts/DejaVuSans.ttf +0 -0
- data/lib/sfml/assets.rb +121 -0
- data/lib/sfml/audio/listener.rb +55 -0
- data/lib/sfml/audio/music.rb +88 -0
- data/lib/sfml/audio/sound.rb +102 -0
- data/lib/sfml/audio/sound_buffer.rb +38 -0
- data/lib/sfml/audio/sound_buffer_recorder.rb +71 -0
- data/lib/sfml/audio/sound_recorder.rb +30 -0
- data/lib/sfml/c/audio.rb +106 -0
- data/lib/sfml/c/graphics.rb +425 -0
- data/lib/sfml/c/network.rb +79 -0
- data/lib/sfml/c/system.rb +43 -0
- data/lib/sfml/c/window.rb +186 -0
- data/lib/sfml/c.rb +72 -0
- data/lib/sfml/game.rb +101 -0
- data/lib/sfml/graphics/blend_mode.rb +108 -0
- data/lib/sfml/graphics/circle_shape.rb +67 -0
- data/lib/sfml/graphics/color.rb +89 -0
- data/lib/sfml/graphics/convex_shape.rb +82 -0
- data/lib/sfml/graphics/font.rb +67 -0
- data/lib/sfml/graphics/image.rb +125 -0
- data/lib/sfml/graphics/rectangle_shape.rb +62 -0
- data/lib/sfml/graphics/render_states.rb +56 -0
- data/lib/sfml/graphics/render_target.rb +146 -0
- data/lib/sfml/graphics/render_texture.rb +72 -0
- data/lib/sfml/graphics/render_window.rb +154 -0
- data/lib/sfml/graphics/shader.rb +132 -0
- data/lib/sfml/graphics/sprite.rb +75 -0
- data/lib/sfml/graphics/text.rb +144 -0
- data/lib/sfml/graphics/texture.rb +79 -0
- data/lib/sfml/graphics/transform.rb +150 -0
- data/lib/sfml/graphics/transformable.rb +74 -0
- data/lib/sfml/graphics/vertex.rb +53 -0
- data/lib/sfml/graphics/vertex_array.rb +114 -0
- data/lib/sfml/graphics/view.rb +126 -0
- data/lib/sfml/network/ip_address.rb +67 -0
- data/lib/sfml/network/tcp_listener.rb +61 -0
- data/lib/sfml/network/tcp_socket.rb +74 -0
- data/lib/sfml/network/udp_socket.rb +71 -0
- data/lib/sfml/system/clock.rb +44 -0
- data/lib/sfml/system/rect.rb +64 -0
- data/lib/sfml/system/time.rb +48 -0
- data/lib/sfml/system/vector2.rb +66 -0
- data/lib/sfml/system/vector3.rb +63 -0
- data/lib/sfml/version.rb +19 -0
- data/lib/sfml/window/clipboard.rb +38 -0
- data/lib/sfml/window/cursor.rb +68 -0
- data/lib/sfml/window/event.rb +133 -0
- data/lib/sfml/window/joystick.rb +90 -0
- data/lib/sfml/window/keyboard.rb +60 -0
- data/lib/sfml/window/mouse.rb +71 -0
- data/lib/sfml/window/video_mode.rb +37 -0
- data/lib/sfml/window/window.rb +149 -0
- data/lib/sfml.rb +98 -0
- data/ruby-sfml.gemspec +38 -0
- metadata +163 -0
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
module SFML
|
|
2
|
+
module C
|
|
3
|
+
module Graphics
|
|
4
|
+
extend FFI::Library
|
|
5
|
+
|
|
6
|
+
ffi_lib LIB_CANDIDATES[:graphics]
|
|
7
|
+
|
|
8
|
+
class Color < FFI::Struct
|
|
9
|
+
layout :r, :uint8, :g, :uint8, :b, :uint8, :a, :uint8
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class FloatRect < FFI::Struct
|
|
13
|
+
layout :position, System::Vector2f, :size, System::Vector2f
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class IntRect < FFI::Struct
|
|
17
|
+
layout :position, System::Vector2i, :size, System::Vector2i
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Render-state plumbing. The struct shapes mirror CSFML 3 exactly so
|
|
21
|
+
# we can construct sfRenderStates by populating fields from kwargs
|
|
22
|
+
# and passing the buffer pointer to sfRenderWindow_drawXxx.
|
|
23
|
+
class BlendMode < FFI::Struct
|
|
24
|
+
layout :color_src_factor, :int,
|
|
25
|
+
:color_dst_factor, :int,
|
|
26
|
+
:color_equation, :int,
|
|
27
|
+
:alpha_src_factor, :int,
|
|
28
|
+
:alpha_dst_factor, :int,
|
|
29
|
+
:alpha_equation, :int
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class StencilValue < FFI::Struct
|
|
33
|
+
layout :value, :uint32
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class StencilMode < FFI::Struct
|
|
37
|
+
layout :comparison, :int,
|
|
38
|
+
:update_operation, :int,
|
|
39
|
+
:reference, StencilValue,
|
|
40
|
+
:mask, StencilValue,
|
|
41
|
+
:only_write_mask, :bool
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
class Transform < FFI::Struct
|
|
45
|
+
layout :matrix, [:float, 9]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class RenderStates < FFI::Struct
|
|
49
|
+
layout :blend_mode, BlendMode,
|
|
50
|
+
:stencil_mode, StencilMode,
|
|
51
|
+
:transform, Transform,
|
|
52
|
+
:coordinate_type, :int,
|
|
53
|
+
:texture, :pointer,
|
|
54
|
+
:shader, :pointer
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# CSFML exposes default-initialised values as global constants.
|
|
58
|
+
# We read them at load time and copy from them when building Ruby
|
|
59
|
+
# RenderStates / BlendMode to avoid hand-coding the SFML defaults.
|
|
60
|
+
attach_variable :sfBlendAlpha, BlendMode
|
|
61
|
+
attach_variable :sfBlendAdd, BlendMode
|
|
62
|
+
attach_variable :sfBlendMultiply, BlendMode
|
|
63
|
+
attach_variable :sfBlendMin, BlendMode
|
|
64
|
+
attach_variable :sfBlendMax, BlendMode
|
|
65
|
+
attach_variable :sfBlendNone, BlendMode
|
|
66
|
+
attach_variable :sfRenderStates_default, RenderStates
|
|
67
|
+
attach_variable :sfTransform_Identity, Transform
|
|
68
|
+
|
|
69
|
+
attach_function :sfTransform_combine, [:pointer, :pointer], :void
|
|
70
|
+
attach_function :sfTransform_translate, [:pointer, System::Vector2f.by_value], :void
|
|
71
|
+
attach_function :sfTransform_rotate, [:pointer, :float], :void
|
|
72
|
+
attach_function :sfTransform_rotateWithCenter, [:pointer, :float, System::Vector2f.by_value], :void
|
|
73
|
+
attach_function :sfTransform_scale, [:pointer, System::Vector2f.by_value], :void
|
|
74
|
+
attach_function :sfTransform_scaleWithCenter, [:pointer, System::Vector2f.by_value, System::Vector2f.by_value], :void
|
|
75
|
+
attach_function :sfTransform_getInverse, [:pointer], Transform.by_value
|
|
76
|
+
attach_function :sfTransform_transformPoint, [:pointer, System::Vector2f.by_value], System::Vector2f.by_value
|
|
77
|
+
attach_function :sfTransform_transformRect, [:pointer, FloatRect.by_value], FloatRect.by_value
|
|
78
|
+
attach_function :sfTransform_equal, [:pointer, :pointer], :bool
|
|
79
|
+
|
|
80
|
+
typedef :pointer, :render_window_t
|
|
81
|
+
|
|
82
|
+
# See CSFML/Graphics/RenderWindow.h. We pass NULL for sfContextSettings
|
|
83
|
+
# in the high-level wrapper; that matches SFML defaults.
|
|
84
|
+
attach_function :sfRenderWindow_create,
|
|
85
|
+
[Window::VideoMode.by_value, :string, :uint32, :int, :pointer],
|
|
86
|
+
:render_window_t
|
|
87
|
+
|
|
88
|
+
attach_function :sfRenderWindow_destroy, [:render_window_t], :void
|
|
89
|
+
attach_function :sfRenderWindow_close, [:render_window_t], :void
|
|
90
|
+
attach_function :sfRenderWindow_isOpen, [:render_window_t], :bool
|
|
91
|
+
attach_function :sfRenderWindow_pollEvent, [:render_window_t, :pointer], :bool
|
|
92
|
+
attach_function :sfRenderWindow_setTitle, [:render_window_t, :string], :void
|
|
93
|
+
attach_function :sfRenderWindow_setVerticalSyncEnabled, [:render_window_t, :bool], :void
|
|
94
|
+
attach_function :sfRenderWindow_setFramerateLimit, [:render_window_t, :uint32], :void
|
|
95
|
+
attach_function :sfRenderWindow_display, [:render_window_t], :void
|
|
96
|
+
attach_function :sfRenderWindow_clear, [:render_window_t, Color.by_value], :void
|
|
97
|
+
attach_function :sfRenderWindow_getSize, [:render_window_t], System::Vector2u.by_value
|
|
98
|
+
attach_function :sfRenderWindow_setSize, [:render_window_t, System::Vector2u.by_value], :void
|
|
99
|
+
|
|
100
|
+
typedef :pointer, :texture_t
|
|
101
|
+
typedef :pointer, :render_texture_t
|
|
102
|
+
typedef :pointer, :sprite_t
|
|
103
|
+
typedef :pointer, :circle_shape_t
|
|
104
|
+
typedef :pointer, :rectangle_shape_t
|
|
105
|
+
typedef :pointer, :convex_shape_t
|
|
106
|
+
typedef :pointer, :font_t
|
|
107
|
+
typedef :pointer, :text_t
|
|
108
|
+
typedef :pointer, :view_t
|
|
109
|
+
typedef :pointer, :image_t
|
|
110
|
+
typedef :pointer, :vertex_array_t
|
|
111
|
+
typedef :pointer, :shader_t
|
|
112
|
+
typedef :pointer, :render_states_t
|
|
113
|
+
|
|
114
|
+
# GLSL types: vec2/vec3 are typedef'd to sfVector2f/sfVector3f, so
|
|
115
|
+
# we don't need separate structs for those. The other arities are
|
|
116
|
+
# fresh struct shapes.
|
|
117
|
+
class GlslVec4 < FFI::Struct
|
|
118
|
+
layout :x, :float, :y, :float, :z, :float, :w, :float
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
class GlslIvec3 < FFI::Struct
|
|
122
|
+
layout :x, :int32, :y, :int32, :z, :int32
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
class GlslIvec4 < FFI::Struct
|
|
126
|
+
layout :x, :int32, :y, :int32, :z, :int32, :w, :int32
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
class Vertex < FFI::Struct
|
|
130
|
+
layout :position, System::Vector2f,
|
|
131
|
+
:color, Color,
|
|
132
|
+
:tex_coords, System::Vector2f
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
attach_function :sfRenderWindow_drawSprite,
|
|
136
|
+
[:render_window_t, :sprite_t, :render_states_t], :void
|
|
137
|
+
attach_function :sfRenderWindow_drawCircleShape,
|
|
138
|
+
[:render_window_t, :circle_shape_t, :render_states_t], :void
|
|
139
|
+
attach_function :sfRenderWindow_drawRectangleShape,
|
|
140
|
+
[:render_window_t, :rectangle_shape_t, :render_states_t], :void
|
|
141
|
+
attach_function :sfRenderWindow_drawConvexShape,
|
|
142
|
+
[:render_window_t, :convex_shape_t, :render_states_t], :void
|
|
143
|
+
attach_function :sfRenderWindow_drawText,
|
|
144
|
+
[:render_window_t, :text_t, :render_states_t], :void
|
|
145
|
+
attach_function :sfRenderWindow_drawVertexArray,
|
|
146
|
+
[:render_window_t, :vertex_array_t, :render_states_t], :void
|
|
147
|
+
|
|
148
|
+
# Mouse position queries relative to a render-window.
|
|
149
|
+
attach_function :sfMouse_getPositionRenderWindow,
|
|
150
|
+
[:render_window_t], System::Vector2i.by_value
|
|
151
|
+
attach_function :sfMouse_setPositionRenderWindow,
|
|
152
|
+
[System::Vector2i.by_value, :render_window_t], :void
|
|
153
|
+
|
|
154
|
+
# ---- View ----
|
|
155
|
+
attach_function :sfView_create, [], :view_t
|
|
156
|
+
attach_function :sfView_createFromRect, [FloatRect.by_value], :view_t
|
|
157
|
+
attach_function :sfView_copy, [:view_t], :view_t
|
|
158
|
+
attach_function :sfView_destroy, [:view_t], :void
|
|
159
|
+
attach_function :sfView_setCenter, [:view_t, System::Vector2f.by_value], :void
|
|
160
|
+
attach_function :sfView_getCenter, [:view_t], System::Vector2f.by_value
|
|
161
|
+
attach_function :sfView_setSize, [:view_t, System::Vector2f.by_value], :void
|
|
162
|
+
attach_function :sfView_getSize, [:view_t], System::Vector2f.by_value
|
|
163
|
+
attach_function :sfView_setRotation, [:view_t, :float], :void
|
|
164
|
+
attach_function :sfView_getRotation, [:view_t], :float
|
|
165
|
+
attach_function :sfView_setViewport, [:view_t, FloatRect.by_value], :void
|
|
166
|
+
attach_function :sfView_getViewport, [:view_t], FloatRect.by_value
|
|
167
|
+
attach_function :sfView_move, [:view_t, System::Vector2f.by_value], :void
|
|
168
|
+
attach_function :sfView_rotate, [:view_t, :float], :void
|
|
169
|
+
attach_function :sfView_zoom, [:view_t, :float], :void
|
|
170
|
+
|
|
171
|
+
# RenderWindow ↔ View bridge
|
|
172
|
+
attach_function :sfRenderWindow_setMouseCursor, [:render_window_t, :pointer], :void
|
|
173
|
+
attach_function :sfRenderWindow_setMouseCursorVisible, [:render_window_t, :bool], :void
|
|
174
|
+
attach_function :sfRenderWindow_setMouseCursorGrabbed, [:render_window_t, :bool], :void
|
|
175
|
+
|
|
176
|
+
attach_function :sfRenderWindow_setView, [:render_window_t, :view_t], :void
|
|
177
|
+
attach_function :sfRenderWindow_getView, [:render_window_t], :view_t
|
|
178
|
+
attach_function :sfRenderWindow_getDefaultView, [:render_window_t], :view_t
|
|
179
|
+
|
|
180
|
+
attach_function :sfRenderWindow_mapPixelToCoords,
|
|
181
|
+
[:render_window_t, System::Vector2i.by_value, :view_t],
|
|
182
|
+
System::Vector2f.by_value
|
|
183
|
+
attach_function :sfRenderWindow_mapCoordsToPixel,
|
|
184
|
+
[:render_window_t, System::Vector2f.by_value, :view_t],
|
|
185
|
+
System::Vector2i.by_value
|
|
186
|
+
|
|
187
|
+
# ---- Texture ----
|
|
188
|
+
attach_function :sfTexture_createFromFile, [:string, :pointer], :texture_t
|
|
189
|
+
attach_function :sfTexture_createFromImage,[:image_t, :pointer], :texture_t
|
|
190
|
+
attach_function :sfTexture_destroy, [:texture_t], :void
|
|
191
|
+
attach_function :sfTexture_getSize, [:texture_t], System::Vector2u.by_value
|
|
192
|
+
attach_function :sfTexture_setSmooth, [:texture_t, :bool], :void
|
|
193
|
+
attach_function :sfTexture_isSmooth, [:texture_t], :bool
|
|
194
|
+
attach_function :sfTexture_setRepeated, [:texture_t, :bool], :void
|
|
195
|
+
attach_function :sfTexture_isRepeated, [:texture_t], :bool
|
|
196
|
+
attach_function :sfTexture_copyToImage, [:texture_t], :image_t
|
|
197
|
+
attach_function :sfTexture_updateFromImage,[:texture_t, :image_t, System::Vector2u.by_value], :void
|
|
198
|
+
attach_function :sfTexture_updateFromPixels,
|
|
199
|
+
[:texture_t, :pointer, System::Vector2u.by_value, System::Vector2u.by_value], :void
|
|
200
|
+
|
|
201
|
+
# ---- Image ----
|
|
202
|
+
attach_function :sfImage_create, [System::Vector2u.by_value], :image_t
|
|
203
|
+
attach_function :sfImage_createFromColor, [System::Vector2u.by_value, Color.by_value], :image_t
|
|
204
|
+
attach_function :sfImage_createFromPixels, [System::Vector2u.by_value, :pointer], :image_t
|
|
205
|
+
attach_function :sfImage_createFromFile, [:string], :image_t
|
|
206
|
+
attach_function :sfImage_copy, [:image_t], :image_t
|
|
207
|
+
attach_function :sfImage_destroy, [:image_t], :void
|
|
208
|
+
attach_function :sfImage_saveToFile, [:image_t, :string], :bool
|
|
209
|
+
attach_function :sfImage_getSize, [:image_t], System::Vector2u.by_value
|
|
210
|
+
attach_function :sfImage_setPixel, [:image_t, System::Vector2u.by_value, Color.by_value], :void
|
|
211
|
+
attach_function :sfImage_getPixel, [:image_t, System::Vector2u.by_value], Color.by_value
|
|
212
|
+
attach_function :sfImage_getPixelsPtr, [:image_t], :pointer
|
|
213
|
+
attach_function :sfImage_createMaskFromColor, [:image_t, Color.by_value, :uint8], :void
|
|
214
|
+
attach_function :sfImage_flipHorizontally, [:image_t], :void
|
|
215
|
+
attach_function :sfImage_flipVertically, [:image_t], :void
|
|
216
|
+
|
|
217
|
+
# ---- Sprite (transform-style methods are shared with shapes; same shape) ----
|
|
218
|
+
attach_function :sfSprite_create, [:texture_t], :sprite_t
|
|
219
|
+
attach_function :sfSprite_destroy, [:sprite_t], :void
|
|
220
|
+
attach_function :sfSprite_setPosition, [:sprite_t, System::Vector2f.by_value], :void
|
|
221
|
+
attach_function :sfSprite_getPosition, [:sprite_t], System::Vector2f.by_value
|
|
222
|
+
attach_function :sfSprite_setRotation, [:sprite_t, :float], :void
|
|
223
|
+
attach_function :sfSprite_getRotation, [:sprite_t], :float
|
|
224
|
+
attach_function :sfSprite_setScale, [:sprite_t, System::Vector2f.by_value], :void
|
|
225
|
+
attach_function :sfSprite_getScale, [:sprite_t], System::Vector2f.by_value
|
|
226
|
+
attach_function :sfSprite_setOrigin, [:sprite_t, System::Vector2f.by_value], :void
|
|
227
|
+
attach_function :sfSprite_getOrigin, [:sprite_t], System::Vector2f.by_value
|
|
228
|
+
attach_function :sfSprite_move, [:sprite_t, System::Vector2f.by_value], :void
|
|
229
|
+
attach_function :sfSprite_rotate, [:sprite_t, :float], :void
|
|
230
|
+
attach_function :sfSprite_scale, [:sprite_t, System::Vector2f.by_value], :void
|
|
231
|
+
attach_function :sfSprite_setColor, [:sprite_t, Color.by_value], :void
|
|
232
|
+
attach_function :sfSprite_getColor, [:sprite_t], Color.by_value
|
|
233
|
+
attach_function :sfSprite_setTexture, [:sprite_t, :texture_t, :bool], :void
|
|
234
|
+
|
|
235
|
+
# ---- CircleShape ----
|
|
236
|
+
attach_function :sfCircleShape_create, [], :circle_shape_t
|
|
237
|
+
attach_function :sfCircleShape_destroy, [:circle_shape_t], :void
|
|
238
|
+
attach_function :sfCircleShape_setRadius, [:circle_shape_t, :float], :void
|
|
239
|
+
attach_function :sfCircleShape_getRadius, [:circle_shape_t], :float
|
|
240
|
+
attach_function :sfCircleShape_setPointCount, [:circle_shape_t, :size_t], :void
|
|
241
|
+
attach_function :sfCircleShape_getPointCount, [:circle_shape_t], :size_t
|
|
242
|
+
attach_function :sfCircleShape_setFillColor, [:circle_shape_t, Color.by_value], :void
|
|
243
|
+
attach_function :sfCircleShape_getFillColor, [:circle_shape_t], Color.by_value
|
|
244
|
+
attach_function :sfCircleShape_setOutlineColor, [:circle_shape_t, Color.by_value], :void
|
|
245
|
+
attach_function :sfCircleShape_getOutlineColor, [:circle_shape_t], Color.by_value
|
|
246
|
+
attach_function :sfCircleShape_setOutlineThickness,[:circle_shape_t, :float], :void
|
|
247
|
+
attach_function :sfCircleShape_getOutlineThickness,[:circle_shape_t], :float
|
|
248
|
+
attach_function :sfCircleShape_setPosition, [:circle_shape_t, System::Vector2f.by_value], :void
|
|
249
|
+
attach_function :sfCircleShape_getPosition, [:circle_shape_t], System::Vector2f.by_value
|
|
250
|
+
attach_function :sfCircleShape_setRotation, [:circle_shape_t, :float], :void
|
|
251
|
+
attach_function :sfCircleShape_getRotation, [:circle_shape_t], :float
|
|
252
|
+
attach_function :sfCircleShape_setScale, [:circle_shape_t, System::Vector2f.by_value], :void
|
|
253
|
+
attach_function :sfCircleShape_getScale, [:circle_shape_t], System::Vector2f.by_value
|
|
254
|
+
attach_function :sfCircleShape_setOrigin, [:circle_shape_t, System::Vector2f.by_value], :void
|
|
255
|
+
attach_function :sfCircleShape_getOrigin, [:circle_shape_t], System::Vector2f.by_value
|
|
256
|
+
attach_function :sfCircleShape_move, [:circle_shape_t, System::Vector2f.by_value], :void
|
|
257
|
+
attach_function :sfCircleShape_rotate, [:circle_shape_t, :float], :void
|
|
258
|
+
attach_function :sfCircleShape_scale, [:circle_shape_t, System::Vector2f.by_value], :void
|
|
259
|
+
|
|
260
|
+
# ---- RectangleShape ----
|
|
261
|
+
attach_function :sfRectangleShape_create, [], :rectangle_shape_t
|
|
262
|
+
attach_function :sfRectangleShape_destroy, [:rectangle_shape_t], :void
|
|
263
|
+
attach_function :sfRectangleShape_setSize, [:rectangle_shape_t, System::Vector2f.by_value], :void
|
|
264
|
+
attach_function :sfRectangleShape_getSize, [:rectangle_shape_t], System::Vector2f.by_value
|
|
265
|
+
attach_function :sfRectangleShape_setFillColor, [:rectangle_shape_t, Color.by_value], :void
|
|
266
|
+
attach_function :sfRectangleShape_getFillColor, [:rectangle_shape_t], Color.by_value
|
|
267
|
+
attach_function :sfRectangleShape_setOutlineColor, [:rectangle_shape_t, Color.by_value], :void
|
|
268
|
+
attach_function :sfRectangleShape_getOutlineColor, [:rectangle_shape_t], Color.by_value
|
|
269
|
+
attach_function :sfRectangleShape_setOutlineThickness,[:rectangle_shape_t, :float], :void
|
|
270
|
+
attach_function :sfRectangleShape_getOutlineThickness,[:rectangle_shape_t], :float
|
|
271
|
+
attach_function :sfRectangleShape_setPosition, [:rectangle_shape_t, System::Vector2f.by_value], :void
|
|
272
|
+
attach_function :sfRectangleShape_getPosition, [:rectangle_shape_t], System::Vector2f.by_value
|
|
273
|
+
attach_function :sfRectangleShape_setRotation, [:rectangle_shape_t, :float], :void
|
|
274
|
+
attach_function :sfRectangleShape_getRotation, [:rectangle_shape_t], :float
|
|
275
|
+
attach_function :sfRectangleShape_setScale, [:rectangle_shape_t, System::Vector2f.by_value], :void
|
|
276
|
+
attach_function :sfRectangleShape_getScale, [:rectangle_shape_t], System::Vector2f.by_value
|
|
277
|
+
attach_function :sfRectangleShape_setOrigin, [:rectangle_shape_t, System::Vector2f.by_value], :void
|
|
278
|
+
attach_function :sfRectangleShape_getOrigin, [:rectangle_shape_t], System::Vector2f.by_value
|
|
279
|
+
attach_function :sfRectangleShape_move, [:rectangle_shape_t, System::Vector2f.by_value], :void
|
|
280
|
+
attach_function :sfRectangleShape_rotate, [:rectangle_shape_t, :float], :void
|
|
281
|
+
attach_function :sfRectangleShape_scale, [:rectangle_shape_t, System::Vector2f.by_value], :void
|
|
282
|
+
|
|
283
|
+
# ---- ConvexShape ----
|
|
284
|
+
attach_function :sfConvexShape_create, [], :convex_shape_t
|
|
285
|
+
attach_function :sfConvexShape_destroy, [:convex_shape_t], :void
|
|
286
|
+
attach_function :sfConvexShape_setPointCount, [:convex_shape_t, :size_t], :void
|
|
287
|
+
attach_function :sfConvexShape_getPointCount, [:convex_shape_t], :size_t
|
|
288
|
+
attach_function :sfConvexShape_setPoint, [:convex_shape_t, :size_t, System::Vector2f.by_value], :void
|
|
289
|
+
attach_function :sfConvexShape_getPoint, [:convex_shape_t, :size_t], System::Vector2f.by_value
|
|
290
|
+
attach_function :sfConvexShape_setFillColor, [:convex_shape_t, Color.by_value], :void
|
|
291
|
+
attach_function :sfConvexShape_getFillColor, [:convex_shape_t], Color.by_value
|
|
292
|
+
attach_function :sfConvexShape_setOutlineColor, [:convex_shape_t, Color.by_value], :void
|
|
293
|
+
attach_function :sfConvexShape_getOutlineColor, [:convex_shape_t], Color.by_value
|
|
294
|
+
attach_function :sfConvexShape_setOutlineThickness, [:convex_shape_t, :float], :void
|
|
295
|
+
attach_function :sfConvexShape_getOutlineThickness, [:convex_shape_t], :float
|
|
296
|
+
attach_function :sfConvexShape_setPosition, [:convex_shape_t, System::Vector2f.by_value], :void
|
|
297
|
+
attach_function :sfConvexShape_getPosition, [:convex_shape_t], System::Vector2f.by_value
|
|
298
|
+
attach_function :sfConvexShape_setRotation, [:convex_shape_t, :float], :void
|
|
299
|
+
attach_function :sfConvexShape_getRotation, [:convex_shape_t], :float
|
|
300
|
+
attach_function :sfConvexShape_setScale, [:convex_shape_t, System::Vector2f.by_value], :void
|
|
301
|
+
attach_function :sfConvexShape_getScale, [:convex_shape_t], System::Vector2f.by_value
|
|
302
|
+
attach_function :sfConvexShape_setOrigin, [:convex_shape_t, System::Vector2f.by_value], :void
|
|
303
|
+
attach_function :sfConvexShape_getOrigin, [:convex_shape_t], System::Vector2f.by_value
|
|
304
|
+
attach_function :sfConvexShape_move, [:convex_shape_t, System::Vector2f.by_value], :void
|
|
305
|
+
attach_function :sfConvexShape_rotate, [:convex_shape_t, :float], :void
|
|
306
|
+
attach_function :sfConvexShape_scale, [:convex_shape_t, System::Vector2f.by_value], :void
|
|
307
|
+
|
|
308
|
+
# ---- VertexArray ----
|
|
309
|
+
attach_function :sfVertexArray_create, [], :vertex_array_t
|
|
310
|
+
attach_function :sfVertexArray_destroy, [:vertex_array_t], :void
|
|
311
|
+
attach_function :sfVertexArray_getVertexCount, [:vertex_array_t], :size_t
|
|
312
|
+
attach_function :sfVertexArray_getVertex, [:vertex_array_t, :size_t], :pointer
|
|
313
|
+
attach_function :sfVertexArray_clear, [:vertex_array_t], :void
|
|
314
|
+
attach_function :sfVertexArray_resize, [:vertex_array_t, :size_t], :void
|
|
315
|
+
attach_function :sfVertexArray_append, [:vertex_array_t, Vertex.by_value], :void
|
|
316
|
+
attach_function :sfVertexArray_setPrimitiveType, [:vertex_array_t, :int], :void
|
|
317
|
+
attach_function :sfVertexArray_getPrimitiveType, [:vertex_array_t], :int
|
|
318
|
+
attach_function :sfVertexArray_getBounds, [:vertex_array_t], FloatRect.by_value
|
|
319
|
+
|
|
320
|
+
# ---- RenderTexture ----
|
|
321
|
+
attach_function :sfRenderTexture_create, [System::Vector2u.by_value, :pointer], :render_texture_t
|
|
322
|
+
attach_function :sfRenderTexture_destroy, [:render_texture_t], :void
|
|
323
|
+
attach_function :sfRenderTexture_getSize, [:render_texture_t], System::Vector2u.by_value
|
|
324
|
+
attach_function :sfRenderTexture_setActive, [:render_texture_t, :bool], :bool
|
|
325
|
+
attach_function :sfRenderTexture_display, [:render_texture_t], :void
|
|
326
|
+
attach_function :sfRenderTexture_clear, [:render_texture_t, Color.by_value], :void
|
|
327
|
+
attach_function :sfRenderTexture_setView, [:render_texture_t, :view_t], :void
|
|
328
|
+
attach_function :sfRenderTexture_getView, [:render_texture_t], :view_t
|
|
329
|
+
attach_function :sfRenderTexture_getDefaultView, [:render_texture_t], :view_t
|
|
330
|
+
attach_function :sfRenderTexture_getTexture, [:render_texture_t], :texture_t
|
|
331
|
+
attach_function :sfRenderTexture_setSmooth, [:render_texture_t, :bool], :void
|
|
332
|
+
attach_function :sfRenderTexture_isSmooth, [:render_texture_t], :bool
|
|
333
|
+
attach_function :sfRenderTexture_setRepeated, [:render_texture_t, :bool], :void
|
|
334
|
+
attach_function :sfRenderTexture_isRepeated, [:render_texture_t], :bool
|
|
335
|
+
|
|
336
|
+
attach_function :sfRenderTexture_mapPixelToCoords,
|
|
337
|
+
[:render_texture_t, System::Vector2i.by_value, :view_t],
|
|
338
|
+
System::Vector2f.by_value
|
|
339
|
+
attach_function :sfRenderTexture_mapCoordsToPixel,
|
|
340
|
+
[:render_texture_t, System::Vector2f.by_value, :view_t],
|
|
341
|
+
System::Vector2i.by_value
|
|
342
|
+
|
|
343
|
+
# Mirror sfRenderWindow_drawXxx for textures.
|
|
344
|
+
attach_function :sfRenderTexture_drawSprite, [:render_texture_t, :sprite_t, :render_states_t], :void
|
|
345
|
+
attach_function :sfRenderTexture_drawCircleShape, [:render_texture_t, :circle_shape_t, :render_states_t], :void
|
|
346
|
+
attach_function :sfRenderTexture_drawRectangleShape, [:render_texture_t, :rectangle_shape_t, :render_states_t], :void
|
|
347
|
+
attach_function :sfRenderTexture_drawConvexShape, [:render_texture_t, :convex_shape_t, :render_states_t], :void
|
|
348
|
+
attach_function :sfRenderTexture_drawText, [:render_texture_t, :text_t, :render_states_t], :void
|
|
349
|
+
attach_function :sfRenderTexture_drawVertexArray, [:render_texture_t, :vertex_array_t, :render_states_t], :void
|
|
350
|
+
|
|
351
|
+
# ---- Raw primitive drawing (without a VertexArray object) ----
|
|
352
|
+
attach_function :sfRenderWindow_drawPrimitives,
|
|
353
|
+
[:render_window_t, :pointer, :size_t, :int, :render_states_t], :void
|
|
354
|
+
attach_function :sfRenderTexture_drawPrimitives,
|
|
355
|
+
[:render_texture_t, :pointer, :size_t, :int, :render_states_t], :void
|
|
356
|
+
|
|
357
|
+
# ---- Shader ----
|
|
358
|
+
attach_function :sfShader_createFromFile, [:string, :string, :string], :shader_t
|
|
359
|
+
attach_function :sfShader_createFromMemory, [:string, :string, :string], :shader_t
|
|
360
|
+
attach_function :sfShader_destroy, [:shader_t], :void
|
|
361
|
+
attach_function :sfShader_isAvailable, [], :bool
|
|
362
|
+
attach_function :sfShader_isGeometryAvailable, [], :bool
|
|
363
|
+
|
|
364
|
+
attach_function :sfShader_setFloatUniform, [:shader_t, :string, :float], :void
|
|
365
|
+
attach_function :sfShader_setVec2Uniform, [:shader_t, :string, System::Vector2f.by_value], :void
|
|
366
|
+
attach_function :sfShader_setVec3Uniform, [:shader_t, :string, System::Vector3f.by_value], :void
|
|
367
|
+
attach_function :sfShader_setVec4Uniform, [:shader_t, :string, GlslVec4.by_value], :void
|
|
368
|
+
attach_function :sfShader_setIntUniform, [:shader_t, :string, :int32], :void
|
|
369
|
+
attach_function :sfShader_setIvec2Uniform, [:shader_t, :string, System::Vector2i.by_value], :void
|
|
370
|
+
attach_function :sfShader_setIvec3Uniform, [:shader_t, :string, GlslIvec3.by_value], :void
|
|
371
|
+
attach_function :sfShader_setIvec4Uniform, [:shader_t, :string, GlslIvec4.by_value], :void
|
|
372
|
+
attach_function :sfShader_setBoolUniform, [:shader_t, :string, :bool], :void
|
|
373
|
+
attach_function :sfShader_setColorUniform, [:shader_t, :string, Color.by_value], :void
|
|
374
|
+
attach_function :sfShader_setTextureUniform,[:shader_t, :string, :texture_t], :void
|
|
375
|
+
attach_function :sfShader_setCurrentTextureUniform, [:shader_t, :string], :void
|
|
376
|
+
|
|
377
|
+
# ---- Font ----
|
|
378
|
+
attach_function :sfFont_createFromFile, [:string], :font_t
|
|
379
|
+
attach_function :sfFont_destroy, [:font_t], :void
|
|
380
|
+
attach_function :sfFont_setSmooth, [:font_t, :bool], :void
|
|
381
|
+
attach_function :sfFont_isSmooth, [:font_t], :bool
|
|
382
|
+
|
|
383
|
+
# ---- Text ----
|
|
384
|
+
attach_function :sfText_create, [:font_t], :text_t
|
|
385
|
+
attach_function :sfText_destroy, [:text_t], :void
|
|
386
|
+
# CSFML 3's sfText_setString takes a Latin-1 char*, so a multi-byte
|
|
387
|
+
# UTF-8 string would render each byte as a separate (garbage) glyph.
|
|
388
|
+
# We always go through the Unicode (UTF-32 / sfChar32*) variant,
|
|
389
|
+
# converting to/from Ruby UTF-8 in the high-level wrapper.
|
|
390
|
+
attach_function :sfText_setUnicodeString, [:text_t, :pointer], :void
|
|
391
|
+
attach_function :sfText_getUnicodeString, [:text_t], :pointer
|
|
392
|
+
attach_function :sfText_setFont, [:text_t, :font_t], :void
|
|
393
|
+
attach_function :sfText_setCharacterSize, [:text_t, :uint32], :void
|
|
394
|
+
attach_function :sfText_getCharacterSize, [:text_t], :uint32
|
|
395
|
+
attach_function :sfText_setFillColor, [:text_t, Color.by_value], :void
|
|
396
|
+
attach_function :sfText_getFillColor, [:text_t], Color.by_value
|
|
397
|
+
attach_function :sfText_setOutlineColor, [:text_t, Color.by_value], :void
|
|
398
|
+
attach_function :sfText_getOutlineColor, [:text_t], Color.by_value
|
|
399
|
+
attach_function :sfText_setOutlineThickness,[:text_t, :float], :void
|
|
400
|
+
attach_function :sfText_getOutlineThickness,[:text_t], :float
|
|
401
|
+
attach_function :sfText_setStyle, [:text_t, :uint32], :void
|
|
402
|
+
attach_function :sfText_getStyle, [:text_t], :uint32
|
|
403
|
+
attach_function :sfText_setLetterSpacing, [:text_t, :float], :void
|
|
404
|
+
attach_function :sfText_setLineSpacing, [:text_t, :float], :void
|
|
405
|
+
attach_function :sfText_setPosition, [:text_t, System::Vector2f.by_value], :void
|
|
406
|
+
attach_function :sfText_getPosition, [:text_t], System::Vector2f.by_value
|
|
407
|
+
attach_function :sfText_setRotation, [:text_t, :float], :void
|
|
408
|
+
attach_function :sfText_getRotation, [:text_t], :float
|
|
409
|
+
attach_function :sfText_setScale, [:text_t, System::Vector2f.by_value], :void
|
|
410
|
+
attach_function :sfText_getScale, [:text_t], System::Vector2f.by_value
|
|
411
|
+
attach_function :sfText_setOrigin, [:text_t, System::Vector2f.by_value], :void
|
|
412
|
+
attach_function :sfText_getOrigin, [:text_t], System::Vector2f.by_value
|
|
413
|
+
attach_function :sfText_move, [:text_t, System::Vector2f.by_value], :void
|
|
414
|
+
attach_function :sfText_rotate, [:text_t, :float], :void
|
|
415
|
+
attach_function :sfText_scale, [:text_t, System::Vector2f.by_value], :void
|
|
416
|
+
attach_function :sfText_getLocalBounds, [:text_t], FloatRect.by_value
|
|
417
|
+
attach_function :sfText_getGlobalBounds, [:text_t], FloatRect.by_value
|
|
418
|
+
|
|
419
|
+
attach_function :sfSprite_setTextureRect, [:sprite_t, IntRect.by_value], :void
|
|
420
|
+
attach_function :sfSprite_getTextureRect, [:sprite_t], IntRect.by_value
|
|
421
|
+
attach_function :sfSprite_getLocalBounds, [:sprite_t], FloatRect.by_value
|
|
422
|
+
attach_function :sfSprite_getGlobalBounds, [:sprite_t], FloatRect.by_value
|
|
423
|
+
end
|
|
424
|
+
end
|
|
425
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
module SFML
|
|
2
|
+
module C
|
|
3
|
+
module Network
|
|
4
|
+
extend FFI::Library
|
|
5
|
+
|
|
6
|
+
ffi_lib LIB_CANDIDATES[:network]
|
|
7
|
+
|
|
8
|
+
typedef :pointer, :tcp_socket_t
|
|
9
|
+
typedef :pointer, :tcp_listener_t
|
|
10
|
+
typedef :pointer, :udp_socket_t
|
|
11
|
+
typedef :pointer, :packet_t
|
|
12
|
+
|
|
13
|
+
# sfIpAddress is just a 16-byte string buffer (IPv4 dotted-decimal,
|
|
14
|
+
# NUL-terminated). Pass-by-value for most CSFML calls.
|
|
15
|
+
class IpAddress < FFI::Struct
|
|
16
|
+
layout :address, [:char, 16]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# sfSocketStatus enum order — see CSFML/Network/SocketStatus.h.
|
|
20
|
+
STATUSES = %i[done not_ready partial disconnected error].freeze
|
|
21
|
+
|
|
22
|
+
# ---- IpAddress ----
|
|
23
|
+
attach_variable :sfIpAddress_None, IpAddress
|
|
24
|
+
attach_variable :sfIpAddress_Any, IpAddress
|
|
25
|
+
attach_variable :sfIpAddress_LocalHost, IpAddress
|
|
26
|
+
attach_variable :sfIpAddress_Broadcast, IpAddress
|
|
27
|
+
|
|
28
|
+
attach_function :sfIpAddress_fromString, [:string], IpAddress.by_value
|
|
29
|
+
attach_function :sfIpAddress_fromBytes, [:uint8, :uint8, :uint8, :uint8], IpAddress.by_value
|
|
30
|
+
attach_function :sfIpAddress_fromInteger, [:uint32], IpAddress.by_value
|
|
31
|
+
attach_function :sfIpAddress_toInteger, [IpAddress.by_value], :uint32
|
|
32
|
+
attach_function :sfIpAddress_getLocalAddress, [], IpAddress.by_value
|
|
33
|
+
attach_function :sfIpAddress_getPublicAddress,[System::Time.by_value], IpAddress.by_value
|
|
34
|
+
|
|
35
|
+
# ---- TcpSocket ----
|
|
36
|
+
attach_function :sfTcpSocket_create, [], :tcp_socket_t
|
|
37
|
+
attach_function :sfTcpSocket_destroy, [:tcp_socket_t], :void
|
|
38
|
+
attach_function :sfTcpSocket_setBlocking, [:tcp_socket_t, :bool], :void
|
|
39
|
+
attach_function :sfTcpSocket_isBlocking, [:tcp_socket_t], :bool
|
|
40
|
+
attach_function :sfTcpSocket_getLocalPort, [:tcp_socket_t], :uint16
|
|
41
|
+
attach_function :sfTcpSocket_getRemoteAddress, [:tcp_socket_t], IpAddress.by_value
|
|
42
|
+
attach_function :sfTcpSocket_getRemotePort, [:tcp_socket_t], :uint16
|
|
43
|
+
attach_function :sfTcpSocket_connect, [:tcp_socket_t, IpAddress.by_value, :uint16, System::Time.by_value], :int
|
|
44
|
+
attach_function :sfTcpSocket_disconnect, [:tcp_socket_t], :void
|
|
45
|
+
attach_function :sfTcpSocket_send, [:tcp_socket_t, :pointer, :size_t], :int
|
|
46
|
+
attach_function :sfTcpSocket_sendPartial, [:tcp_socket_t, :pointer, :size_t, :pointer], :int
|
|
47
|
+
attach_function :sfTcpSocket_receive, [:tcp_socket_t, :pointer, :size_t, :pointer], :int
|
|
48
|
+
|
|
49
|
+
# ---- TcpListener ----
|
|
50
|
+
attach_function :sfTcpListener_create, [], :tcp_listener_t
|
|
51
|
+
attach_function :sfTcpListener_destroy, [:tcp_listener_t], :void
|
|
52
|
+
attach_function :sfTcpListener_setBlocking, [:tcp_listener_t, :bool], :void
|
|
53
|
+
attach_function :sfTcpListener_isBlocking, [:tcp_listener_t], :bool
|
|
54
|
+
attach_function :sfTcpListener_getLocalPort, [:tcp_listener_t], :uint16
|
|
55
|
+
attach_function :sfTcpListener_listen, [:tcp_listener_t, :uint16, IpAddress.by_value], :int
|
|
56
|
+
attach_function :sfTcpListener_close, [:tcp_listener_t], :void
|
|
57
|
+
attach_function :sfTcpListener_accept, [:tcp_listener_t, :pointer], :int
|
|
58
|
+
|
|
59
|
+
# ---- UdpSocket ----
|
|
60
|
+
attach_function :sfUdpSocket_create, [], :udp_socket_t
|
|
61
|
+
attach_function :sfUdpSocket_destroy, [:udp_socket_t], :void
|
|
62
|
+
attach_function :sfUdpSocket_setBlocking, [:udp_socket_t, :bool], :void
|
|
63
|
+
attach_function :sfUdpSocket_isBlocking, [:udp_socket_t], :bool
|
|
64
|
+
attach_function :sfUdpSocket_getLocalPort, [:udp_socket_t], :uint16
|
|
65
|
+
attach_function :sfUdpSocket_bind, [:udp_socket_t, :uint16, IpAddress.by_value], :int
|
|
66
|
+
attach_function :sfUdpSocket_unbind, [:udp_socket_t], :void
|
|
67
|
+
attach_function :sfUdpSocket_send, [:udp_socket_t, :pointer, :size_t, IpAddress.by_value, :uint16], :int
|
|
68
|
+
attach_function :sfUdpSocket_receive, [:udp_socket_t, :pointer, :size_t, :pointer, :pointer, :pointer], :int
|
|
69
|
+
attach_function :sfUdpSocket_maxDatagramSize, [], :uint32
|
|
70
|
+
|
|
71
|
+
# ---- Packet (typed serializer) ----
|
|
72
|
+
attach_function :sfPacket_create, [], :packet_t
|
|
73
|
+
attach_function :sfPacket_destroy, [:packet_t], :void
|
|
74
|
+
attach_function :sfPacket_append, [:packet_t, :pointer, :size_t], :void
|
|
75
|
+
attach_function :sfPacket_clear, [:packet_t], :void
|
|
76
|
+
attach_function :sfPacket_getData, [:packet_t], :pointer
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module SFML
|
|
2
|
+
module C
|
|
3
|
+
module System
|
|
4
|
+
extend FFI::Library
|
|
5
|
+
|
|
6
|
+
ffi_lib LIB_CANDIDATES[:system]
|
|
7
|
+
|
|
8
|
+
class Time < FFI::Struct
|
|
9
|
+
layout :microseconds, :int64
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class Vector2f < FFI::Struct
|
|
13
|
+
layout :x, :float, :y, :float
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class Vector2i < FFI::Struct
|
|
17
|
+
layout :x, :int32, :y, :int32
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class Vector2u < FFI::Struct
|
|
21
|
+
layout :x, :uint32, :y, :uint32
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Vector3f < FFI::Struct
|
|
25
|
+
layout :x, :float, :y, :float, :z, :float
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
typedef :pointer, :clock_t
|
|
29
|
+
|
|
30
|
+
attach_function :sfClock_create, [], :clock_t
|
|
31
|
+
attach_function :sfClock_copy, [:clock_t], :clock_t
|
|
32
|
+
attach_function :sfClock_destroy, [:clock_t], :void
|
|
33
|
+
attach_function :sfClock_getElapsedTime, [:clock_t], Time.by_value
|
|
34
|
+
attach_function :sfClock_isRunning, [:clock_t], :bool
|
|
35
|
+
attach_function :sfClock_start, [:clock_t], :void
|
|
36
|
+
attach_function :sfClock_stop, [:clock_t], :void
|
|
37
|
+
attach_function :sfClock_restart, [:clock_t], Time.by_value
|
|
38
|
+
attach_function :sfClock_reset, [:clock_t], Time.by_value
|
|
39
|
+
|
|
40
|
+
attach_function :sfSleep, [Time.by_value], :void
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|