From e79a3181dc9a64232ead448946c70dabb35d5b30 Mon Sep 17 00:00:00 2001 From: Arthur Vimond Date: Mon, 6 Oct 2025 23:31:54 +0200 Subject: [PATCH] [orx-syphon] Fix wrong Syphon resolution with alternate RenderTarget (#378) --- .../src/demo/kotlin/DemoServer02.kt | 44 +++++++++++++++++++ .../ServerExampleAlternateRenderTarget.kt | 36 --------------- .../src/main/kotlin/SyphonServer.kt | 12 ++--- 3 files changed, 51 insertions(+), 41 deletions(-) create mode 100644 orx-jvm/orx-syphon/src/demo/kotlin/DemoServer02.kt delete mode 100644 orx-jvm/orx-syphon/src/demo/kotlin/ServerExampleAlternateRenderTarget.kt diff --git a/orx-jvm/orx-syphon/src/demo/kotlin/DemoServer02.kt b/orx-jvm/orx-syphon/src/demo/kotlin/DemoServer02.kt new file mode 100644 index 00000000..b6c8a796 --- /dev/null +++ b/orx-jvm/orx-syphon/src/demo/kotlin/DemoServer02.kt @@ -0,0 +1,44 @@ +import jsyphon.SyphonServer +import org.openrndr.application +import org.openrndr.color.ColorRGBa +import org.openrndr.draw.isolatedWithTarget +import org.openrndr.draw.renderTarget +import kotlin.math.abs +import kotlin.math.cos +import kotlin.math.sin + +/* This demo uses an alternate RenderTarget to send frames to Syphon (instead of the entire screen). +* */ +fun main() { + // force to use GL driver + System.setProperty("org.openrndr.gl3.gl_type", "gl") + application { + configure { + width = 1000 + height = 1000 + } + + program { + val rt = renderTarget(100, 100) { + colorBuffer() + } + + // You can give the server a different name + extend(SyphonServer("Test", rt)) + + extend { + /** + * This is what will be sent to Syphon, and drawn in a small corner of the screen + */ + drawer.isolatedWithTarget(rt) { + drawer.clear(ColorRGBa(sin(seconds), cos(seconds / 2.0), 0.5, 1.0)) + } + + drawer.clear(ColorRGBa.PINK) + drawer.fill = ColorRGBa.WHITE + drawer.circle(drawer.bounds.center, abs(cos(seconds)) * height * 0.5) + drawer.image(rt.colorBuffer(0)) + } + } + } +} \ No newline at end of file diff --git a/orx-jvm/orx-syphon/src/demo/kotlin/ServerExampleAlternateRenderTarget.kt b/orx-jvm/orx-syphon/src/demo/kotlin/ServerExampleAlternateRenderTarget.kt deleted file mode 100644 index 53e25761..00000000 --- a/orx-jvm/orx-syphon/src/demo/kotlin/ServerExampleAlternateRenderTarget.kt +++ /dev/null @@ -1,36 +0,0 @@ -//import org.openrndr.application -//import org.openrndr.color.ColorRGBa -//import org.openrndr.draw.isolatedWithTarget -//import org.openrndr.draw.renderTarget -//import org.openrndr.extra.syphon.SyphonServer -//import kotlin.math.* -// -//fun main() = application { -// configure { -// width = 1000 -// height = 1000 -// } -// -// program { -// val rt = renderTarget(100, 100) { -// colorBuffer() -// } -// -// // You can give the server a different name -// extend(SyphonServer("Test", rt)) -// -// extend { -// /** -// * This is what will be sent to Syphon, and drawn in a small corner of the screen -// */ -// drawer.isolatedWithTarget(rt) { -// drawer.clear(ColorRGBa(sin(seconds), cos(seconds / 2.0), 0.5, 1.0)) -// } -// -// drawer.clear(ColorRGBa.PINK) -// drawer.fill = ColorRGBa.WHITE -// drawer.circle(drawer.bounds.center, abs(cos(seconds)) * height * 0.5) -// drawer.image(rt.colorBuffer(0)) -// } -// } -//} \ No newline at end of file diff --git a/orx-jvm/orx-syphon/src/main/kotlin/SyphonServer.kt b/orx-jvm/orx-syphon/src/main/kotlin/SyphonServer.kt index 1c5cb4a6..c0dd9b32 100644 --- a/orx-jvm/orx-syphon/src/main/kotlin/SyphonServer.kt +++ b/orx-jvm/orx-syphon/src/main/kotlin/SyphonServer.kt @@ -53,11 +53,13 @@ class SyphonServer(private val name: String = "OPENRNDR", var providedTarget: Re val glBuffer = targetToSend?.colorBuffer(0) as ColorBufferGL3 - // Send to Syphon - server.publishFrameTexture( - glBuffer.texture, glBuffer.target, 0, 0, - program.width, program.height, program.width, program.height, false - ) + targetToSend?.let { targetToSend -> + // Send to Syphon + server.publishFrameTexture( + glBuffer.texture, glBuffer.target, 0, 0, + targetToSend.width, targetToSend.height, targetToSend.width, targetToSend.height, false + ) + } } override fun shutdown(program: Program) {