4

First off, I'm using OpenTK in a WPF application, but I think this is more a generic OpenGL thing.

In my application I want to be able to render 3D stuff to a texture. I do NOT need output to a window or control on screen - I just want to render to a background texture.

So, how should I set up OpenGL to do that ? Normally, a graphicscontext should be created with a devicecontext as parameter. But in my case I don't want to output to a devicecontext, and I want to render to a fixed-size FrameBufferObject with settings (f.e. 1024x1024, 32bpp, 32bits ZBuffer) that are unrelated to the window or display.

I hope anyone has any experience with a setup like this :)

Pygmy
  • 1,268
  • 17
  • 33

1 Answers1

3

Context creation is outside of the scope of the OpenGL API itself. GL contexts are created by a target graphics system, like Windows GDI, X11/GLX, Quartz/AGL. Now there is a concept called PBuffers, which can be used to create HW accelerated OpenGL contexts that are not tied to a window. However PBuffers are normally only accessible as extension only, so you need an OpenGL context to get so far. The solution is to create a dummy window, that never needs to be visible on the screen, with which a dummy GL context is created to obtain the extension. Then using that the PBuffer and an OpenGL context on that one is created.

However if you want to use FBOs, then you don't need to jump through the PBuffer hoop. The invisible dummy window with OpenGL context does the job as well, as the render target will be the FBO.

datenwolf
  • 159,371
  • 13
  • 185
  • 298