[SOLVED] Windowless app on OSX using CGL

Hi there!

I have an application that works on OSX. Renders stuff on the GPU and serves it over network I use ofFbo to draw and then I fetch the texture. It works well, BUT I then have a window on my desktop. I would like to run this in the console directly without icons or windows.

I am creating an alternative ofAppWindow based on CGL. I used ofAppGLFWWindow as a base and I removed everything GLFW-related. I get a context, and I activate it.

What is working:

  • ofClear() with colors. I can fetch a texture with the color used
  • ofShader() with custom shaders. I get the normal result

If I use OF drawing primitives, I get a black texture.

I am a bit lost on why this is happening. Any ideas?

I am using OF0.9.8

Got it! I wasn’t calling ofGLProgrammableRenderer::setup() :sweat_smile:

Well, everything working except ofxVideoPlayer…

But I get nothing (no sound, no video, no advance in position, no errors)

may be it expects a window somehow? :thinking:

Sorry to use this as a personal log. If you have any idea about ofAVFoundationPlayer needing an actual window to be used please comment.

Another approach, could be to set the visible property in the settings object to false. (I think it is called visible).

Yes, but the visible property prevents the window to appear, but I still get an Icon on the task bar :confused:

Regarding ofAVFoundationPlayer, it seems that since I deleted glfwPollEvents , observeValueForKeyPath (in ofAVFoundationVideoPlayer.m) never gets called.

How is this function getting subscribed to the poll loop?

So this is the thing:

OSX-specific addons may need a NSApp instance present with an event loop to work. I added a NSApplication and video, syphon worked; but then I get again the icon of the application.

SOLUTION:

It turns out that you can hide entirely your application with this simple line:

[NSApp setActivationPolicy: NSApplicationActivationPolicyProhibited];

So all this journey to discover that this line did the trick :sweat_smile:. It doesn’t matter if you are using GLFW or CGL with NSApp.

2 Likes