CEGUI + Ogre3D: can't take CEGUI screenshot

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

Falcon
Just popping in
Just popping in
Posts: 6
Joined: Thu Aug 30, 2012 09:49

CEGUI + Ogre3D: can't take CEGUI screenshot

Postby Falcon » Thu Aug 30, 2012 11:49

Hi,

I'm using CEGUI with Ogre, and when I take a screenshot within a ogre scene it's fine, but when I load a CEGUI window and take a screenshot only the ogre scene appears in it. Do you know how to solve this problem?

I can show some frags of the code. The app is heavly OOP and there are lot's of classes and factories; just ask something specific and I will post it.

Falcon
Just popping in
Just popping in
Posts: 6
Joined: Thu Aug 30, 2012 09:49

Re: CEGUI + Ogre3D: can't take CEGUI screenshot

Postby Falcon » Tue Sep 04, 2012 18:34

Let me post some relevant code of the application.

I have a method of the application class that initializes CEGUI:

Code: Select all

const bool RSOApp::RSOApplication::initCEGUI() {
   bool success = true;

   if (!this->ceguiOgreRenderer) {
      // this->window is a Ogre::RenderWindow* initialized as:
      // this->window = this->root->initialise(true, "RSOApplication Render Window");
      // this->root is a Ogre::Root* initialized as:
      // this->root = new Ogre::Root(this->pluginsCfg);
      Ogre::RenderTarget* renderTarget = this->window;
      this->ceguiOgreRenderer = &CEGUI::OgreRenderer::bootstrapSystem(*renderTarget);
      CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);

      CEGUI::Imageset::setDefaultResourceGroup("Imagesets");
      CEGUI::Font::setDefaultResourceGroup("Fonts");
      CEGUI::Scheme::setDefaultResourceGroup("Schemes");
      CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
      CEGUI::WindowManager::setDefaultResourceGroup("Layouts");

      CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme");
      CEGUI::FontManager::getSingleton().create("DejaVuSans-10.font");
      CEGUI::System::getSingleton().setDefaultFont("DejaVuSans-10");
      CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
      CEGUI::Window* myRoot = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow");
      CEGUI::System::getSingleton().setGUISheet(myRoot);
      CEGUI::SchemeManager::getSingleton().create("RSO.scheme");
   }

   return success;
}


I call this method after I setup the application (configure, create camera, create viewports) just when I'm creating the scene _before_ I create the frame listener.

For the record, the method (it's from another class) that loads the CEGUI window is:

Code: Select all

void BaseWindow::createCEGUIWindow(const char* layoutName) {
   std::ostringstream cast;

   ++this->instanceNumber;
   cast << this->instanceNumber;
   this->namePrefix = cast.str();
   this->namePrefix += "_";

   this->window = CEGUI::WindowManager::getSingletonPtr()->loadWindowLayout(layoutName, this->namePrefix);

   if (this->window) {
      CEGUI::System::getSingleton().getGUISheet()->addChildWindow(this->window);
      this->registerHandlers();
      this->window->setUserData(this);
   } else {
      CEGUI::Logger::getSingleton().logEvent("Error: Unable to load the window from .layout");
   }
}


I think that the problem would be in the initCEGUI method, or maybe in the order that I setup the application. It would be nice if any of you can take a look at this and help me, I'm sure that I'm missing something really easy and therefore making a little mistake.

Thank you in advance :)

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: CEGUI + Ogre3D: can't take CEGUI screenshot

Postby Kulik » Tue Sep 04, 2012 19:19

What are you using to take the screenshot? Your OS feature or some Ogre feature? At which point are you taking the screenshot? My bet would be that you are taking it before CEGUI renders over the scene.

Falcon
Just popping in
Just popping in
Posts: 6
Joined: Thu Aug 30, 2012 09:49

Re: CEGUI + Ogre3D: can't take CEGUI screenshot

Postby Falcon » Tue Sep 04, 2012 21:48

I'm taking it with ogre, this way:

Code: Select all

this->window->writeContentsToTimestampedFile("screenshot", ".jpg");


