In order to be compatible with MWorks 0.5, plugins developed for earlier releases need some minor updates. The exact changes required depend on the type of plugin and are described below.
All plugins
All MWorks plugins (core and client) must now link against libboost_system, specifically /Library/Application Support/MWorks/Developer/lib/libboost_system.a
. Otherwise, builds of the plugin will fail at the linking phase.
Core plugins
In order to be loadable by MWorks, core plugins must mark their getPlugin
function as a public symbol, like so:
MW_SYMBOL_PUBLIC
extern "C" Plugin* getPlugin() {
return new MyPlugin();
}
Note that this must be done in the implementation (i.e. .cpp
) file, not in a header file.
Failure to make this change will result in “No factory for object type” errors when attempting to load an experiment that uses the plugin.
Stimulus plugins
If your plugin implements a stimulus type that uses StimulusDisplay::setCurrent
to change the current OpenGL context, then your code must be updated to store that method’s new return value. Otherwise, your stimulus will fail to draw, and you’ll probably crash MWServer.
Typically, setCurrent
is used to perform some GL task (e.g. creating textures) on all contexts. Here’s the correct way to do this in MWorks 0.5:
for (int i = 0; i < display->getNContexts(); i++) {
// Set current context and acquire the context lock
OpenGLContextLock ctxLock = display->setCurrent(i);
// Perform GL tasks on the current context
...
// When ctxLock goes out of scope, its destructor releases
// the lock and clears the current context
}