Powerino73's picture

Multiple Window

II have to develop a prpoject with multiple windows like an editor thar need to share texture and resource. it is possible with opentk?
How? Any examples?


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Resources and textures are always shared if possible. However:

  • GraphicsContexts should have the same GraphicsMode (otherwise resource sharing may fail)
  • all GraphicsContexts should be created before loading any OpenGL resources (otherwise resource sharing may fail, again)
  • some drivers cannot share resources anyway (for example Intel drivers on Windows).

The other approach is to have a single GraphicsContext and "move" it between different windows/controls via MakeCurrent(IWindowInfo). This way, you won't have to juggle multiple contexts, threads and resource sharing, at the cost of a slight performance penalty (you will have to render each viewport in series instead of in parallel).

In any case, multiple-contexts or single-context-multiple-windows are some of the most complicated parts of OpenTK (and OpenGL in general). If possible, I'd advise checking whether a single-context-single-window-multiple-viewports approach is feasible (similar to 3d studio max, for instance, where all viewports appear on the same context). Depending on your design, this may or may not be possible - but if it is, it will be easier to implement and faster to boot.

For more information, check the documentation on GraphicsContext and the source code for the "Multiple GLControls" sample.