Only Render a Single Camera

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
User avatar
Moohasha
Gnoll
Posts: 672
Joined: Fri Dec 07, 2007 7:37 pm
x 8

Only Render a Single Camera

Post by Moohasha »

I have an application in which I'm creating multiple view windows, each of which has its own camera in the same scene. For the sake of performance I don't want to use a render loop, because much of the time things in my scene won't be changing and it's wasted overhead to render the scene if nothing changed. If something in the scene changes (an item is added or moved), then I want to refresh the whole scene and update all windows. This is working fine.

However, if the user just moves the camera in a single window, I only want to refresh the view in that window. I don't want to render the entire scene again and have all windows get updated.

The documentation for Ogre::Camera::_renderScene() says that it tells the camera to contact the SceneManager to render from its viewport, but calling this doesn't seem to do anything. As in, the scene does not actually render and I don't see anything in the window. Am I not doing this right, or is there a better way to render only a single camera?

Edit: I'm using Ogre 1.7. I know it's a little old. I'm trying to get 2.1 approved for us to use, but for now we're stuck with 1.7.
Black holes are where God divided by 0
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Only Render a Single Camera

Post by Kojack »

You could call the update method of the viewport. That will render the scene using the camera attached to that viewport.
That will bypass the buffer swap though, you might need to do that manually for the changes to appear on screen.

If you want everything to work normally (render events fired, buffer swapping, etc) and your program is using separate render targets for each view (such as separate windows), then you could deactivate all render targets by default, set just one to active and call renderOneFrame. Only that one will update.
User avatar
Moohasha
Gnoll
Posts: 672
Joined: Fri Dec 07, 2007 7:37 pm
x 8

Re: Only Render a Single Camera

Post by Moohasha »

Thanks Kojack! I changed my window to just call mRenderTarget->update(true); and it works like a charm! :D
Black holes are where God divided by 0
Post Reply