imgui-bindings 0.1.17-aarch64-linux → 1.0.1-aarch64-linux
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 +14 -0
- data/LICENSE.txt +1 -1
- data/README.md +22 -27
- data/lib/imgui.aarch64.so +0 -0
- data/lib/imgui.rb +13276 -6476
- data/lib/imgui_impl_docking_opengl3.rb +638 -0
- data/lib/imgui_impl_docking_raylib.rb +4 -0
- data/lib/imgui_impl_docking_sdl3.rb +1129 -0
- data/lib/imgui_impl_docking_sdl3renderer.rb +259 -0
- data/lib/imgui_impl_opengl3.rb +302 -200
- data/lib/imgui_impl_raylib.rb +337 -11
- data/lib/imgui_impl_sdl3.rb +599 -0
- data/lib/imgui_impl_sdl3renderer.rb +254 -0
- metadata +26 -13
- data/lib/imgui_impl_glfw.rb +0 -511
- data/lib/imgui_impl_opengl2.rb +0 -212
- data/lib/imgui_impl_sdl2.rb +0 -409
- data/lib/imgui_impl_sdlrenderer.rb +0 -200
- data/lib/imgui_internal.rb +0 -49
- data/lib/imnodes.aarch64.so +0 -0
- data/lib/imnodes.rb +0 -161
data/lib/imgui_impl_raylib.rb
CHANGED
|
@@ -5,17 +5,40 @@ require_relative 'imgui'
|
|
|
5
5
|
|
|
6
6
|
module ImGui
|
|
7
7
|
|
|
8
|
+
CAMERA_MOVE_SPEED = 5.4
|
|
9
|
+
CAMERA_ROTATION_SPEED = 0.03
|
|
10
|
+
CAMERA_PAN_SPEED = 2.0
|
|
11
|
+
CAMERA_MOUSE_MOVE_SENSITIVITY = 0.003
|
|
12
|
+
CAMERA_ORBITAL_SPEED = 0.5
|
|
13
|
+
|
|
8
14
|
@@g_BackendPlatformName = FFI::MemoryPointer.from_string("imgui_impl_raylib")
|
|
15
|
+
@@g_BackendRendererName = FFI::MemoryPointer.from_string("imgui_impl_raylib")
|
|
9
16
|
|
|
10
17
|
# ImGui::GetCurrentContext().address => ImGui_ImplRaylib_Data
|
|
11
18
|
@@g_BackendData = Hash.new
|
|
12
19
|
|
|
13
20
|
# [INTERNAL]
|
|
14
21
|
class ImGui_ImplRaylib_Data
|
|
15
|
-
attr_accessor :time
|
|
22
|
+
attr_accessor :time, :textures, :warned_viewports_unsupported
|
|
16
23
|
|
|
17
24
|
def initialize
|
|
18
25
|
@time = 0.0
|
|
26
|
+
@textures = {}
|
|
27
|
+
@warned_viewports_unsupported = false
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# [INTERNAL]
|
|
32
|
+
def self.ImplRaylib_DisableUnsupportedViewports(io = nil)
|
|
33
|
+
io = ImGuiIO.new(ImGui::GetIO()) if io == nil
|
|
34
|
+
return if (io[:ConfigFlags] & ImGuiConfigFlags_ViewportsEnable) == 0
|
|
35
|
+
|
|
36
|
+
io[:ConfigFlags] &= ~ImGuiConfigFlags_ViewportsEnable
|
|
37
|
+
bd = ImGui_ImplRaylib_GetBackendData()
|
|
38
|
+
if bd != nil && !bd.warned_viewports_unsupported
|
|
39
|
+
# raylib backend currently supports docking in a single OS window only.
|
|
40
|
+
$stderr.puts('[imgui_impl_raylib] ImGuiConfigFlags_ViewportsEnable is not supported and was disabled.')
|
|
41
|
+
bd.warned_viewports_unsupported = true
|
|
19
42
|
end
|
|
20
43
|
end
|
|
21
44
|
|
|
@@ -28,6 +51,89 @@ module ImGui
|
|
|
28
51
|
end
|
|
29
52
|
end
|
|
30
53
|
|
|
54
|
+
# [INTERNAL]
|
|
55
|
+
def self.ImplRaylib_UpdateTexture(tex_raw)
|
|
56
|
+
bd = ImGui_ImplRaylib_GetBackendData()
|
|
57
|
+
return if bd == nil
|
|
58
|
+
|
|
59
|
+
tex = tex_raw.kind_of?(ImTextureData) ? tex_raw : ImTextureData.new(tex_raw)
|
|
60
|
+
|
|
61
|
+
case tex[:Status]
|
|
62
|
+
when ImTextureStatus_WantCreate
|
|
63
|
+
return if tex[:Format] != ImTextureFormat_RGBA32
|
|
64
|
+
|
|
65
|
+
image = Raylib::Image.new
|
|
66
|
+
image[:data] = tex.GetPixels()
|
|
67
|
+
image[:width] = tex[:Width]
|
|
68
|
+
image[:height] = tex[:Height]
|
|
69
|
+
image[:mipmaps] = 1
|
|
70
|
+
image[:format] = Raylib::PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
|
|
71
|
+
|
|
72
|
+
texture = Raylib.LoadTextureFromImage(image)
|
|
73
|
+
raise 'Backend failed to create Raylib texture!' if texture[:id] == 0
|
|
74
|
+
|
|
75
|
+
Raylib.SetTextureFilter(texture, Raylib::TEXTURE_FILTER_BILINEAR)
|
|
76
|
+
Raylib.SetTextureWrap(texture, Raylib::TEXTURE_WRAP_CLAMP)
|
|
77
|
+
|
|
78
|
+
bd.textures[texture[:id]] = texture
|
|
79
|
+
|
|
80
|
+
tex.SetTexID(texture[:id])
|
|
81
|
+
tex.SetStatus(ImTextureStatus_OK)
|
|
82
|
+
|
|
83
|
+
when ImTextureStatus_WantUpdates
|
|
84
|
+
tex_id = tex.GetTexID()
|
|
85
|
+
return if tex_id == 0
|
|
86
|
+
|
|
87
|
+
texture = bd.textures[tex_id]
|
|
88
|
+
if texture == nil
|
|
89
|
+
texture = Raylib::Texture.new
|
|
90
|
+
texture[:id] = tex_id
|
|
91
|
+
texture[:width] = tex[:Width]
|
|
92
|
+
texture[:height] = tex[:Height]
|
|
93
|
+
texture[:mipmaps] = 1
|
|
94
|
+
texture[:format] = Raylib::PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Raylib.UpdateTextureRec has no row-pitch argument, so sub-rect updates
|
|
98
|
+
# sourced from a larger atlas can sample incorrect rows and corrupt glyphs.
|
|
99
|
+
# Uploading the full atlas keeps texture data consistent across backends.
|
|
100
|
+
Raylib.UpdateTexture(texture, tex.GetPixels())
|
|
101
|
+
tex.SetStatus(ImTextureStatus_OK)
|
|
102
|
+
|
|
103
|
+
when ImTextureStatus_WantDestroy
|
|
104
|
+
tex_id = tex.GetTexID()
|
|
105
|
+
if tex_id != 0 && tex[:UnusedFrames] > 0
|
|
106
|
+
texture = bd.textures.delete(tex_id)
|
|
107
|
+
if texture == nil
|
|
108
|
+
texture = Raylib::Texture.new
|
|
109
|
+
texture[:id] = tex_id
|
|
110
|
+
texture[:width] = tex[:Width]
|
|
111
|
+
texture[:height] = tex[:Height]
|
|
112
|
+
texture[:mipmaps] = 1
|
|
113
|
+
texture[:format] = Raylib::PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
Raylib.UnloadTexture(texture)
|
|
117
|
+
tex.SetTexID(0)
|
|
118
|
+
tex.SetStatus(ImTextureStatus_Destroyed)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# [INTERNAL]
|
|
124
|
+
def self.ImplRaylib_ProcessTextureUpdates(draw_data)
|
|
125
|
+
return if draw_data[:Textures] == nil || draw_data[:Textures].address == 0
|
|
126
|
+
|
|
127
|
+
textures = ImVector_ImTextureDataPtr.new(draw_data[:Textures])
|
|
128
|
+
textures[:Size].times do |i|
|
|
129
|
+
tex_ptr = (textures[:Data] + FFI.type_size(:pointer) * i).read_pointer
|
|
130
|
+
next if tex_ptr == nil || tex_ptr.address == 0
|
|
131
|
+
|
|
132
|
+
tex = ImTextureData.new(tex_ptr)
|
|
133
|
+
ImplRaylib_UpdateTexture(tex) if tex[:Status] != ImTextureStatus_OK
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
31
137
|
# [TODO] Support ClipboardText
|
|
32
138
|
# g_ClipboardTextData
|
|
33
139
|
# ImplRaylib_GetClipboardText
|
|
@@ -203,7 +309,7 @@ module ImGui
|
|
|
203
309
|
when Raylib::KEY_RIGHT_SHIFT then ImGuiKey_RightShift
|
|
204
310
|
when Raylib::KEY_RIGHT_ALT then ImGuiKey_RightAlt
|
|
205
311
|
when Raylib::KEY_RIGHT_SUPER then ImGuiKey_RightSuper
|
|
206
|
-
when Raylib::
|
|
312
|
+
when Raylib::KEY_KB_MENU then ImGuiKey_Menu
|
|
207
313
|
when Raylib::KEY_ZERO then ImGuiKey_0
|
|
208
314
|
when Raylib::KEY_ONE then ImGuiKey_1
|
|
209
315
|
when Raylib::KEY_TWO then ImGuiKey_2
|
|
@@ -289,7 +395,6 @@ module ImGui
|
|
|
289
395
|
|
|
290
396
|
# [INTERNAL]
|
|
291
397
|
def self.ImplRaylib_UpdateMouseData()
|
|
292
|
-
bd = ImGui_ImplRaylib_GetBackendData()
|
|
293
398
|
io = ImGuiIO.new(ImGui::GetIO())
|
|
294
399
|
|
|
295
400
|
# Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
|
@@ -335,17 +440,176 @@ module ImGui
|
|
|
335
440
|
# [TODO] Support ImplRaylib_UpdateGamepads
|
|
336
441
|
#
|
|
337
442
|
|
|
443
|
+
# [INTERNAL]
|
|
444
|
+
def self.ImplRaylib_CameraPointer(camera)
|
|
445
|
+
if camera.kind_of?(FFI::Pointer)
|
|
446
|
+
camera
|
|
447
|
+
elsif camera.respond_to?(:pointer)
|
|
448
|
+
camera.pointer
|
|
449
|
+
else
|
|
450
|
+
raise ArgumentError, 'camera must be Raylib::Camera (FFI::Struct) or FFI::Pointer'
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
# ImGui-aware UpdateCamera implementation in Ruby.
|
|
455
|
+
# Unlike Raylib.UpdateCamera(), this checks io[:WantCaptureMouse]/io[:WantCaptureKeyboard]
|
|
456
|
+
# and avoids camera control while ImGui is consuming corresponding inputs.
|
|
457
|
+
def self.ImplRaylib_UpdateCamera(camera, mode)
|
|
458
|
+
camera_ptr = ImplRaylib_CameraPointer(camera)
|
|
459
|
+
io = ImGuiIO.new(ImGui::GetIO())
|
|
460
|
+
|
|
461
|
+
mouse_position_delta = Raylib.GetMouseDelta()
|
|
462
|
+
|
|
463
|
+
move_in_world_plane = (mode == Raylib::CAMERA_FIRST_PERSON) || (mode == Raylib::CAMERA_THIRD_PERSON)
|
|
464
|
+
rotate_around_target = (mode == Raylib::CAMERA_THIRD_PERSON) || (mode == Raylib::CAMERA_ORBITAL)
|
|
465
|
+
lock_view = (mode == Raylib::CAMERA_FREE) || (mode == Raylib::CAMERA_FIRST_PERSON) || (mode == Raylib::CAMERA_THIRD_PERSON) || (mode == Raylib::CAMERA_ORBITAL)
|
|
466
|
+
rotate_up = false
|
|
467
|
+
|
|
468
|
+
frame_time = Raylib.GetFrameTime()
|
|
469
|
+
camera_move_speed = CAMERA_MOVE_SPEED * frame_time
|
|
470
|
+
camera_rotation_speed = CAMERA_ROTATION_SPEED * frame_time
|
|
471
|
+
camera_pan_speed = CAMERA_PAN_SPEED * frame_time
|
|
472
|
+
camera_orbital_speed = CAMERA_ORBITAL_SPEED * frame_time
|
|
473
|
+
|
|
474
|
+
wants_mouse = io[:WantCaptureMouse]
|
|
475
|
+
wants_keyboard = io[:WantCaptureKeyboard]
|
|
476
|
+
any_imgui_window_focused = false
|
|
477
|
+
begin
|
|
478
|
+
any_imgui_window_focused = ImGui.IsWindowFocused(ImGuiFocusedFlags_AnyWindow)
|
|
479
|
+
rescue StandardError
|
|
480
|
+
# Keep backward compatibility with older bindings.
|
|
481
|
+
any_imgui_window_focused = false
|
|
482
|
+
end
|
|
483
|
+
block_keyboard_controls = wants_keyboard || any_imgui_window_focused
|
|
484
|
+
|
|
485
|
+
if mode == Raylib::CAMERA_CUSTOM
|
|
486
|
+
# no-op
|
|
487
|
+
elsif mode == Raylib::CAMERA_ORBITAL
|
|
488
|
+
rotation = Raylib.MatrixRotate(Raylib.GetCameraUp(camera_ptr), camera_orbital_speed)
|
|
489
|
+
view = Raylib.Vector3Subtract(Raylib::Camera.new(camera_ptr)[:position], Raylib::Camera.new(camera_ptr)[:target])
|
|
490
|
+
view = Raylib.Vector3Transform(view, rotation)
|
|
491
|
+
camera_data = Raylib::Camera.new(camera_ptr)
|
|
492
|
+
camera_data[:position] = Raylib.Vector3Add(camera_data[:target], view)
|
|
493
|
+
else
|
|
494
|
+
if !block_keyboard_controls
|
|
495
|
+
if Raylib.IsKeyDown(Raylib::KEY_DOWN)
|
|
496
|
+
Raylib.CameraPitch(camera_ptr, -camera_rotation_speed, lock_view, rotate_around_target, rotate_up)
|
|
497
|
+
end
|
|
498
|
+
if Raylib.IsKeyDown(Raylib::KEY_UP)
|
|
499
|
+
Raylib.CameraPitch(camera_ptr, camera_rotation_speed, lock_view, rotate_around_target, rotate_up)
|
|
500
|
+
end
|
|
501
|
+
if Raylib.IsKeyDown(Raylib::KEY_RIGHT)
|
|
502
|
+
Raylib.CameraYaw(camera_ptr, -camera_rotation_speed, rotate_around_target)
|
|
503
|
+
end
|
|
504
|
+
if Raylib.IsKeyDown(Raylib::KEY_LEFT)
|
|
505
|
+
Raylib.CameraYaw(camera_ptr, camera_rotation_speed, rotate_around_target)
|
|
506
|
+
end
|
|
507
|
+
if Raylib.IsKeyDown(Raylib::KEY_Q)
|
|
508
|
+
Raylib.CameraRoll(camera_ptr, -camera_rotation_speed)
|
|
509
|
+
end
|
|
510
|
+
if Raylib.IsKeyDown(Raylib::KEY_E)
|
|
511
|
+
Raylib.CameraRoll(camera_ptr, camera_rotation_speed)
|
|
512
|
+
end
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
if !wants_mouse
|
|
516
|
+
if (mode == Raylib::CAMERA_FREE) && Raylib.IsMouseButtonDown(Raylib::MOUSE_BUTTON_MIDDLE)
|
|
517
|
+
mouse_delta = Raylib.GetMouseDelta()
|
|
518
|
+
if mouse_delta[:x] > 0.0
|
|
519
|
+
Raylib.CameraMoveRight(camera_ptr, camera_pan_speed, move_in_world_plane)
|
|
520
|
+
end
|
|
521
|
+
if mouse_delta[:x] < 0.0
|
|
522
|
+
Raylib.CameraMoveRight(camera_ptr, -camera_pan_speed, move_in_world_plane)
|
|
523
|
+
end
|
|
524
|
+
if mouse_delta[:y] > 0.0
|
|
525
|
+
Raylib.CameraMoveUp(camera_ptr, -camera_pan_speed)
|
|
526
|
+
end
|
|
527
|
+
if mouse_delta[:y] < 0.0
|
|
528
|
+
Raylib.CameraMoveUp(camera_ptr, camera_pan_speed)
|
|
529
|
+
end
|
|
530
|
+
else
|
|
531
|
+
Raylib.CameraYaw(camera_ptr, -mouse_position_delta[:x] * CAMERA_MOUSE_MOVE_SENSITIVITY, rotate_around_target)
|
|
532
|
+
Raylib.CameraPitch(camera_ptr, -mouse_position_delta[:y] * CAMERA_MOUSE_MOVE_SENSITIVITY, lock_view, rotate_around_target, rotate_up)
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
if !block_keyboard_controls
|
|
537
|
+
if Raylib.IsKeyDown(Raylib::KEY_W)
|
|
538
|
+
Raylib.CameraMoveForward(camera_ptr, camera_move_speed, move_in_world_plane)
|
|
539
|
+
end
|
|
540
|
+
if Raylib.IsKeyDown(Raylib::KEY_A)
|
|
541
|
+
Raylib.CameraMoveRight(camera_ptr, -camera_move_speed, move_in_world_plane)
|
|
542
|
+
end
|
|
543
|
+
if Raylib.IsKeyDown(Raylib::KEY_S)
|
|
544
|
+
Raylib.CameraMoveForward(camera_ptr, -camera_move_speed, move_in_world_plane)
|
|
545
|
+
end
|
|
546
|
+
if Raylib.IsKeyDown(Raylib::KEY_D)
|
|
547
|
+
Raylib.CameraMoveRight(camera_ptr, camera_move_speed, move_in_world_plane)
|
|
548
|
+
end
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
if Raylib.IsGamepadAvailable(0)
|
|
552
|
+
Raylib.CameraYaw(camera_ptr, -(Raylib.GetGamepadAxisMovement(0, Raylib::GAMEPAD_AXIS_RIGHT_X) * 2.0) * CAMERA_MOUSE_MOVE_SENSITIVITY, rotate_around_target)
|
|
553
|
+
Raylib.CameraPitch(camera_ptr, -(Raylib.GetGamepadAxisMovement(0, Raylib::GAMEPAD_AXIS_RIGHT_Y) * 2.0) * CAMERA_MOUSE_MOVE_SENSITIVITY, lock_view, rotate_around_target, rotate_up)
|
|
554
|
+
|
|
555
|
+
if Raylib.GetGamepadAxisMovement(0, Raylib::GAMEPAD_AXIS_LEFT_Y) <= -0.25
|
|
556
|
+
Raylib.CameraMoveForward(camera_ptr, camera_move_speed, move_in_world_plane)
|
|
557
|
+
end
|
|
558
|
+
if Raylib.GetGamepadAxisMovement(0, Raylib::GAMEPAD_AXIS_LEFT_X) <= -0.25
|
|
559
|
+
Raylib.CameraMoveRight(camera_ptr, -camera_move_speed, move_in_world_plane)
|
|
560
|
+
end
|
|
561
|
+
if Raylib.GetGamepadAxisMovement(0, Raylib::GAMEPAD_AXIS_LEFT_Y) >= 0.25
|
|
562
|
+
Raylib.CameraMoveForward(camera_ptr, -camera_move_speed, move_in_world_plane)
|
|
563
|
+
end
|
|
564
|
+
if Raylib.GetGamepadAxisMovement(0, Raylib::GAMEPAD_AXIS_LEFT_X) >= 0.25
|
|
565
|
+
Raylib.CameraMoveRight(camera_ptr, camera_move_speed, move_in_world_plane)
|
|
566
|
+
end
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
if mode == Raylib::CAMERA_FREE && !block_keyboard_controls
|
|
570
|
+
if Raylib.IsKeyDown(Raylib::KEY_SPACE)
|
|
571
|
+
Raylib.CameraMoveUp(camera_ptr, camera_move_speed)
|
|
572
|
+
end
|
|
573
|
+
if Raylib.IsKeyDown(Raylib::KEY_LEFT_CONTROL)
|
|
574
|
+
Raylib.CameraMoveUp(camera_ptr, -camera_move_speed)
|
|
575
|
+
end
|
|
576
|
+
end
|
|
577
|
+
end
|
|
578
|
+
|
|
579
|
+
if ((mode == Raylib::CAMERA_THIRD_PERSON) || (mode == Raylib::CAMERA_ORBITAL) || (mode == Raylib::CAMERA_FREE)) && !wants_mouse
|
|
580
|
+
Raylib.CameraMoveToTarget(camera_ptr, -Raylib.GetMouseWheelMove())
|
|
581
|
+
if Raylib.IsKeyPressed(Raylib::KEY_KP_SUBTRACT)
|
|
582
|
+
Raylib.CameraMoveToTarget(camera_ptr, 2.0)
|
|
583
|
+
end
|
|
584
|
+
if Raylib.IsKeyPressed(Raylib::KEY_KP_ADD)
|
|
585
|
+
Raylib.CameraMoveToTarget(camera_ptr, -2.0)
|
|
586
|
+
end
|
|
587
|
+
end
|
|
588
|
+
end
|
|
589
|
+
|
|
338
590
|
def self.ImplRaylib_Init()
|
|
339
591
|
# Setup backend capabilities flags
|
|
340
592
|
bd = ImGui_ImplRaylib_Data.new
|
|
341
593
|
@@g_BackendData[ImGui::GetCurrentContext().address] = bd
|
|
342
594
|
|
|
343
595
|
io = ImGuiIO.new(ImGui::GetIO())
|
|
596
|
+
platform_io = ImGuiPlatformIO.new(ImGui::GetPlatformIO())
|
|
344
597
|
|
|
345
598
|
io[:BackendPlatformUserData] = nil
|
|
346
599
|
io[:BackendPlatformName] = @@g_BackendPlatformName
|
|
600
|
+
io[:BackendRendererUserData] = nil
|
|
601
|
+
io[:BackendRendererName] = @@g_BackendRendererName
|
|
347
602
|
io[:BackendFlags] |= ImGuiBackendFlags_HasMouseCursors # We can honor GetMouseCursor() values (optional)
|
|
348
603
|
io[:BackendFlags] |= ImGuiBackendFlags_HasSetMousePos # We can honor io.WantSetMousePos requests (optional, rarely used)
|
|
604
|
+
io[:BackendFlags] |= ImGuiBackendFlags_RendererHasVtxOffset
|
|
605
|
+
io[:BackendFlags] |= ImGuiBackendFlags_RendererHasTextures
|
|
606
|
+
io[:BackendFlags] &= ~(ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_RendererHasViewports)
|
|
607
|
+
|
|
608
|
+
ImplRaylib_DisableUnsupportedViewports(io)
|
|
609
|
+
|
|
610
|
+
# Conservative limit suitable for most GL backends used by raylib.
|
|
611
|
+
platform_io[:Renderer_TextureMaxWidth] = 8192
|
|
612
|
+
platform_io[:Renderer_TextureMaxHeight] = 8192
|
|
349
613
|
|
|
350
614
|
bd.time = 0.0
|
|
351
615
|
|
|
@@ -353,10 +617,32 @@ module ImGui
|
|
|
353
617
|
end
|
|
354
618
|
|
|
355
619
|
def self.ImplRaylib_Shutdown()
|
|
620
|
+
bd = ImGui_ImplRaylib_GetBackendData()
|
|
356
621
|
io = ImGuiIO.new(ImGui::GetIO())
|
|
622
|
+
platform_io = ImGuiPlatformIO.new(ImGui::GetPlatformIO())
|
|
623
|
+
|
|
624
|
+
if bd != nil
|
|
625
|
+
bd.textures.each_value do |texture|
|
|
626
|
+
Raylib.UnloadTexture(texture) if texture != nil && texture[:id] != 0
|
|
627
|
+
end
|
|
628
|
+
bd.textures.clear
|
|
629
|
+
end
|
|
630
|
+
|
|
357
631
|
io[:BackendPlatformName] = nil
|
|
358
632
|
io[:BackendPlatformUserData] = nil
|
|
359
|
-
|
|
633
|
+
io[:BackendRendererName] = nil
|
|
634
|
+
io[:BackendRendererUserData] = nil
|
|
635
|
+
io[:BackendFlags] &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_RendererHasViewports)
|
|
636
|
+
|
|
637
|
+
begin
|
|
638
|
+
platform_io.ClearRendererHandlers()
|
|
639
|
+
rescue StandardError
|
|
640
|
+
# Older generated bindings may not expose this helper.
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
if ImGui::GetCurrentContext() != nil
|
|
644
|
+
@@g_BackendData.delete(ImGui::GetCurrentContext().address)
|
|
645
|
+
end
|
|
360
646
|
end
|
|
361
647
|
|
|
362
648
|
def self.ImplRaylib_NewFrame()
|
|
@@ -373,6 +659,8 @@ module ImGui
|
|
|
373
659
|
io[:DeltaTime] = bd.time > 0 ? (current_time - bd.time).to_f : 1.0 / 60.0
|
|
374
660
|
bd.time = current_time
|
|
375
661
|
|
|
662
|
+
ImplRaylib_DisableUnsupportedViewports(io)
|
|
663
|
+
|
|
376
664
|
ImplRaylib_ProcessKeyboard()
|
|
377
665
|
ImplRaylib_UpdateMouseData()
|
|
378
666
|
ImplRaylib_UpdateMouseCursor()
|
|
@@ -389,9 +677,17 @@ module ImGui
|
|
|
389
677
|
|
|
390
678
|
def self.ImplRaylib_RenderDrawData(draw_data_raw)
|
|
391
679
|
draw_data = ImDrawData.new(draw_data_raw)
|
|
680
|
+
|
|
681
|
+
fb_width = (draw_data[:DisplaySize][:x] * draw_data[:FramebufferScale][:x]).to_i
|
|
682
|
+
fb_height = (draw_data[:DisplaySize][:y] * draw_data[:FramebufferScale][:y]).to_i
|
|
683
|
+
return if fb_width <= 0 || fb_height <= 0
|
|
684
|
+
|
|
685
|
+
ImplRaylib_ProcessTextureUpdates(draw_data)
|
|
686
|
+
|
|
392
687
|
Raylib.rlDisableBackfaceCulling()
|
|
393
688
|
|
|
394
689
|
clip_offset = draw_data[:DisplayPos]
|
|
690
|
+
clip_scale = draw_data[:FramebufferScale]
|
|
395
691
|
draw_data[:CmdListsCount].times do |n|
|
|
396
692
|
cmd_list = ImDrawList.new((draw_data[:CmdLists][:Data] + FFI.type_size(:pointer) * n).read_pointer)
|
|
397
693
|
vtx_buffer = cmd_list[:VtxBuffer][:Data] # const ImDrawVert*
|
|
@@ -402,15 +698,21 @@ module ImGui
|
|
|
402
698
|
if pcmd[:UserCallback] != nil
|
|
403
699
|
# [TODO] Handle user callback (Ref.: https://github.com/ffi/ffi/wiki/Callbacks )
|
|
404
700
|
else
|
|
405
|
-
rect_min_x = (pcmd[:ClipRect][:x] - clip_offset[:x])
|
|
406
|
-
rect_min_y = (pcmd[:ClipRect][:y] - clip_offset[:y])
|
|
407
|
-
rect_max_x = (pcmd[:ClipRect][:z] - clip_offset[:x])
|
|
408
|
-
rect_max_y = (pcmd[:ClipRect][:w] - clip_offset[:y])
|
|
701
|
+
rect_min_x = (pcmd[:ClipRect][:x] - clip_offset[:x]) * clip_scale[:x]
|
|
702
|
+
rect_min_y = (pcmd[:ClipRect][:y] - clip_offset[:y]) * clip_scale[:y]
|
|
703
|
+
rect_max_x = (pcmd[:ClipRect][:z] - clip_offset[:x]) * clip_scale[:x]
|
|
704
|
+
rect_max_y = (pcmd[:ClipRect][:w] - clip_offset[:y]) * clip_scale[:y]
|
|
705
|
+
|
|
706
|
+
rect_min_x = 0.0 if rect_min_x < 0.0
|
|
707
|
+
rect_min_y = 0.0 if rect_min_y < 0.0
|
|
708
|
+
rect_max_x = fb_width.to_f if rect_max_x > fb_width
|
|
709
|
+
rect_max_y = fb_height.to_f if rect_max_y > fb_height
|
|
710
|
+
next if rect_max_x <= rect_min_x || rect_max_y <= rect_min_y
|
|
409
711
|
|
|
410
712
|
rect_w = rect_max_x - rect_min_x
|
|
411
713
|
rect_h = rect_max_y - rect_min_y
|
|
412
714
|
|
|
413
|
-
Raylib.BeginScissorMode(rect_min_x, rect_min_y, rect_w, rect_h)
|
|
715
|
+
Raylib.BeginScissorMode(rect_min_x.to_i, rect_min_y.to_i, rect_w.to_i, rect_h.to_i)
|
|
414
716
|
|
|
415
717
|
# Render triangles
|
|
416
718
|
indices = idx_buffer + FFI.type_size(:ImDrawIdx) * pcmd[:IdxOffset]
|
|
@@ -418,8 +720,7 @@ module ImGui
|
|
|
418
720
|
0.step(pcmd[:ElemCount] - 3, 3) do |i|
|
|
419
721
|
Raylib.rlPushMatrix()
|
|
420
722
|
Raylib.rlBegin(Raylib::RL_TRIANGLES)
|
|
421
|
-
|
|
422
|
-
Raylib.rlSetTexture(pcmd[:TextureId])
|
|
723
|
+
Raylib.rlSetTexture(pcmd.GetTexID())
|
|
423
724
|
|
|
424
725
|
index = indices.get_array_of_uint16(i * FFI::type_size(:ImDrawIdx), 3)
|
|
425
726
|
|
|
@@ -452,4 +753,29 @@ module ImGui
|
|
|
452
753
|
Raylib.rlEnableBackfaceCulling()
|
|
453
754
|
end
|
|
454
755
|
|
|
756
|
+
# Docking-compatible wrapper API (single viewport only)
|
|
757
|
+
def self.ImplDockingRaylib_Init()
|
|
758
|
+
ImplRaylib_Init()
|
|
759
|
+
end
|
|
760
|
+
|
|
761
|
+
# Docking-compatible wrapper API (single viewport only)
|
|
762
|
+
def self.ImplDockingRaylib_Shutdown()
|
|
763
|
+
ImplRaylib_Shutdown()
|
|
764
|
+
end
|
|
765
|
+
|
|
766
|
+
# Docking-compatible wrapper API (single viewport only)
|
|
767
|
+
def self.ImplDockingRaylib_NewFrame()
|
|
768
|
+
ImplRaylib_NewFrame()
|
|
769
|
+
end
|
|
770
|
+
|
|
771
|
+
# Docking-compatible wrapper API (single viewport only)
|
|
772
|
+
def self.ImplDockingRaylib_RenderDrawData(draw_data_raw)
|
|
773
|
+
ImplRaylib_RenderDrawData(draw_data_raw)
|
|
774
|
+
end
|
|
775
|
+
|
|
776
|
+
# Docking-compatible wrapper API (single viewport only)
|
|
777
|
+
def self.ImplDockingRaylib_UpdateCamera(camera, mode)
|
|
778
|
+
ImplRaylib_UpdateCamera(camera, mode)
|
|
779
|
+
end
|
|
780
|
+
|
|
455
781
|
end
|