On Windows.
I’ve created a library that uses OF, it uses some OpenGL related classes such as ofFbo.
If I generate a static library, it just works. But if I generate a shared (dll) library, OpenGL functions crash.
I’m guessing the OpenGL context is not reachable by the dll’s, as it’s a different binary? Can someone explain why this happens?
[Deleted post content]
Turns out I needed OF to be initialized from the ofAppRunner
code, as it initializes all OpenGL context properly. I was trying to directly initialize GLFW but then ofGetCurrentRenderer()
and other code was not working.
More specifically, I’m running Boost testing for my DLL. I’ve defined a simple ofApp::setup
in order to mix OF and Boost…here it is in case someone finds it useful:
/**
* For unit testing using Boost test suite,
* place before any boost test case that requires OF
* to be initialized, this includes any OpenGL context
* call.
* You must call BOOST_OF_APP_END afterwards
* @see BOOST_OF_APP_END
*/
#define BOOST_OF_APP_BEGIN \
class ofBoostApp : public ofBaseApp{\
public:\
void setup()\
{
/**
* @see BOOST_OF_APP_BEGIN
*/
#define BOOST_OF_APP_END \
ofGetWindowPtr()->windowShouldClose();\
}\
};\
ofSetupOpenGL(1024,768, OF_WINDOW);\
ofRunApp(new ofBoostApp());
Then in a test case…
BOOST_AUTO_TEST_CASE(some_test)
{
BOOST_OF_APP_BEGIN;
// OpenGL calls
// Boost test calls
BOOST_OF_APP_END;
}