I recently had a request from a friend to write a plugin for his VJ software on Mac OSX, that appears to be Resolume Arena. The best option seems to be developing it with OF plus ofxFFGL plugin. After a few days struggling with different versions of libraries, compilers, SDKs and the like I managed to:
Build a working plugin with Xcode 3.2, OF 0.6.2 and ofxFfgl. It works in resolume, but OF 062 is quite old, misses a lot of nice features and I have not been able to find the docs for it.
Build and run OF applications (not plugins) as apps (with their window), exploring the framework, with the help of Denis Perevalov’s book. No problems with that.
Compile and build a test plugin with ofxFFGLplugin, after fixing a few issues in its source code. Now it compiles smoothly (apart from a few warnings for deprecated function calls) and produces a bundle.
The problem is that this bundle for some reason is not loaded from Resolume, it simply does not appear in the FFGL plugins list. If I copy inside it the old executable from a working bundle (changing its name to match) it loads. Any idea about what could be the reason? I do not know what resolume wants from its plugins, and haw eventually to debug that.
Any help would be appreciated, and (I believe) help others in the need of a working ofxFFGLplugin and OF 080.
My developing machine is an iMac with the latest OS (10.9 Mavericks) and Xcode 5.0.2
Here you find the modified ofxFFGLplugin source (to be put in addons dir) and my test project.
ofxFFGLplugin example with Xcode5 and OF 080
modified ofxFFGL plugin
sorry for the links to an external site but the forum doesn’t allow me to attach files to my post. And please forgive my bad English, my first language is Italian!
been doing the same with ffgl for windows, so can’t help with OSX, but I also run into problems with concurrency (2 identical plugins in different colums in resolume results in lost parameters) and depth buffering (getting a white screen when depth testing is on).
Do these things work with you?
With the old libraries it seems it is working well (though I am not an experienced resolume user), with the new ones I can’t even have the plugin loaded so I don’t know if it will function properly. I also asked in the resolume forum, where may be someone can help from the other side. Anyway I’ll post any useful result here should I learn something new.
I read a post in the resolume forum where they were mentioning problems with z-ordering, they said this is why they did not release a new version of the plugin.
On my side I tried various combinations and found out that it is OK to build a plugin with the old libraries and code (the one from 062) with the latest XCode (5.0.2 as now), it gets loaded and works successfully. In my experiments I had to create a new project with projectgenerator (adding ofxFFGLplugin) and modifying settings (architecture, SDK and the like) to match the ones in the working example. This led to a successful compile and link but no hope to have the plugin loaded.
Today I tried to build a copy of the working project with the new libs, but even after fixing all I could there still were a lot of linker errors at the end, complaining about missing functions in various libraries. If someone is willing to help I can post the actual error messages here.
feel free to post.
indeed, I can get everything working (even debugging & console out), but not depth testing. Note I can use depth coordinates and camera’s and the like - see secreenshot - but when I turn on depth testing everything turns white.
My current guess is that it has something to do with depth buffers not being allocated/assigned. I’m quite new to this opengl thingy (i like the openframeworks abstractions to much) so I might be completely off. Correct me if i’m wrong: the depth buffers are usually handled by the window manager (glut, glfw) or the ffgl plugin (see the fbo extentions). But they are not used with the ffgl plugin.
I found some OSX inspiration here that might help you for creating bundles: https://code.google.com/p/vvffgl/source/browse/#svn%2Ftrunk%2FVVFFGL%2FFrameworkSource
But i’m completely lost in fixing the depth buffer. Also with the programmable render thing of 0.8. PS sorry for hijacking your thread! If you get it working we should put it together and release an updated addon working for win & osx.
also, can you check the debug output on the console somewhere in osx (configure xcode to launch resolume i guess).
In visual studio, I get this output when resolume starts (with custom cout messages from OF):
'Arena.exe' (Win32): loaded 'D:\Hangaar\OpenFrameworks_081_v20131125\apps\myApps\FFGLShaders\bin\FFGLShaders_debug.dll'
[FFGLDEBUG] Starting shader OF dll setup() method
[FFGLDEBUG] Starting shader OF dll update() method
[FFGLDEBUG] Starting shader OF dll draw() method
'Arena.exe' (Win32): unloaded 'D:\Hangaar\OpenFrameworks_081_v20131125\apps\myApps\FFGLShaders\bin\FFGLShaders_debug.dll'
So it loads the plugin, generates a preview and unloads it. When something is wrong in my code, it loads the dll and runs the setup method but stops there - then the plugin issn’t visible in the sources list. So you could check it actually loads the plugin this way?
Thanks, I’ll try and see if the setup() method is actually called. Today I’d like to investigate the format of classed used to send and receive info from host to client, something may have changed with newer OF versions and may be there is a mismatch between Arena and the plugin.
I’m new to the OF world (I usually write C++ with QT), so there is much to learn here
Of course releasing an updated ofxFFGLplugin would be nice, let’s hope so!
OK now it loads. In the custom script fase used for postprocessing the setting @executable_path had to changed to @loader_path, otherwise the fmodex.dylib dynamic library would not load and the plugin would fail. I don’t use anything from that library, but that’s how it goes
Now Arena crashes when I try to use the plugin, but that’s something that can be investigated, at least I can print debug messages!
it crashes, thats an improvement! Seems odd to say this way.
Good luck and please keep us posted about your progress!
A little debugging (XCode does a good job on that, makes it possible to do single stepping and watch variables in a plugin running inside an host) showed that the crash is here
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,pGL->HostFBO); // BAD ACCESS HERE!!!
doing the same with the working 062 plugin shows (more or less) identical values for the variables involved, so I suspect the problem lays in a wrong initialization for the function pointer itself. This could be because of the switch from GLEE to GLEW, but the matter requires further investigation. As I said this stuff is all new for me and it’s not that easy to grasp it at once.
How did you solve the problem of the two different libraries (glee/glew) in windows? Did you have any issues from that?
[EDIT] It turned out that OPENGL was not being initialized properly, adding a glewInit() inside ofFFGLPlugin::InitGL, just after ofSetupOpenGL apparently fixed the null pointers. But there must be other issues (or I am not initializing glew properly) because the drawing is not yet working.
In which source file did you find that line? I cannot find it but it looks familiar.
I’ve also added glewInit(); in the window init method that solved some fbo/shader issues in OF.
try disabling depth testing (ofDisableDepth() or glDisable( GL_DEPTH_TEST ) ; )
it is part of
ofFFGLPlugin::ProcessOpenGL, in ofxFFGLPlugin.cpp
Now drawing (more or less works) but for some reason ofGetWidth() and ofGetheigth() both return zero and the plugin does not get the parameters from host…
Now it is late, but tomorrow I’ll try your suggestion and see what happens!
So something weird is happening. First of all here there is a short list with what I did so far:
Steps for ofxFFGLPlugin with 080 and XC5.zip (2.5 KB)
At a first sight the plugin appears to be working, it gets the webcam picture and shows it on the screen (tiling it multiple times as you change the parameter slider). Also drawing a rectangle, and a line work properly. Yesterday drawing true type text and a gif picture did not work (the program crashed), but today they do. It is very likely we have some crazy pointer somewhere… drawing a bitmapText gives no results, and digging with the debugger gave this weird result:
This is what you can see at a breakpoint just before the actual drawBitmapString call:
The pointer to the renderer is fine, I took note of it while stepping in its constructor. But just stepping into the function (one step later) results in this:
“this” pointer is screwed up, and so are the function arguments. I have no clue about what could be happening here (I am not too familiar with shared pointers usage, I’m afraid). Of course the function call fails, and it’s just a matter of luck if it’s going to throw an exception and crash everything or not.
I wanted to compare this with the working code (OF 062) but that is completely different (no concept of renderers as far as I can tell) so it made no sense to try.
If you can’t help is there someone with a good knowledge of the OF internals that could solve this puzzle?
the most useless reply ever: im stuck there also. The most annoying thing; sometimes it works, sometimes it doens’t.
The shared pointers & custom renders gives me a headache. Any insights there (updated 0.8 tutorials about the render thing & shared pointer thing? Some explenations about the concepts involved?) would help a lot!
to add to the weirdness, writing
ofBaseRenderer* r = renderer.get();immediately before the
renderer-> stuff puts a nice NULL in r, while the value stored in the render internals is different (and the value of “this” in the called function is different from both).
In other locations the shared pointer magic seems to work properly.
[EDIT] it seems the shared pointer is not guilty (not the only one at least). I tried changing the ofPtr definition with the std::shared_ptr (with a simple #define, but it works for testing purposes). What happens is even more puzzling. Writing this
ofBaseRenderer* r = renderer.get();
results in r correctly handling the pointer for “renderer”, but stepping in the drawString method takes a while (that’s strange, there is a pause like two seconds long) then the variables are as crazy as before. Even stranger when going back in the execution trace r is shown as NULL.
I’m afraid I can go no further than this without the help of a kind C++ and OF guru
Ok it turned out it was a debugger issue. The projects generated with Project Generator still have code optimizations turned on in the debug target, and this made the debugger go nuts (is this a bug to be reported somewhere?)
Setting optimizations to none fixed the pointer craziness, but bitmap text still does not get drawn. Were it only for that it wouldn’t be a big issue, but I suspect it could be a symptom that something is broken in the inners of the program. What exactly we have to find out
Where would i be able to download the new OF Wrapper, I want to give this a test try as well.
I wouldn’t call it a new wrapper (wish I had one ) but if you want to give a try to my xcode project you are welcome, it is all in these archives:
FFGLdata (decompress in vfx dir).zip (422.1 KB)
ofxPluginEffectTest080 (decompress in myApps dir).zip (64.6 KB)
ofxFFGLPlugin (decompress in addons).zip (43.3 KB)
It builds and works for me with OSX Mavericks, XCode 5.0.2 and OF080. There are issues for sure, for example the drawBitmapString shows nothing on the screen, and besides that I’m afraid my knowledge of OF is not deep enough to properly test the plugin. I tried drawing to and from ofFbo and it seems to work fine.
Let me know if (and how much) it works for you.
@Kj1 it would be nice if you could try it on windows too, to see what happens.
Any news with this? In the meantime I noticed another problem. With the OF060 plugins you can stack as many as you wish (within reason I suppose) and they all work. With 080 the first instance works but the second one immediately crashes.
I had severe problems (with crashes) when trying to use multiple copies of the same effect in host. To cope with this unfortunately I had to rewrite large portions of the code. Now the plugin no longer uses an OF app to run but everything lives in the ofxFFGLPlugin class (I had to because it uses globals and it is impossible to run multiple indipendent instances of ofApp at the same time), and the window has been changed to ofAppNoWindow.
The code in FFGL.cpp that was managing the interface with host needed heavy changes too, since it was using globals. A drawback is that the plugin object gets created and destroyed many times when host asks for parameters, but this should not be too bad a problem since it happens only at startup.
I had a weird issue with plugin names, they appeared scrambled in host. My guess is it keeps the pointer to a previous version of the plugin that gets corrupted when it is destroyed and rebuilt. Would be better if host copied the actual string and not only the pointer, to cope with this I had to create a static object to keep the parameters names (they are identical for all instances). Good luck values seem to work correctly.
The actual drawing and OpenGL seems to work well enough (let alone that damn drawBitmapString that apparently does nothing), but I do not have yet the experience to fully test it. I successfully tried drawing textures from webcam and files, true type text, primitives like lines and rectangles, and using FBOs but that’s it.
If someone wants to give it a try I can post here my project folder.