This commit is contained in:
立音喵 2025-01-11 02:29:03 +08:00 committed by GitHub
commit c28dfb1255
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 202 additions and 55 deletions

77
addons/spout-gd/README.md Normal file
View file

@ -0,0 +1,77 @@
# Spout GD
[Godot](https://github.com/godotengine/godot) 4.2.1 bindings for [Spout](https://github.com/leadedge/Spout2).
The Godot 3 engine module is located on the `godot-3` branch.
Precompiled builds of the plugin can be found in the [releases](../../releases/tag/latest) section of github.
## Status
The sender/receiver apis have been implemented. Please open an issue if something doesn't seem to work.
## Building
Prerequisites:
* Windows (Spout only works on Windows)
* git
* bash
* scons
* a C++ compiler capable of [compiling Godot](https://docs.godotengine.org/en/stable/contributing/development/compiling/compiling_for_windows.html)
* cmake
Clone the repository: `git clone --recurse-submodules https://github.com/you-win/spout-gd.git`
Run `build.sh` in a bash-compatible terminal. This will:
* Compile Spout2
* Compile the gdextension bindings
* Compile spout-gd
Once compilation is finished, the following files should be moved to your project's `addons/spout-gd` folder (create it manually if it does not exist):
* `spout_gd.gdextension`
* `Spout2/Binaries/x64/SpoutLibrary.dll`
* `out/spout_gd.windows.template_debug.dll`
* `out/spout_gd.windows.template_release.dll`
Like this:
```
Godot_project_root
├───addons
│ ├───spout-gd
│ │ ├───SpoutLibrary.dll
│ │ ├───spout_gd.gdextension
│ │ ├───spout_gd.windows.template_debug.dll
│ │ ├───spout_gd.windows.template_release.dll
```
## Basic usage
```gdscript
var spout: Spout
var my_image: Image = load_from_somewhere_idk() # Provide your own image somehow
func _ready():
spout = Spout.new()
spout.send_image(my_image, image.get_width(), image.get_height())
```
## SpoutTexture - Simple Receiving
Provided as a convenience is a Texture resource for receiving streams from a Spout sender. You can use this any place you can use any other kind of Texture, including places like UI elements and Materials on 3D objects.
The sender is polled per render cycle.
<img src="https://github.com/erodozer/spout-gd/assets/316728/989389ab-23ed-4ae0-8ccc-ca9ba51f6346" width=400>
<img src="https://github.com/erodozer/spout-gd/assets/316728/dab4ed75-e046-4197-be50-5d634216b7c2" width=600>
## SpoutViewport - Simple Sending
By wrapping the scene you wish to render in a SpoutViewport, you can easily send render target contents over Spout. Simply use it the same way as you would a SubViewport, and assign a sender name for it to assume.
The SpoutViewport is designed to only send during application run time, not within the editor. This helps prevent creating multiple senders with the same name during testing, allowing for more stable capture.
<img src="https://github.com/erodozer/spout-gd/assets/316728/08a021a6-eaab-408e-9961-51adac31e958" width=800>

Binary file not shown.

View file

@ -0,0 +1,11 @@
[configuration]
entry_symbol = "spout_gd_library_init"
compatibility_minimum = 4.2
[libraries]
windows.debug.x86_64 = "res://addons/spout-gd/spout_gd.windows.template_debug.dll"
windows.release.x86_64 = "res://addons/spout-gd/spout_gd.windows.template_release.dll"
[dependencies]
windows.debug = {"res://addons/spout-gd/SpoutLibrary.dll":""}
windows.release= {"res://addons/spout-gd/SpoutLibrary.dll":""}

Binary file not shown.

Binary file not shown.

19
main_scenes/Spout.gd Normal file
View file

@ -0,0 +1,19 @@
extends Node
var spout: Spout
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
spout = Spout.new()
spout.set_sender_name("PNGTuber")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
var sub_viewport = get_tree().root.get_node("Main").get_node('SpoutViewport');
if sub_viewport:
#sub_viewport.size = get_viewport().get_texture().get_size()
var texture = sub_viewport.get_texture()
var image = texture.get_image()
image.flip_y()
spout.send_image(image, texture.get_width(), texture.get_height())

View file

@ -3,7 +3,7 @@ extends Node2D
var editMode = true
#Node Reference
@onready var origin = $OriginMotion/Origin
@onready var origin = $SpoutViewport/OriginMotion/Origin
@onready var camera = $Camera2D
@onready var controlPanel = $ControlPanel
@onready var editControls = $EditControls
@ -306,7 +306,8 @@ func _on_load_dialog_file_selected(path):
origin.queue_free()
var new = Node2D.new()
$OriginMotion.add_child(new)
var originMotion = $SpoutViewport/OriginMotion
originMotion.add_child(new)
origin = new
for item in data:

File diff suppressed because one or more lines are too long

View file

@ -12,7 +12,7 @@ config_version=5
config/name="PNGTuberPlus"
run/main_scene="res://main_scenes/main.tscn"
config/features=PackedStringArray("4.1", "GL Compatibility")
config/features=PackedStringArray("4.3", "GL Compatibility")
run/max_fps=60
boot_splash/bg_color=Color(0.0313726, 0.0313726, 0.0313726, 1)
boot_splash/image="res://splash.png"
@ -65,79 +65,79 @@ mouse_left={
}
origin={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":79,"key_label":0,"unicode":111,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":79,"key_label":0,"unicode":111,"location":0,"echo":false,"script":null)
]
}
move_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
]
}
move_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
]
}
move_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
]
}
move_down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
]
}
reparent={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":80,"key_label":0,"unicode":112,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":80,"key_label":0,"unicode":112,"location":0,"echo":false,"script":null)
]
}
zDown={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":113,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":113,"location":0,"echo":false,"script":null)
]
}
zUp={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
]
}
openFolder={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
scrollUp={
"deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":4,"canceled":false,"pressed":false,"double_click":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
scrollDown={
"deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"canceled":false,"pressed":false,"double_click":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
refresh={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null)
]
}
unlink={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":85,"key_label":0,"unicode":117,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":85,"key_label":0,"unicode":117,"location":0,"echo":false,"script":null)
]
}
control={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
saveImages={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"location":0,"echo":false,"script":null)
]
}

View file

@ -4,20 +4,25 @@
[ext_resource type="Texture2D" uid="uid://b0qvkbedini2y" path="res://ui_scenes/selectedSprite/origin.png" id="4_i4lmg"]
[node name="Sprite" type="Node2D" groups=["saved"]]
visibility_layer = 3
script = ExtResource("1_r8clt")
[node name="WobbleOrigin" type="Node2D" parent="."]
visibility_layer = 3
[node name="Dragger" type="Node2D" parent="WobbleOrigin"]
top_level = true
[node name="DragOrigin" type="Node2D" parent="WobbleOrigin"]
visibility_layer = 3
[node name="Sprite" type="Sprite2D" parent="WobbleOrigin/DragOrigin"]
visibility_layer = 3
z_as_relative = false
texture_repeat = 1
[node name="Origin" type="Sprite2D" parent="WobbleOrigin/DragOrigin/Sprite"]
visibility_layer = 3
z_index = 2100
position = Vector2(-16, -16)
texture = ExtResource("4_i4lmg")