I have three cameras each one associated to one viewport in my application. I need to update one of them on every cycle and the other two only once in a while. How to do it? There's only one scene manager in the device.
At this moment I can only update all the viewports at once, which kills my framerate. Instead of smgr->drawAll() is there any method like smgr->drawAllOnViewport()?
Render to viewport
-
QuantumLeap
- Posts: 38
- Joined: Mon Sep 25, 2006 6:31 pm
- Location: San Francisco, California
Render to viewport
It's easier to curse a candle than light the darkness
Write a little bit of code that only updates the two other viewports occasionally or when necessary. It isn't difficult to do.need to update one of them on every cycle and the other two only once in a while. How to do it?
Code: Select all
u32 time0 = device->getTimer()->getRealTime();
while (device->run())
{
// snip...
// setup and render first viewport
u32 time1 = device->getTimer()->getRealTime();
if (1000 < (time1 - time0 ) || reallyNeedRefresh)
{
time0 = time1;
// setup and render other viewports
}
// snip...
}
You could also just alternate which viewport you render each frame. i.e. render view 0 in one render, render view 1 in the next, then 2, then 0, ...
What would such a method do? Just the setup stuff and the drawAll? In that case...Instead of smgr->drawAll() is there any method like smgr->drawAllOnViewport()?
Code: Select all
void ISceneManager_drawAllOnViewPort(IVideoDriver* driver, ISceneManager* smgr, SViewPort* viewPort)
{
driver->setViewPort(viewPort->ViewPort);
smgr->setActiveCamera(viewPort->Camera);
smgr->drawAll();
}
Travis