Pixel-Composer/scripts/node_spout_send/node_spout_send.gml

38 lines
1.0 KiB
Plaintext
Raw Normal View History

2023-12-18 04:40:21 +01:00
function Node_Spout_Send(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Spout Send";
2024-08-08 06:57:51 +02:00
inputs[0] = nodeValue_Text("Sender name", self, "PixelComposer");
2023-12-18 04:40:21 +01:00
2024-08-08 06:57:51 +02:00
inputs[1] = nodeValue_Surface("Surface", self);
2023-12-18 04:40:21 +01:00
2024-08-08 06:57:51 +02:00
outputs[0] = nodeValue_Output("Surface", self, VALUE_TYPE.surface, noone)
2023-12-18 04:40:21 +01:00
.setVisible(false);
spoutIndex = spoutSenderInit();
2024-06-26 06:38:57 +02:00
if(spoutIndex == noone) {
var _txt = "Spout initialize error";
logNode(_txt); noti_warning(_txt);
}
2023-12-18 04:40:21 +01:00
surf_buff = buffer_create(1, buffer_grow, 1);
static update = function() { #region
if(spoutIndex == noone) return;
2024-08-08 06:57:51 +02:00
var _name = inputs[0].getValue();
var _surf = inputs[1].getValue();
2023-12-18 04:40:21 +01:00
if(!is_surface(_surf)) return;
var _sw = surface_get_width_safe(_surf);
var _sh = surface_get_height_safe(_surf);
buffer_resize(surf_buff, _sw * _sh * 4);
buffer_get_surface(surf_buff, _surf, 0);
spoutSetSenderName(spoutIndex, _name);
spoutSendPixels(spoutIndex, buffer_get_address(surf_buff), _sw, _sh);
2024-08-08 06:57:51 +02:00
outputs[0].setValue(_surf);
2023-12-18 04:40:21 +01:00
} #endregion
}