No rendering on child windows created by SetParent native api method

glfw 3.3.2
windows 10

I am creating a unified window system and using native api using SetParent function.

SetParent(glfwGetWin32Window(child), glfwGetWin32Window(parent));

It’s working perfectly fine and all the child windows seamlessly become one with the main window. All the child windows are created with no decoration. However, the problem is that when rendering, nothing appears. I’m setting the context using glfwMakeContextCurrent(child) just before rendering on the child window but nothing appears.
After searching on google I even tried this:

glfwMakeContextCurrent( window );   
auto hglrc = glfwGetWGLContext(window);
auto current_dc = wglGetCurrentDC();
wglMakeCurrent(current_dc, hglrc);

still no luck!!! If I don’t use the SetParent call then everything renders perfectly but that’s not the purpose. I would appreciate if someone point out the correct way to do it.

Hi PrashantSaxena ,

Welcome to the GLFW forum.

I don’t know enough about child windows and OpenGL since when I’ve needed this behaviour I’ve simply closed the second window and rendered the window content to a region of the main window directly - this is also how the popular Dear ImGui docking branch works.

I did find a bit of code on Github using GLFW and SetParent, which I can’t find again (sorry). However it appeared to be resting some style attributes similar to the post below:

Perhaps that might work for you?

Good luck,