How to draw graphics outside window (OpenGL glfw)

Viewed 1667

I want to know how I can draw opengl graphics outside the main drawing window (GLFW). An example can be seen with the ImGUI library. With the ImGui docking, you are able to drag the panels outside the main window. How does ImGui go about doing that; drawing graphics outside the main window?. How can I achieve this with openGL and glfw? I am using c++ btw. Thanks!

1 Answers

For OpenGL you always need a context to draw in. Such a context is either an offscreen context (all drawing to that context are not visible on the screen) or a context that is bound to the canvas of a window.

How that window looks like depends on the used library and system, but you never can draw outside of that window/canvas.

ImGUI is a library that composes a UI using various components/primitives within the OpenGL context. The UI elements of ImGUI are no OS related UI elements. And ImGUI windows are nothing that will be recognized by the OS as a window, but just a collection of pixels in the OpenGL context that form the visual appearance of the UI. ImGUI has the same limitations you have, it can't draw outside of the main window of the OpenGL context.

Related