I've tried many things to get CEGUI to render interface to multiple windows, but in the end, it renders to only one window, whichever one I last activated the OpenGL viewport of. I believe that is because of:
Code: Select all
CEGUI::System::getSingleton().renderAllGUIContexts();
Which is rendering all GUIContexts at once to the currently active OpenGL viewport (which is odd, since at least the default GUI context should be rendering to the OpenGL context that was active when I bootstrapped its OpenGL renderer -- at least that should be happening according to the wiki).
Therefore, I believe the solution to the problem is something like this:
Code: Select all
for (std::vector<GUIContext_wrapper* >::iterator iter = contexts.begin(); iter != contexts.end(); ++iter)
{
(*iter)->sfml_window->setActive(); //This sets the current OpenGL viewpoint to the target window.
CEGUI::GUIContext& context = (*iter)->cegui_gui_context;
//Draw the GUI context here.
}
Which would explicitly render each GUI context to the desired OpenGL viewport as opposed to CEGUI rendering to whatever it happens upon in renderAllGUIContexts().
I looked at the API reference and tried:
Code: Select all
for (std::vector<GUIContext_wrapper* >::iterator iter = contexts.begin(); iter != contexts.end(); ++iter)
{
(*iter)->sfml_window->setActive(); //This sets the current OpenGL viewpoint to the target window.
CEGUI::GUIContext& context = (*iter)->cegui_gui_context;
context.draw();
}
But that doesn't work. CEGUI doesn't render anything and any rendering I do with OpenGL or SFML is very glitchy.
I tried combining the context.draw() with renderAllGUIContexts():
Code: Select all
for (std::vector<GUIContext_wrapper* >::iterator iter = contexts.begin(); iter != contexts.end(); ++iter)
{
(*iter)->sfml_window->setActive(); //This sets the current OpenGL viewpoint to the target window.
CEGUI::GUIContext& context = (*iter)->cegui_gui_context;
context.draw();
}
CEGUI::System::getSingleton().renderAllGUIContexts();
No go. CEGUI renders now, but it's still only to one window. Rendering with OpenGL or SFML is very glitchy, again.
I remembered I read:
The created Renderer will use the current OpenGL viewport as it's
default surface size.
in the API documentation about the bootstrap function for the OpenGL Renderer, so I set the current OpenGL viewport where I created the renderer and GUI context to the viewport I want it to render to:
Code: Select all
wrapper.window->setActive();
wrapper.cegui_renderer = &CEGUI::OpenGLRenderer::create();
wrapper.cegui_gui_context = &CEGUI::System::getSingleton().createGUIContext(wrapper.cegui_renderer->getDefaultRenderTarget());
[code]
I know the GUI contexts see the right OpenGL viewport because:
[code]
std::cout << "Context size: " << context.getSurfaceSize() << "\n";
Outputs each context's target window's size, not the size of any other window.
Therefore, I conclude that neither ideas I had, nor any of the other countless things I've tried while browsing the forums, wiki, and API reference, are the solution.
In conclusion, how do I tell a CEGUI::GUIContext to render itself to the OpenGL viewport I want?