Reply To: Mirroring texture horizontally and vertically

Home Forums Syphon Syphon Development – Developer Mirroring texture horizontally and vertically Reply To: Mirroring texture horizontally and vertically

#26282
vade
Keymaster

This is easily done in OpenGL via the servers

bindToDrawFrameOfSize: and unbindAndPublish

methods, (see http://syphon.v002.info/FrameworkDocumentation/interface_syphon_server.html#ab5da335ea3e45903eceae51adb363240 )

What this does is, Syphon framework attaches an internally used and managed frame buffer object, which is attached to the ‘texture’ / surface that it will share. You are then responsible for drawing your scene to OpenGL, as normal (assuming you are drawing directly to the frame buffer object weve attached) – you then call unbindAndPublish on the server – and any drawing youve done will be sent off via Syphon.

You can then get the Syphon Image from the server you just made, to draw to your own OpenGL View, like you would any texture.

Essentially you would:

*Set Up OpenGL Context
*Set up Syphon Server.
*Set up your resources.

in your render loop:

*attach context

*server bindToDrawFrameOfSize (you are now drawing “into” Syphon)

*Draw your OpenGL content, and modify the vertices and texture coordinates of your texture to achieve the desired effect, or use a GLSL shader, or any number of methods appropriate.

* unbindAndPublish (youve now notified any listening clients youre drawing is done and its ready to be seen elsewhere). This unbinds the frame buffer object, and synchronizes the contents of the shared texture to other applications.

If you want, you may now:

* get the SyphonImage from the server (its the most recent thing you’ve drawn above)
* draw that image as normal (no effects) to your own scene for a live preview of your applications output that will be seen by others, etc.

I hope that helps.

We highly suggest avoiding pixel readback to the CPU – it defeats the entire purpose of using Syphon to begin with : keeping things fast on the GPU. Where it belongs.

One thing to note is that we try to do a good job of isolating OpenGL state before and after our OpenGL calls into your context. Ensure you leave things as they were, if you’ve altered state within the bind and unbind calls on the server.