OpenGLTexture with custom ID

Hey everyone!

I'm working on a Syphon binding for JUCE. Syphon ( is a wonderful tool to share GL textures between apps on OSX. (There's an equivalent for Windows called Spout, later I'd like to Jucify that too.)

My starting point was the already existing OFX ( and Cinder ( bindings. I've already changed a lot of stuff to fit better JUCE, I get the notifications about the Server list changes, etc. But I stucked where I have to load the texture. I can get the textureID and the dimensions of the shared texture, but have no idea how to get/use the actual image data.

Here are the two solutions for the other platforms:

OFX (mTex here is an ofTexture)

[(SyphonNameboundClient*)mClient lockClient];
SyphonClient *client = [(SyphonNameboundClient*)mClient client];

latestImage = [client newFrameImageForContext:CGLGetCurrentContext()];
NSSize texSize = [(SyphonImage*)latestImage textureSize];

// we now have to manually make our ofTexture's ofTextureData a proxy to our SyphonImage
mTex.setUseExternalTextureID([(SyphonImage*)latestImage textureName]);
mTex.texData.textureTarget = GL_TEXTURE_RECTANGLE_ARB;  // Syphon always outputs rect textures.
mTex.texData.width = texSize.width;
mTex.texData.height = texSize.height;
mTex.texData.tex_w = texSize.width;
mTex.texData.tex_h = texSize.height;
mTex.texData.tex_t = texSize.width;
mTex.texData.tex_u = texSize.height;
mTex.texData.glInternalFormat = GL_RGBA;

mTex.texData.glType = GL_RGBA;
mTex.texData.pixelType = GL_UNSIGNED_BYTE;

mTex.texData.bFlipTexture = YES;
mTex.texData.bAllocated = YES;


Cinder (mTex here is an ci::gl::Texture)

[(SyphonNameboundClient*)mClient lockClient];
SyphonClient *client = [(SyphonNameboundClient*)mClient client];

latestImage = [client newFrameImageForContext:CGLGetCurrentContext()];
NSSize texSize = [(SyphonImage*)latestImage textureSize];
GLuint m_id = [(SyphonImage*)latestImage textureName];

mTex = ci::gl::Texture::create(GL_TEXTURE_RECTANGLE_ARB, m_id, texSize.width, texSize.height, true);

As you can see, the key is to create the GL texture with the given size, id, pixel format, but in JUCE you can't create an OpenGLTexture this way. Should I write a custom OpenGLTexture class/subclass, or is there something I missed?

Thank you!

(If I can get this work, I'd like to share the code with you... :) )

Hi @timo, did you get anywhere with this? I’m interested in sending animations to other apps, and been looking at the Syphon SDK. Would be good even if you have a starting point to look at.

@timo I was aso wondering the same thing. I want to create some A/V plugins with GLSL and Syphon, and I would love to help figure this out. Did you get anywhere or post your work in progress?

oh is this related :

Hello everybody!

I’m still Timo, but with a different account.

No, unfortunately I couldn’t figure that out, so I wrote the necessary parts with pure OpenGL, FBOs, PBOs and all that - at least to me - horrible stuff. I’ll be very happy if I could change it to a more jucy solution.

I’ll check the mentioned Spout solution more in detail when I have a bit time for that, and see how can I implement the Syphon part.

@Sesores I contacted the developer, @benkuper . You may want to consort with him, as it sounds like you may have some complimentary knowledge. In my email I suggested referencing the Cinder Syphon implementation, as Ben was referencing the OpenFrameworks version and it was difficult to port. The Cinder version is a bit cleaner code and looks like it may be more relatable to the JUCE API, so it may be worth looking at and discussing any issues here, I am sure we can figure it out. :smiley:

The syphon development forum might be useful for asking questions, Vade rocks:

I realize most of the implementation is in objective C, maybe its possible to integrate by using some pre-compiler directives in the JUCE project and connecting C++ with the objective C? I know very little about objC :confused:

I realize its an obvious place to check, but figured I would include this link: