Hello Guest

Does LWJGL3 support creating a windowless OpenGL context?

  • 4 Replies
  • 4239 Views
Does LWJGL3 support creating a windowless OpenGL context?
« on: August 05, 2019, 02:43:00 »
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.
« Last Edit: August 06, 2019, 17:52:02 by Illari »

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Does LWJGL3 support creating a windowless OpenGL context?
« Reply #1 on: August 05, 2019, 08:01:45 »
Hey Illari,

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

Re: Does LWJGL3 support creating a windowless OpenGL context?
« Reply #2 on: August 06, 2019, 17:56:57 »
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.
« Last Edit: August 06, 2019, 18:02:21 by Illari »

*

Offline KaiHH

  • ****
  • 334
Re: Does LWJGL3 support creating a windowless OpenGL context?
« Reply #3 on: August 06, 2019, 18:18:16 »
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.

Re: Does LWJGL3 support creating a windowless OpenGL context?
« Reply #4 on: August 07, 2019, 03:17:25 »
That's what I did. Perhaps it's only on some systems?

Code: [Select]
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);
« Last Edit: August 07, 2019, 03:26:33 by Illari »