I'm taking several screenshots, anytime after the cegui window is shown.

The screenshot only saves the content of the ogre "scene", or whatever is called. It doesn't save the content of the cegui window.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: CEGUI + Ogre3D: can't take CEGUI screenshot

Postby Kulik » Wed Sep 05, 2012 00:33

Kulik wrote:My bet would be that you are taking it before CEGUI renders over the scene.


Make sure you write the contents to disk AFTER CEGUI renders or before you clear the colour buffer.

Falcon
Just popping in
Just popping in
Posts: 6
Joined: Thu Aug 30, 2012 09:49

Re: CEGUI + Ogre3D: can't take CEGUI screenshot

Postby Falcon » Wed Sep 05, 2012 23:09

Kulik wrote:
Kulik wrote:My bet would be that you are taking it before CEGUI renders over the scene.


Make sure you write the contents to disk AFTER CEGUI renders or before you clear the colour buffer.


How can I check that? The application uses the Ogre::Root startRendering method and there I think that it calls the frameRenderingQueued method until returns false. Do I have to write a custom render loop?

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: CEGUI + Ogre3D: can't take CEGUI screenshot

Postby Kulik » Thu Sep 06, 2012 08:27

I always have custom render loop with Ogre so I am not overly familiar with this interface. Either have a custom loop or look it up in the docs, IIRC it's something priority based, you definitely can change the order in which the listeners get called.

Going forward you do want a custom loop IMO, personally I don't see much benefit in the startRendering() interface.

EDIT: One more thing I forgot, CEGUI plugs itself in using listeners, this will still work when you use renderOneFrame()

Falcon
Just popping in
Just popping in
Posts: 6
Joined: Thu Aug 30, 2012 09:49

Re: CEGUI + Ogre3D: can't take CEGUI screenshot

Postby Falcon » Thu Sep 06, 2012 23:17

Kulik wrote:Either have a custom loop or look it up in the docs, IIRC it's something priority based, you definitely can change the order in which the listeners get called.


I have implemented a basic render loop from OGRE tutorials:

Code: Select all

bool stopRendering = false;

while (!stopRendering) {
   Ogre::WindowEventUtilities::messagePump();

   if (this->window->isClosed()) {
      stopRendering = true;
   } else {
      if (!this->root->renderOneFrame()) {
         stopRendering = true;
         success = false;
      }
   }
}


This loop is doing exactly the same as before (this->root->startRendering()) and therefore the app doesn't dump the CEGUI window in the screenshot.

Kulik wrote:EDIT: One more thing I forgot, CEGUI plugs itself in using listeners, this will still work when you use renderOneFrame()


You have made me think of the events of the frameListener, and maybe the problem is that I must take the screenshot in he frameEnded event and not in the frameRenderingQueued. In the queued event I catch the keyboard input so is there where the screenshot is taken.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: CEGUI + Ogre3D: can't take CEGUI screenshot

Postby Kulik » Fri Sep 07, 2012 09:24

You keep posting code but you haven't posted where exactly you snap the screenshot! Do it in the main loop after everything has rendered.

If you just copy the startRendering method as it is with no changes it will not work, as you remarked.

Falcon
Just popping in
Just popping in
Posts: 6
Joined: Thu Aug 30, 2012 09:49

Re: CEGUI + Ogre3D: can't take CEGUI screenshot

Postby Falcon » Sun Sep 09, 2012 23:08

I have finally solved this moving the keyboard input capture to the frameEnded method. Thank you for your hint Kulik :)

Anyway, the keyboard capture method I think that must happen before the rendering, so I will implement some logic to catch the screenshot order before rendering and save the content to file later after the rendering has ended.

MorbidAngel
Just popping in
Just popping in
Posts: 18
Joined: Sat Aug 04, 2012 16:35

Re: CEGUI + Ogre3D: can't take CEGUI screenshot

Postby MorbidAngel » Mon Sep 10, 2012 17:56

Just force a render 1 frame call in the screenshot function to ensure you get the latest, grab the backbuffer content and add any overlay on top if you want that.


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 11 guests