Do I need to create sub-windows for that?
No, there is an example [1] using only one window. Basically, it is similar to already mentioned in comment above ("rendering to offscreen pixmap"):
Draws all x11 things include text, on pixmap instead of directly on window (all commands are same);
Creates texture from it;
Uses texture as openGL substrate. One may continue to draw openGL things over it.
[1] https://www.khronos.org/opengl/wiki/Programming_OpenGL_in_Linux:_Creating_a_texture_from_a_Pixmap