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.
CEGUI + Ogre3D: can't take CEGUI screenshot
Moderators: CEGUI MVP, CEGUI Team
Re: CEGUI + Ogre3D: can't take CEGUI screenshot
Let me post some relevant code of the application.
I have a method of the application class that initializes CEGUI:
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:
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
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
Re: CEGUI + Ogre3D: can't take CEGUI screenshot
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.
Re: CEGUI + Ogre3D: can't take CEGUI screenshot
I'm taking it with ogre, this way:
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.
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.
Re: CEGUI + Ogre3D: can't take CEGUI screenshot
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.
Re: CEGUI + Ogre3D: can't take CEGUI screenshot
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?
Re: CEGUI + Ogre3D: can't take CEGUI screenshot
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()
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()
Re: CEGUI + Ogre3D: can't take CEGUI screenshot
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.
Re: CEGUI + Ogre3D: can't take CEGUI screenshot
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.
If you just copy the startRendering method as it is with no changes it will not work, as you remarked.
Re: CEGUI + Ogre3D: can't take CEGUI screenshot
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.
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.
-
- Just popping in
- Posts: 18
- Joined: Sat Aug 04, 2012 16:35
Re: CEGUI + Ogre3D: can't take CEGUI screenshot
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.
Who is online
Users browsing this forum: No registered users and 6 guests