Render to viewport

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
QuantumLeap
Posts: 38
Joined: Mon Sep 25, 2006 6:31 pm
Location: San Francisco, California

Render to viewport

Post by QuantumLeap »

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()?
It's easier to curse a candle than light the darkness
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

need to update one of them on every cycle and the other two only once in a while. How to do it?
Write a little bit of code that only updates the two other viewports occasionally or when necessary. It isn't difficult to do.

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...
}
Of course a cleaner way to do it would be to create a task system that invokes a function object periodically. You would just create a function object that would render the view given the driver, scene manager, camera and view area. You would just set the task system to invoke that function every second and you'd be set.

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, ...
Instead of smgr->drawAll() is there any method like smgr->drawAllOnViewport()?
What would such a method do? Just the setup stuff and the drawAll? In that case...

Code: Select all

void ISceneManager_drawAllOnViewPort(IVideoDriver* driver, ISceneManager* smgr, SViewPort* viewPort)
{
    driver->setViewPort(viewPort->ViewPort);
    smgr->setActiveCamera(viewPort->Camera);
    smgr->drawAll();
}
Like I said, a task or timer system would be just perfect. That way you wouldn't have to clutter up your main loop with viewport manipulation and draw calls.

Travis
Post Reply