アップデートにより、4.1にも対応しました。ここでの内容は非推奨です。
https://github.com/astellato/ofxSyphon
OpenGL2.1だと問題ないのですが、3.X系に上げた瞬間死にます。(真っ黒)それを解決しようぜ!!!というHackをここに書いておきます。
アドオンをカスタマイズ
アドオンに以下の関数を追加。もちろんヘッダーファイルにもプロトタイプ宣言を忘れずに。
ofxsypthonserver.mm
void ofxSyphonServer::publishFBO(ofFbo* inputFbo){
// If we are setup, and our input texture
if(inputFbo->isAllocated())
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
if (!mSyphon)
{
mSyphon = [[SyphonServer alloc] initWithName:@"Untitled" context:CGLGetCurrentContext() options:nil];
}
SyphonServer *ss = static_cast<SyphonServer*>(mSyphon);
CGLLockContext(ss.context);
CGLSetCurrentContext(ss.context);
NSSize size;
size.width = inputFbo->getWidth();
size.height = inputFbo->getHeight();
[ss bindToDrawFrameOfSize:size];
GLint syFBO;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &syFBO);
glBindFramebuffer(GL_READ_FRAMEBUFFER, inputFbo->getFbo());
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, syFBO);
glBlitFramebuffer(0, 0, size.width, size.height,
0, 0, size.width, size.height,
GL_COLOR_BUFFER_BIT, GL_LINEAR);
[ss unbindAndPublish];
CGLUnlockContext(ss.context);
[pool drain];
}
else
{
cout<<"ofxSyphonServer FBO is not properly backed. Cannot draw.\n";
}
}
使い方
そのままVDMXとかに出すと垂直方向に反転した画がでるので、出力用ofFboのY座標を反転させる。(Y座標反転はたしかOpenGLのFBOの仕様だったかな?)
ofApp.cpp
ofFbo fbo;
void setup()
{
fbo.allocate(ofGetWidth(), ofGEtHeight());
fbo.getTexture().getTextureData().bFlipTexture = true;
}
void draw()
{
fbo.begin();
ofClear(0);
//draw some stuff
fbo.end();
fbo.draw(0, 0);
mainOutputSyphonServer.publishFBO(&fbo);
}
これで、OpenGL3.X系以上のプロジェクトもSyphonで渡せます。
乾杯!!!🍺