[orx-syphon] Fix wrong Syphon resolution with alternate RenderTarget (#378)

This commit is contained in:
Arthur Vimond
2025-10-06 23:31:54 +02:00
committed by GitHub
parent bd71426660
commit e79a3181dc
3 changed files with 51 additions and 41 deletions

View File

@@ -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))
}
}
}
}

View File

@@ -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))
// }
// }
//}

View File

@@ -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) {