Client working!
This commit is contained in:
committed by
edwin
parent
31b79685eb
commit
4a1a4103c3
@@ -1,4 +1,5 @@
|
||||
dependencies {
|
||||
compile project(":orx-camera")
|
||||
compile "org.openrndr:openrndr-core:$openrndrVersion"
|
||||
compile "org.openrndr:openrndr-gl3:$openrndrVersion"
|
||||
compile "org.lwjgl:lwjgl-opengl:3.2.3"
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import jsyphon.JSyphonClient
|
||||
import jsyphon.JSyphonServer
|
||||
import org.lwjgl.opengl.GL33C
|
||||
import org.openrndr.Extension
|
||||
import org.openrndr.Program
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.internal.gl3.ColorBufferGL3
|
||||
|
||||
|
||||
class SyphonClient: Extension {
|
||||
override var enabled = true
|
||||
|
||||
private val client = JSyphonClient()
|
||||
var buffer: ColorBuffer = colorBuffer(10, 10)
|
||||
|
||||
override fun setup(program: Program) {
|
||||
var buffer = colorBuffer(program.width, program.height)
|
||||
client.init()
|
||||
}
|
||||
|
||||
override fun beforeDraw(drawer: Drawer, program: Program) {
|
||||
if (client.hasNewFrame()) {
|
||||
val img = client.newFrameImageForContext()
|
||||
val w = img.textureWidth()
|
||||
val h = img.textureHeight()
|
||||
|
||||
val rectBuffer = ColorBufferGL3(GL33C.GL_TEXTURE_RECTANGLE, img.textureName(), w, h,
|
||||
1.0, ColorFormat.RGBa, ColorType.UINT8, 0, BufferMultisample.Disabled, Session.root)
|
||||
|
||||
if (buffer.height != h || buffer.width != w) {
|
||||
buffer = colorBuffer(w, h)
|
||||
}
|
||||
|
||||
rectBuffer.copyTo(buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class SyphonServer(private val name: String = "OPENRNDR", var target: RenderTarg
|
||||
drawer.image(target?.colorBuffer(0)!!)
|
||||
val glBuffer = target?.colorBuffer(0) as ColorBufferGL3
|
||||
|
||||
println(glBuffer.multisample)
|
||||
println(glBuffer.target)
|
||||
|
||||
// Send to Syphon
|
||||
server.publishFrameTexture(
|
||||
|
||||
@@ -1,38 +1,20 @@
|
||||
import jsyphon.JSyphonClient
|
||||
import jsyphon.JSyphonImage
|
||||
import org.lwjgl.opengl.GL11C.GL_TEXTURE_2D
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.internal.Driver
|
||||
import org.openrndr.internal.gl3.ColorBufferGL3
|
||||
import kotlin.math.sin
|
||||
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 1000
|
||||
height = 1000
|
||||
height = 800
|
||||
}
|
||||
|
||||
program {
|
||||
val client = JSyphonClient()
|
||||
client.init()
|
||||
|
||||
val syphonClient = SyphonClient()
|
||||
|
||||
extend(syphonClient)
|
||||
extend {
|
||||
drawer.background(ColorRGBa.RED)
|
||||
|
||||
if (client.hasNewFrame()) {
|
||||
println("hasnewframe")
|
||||
val img = client.newFrameImageForContext()
|
||||
val buffer = ColorBufferGL3(GL_TEXTURE_2D, img.textureName(), img.textureWidth(), img.textureHeight(),
|
||||
1.0, ColorFormat.RGBa, ColorType.UINT8, 1, BufferMultisample.Disabled, Session.active)
|
||||
|
||||
|
||||
drawer.image(buffer)
|
||||
}
|
||||
|
||||
drawer.background(ColorRGBa.BLACK)
|
||||
drawer.image(syphonClient.buffer)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user