OpenGL: How to configure OpenGL to just visualize FBO, no screen / window / control output?

First, I use OpenTK in a WPF application, but I think this is a more general OpenGL thing.

In my application, I want to be able to render 3D material for texture. I do not need window output or screen controls - I just want to make the background texture.

So how do I configure OpenGL for this? Typically, a graphics context should be created with the devicecontext parameter. But in my case, I do not want to output to devicecontext, and I want to display a fixed size in FrameBufferObject with settings (for example, 1024x1024, 32bpp, 32bits ZBuffer) that are not associated with a window or display.

I hope someone has experience with such an installation :)

+4
source share
1 answer

Contextual creation is beyond the scope of the OpenGL API itself. GL contexts are created by the target graphics system, such as Windows GDI, X11 / GLX, Quartz / AGL. Now there is the concept of PBuffers, which can be used to create HW-accelerated OpenGL contexts that are not window bound. However, PBuffers are usually only available as an extension, so you need an OpenGL context to get so far. The solution is to create a dummy window that should never be visible on the screen, with which a dummy GL context is created to receive the extension. Then, using this, a PBuffer is created and an OpenGL context on it.

However, if you want to use FBOs, you do not need to jump through the PBuffer hoop. An invisible dummy window with an OpenGL context also does the job, since the rendering target will be FBO.

+3
source

Source: https://habr.com/ru/post/1334596/


All Articles