Of without a window?

is it possible to run of without a gl window, say i want to do opencv and send the data out via osc

thanks

[quote author=“liuboto”]is it possible to run of without a gl window, say i want to do opencv and send the data out via osc

thanks[/quote]

OF course it is (excuse the pun), but why? You could run an app without activating the window I suppose, or you could work WITH the window and make a control panel or base display.

yes you can get an of app to run without starting an opengl context by commenting out ofSetupOpenGL and ofRunApp in main.cpp

Then you will need to do all you did in setup in the main function and use an infinite loop to simulate the update cycle. You will need some kind of exit condition. for example you can read the state of the keyboard at the end of that loop.

Or you can simulate the setup/update cycle by having a main like:

  
  
#include "ofMain.h"  
#include "testApp.h"  
  
//========================================================================  
int main( ){  
     testApp * app = new testApp();  
     testApp->setup();  
     while(1){  
       testApp->update();  
     }  
}  
  

note that with this the keyPressed, keyReleased, mouse… won’t work.

2 Likes

Is this still the best way to achieve this?

Also, curious/confused about the two different methods you mention here - assuming they properly are two separate methods?

I.E. how would you have an exit condition without being able to read the keyboard state ?

Thanks,

~ J

since 0.8.0 there’s an ofAppNoWindow class that you can use, in main:

  
  
#include "ofAppNoWindow.h"  
  
int main(){  
    ofAppNoWindow window;  
    ofSetupOpenGL(&window,1024,768,OF_WINDOW);  
    ofRunApp(new testApp);  
}  
  

5 Likes

hello,

I’ve tested the ofAppNoWindow method with Duration app in linux
and it leads to a segfault
here is the gdb backtrace

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) thread apply all bt 

Thread 5 (Thread 0x7fffe92bb700 (LWP 5903)):
#0  0x00007ffff32bdd7d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007ffff32ef334 in usleep (useconds=<optimized out>) at ../sysdeps/unix/sysv/linux/usleep.c:32
#2  0x000000000045d622 in DurationController::threadedFunction() ()
#3  0x00000000005d177f in ofThread::run() ()
#4  0x00000000006cc601 in Poco::ThreadImpl::runnableEntry(void*) ()
#5  0x00007ffff4092182 in start_thread (arg=0x7fffe92bb700) at pthread_create.c:312
#6  0x00007ffff32f730d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 4 (Thread 0x7fffe9abc700 (LWP 5902)):
#0  0x00007ffff32eec33 in select () at ../sysdeps/unix/syscall-template.S:81
#1  0x000000000047b86c in SocketReceiveMultiplexer::Implementation::Run() ()
#2  0x0000000000473201 in ofxOscReceiver::startThread(void*) ()
#3  0x00007ffff4092182 in start_thread (arg=0x7fffe9abc700) at pthread_create.c:312
#4  0x00007ffff32f730d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 3 (Thread 0x7fffea2bd700 (LWP 5901)):
#0  0x00007ffff32bdd7d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007ffff32ef334 in usleep (useconds=<optimized out>) at ../sysdeps/unix/sysv/linux/usleep.c:32
#2  0x00000000004ac886 in ofxTimeline::threadedFunction() ()
#3  0x00000000005d177f in ofThread::run() ()
#4  0x00000000006cc601 in Poco::ThreadImpl::runnableEntry(void*) ()
---Type <return> to continue, or q <return> to quit---
#5  0x00007ffff4092182 in start_thread (arg=0x7fffea2bd700) at pthread_create.c:312
#6  0x00007ffff32f730d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 1 (Thread 0x7ffff7f9ca40 (LWP 5896)):
#0  0x0000000000000000 in ?? ()
#1  0x0000000000508f8f in ofxUICanvas::draw() ()
#2  0x0000000000466441 in DurationController::draw(ofEventArgs&) ()
#3  0x0000000000467cb1 in Poco::PriorityDelegate<DurationController, ofEventArgs, false>::notify(void const*, ofEventArgs&) ()
#4  0x00000000004bcbd0 in void ofNotifyEvent<ofEvent<ofEventArgs>, ofEventArgs>(ofEvent<ofEventArgs>&, ofEventArgs&) ()
#5  0x0000000000608335 in ofNotifyDraw() ()
#6  0x000000000056ee5a in ofAppNoWindow::runAppViaInfiniteLoop(ofBaseApp*) ()
#7  0x000000000041726e in main ()

I think canvasdraw() function does matter

I’ll try the other method

hello,

I think the main() should be :

int main( ){
     testApp * app = new testApp();
     app->setup();
     while(1){
       app->update();
     }
}

just a typo :wink:

1 Like

I’m trying to run an app without GL context but have sound working via void audioOut
I tried it with ofAppNoWindow but it didn’t produce any sound.
Is it possible to do something similar to this:

#include "ofMain.h"  
#include "ofApp.h"  

int main( ){  
     ofApp * app = new ofApp();  
     app->setup();  
     while(1){  
       app->update();  
     }  
}  

but use app->audioOut() instead of update()? I tried but audioOut needs a buffer argument and I have no clue what to put in there.

Thanks!

How would you do this for an Android app? If you have existing GL context and application loop, how would I call OF functions? Would I have to create my own Android window+app classe?