Does LWJGL3 support creating a windowless OpenGL context?

Started by Illari, August 05, 2019, 02:43:00

Previous topic - Next topic

Illari

Hi,

I heard that you have to create a context without ever creating a window if you want to render to a Framebuffer Object larger than the screen size. Otherwise the contents of the Framebuffer Object get cropped by the window size, which can't be larger than the screen. This happens even if the window is hidden. There doesn't seem to be a sensible workaround to this besides not creating a window in the first place in any of the Stackoverflow answers on the topic.

Thanks for your time.

spasi

Hey Illari,

You can create a hidden GLFW window and use its OpenGL context to render to a framebuffer object of arbitrary size.

Illari

Hi,

I edited the post to clarify that the image still gets cropped even if the window is hidden. Looks like I might need to draw it in pieces and move them afterwards.

Well unless there's a solution besides this one it's something to be aware of.

KaiHH

As @spasi said, you need to create a Framebuffer Object and not render to the default (window-provided) framebuffer object 0. You need to create and bind a separate Framebuffer Object which you render to.

Illari

That's what I did. Perhaps it's only on some systems?

glGenFramebuffers(fbuffer);
int framebuffer = fbuffer.get(0);

glBindFramebuffer(GL_DRAW_BUFFER, framebuffer);
Integer[] size = drawnauha(-1);
int w = size[0], h = size[1];
glBindBuffer(GL_RENDERBUFFER, buffer.get(1));
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, w, h);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, buffer.get(1));
glViewport(0, 0, w, h);