How to create a GLRenderer without create showing window?

Hi everyone,

I want to use get the texture of image, thus, I need to enable GLRenderer. However, I do not want to show it on the screen.

Create app without window:

ofAppBaseWindow* window = new ofAppNoWindow();
ofSetupOpenGL(window, 640, 480, OF_WINDOW);

However, this method will give me error when I want to use GLRenderer (such as ofFbo).
ERROR:gl frame buffer object not supported by this graphics card.

According to the documentation:
if I want to use GLRenderer, the only way is create a window.

ofSetupOpenGL(1024,768, OF_WINDOW);

Any other methods to solve this? :pray:

Have you tried the ofAppNoWindow class? Not sure if it creates a GL context, but worth looking into.
More info on this thread:

Looks like it doesn’t create the GL context. Could you just hide the window? On OSX using the GLFW window class you can do

int main( ){
	ofAppGLFWWindow* win = new ofAppGLFWWindow();
    ofSetupOpenGL(win, 1400, 868, OF_WINDOW);
	ofRunApp( new ofApp());

and then in your setup function

NSWindow* nswin =  (NSWindow*)((ofAppGLFWWindow*)ofGetWindowPtr())->getCocoaWindow();
        [nswin orderOut:nil];

thank you for your reminder. I have tried this method also, but this method can not create a GL context for me. By the way, I do not know whether it is reasonable to create a GL renderer but not display it.

You could also look into the GLFW_VISIBLE hint while creating your GLFW window.

And also glfwHideWindow

ok, thank you very much. This is a good solution. BTW, if we hide the window, I am wondering whether the update() and draw() function will still work or not. :smile: Anyway, l will try it first.

Update and draw will definitely be called (they are internal OF events on a timer), the only thing I wonder about is if the GL context becomes invalid or somehow changes if the window is in a hidden state. I don’t think it should, but best to just try it! :smile: