Custom render loop

Problems building or running the engine, queries about how to use features etc.
Post Reply
kshegunov
Gnoblar
Posts: 10
Joined: Fri May 08, 2015 3:34 pm

Custom render loop

Post by kshegunov »

Hello,
I have somewhat curious behavior when I try to implement my own render loop I could use some help with. Firstly, I'd like to note that I'm using Qt as the ogre window container and for the purpose of testing I've added a terrain group instance with a few tiles and the ogre head mesh at the origin of the coordinate system. I do the rendering as follows:
- I set up a timer with 60fps rate and at each tick I make the following calls:

Code: Select all

// These two I got from the OGRE source code
// I invoke it when I have no windows currently requesting update (if more than one window wants to render, I just call them once).
Ogre::WindowEventUtilities::messagePump();
d->root->_fireFrameStarted();

// This should just render the frame
d->window->update(false);
d->window->swapBuffers();

// Those two I got from the OGRE source code as well
// Similarly when all the requested window render requests have returned (I do this by simple counter), I fire the "frameRendered" event.
for (Ogre::SceneManagerEnumerator::SceneManagerIterator it = d->root->getSceneManagerIterator(); it.hasMoreElements(); it.moveNext())
     it.peekNextValue()->_handleLodEvents();
d->root->_fireFrameEnded();
What I'm trying to achieve is having two windows with different frame rates. All in all this *almost* works. The scene is rendered, but when I start the render timer (my render loop) I get a disappearance of my directional light. I might have missed something, that's why I'm writing here for help. Here is what I get before https://drive.google.com/file/d/0B77vjX ... sp=sharing and after https://drive.google.com/file/d/0B77vjX ... sp=sharing I start the render loop. Ideally I'd like to queue all the render requests and do rendering once for all windows that want it when there's no pending events.

As an additional question, what does Viewport::update exactly do, can I use it to update my window independently of the rendering process?

Kind regards!
kshegunov
Gnoblar
Posts: 10
Joined: Fri May 08, 2015 3:34 pm

Re: Custom render loop

Post by kshegunov »

Right, I have muddled through some of the Ogre source, and I think now I better understand what is called when. Now I was indeed able to put up my own rendering loop, by using a render target listener and calling Ogre::Root::_fireFrameStarted and Ogre::Root::_fireFrameEnded where appropriate. The ogre head mesh is rendering fine, but for some unknown reason (at least I can't figure it out) the terrain is not showing at all. Am I missing something in my update code, should I manually trigger a terrain render/update request?

Kind regards!
Post Reply