FFGL Plugins for Resolume

Sep 20, 2016 · By Darren Mothersele

misc

I recently spent some time learning how to build FFGL plugins.

Download

I’ve put examples up on GitHub in the cyrilcode/ffglplugin-examples repository.

I’ve compiled and uploaded to the releases page but I only have builds for OSX.

Example FFGL Plugin

Details

The website and the spec give the details. But I found the spec quite hard to digest. The only time I’d compiled dynamic plugins like this was to create PHP extensions. This is very different. I got the SDK examples to compile eventually. It wasn’t easy. I had to hack a couple of files due to changes in the OpenGL header files. I’m not sure if this is an OSX issue, or just that the SDK is really old.

There is an example in the resolume/ffgl GitHub repo that I found useful. I also found this ShaderMaker source code to be quite useful.

I ended up creating my own MyPlugin.h header file to abstract some of the boiler-plate work you have to do to create each plugin. Using this header, creating a plugin is a simple matter of converting the GLSL code you want to use. For example:

EmptyEffect.h

#include "MyPlugin.h"

class EmptyEffect {

    float redness = 0.5f;
    float greenness = 0.5f;
    float blueness = 0.5f;
    GLint colorLocation;

public:
    PluginConfig getConfig();

    void init(FFGLShader &shader);
    void process(std::vector<float> &paramValues, FFGLExtensions &extensions);

};

EmptyEffect.cpp


#include "EmptyEffect.h"

FFGL_PLUGIN(EmptyEffect,"DZ00","RGB Source",FF_SOURCE,"Sample FFGL Plugin",
    "by Darren Mothersele - www.darrenmothersele.com")

std::string fragmentShaderCode = R"GLSL(
uniform vec3 color;
void main()
{
    gl_FragColor = vec4(color,1);
}
)GLSL";

PluginConfig EmptyEffect::getConfig() {
    PluginConfig pluginConfig;
    pluginConfig.shaderCode = fragmentShaderCode;
    pluginConfig.params.push_back({"Red", FF_TYPE_STANDARD, 0.5f});
    pluginConfig.params.push_back({"Green", FF_TYPE_STANDARD, 0.5f});
    pluginConfig.params.push_back({"Blue", FF_TYPE_STANDARD, 0.5f});
    return pluginConfig;
}

void EmptyEffect::init(FFGLShader &shader) {
    colorLocation = shader.FindUniform("color");
}

void EmptyEffect::process(std::vector<float> &paramValues, FFGLExtensions &extensions)
{
    extensions.glUniform3fARB(colorLocation, paramValues[0], paramValues[1], paramValues[2]);
}

Compiling

I found I needed to build in 32-bit mode for the plugins to work in Resolume.

See GitHub for more details.

Darren's Photo

Darren Mothersele

Darren is a software developer who builds simple, creative, and independent technology. Read more »