How to create a ofAppEGLwindow

Hello, for my project, I need to be able to initiate my window, with ofEGLwindowsetting, so I can define on which ofEGLWindowSetting.screenNum I want my output.

Every try I made, failed.

It compiles, but then crash at start up.

My code :

int main( ){
ofAppEGLWindow::Settings settings;
settings.width = 400;
settings.height = 480;
settings.setPosition(ofVec2f(0,0));
settings.screenNum = 5;
ofAppEGLWindow windowTest;
ofCreateWindow(settings);
ofRunApp( new ofApp());
}

How can I create an ofappEGLwindow for manage my output windows ?

I must use an ofAppEGLWindow, because it’s the only way on the rpi to define on which display (hdmi or official lcd) I want my output window.

I can’t use Fbcp ( yes the main goal would be to do a dual screen ) so I need to use the vc_dispmanx function for define the display I will use.

Thank you for reading me, sorry for the bad english, a vous CognacJay :slight_smile:

can you try:



int main( ){
ofAppEGLWindow::Settings settings;
settings.width = 400;
settings.height = 480;
settings.setPosition(ofVec2f(0,0));
settings.screenNum = 5;

ofCreateWindow(settings);
ofRunApp( new ofApp());
}

It makes the output window appears on the lcd display.

I placed an oflognotice in the ofAppEGLWindow.cpp, line 394, in the ofAppEGLWindow::setup(const Settings & _settings) and it returns 0 as its setting.screenum value.

It seems the ofAppEGLWindow::Settings settings lose its value screenNum somewhere. Maybe it is casted at some point.

can you report a bug about this in github?

I will try :slightly_smiling:

Hey, I partly solved the issue, I added line 168 of the ofAppRunner.cpp this :

shared_ptr<ofAppBaseWindow> ofCreateWindow2(const struct ofAppEGLWindow::Settings & settings){
ofInit();
return mainLoop()->createWindow2(settings);
}

And I added line 67 of the ofMainLoop.cpp this :

shared_ptr<ofAppBaseWindow> ofMainLoop::createWindow2(const struct ofAppEGLWindow::Settings & settings){
#ifdef TARGET_NODISPLAY
shared_ptr<ofAppNoWindow> window = shared_ptr<ofAppNoWindow>(new ofAppNoWindow());
#else
#if defined(TARGET_OF_IOS)
shared_ptr<ofAppiOSWindow> window = shared_ptr<ofAppiOSWindow>(new ofAppiOSWindow());
#elif defined(TARGET_ANDROID)
shared_ptr<ofAppAndroidWindow> window = shared_ptr<ofAppAndroidWindow>(new ofAppAndroidWindow());
#elif defined(TARGET_RASPBERRY_PI)
shared_ptr<ofAppEGLWindow> window = shared_ptr<ofAppEGLWindow>(new ofAppEGLWindow());
ofLogNotice("ScreeNum in the create window is:"+ofToString(settings.screenNum));
#elif defined(TARGET_EMSCRIPTEN)
shared_ptr<ofxAppEmscriptenWindow> window = shared_ptr<ofxAppEmscriptenWindow>(new      ofxAppEmscriptenWindow);
#elif defined(TARGET_OPENGLES)
shared_ptr<ofAppGLFWWindow> window = shared_ptr<ofAppGLFWWindow>(new ofAppGLFWWindow());
#else
shared_ptr<ofAppGLFWWindow> window = shared_ptr<ofAppGLFWWindow>(new ofAppGLFWWindow());
#endif
#endif
addWindow(window);
window->setup(settings);
return window;
}

And now it works if I use this in my main.cpp :

  auto lcdDisplay = ofCreateWindow2(settings);

My next question is can I place an "#ifdef TARGET_RASPBERRY_PI in front of my customs createWindow() and ofCreateWindow(), and then an “#else” for the other modes, or it won’t work ?