Recently I have been playing around with OpenGL 4.5 and I wanted to add a nice GUI. Since I worked with CEGUI (and Ogre) in the past, I wanted to add CEGUI. So currently I am trying to get CEGUI 0.8.4 to work on a Windows 8.1 x64 machine (my program is x64).
For various reasons, I want to render the GUI to a texture and then send the texture to my shader. At the moment, though, I only send the texture to my shader without using the texture in my shader. I first have to make sure the CPU code works properly. And I think there is a problem with it.
Case: No GUI rendering, with/without texture upload
Result: Sponza
Preview: https://puu.sh/jwqWL/85b425096d.png
Case: GUI rendering, with/without texture upload
Result: Black screen
Preview: https://puu.sh/jwr9W/9c5ad3e12d.png
I am confident, that my initialization code is correct (setting up resource groups and the like). But I think my error is in the code which creates the windows and renders them. Please see the extract below and tell me if I am doing anything wrong. Most of the below code is from the wiki, but is not specific to RTT - my guess is that this is the problem.
Code: Select all
GUI::GUI()
{
//...
renderTextureTarget = ceguiSystem->getRenderer()->createTextureTarget();
renderTextureTarget->declareRenderSize(CEGUI::Sizef(engine->getFromConfig<unsigned int>("window.sizeX") * 1.f, engine->getFromConfig<unsigned int>("window.sizeY") * 1.f));
renderGuiContext = &ceguiSystem->createGUIContext(static_cast<CEGUI::RenderTarget&>(*renderTextureTarget));
//...
wmgr = &CEGUI::WindowManager::getSingleton();
root = wmgr->createWindow("DefaultWindow", "root");
CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(root);
}
void GUI::test()
{
CEGUI::SchemeManager::getSingleton().createFromFile("TaharezLook.scheme", "schemes");
CEGUI::FontManager::getSingleton().createFromFile("DejaVuSans-10.font", "fonts");
CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont("DejaVuSans-10");
CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");
CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultTooltipType("TaharezLook/Tooltip");
FrameWindow* fWnd = static_cast<FrameWindow*>(wmgr->createWindow("TaharezLook/FrameWindow", "testWindow"));
root->addChild(fWnd);
// position a quarter of the way in from the top-left of parent.
fWnd->setPosition(UVector2(UDim(0.25f, 0.0f), UDim(0.25f, 0.0f)));
// set size to be half the size of the parent
fWnd->setSize(USize(UDim(0.5f, 0.0f), UDim(0.5f, 0.0f)));
fWnd->setText("Hello World!");
}
void GUI::render()
{
renderer->beginRendering();
renderTextureTarget->clear();
renderGuiContext->draw();
renderer->endRendering();
}
GLuint GUI::getTexID()
{
return ((CEGUI::OpenGLTexture&)renderTextureTarget->getTexture()).getOpenGLTexture();
}
GUI is initialized, then GUI::test() is called. After that, I call GUI::render() every frame before drawing the geometry. I use multiple render-passes, so there is one screen-filling quad which is drawn to during the last pass. That's when I bind the GUI texture.
Thank you for your help in advance