[orx-syphon] Fix wrong Syphon resolution with alternate RenderTarget (#378)
This commit is contained in:
44
orx-jvm/orx-syphon/src/demo/kotlin/DemoServer02.kt
Normal file
44
orx-jvm/orx-syphon/src/demo/kotlin/DemoServer02.kt
Normal 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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -53,11 +53,13 @@ class SyphonServer(private val name: String = "OPENRNDR", var providedTarget: Re
|
|||||||
|
|
||||||
val glBuffer = targetToSend?.colorBuffer(0) as ColorBufferGL3
|
val glBuffer = targetToSend?.colorBuffer(0) as ColorBufferGL3
|
||||||
|
|
||||||
// Send to Syphon
|
targetToSend?.let { targetToSend ->
|
||||||
server.publishFrameTexture(
|
// Send to Syphon
|
||||||
glBuffer.texture, glBuffer.target, 0, 0,
|
server.publishFrameTexture(
|
||||||
program.width, program.height, program.width, program.height, false
|
glBuffer.texture, glBuffer.target, 0, 0,
|
||||||
)
|
targetToSend.width, targetToSend.height, targetToSend.width, targetToSend.height, false
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shutdown(program: Program) {
|
override fun shutdown(program: Program) {
|
||||||
|
|||||||
Reference in New Issue
Block a user