Using drawing functions in oF app running as a windowless plugin not working

I am trying to make a plugin for Unity using dll exported from oF project.
Everything is working fine except when I use some of drawing functions from oF.
I am guessing the reason for it might be that I didn’t initialize OpenGL context and window since I am not using main method like in any other standard oF app:

// code that I am skipping but probalby should add somewhere
int main() {
	ofSetupOpenGL(width, height, OF_WINDOW);
	ofRunApp(new ofApp());

This is how I create ofApp:

MYSHARED_API ofApp* CreateOfAPI() {
	return new ofApp();

and then I have this method:

MYSHARED_API int* getImage(ofApp* api) {	
	// this is where I am using fbo and some of simple drawing functions which I write to fbo
	// and then I am returning fbo as raw int pixel array
	// this is where my plugin is crushing

I tried doing something like this but with no luck:

MYSHARED_API void init(ofApp* api) {

void ofApp::init() {
		// this is not working for some reason
		ofSetupOpenGL(&myWindow, width, height, OF_WINDOW); // myWindow is ofAppNoWindow
		renderer = new ofGLProgrammableRenderer(&myWindow);

		// other initializations that are working fine
1 Like