RTT rendering

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

minecrawlerx
Just popping in
Just popping in
Posts: 6
Joined: Sun Apr 08, 2012 16:46

RTT rendering

Postby minecrawlerx » Mon Aug 10, 2015 17:12

Hello CEGUI Community :)

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 :)

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: RTT rendering

Postby Ident » Wed Aug 12, 2015 16:15

Have you looked at this: http://cegui.org.uk/wiki/Rendering_to_t ... 9_in_CEGUI ?


Have you debugged the texture on your GPU to see if CEGUI renders correctly to texture?

So you say that the moment you rneder CEGUI your engine renders black? Have you checked OpenGL state changes? To debug the GPU use CodeXL, gldebugger, or whatever is available on your OS and GPU
CrazyEddie: "I don't like GUIs"

minecrawlerx
Just popping in
Just popping in
Posts: 6
Joined: Sun Apr 08, 2012 16:46

Re: RTT rendering

Postby minecrawlerx » Sun Aug 16, 2015 18:33

Ident wrote:Have you looked at this: http://cegui.org.uk/wiki/Rendering_to_t ... 9_in_CEGUI ?

Yes. I use the code from the wiki.

Ident wrote:Have you debugged the texture on your GPU to see if CEGUI renders correctly to texture?

So you say that the moment you rneder CEGUI your engine renders black? Have you checked OpenGL state changes? To debug the GPU use CodeXL, gldebugger, or whatever is available on your OS and GPU


I have a NVIDIA GTX 970. NVIDIA NSIGHT does not find any error when no GUI is rendered. But when I tryt to render the GUI, it tells me: "Trying to draw without a program bound." which is very strange since I do bind a shader program. I cannnot debug further. NSIGHT tells me that I do not use a supported OpenGL version (only up to OpenGL 4.2 in NSIGHT 4.7) - without CEGUI rendering I can debug further (take a look at draw events, view the buffers,...)

NSIGHT debugging with GUI: http://puu.sh/jDP4A/e37c728d45.png

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: RTT rendering

Postby Ident » Sun Aug 16, 2015 18:43

I used NSight in the past and found it absolutely useless. Try gldebugger and check your states. The program is free.

Edit:
Also, did you call enableExtraStateAttribs(true)?
CrazyEddie: "I don't like GUIs"

minecrawlerx
Just popping in
Just popping in
Posts: 6
Joined: Sun Apr 08, 2012 16:46

Re: RTT rendering

Postby minecrawlerx » Mon Aug 24, 2015 21:08

Ident wrote:I used NSight in the past and found it absolutely useless. Try gldebugger and check your states. The program is free.

The only program I found is called "gDEBugger". The latest version which "supports" NVIDIA GPUs is from 2012 and crashes all the time. Also it only supports OpenGL up to version 3. Could you please provide me a link? Maybe you meant a different program?

Ident wrote:Edit: Also, did you call enableExtraStateAttribs()?

Yes, I do.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: RTT rendering

Postby Ident » Mon Aug 24, 2015 21:22

gDEbugger is the correct one. Works nicely here and everywhere I tried, I remember though that it crashed when i turned on glew experimetnal or a OpenGL 3.2 Core profile context (compatibility should work). If that doesnt solve the issue then I am sorry that it doesnt work for you, I know none of the other programs well enough to recommend them.


What you can try is to render as little as you can and see if it still works. Then if you got to a point where you can render something + CEGUI, incrementally add things to figure out what breaks it.
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 9 guests