raylib-bindings 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7377be87c5c5efda168b264deaa7526f03bb948b47199a647fff36b93cf1571
4
- data.tar.gz: f3d9f8465b47291a7e61eb3c6cc168e213826a5dad17aa6ce2d48da333887748
3
+ metadata.gz: 60c0ed2e964a28a7b861f1dd9f2b8f35e9d8e65bec1f7c90746675b58d2407e4
4
+ data.tar.gz: e3030f30c9520538fae1eee5cc58db9308c6cd17fed35c58c311035927692a28
5
5
  SHA512:
6
- metadata.gz: 1f2f44763ca651d69267875fd630ade2bafc23260e44e5cad004e068b0971da664b5fc8adc89bc203b1d16e945ca38a2a523526a1491ef3b45e701fd4783cd57
7
- data.tar.gz: 4d5020ee59e112531bc6c1706af275e3f3bfcb6947501b441e8a885d89f49469948b500fc939be4e09bedef118a620b7512ea5f996d289536bef7ae0622c9fcb
6
+ metadata.gz: 4284b47b0c43125635254ed3eb44986ce29b0df6541521e46d1df37663c134717255a4746f959d6d320429be87c9f7d4d6f23d9c540c61045474a4ca8503d24e
7
+ data.tar.gz: b36f8196992e4b8ee6002d1b8ebea803a1eb5a019ceedda5f4477ea7d14baaa0214bd549a86184883ce9473964e9480775c05fd6bcef0a732e5d6bdf7cf912c3
data/ChangeLog CHANGED
@@ -1,3 +1,19 @@
1
+ 2023-09-09 vaiorabbit <http://twitter.com/vaiorabbit>
2
+
3
+ * Updated with latest raylib ( https://github.com/raysan5/raylib/commit/37f60e75e72eebd5ff687b8857bf9043d291b0df ) and raygui ( https://github.com/raysan5/raygui/commit/0fccdc61fbd787fdfa9e254fd99def2cdb34fb10 )
4
+ * example/template.rb: now calls UpdateCamera only when orbital model is on
5
+
6
+ 2023-09-02 vaiorabbit <http://twitter.com/vaiorabbit>
7
+
8
+ * Updated with latest raylib ( https://github.com/raysan5/raylib/commit/ec6d3bb688ae8c137152eca7cdef9885badd9bee ) and raygui ( https://github.com/raysan5/raygui/commit/12fc56e5e1fe0888a4c73b98890914ca3806a8b4 )
9
+ * Linux (Cross): changed host OS (Ubuntu 22.04 LTS) and cross compiler version
10
+
11
+ 2023-08-10 vaiorabbit <http://twitter.com/vaiorabbit>
12
+
13
+ * Updated with latest raylib ( https://github.com/raysan5/raylib/commit/0959f6ebf69f44d5bb0225cc94fd187ebedf8be5 ) and raygui ( https://github.com/raysan5/raygui/commit/41417db52d951bb08273c892d3e3db3723f1083a )
14
+ * lib/raylib_helper.rb: Added several initialization helper for Camera3D, Camera2D and BoundingBox
15
+ * examples: Fixed broken examples / Adoped new initialization helper APIs / Use accessor helpers for better readability
16
+
1
17
  2023-07-29 vaiorabbit <http://twitter.com/vaiorabbit>
2
18
 
3
19
  * Updated with latest raylib ( https://github.com/raysan5/raylib/commit/962030e70ad3dfcce5d4642ad65890fde93ad117 ) and raygui ( https://github.com/raysan5/raygui/commit/36365199b11dd967e7147e64c85ccfda8c5064d1 )
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  # Yet another raylib wrapper for Ruby #
4
4
 
5
5
  * Created : 2021-10-17
6
- * Last modified : 2023-07-29
6
+ * Last modified : 2023-09-09
7
7
 
8
8
  Provides Ruby bindings for raylib-related libraries including:
9
9
 
data/examples/template.rb CHANGED
@@ -47,7 +47,7 @@ if __FILE__ == $PROGRAM_NAME
47
47
  camera.projection = CAMERA_PERSPECTIVE
48
48
  }
49
49
  reset_camera.call
50
- camera_mode = CAMERA_FREE
50
+ camera_mode = CAMERA_CUSTOM
51
51
  auto_rotate = false
52
52
 
53
53
  # Player (red cube) settings
@@ -68,16 +68,16 @@ if __FILE__ == $PROGRAM_NAME
68
68
  if IsKeyPressed(KEY_F1)
69
69
  auto_rotate = !auto_rotate
70
70
  reset_camera.call
71
- camera_mode = auto_rotate ? CAMERA_ORBITAL : CAMERA_FREE
71
+ camera_mode = auto_rotate ? CAMERA_ORBITAL : CAMERA_CUSTOM
72
72
  end
73
- UpdateCamera(camera.pointer, camera_mode)
73
+ UpdateCamera(camera.pointer, camera_mode) if auto_rotate
74
74
 
75
75
  # Calculate move direction
76
76
  move = Vector3.create(0, 0, 0)
77
- move[:x] += speed if IsKeyDown(KEY_RIGHT)
78
- move[:x] -= speed if IsKeyDown(KEY_LEFT)
79
- move[:z] += speed if IsKeyDown(KEY_DOWN)
80
- move[:z] -= speed if IsKeyDown(KEY_UP)
77
+ move.x += speed if IsKeyDown(KEY_RIGHT)
78
+ move.x -= speed if IsKeyDown(KEY_LEFT)
79
+ move.z += speed if IsKeyDown(KEY_DOWN)
80
+ move.z -= speed if IsKeyDown(KEY_UP)
81
81
 
82
82
  to_camera = Vector3Normalize(Vector3.create(camera.position.x, 0, camera.position.z))
83
83
  rotate_y = QuaternionFromVector3ToVector3(Vector3.create(0, 0, 1), to_camera)
@@ -89,19 +89,13 @@ if __FILE__ == $PROGRAM_NAME
89
89
  # Check collision status
90
90
  collision = false
91
91
 
92
- player_bbox = BoundingBox.create(player_pos.x - player_size.x/2,
93
- player_pos.y - player_size.y/2,
94
- player_pos.z - player_size.z/2,
95
- player_pos.x + player_size.x/2,
96
- player_pos.y + player_size.y/2,
97
- player_pos.z + player_size.z/2)
98
-
99
- obstacle_cube_bbox = BoundingBox.create(obstacle_cube_pos.x - obstacle_cube_size.x/2,
100
- obstacle_cube_pos.y - obstacle_cube_size.y/2,
101
- obstacle_cube_pos.z - obstacle_cube_size.z/2,
102
- obstacle_cube_pos.x + obstacle_cube_size.x/2,
103
- obstacle_cube_pos.y + obstacle_cube_size.y/2,
104
- obstacle_cube_pos.z + obstacle_cube_size.z/2)
92
+ player_bbox = BoundingBox.new
93
+ .with_min(player_pos.x - player_size.x/2, player_pos.y - player_size.y/2, player_pos.z - player_size.z/2)
94
+ .with_max(player_pos.x + player_size.x/2, player_pos.y + player_size.y/2, player_pos.z + player_size.z/2)
95
+
96
+ obstacle_cube_bbox = BoundingBox.new
97
+ .with_min(obstacle_cube_pos.x - obstacle_cube_size.x/2, obstacle_cube_pos.y - obstacle_cube_size.y/2, obstacle_cube_pos.z - obstacle_cube_size.z/2)
98
+ .with_max(obstacle_cube_pos.x + obstacle_cube_size.x/2, obstacle_cube_pos.y + obstacle_cube_size.y/2, obstacle_cube_pos.z + obstacle_cube_size.z/2)
105
99
 
106
100
  # Check collisions player vs obstacle_cube
107
101
  collision = true if CheckCollisionBoxes(player_bbox, obstacle_cube_bbox)
data/lib/config.rb CHANGED
@@ -62,7 +62,6 @@ module Raylib
62
62
  SUPPORT_FILEFORMAT_GIF = 1
63
63
  SUPPORT_FILEFORMAT_QOI = 1
64
64
  SUPPORT_FILEFORMAT_DDS = 1
65
- SUPPORT_FILEFORMAT_HDR = 1
66
65
  SUPPORT_IMAGE_EXPORT = 1
67
66
  SUPPORT_IMAGE_GENERATION = 1
68
67
  SUPPORT_IMAGE_MANIPULATION = 1
Binary file
data/lib/libraylib.dll CHANGED
Binary file
data/lib/libraylib.dylib CHANGED
Binary file
Binary file
Binary file
data/lib/physac.dll CHANGED
Binary file
data/lib/physac.x86_64.so CHANGED
Binary file
Binary file
data/lib/raygui.dll CHANGED
Binary file
data/lib/raygui.dylib CHANGED
Binary file
data/lib/raygui.x86_64.so CHANGED
Binary file
data/lib/raygui_main.rb CHANGED
@@ -14,7 +14,7 @@ module Raylib
14
14
  RAYGUI_VERSION_MAJOR = 4
15
15
  RAYGUI_VERSION_MINOR = 0
16
16
  RAYGUI_VERSION_PATCH = 0
17
- RAYGUI_VERSION = "4.0-dev"
17
+ RAYGUI_VERSION = "4.0"
18
18
  SCROLLBAR_LEFT_SIDE = 0
19
19
  SCROLLBAR_RIGHT_SIDE = 1
20
20
 
@@ -33,6 +33,18 @@ module Raylib
33
33
  TEXT_ALIGN_CENTER = 1
34
34
  TEXT_ALIGN_RIGHT = 2
35
35
 
36
+ # enum GuiTextAlignmentVertical
37
+ # Gui control text alignment vertical
38
+ TEXT_ALIGN_TOP = 0
39
+ TEXT_ALIGN_MIDDLE = 1
40
+ TEXT_ALIGN_BOTTOM = 2
41
+
42
+ # enum GuiTextWrapMode
43
+ # Gui control text wrap mode
44
+ TEXT_WRAP_NONE = 0
45
+ TEXT_WRAP_CHAR = 1
46
+ TEXT_WRAP_WORD = 2
47
+
36
48
  # enum GuiControl
37
49
  # Gui controls
38
50
  DEFAULT = 0
@@ -54,30 +66,31 @@ module Raylib
54
66
 
55
67
  # enum GuiControlProperty
56
68
  # Gui base properties for every control
57
- BORDER_COLOR_NORMAL = 0
58
- BASE_COLOR_NORMAL = 1
59
- TEXT_COLOR_NORMAL = 2
60
- BORDER_COLOR_FOCUSED = 3
61
- BASE_COLOR_FOCUSED = 4
62
- TEXT_COLOR_FOCUSED = 5
63
- BORDER_COLOR_PRESSED = 6
64
- BASE_COLOR_PRESSED = 7
65
- TEXT_COLOR_PRESSED = 8
66
- BORDER_COLOR_DISABLED = 9
67
- BASE_COLOR_DISABLED = 10
68
- TEXT_COLOR_DISABLED = 11
69
- BORDER_WIDTH = 12
70
- TEXT_PADDING = 13
71
- TEXT_ALIGNMENT = 14
72
- RESERVED = 15
69
+ BORDER_COLOR_NORMAL = 0 # Control border color in STATE_NORMAL
70
+ BASE_COLOR_NORMAL = 1 # Control base color in STATE_NORMAL
71
+ TEXT_COLOR_NORMAL = 2 # Control text color in STATE_NORMAL
72
+ BORDER_COLOR_FOCUSED = 3 # Control border color in STATE_FOCUSED
73
+ BASE_COLOR_FOCUSED = 4 # Control base color in STATE_FOCUSED
74
+ TEXT_COLOR_FOCUSED = 5 # Control text color in STATE_FOCUSED
75
+ BORDER_COLOR_PRESSED = 6 # Control border color in STATE_PRESSED
76
+ BASE_COLOR_PRESSED = 7 # Control base color in STATE_PRESSED
77
+ TEXT_COLOR_PRESSED = 8 # Control text color in STATE_PRESSED
78
+ BORDER_COLOR_DISABLED = 9 # Control border color in STATE_DISABLED
79
+ BASE_COLOR_DISABLED = 10 # Control base color in STATE_DISABLED
80
+ TEXT_COLOR_DISABLED = 11 # Control text color in STATE_DISABLED
81
+ BORDER_WIDTH = 12 # Control border size, 0 for no border
82
+ TEXT_PADDING = 13 # Control text padding, not considering border
83
+ TEXT_ALIGNMENT = 14 # Control text horizontal alignment inside control text bound (after border and padding)
73
84
 
74
85
  # enum GuiDefaultProperty
75
86
  # DEFAULT extended properties
76
- TEXT_SIZE = 16 # Text size (glyphs max height)
77
- TEXT_SPACING = 17 # Text spacing between glyphs
78
- LINE_COLOR = 18 # Line control color
79
- BACKGROUND_COLOR = 19 # Background color
80
- TEXT_LINE_SPACING = 20 # Text spacing between lines
87
+ TEXT_SIZE = 16 # Text size (glyphs max height)
88
+ TEXT_SPACING = 17 # Text spacing between glyphs
89
+ LINE_COLOR = 18 # Line control color
90
+ BACKGROUND_COLOR = 19 # Background color
91
+ TEXT_LINE_SPACING = 20 # Text spacing between lines
92
+ TEXT_ALIGNMENT_VERTICAL = 21 # Text vertical alignment inside text bounds (after border and padding)
93
+ TEXT_WRAP_MODE = 22 # Text wrap-mode inside text bounds
81
94
 
82
95
  # enum GuiToggleProperty
83
96
  # Toggle/ToggleGroup
@@ -94,12 +107,12 @@ module Raylib
94
107
 
95
108
  # enum GuiScrollBarProperty
96
109
  # ScrollBar
97
- ARROWS_SIZE = 16
98
- ARROWS_VISIBLE = 17
99
- SCROLL_SLIDER_PADDING = 18 # (SLIDERBAR, SLIDER_PADDING)
100
- SCROLL_SLIDER_SIZE = 19
101
- SCROLL_PADDING = 20
102
- SCROLL_SPEED = 21
110
+ ARROWS_SIZE = 16 # ScrollBar arrows size
111
+ ARROWS_VISIBLE = 17 # ScrollBar arrows visible
112
+ SCROLL_SLIDER_PADDING = 18 # ScrollBar slider internal padding
113
+ SCROLL_SLIDER_SIZE = 19 # ScrollBar slider size
114
+ SCROLL_PADDING = 20 # ScrollBar scroll padding from arrows
115
+ SCROLL_SPEED = 21 # ScrollBar scrolling speed
103
116
 
104
117
  # enum GuiCheckBoxProperty
105
118
  # CheckBox
@@ -117,12 +130,7 @@ module Raylib
117
130
 
118
131
  # enum GuiTextBoxProperty
119
132
  # TextBox/TextBoxMulti/ValueBox/Spinner
120
- TEXT_INNER_PADDING = 16 # TextBox/TextBoxMulti/ValueBox/Spinner inner text padding
121
- TEXT_LINES_SPACING = 17 # TextBoxMulti lines separation
122
- TEXT_ALIGNMENT_VERTICAL = 18 # TextBoxMulti vertical alignment: 0-CENTERED, 1-UP, 2-DOWN
123
- TEXT_MULTILINE = 19 # TextBox supports multiple lines
124
- TEXT_WRAP_MODE = 20 # TextBox wrap mode for multiline: 0-NO_WRAP, 1-CHAR_WRAP, 2-WORD_WRAP
125
- TEXT_READONLY = 21 # TextBox is readonly, no editable
133
+ TEXT_READONLY = 16 # TextBox in read-only mode: 0-text editable, 1-text no-editable
126
134
 
127
135
  # enum GuiSpinnerProperty
128
136
  # Spinner
@@ -134,7 +142,7 @@ module Raylib
134
142
  LIST_ITEMS_HEIGHT = 16 # ListView items height
135
143
  LIST_ITEMS_SPACING = 17 # ListView items separation
136
144
  SCROLLBAR_WIDTH = 18 # ListView scrollbar size (usually width)
137
- SCROLLBAR_SIDE = 19 # ListView scrollbar side (0-left, 1-right)
145
+ SCROLLBAR_SIDE = 19 # ListView scrollbar side (0-SCROLLBAR_LEFT_SIDE, 1-SCROLLBAR_RIGHT_SIDE)
138
146
 
139
147
  # enum GuiColorPickerProperty
140
148
  # ColorPicker
@@ -408,6 +416,8 @@ module Raylib
408
416
 
409
417
  typedef :int, :GuiState
410
418
  typedef :int, :GuiTextAlignment
419
+ typedef :int, :GuiTextAlignmentVertical
420
+ typedef :int, :GuiTextWrapMode
411
421
  typedef :int, :GuiControl
412
422
  typedef :int, :GuiControlProperty
413
423
  typedef :int, :GuiDefaultProperty
@@ -426,12 +436,12 @@ module Raylib
426
436
 
427
437
  # Struct
428
438
 
429
- # Style property
439
+ # NOTE: Used when exporting style as code for convenience
430
440
  class GuiStyleProp < FFI::Struct
431
441
  layout(
432
- :controlId, :ushort,
433
- :propertyId, :ushort,
434
- :propertyValue, :uint,
442
+ :controlId, :ushort, # Control identifier
443
+ :propertyId, :ushort, # Property identifier
444
+ :propertyValue, :int, # Property value
435
445
  )
436
446
  def controlId = self[:controlId]
437
447
  def controlId=(v) self[:controlId] = v end
@@ -661,6 +671,14 @@ module Raylib
661
671
  # @return [int]
662
672
  [:GuiToggleGroup, :GuiToggleGroup, [Rectangle.by_value, :pointer, :pointer], :int],
663
673
 
674
+ # @!method GuiToggleSlider(bounds, text, active)
675
+ # GuiToggleSlider : Toggle Slider control, returns true when clicked
676
+ # @param bounds [Rectangle]
677
+ # @param text [const char *]
678
+ # @param active [int *]
679
+ # @return [int]
680
+ [:GuiToggleSlider, :GuiToggleSlider, [Rectangle.by_value, :pointer, :pointer], :int],
681
+
664
682
  # @!method GuiCheckBox(bounds, text, checked)
665
683
  # GuiCheckBox : Check Box control, returns true when active
666
684
  # @param bounds [Rectangle]
data/lib/raylib_helper.rb CHANGED
@@ -136,20 +136,32 @@ module Raylib
136
136
  end
137
137
  end
138
138
 
139
- def BoundingBox.create(*args)
140
- case args.size
141
- when 2
142
- instance = BoundingBox.new
143
- instance[:min] = args[0] # min
144
- instance[:max] = args[1] # max
145
- instance
146
- when 6
147
- instance = BoundingBox.new
148
- instance[:min] = Vector3.create(args[0], args[1], args[2]) # min_x, min_y, min_z
149
- instance[:max] = Vector3.create(args[3], args[4], args[5]) # max_x, max_y, max_z
150
- instance
151
- else
152
- raise ArgumentError.new 'BoundingBox.create : Number of arguments must be 2 or 6'
139
+ class BoundingBox
140
+ def self.create(*args)
141
+ case args.size
142
+ when 2
143
+ instance = BoundingBox.new
144
+ instance[:min] = args[0] # min
145
+ instance[:max] = args[1] # max
146
+ instance
147
+ when 6
148
+ instance = BoundingBox.new
149
+ instance[:min] = Vector3.create(args[0], args[1], args[2]) # min_x, min_y, min_z
150
+ instance[:max] = Vector3.create(args[3], args[4], args[5]) # max_x, max_y, max_z
151
+ instance
152
+ else
153
+ raise ArgumentError.new 'BoundingBox.create : Number of arguments must be 2 or 6'
154
+ end
155
+ end
156
+
157
+ def with_min(x, y, z)
158
+ self[:min].set(x, y, z)
159
+ self
160
+ end
161
+
162
+ def with_max(x, y, z)
163
+ self[:max].set(x, y, z)
164
+ self
153
165
  end
154
166
  end
155
167
 
@@ -161,6 +173,59 @@ module Raylib
161
173
  MatrixToFloatV(mat)[:v].to_a
162
174
  end
163
175
 
176
+ #
177
+ # Camera helper
178
+ #
179
+
180
+ class Camera3D
181
+ def with_position(x, y, z)
182
+ self[:position].set(x, y, z)
183
+ self
184
+ end
185
+
186
+ def with_target(x, y, z)
187
+ self[:target].set(x, y, z)
188
+ self
189
+ end
190
+
191
+ def with_up(x, y, z)
192
+ self[:up].set(x, y, z)
193
+ self
194
+ end
195
+
196
+ def with_fovy(fovy)
197
+ self[:fovy] = fovy
198
+ self
199
+ end
200
+
201
+ def with_projection(projection)
202
+ self[:projection] = projection
203
+ self
204
+ end
205
+ end
206
+
207
+ class Camera2D
208
+ def with_offset(x, y)
209
+ self[:offset].set(x, y)
210
+ self
211
+ end
212
+
213
+ def with_target(x, y)
214
+ self[:target].set(x, y)
215
+ self
216
+ end
217
+
218
+ def with_rotation(rotation)
219
+ self[:rotation] = rotation
220
+ self
221
+ end
222
+
223
+ def with_zoom(zoom)
224
+ self[:zoom] = zoom
225
+ self
226
+ end
227
+ end
228
+
164
229
  #
165
230
  # Transform helper
166
231
  #