I can't figure out if it's allowed to have a viewport with no camera, either ever, or between frames while changing things around.
Is there a definitive answer?
Creating/setting a viewport with NULL camera?
-
simedj
- Goblin
- Posts: 262
- Joined: Fri Nov 18, 2011 6:50 pm
- x 3
Creating/setting a viewport with NULL camera?
Looking to find experienced Ogre & shader developers/artists. PM me with a contact email address if interested.
-
Mind Calamity
- Ogre Magi
- Posts: 1255
- Joined: Sat Dec 25, 2010 2:55 pm
- Location: Macedonia
- x 81
Re: Creating/setting a viewport with NULL camera?
Viewports basically display what the camera sees, so if there is no camera, what would the viewport show, and why would you need such behavior ?
What are you trying to do ?
What are you trying to do ?
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
-
simedj
- Goblin
- Posts: 262
- Joined: Fri Nov 18, 2011 6:50 pm
- x 3
Re: Creating/setting a viewport with NULL camera?
I know a viewport won't be able to render anything with no camera, that's not the question.
As for an example why I might want to do this... maybe I want a user able to create a panel which they can pick a camera to display on. The panel is not full-screen and there is initially no camera picked. Ideally I'd like to create a viewport the right size, ready to set a camera to. But if I need a camera, I must cache somewhere the dimensions of the viewport to use when the camera is first set. Also, every time the camera is set I must check if the viewport exists first and create it if needed, which is a little messy.
Or another example, what if I'm doing a GUI or overlays or something. Do I have to create a 'dummy' camera just to get things to work? I know overlays are a special case but I assume they are still rendered to a viewport so again - is a camera required?
In my mind, a viewport with no camera would just not bother rendering anything 3D; maybe it gets cleared each frame and 2D stuff rendered, but I have no clue how Ogre internals work to know if that makes sense.
As for an example why I might want to do this... maybe I want a user able to create a panel which they can pick a camera to display on. The panel is not full-screen and there is initially no camera picked. Ideally I'd like to create a viewport the right size, ready to set a camera to. But if I need a camera, I must cache somewhere the dimensions of the viewport to use when the camera is first set. Also, every time the camera is set I must check if the viewport exists first and create it if needed, which is a little messy.
Or another example, what if I'm doing a GUI or overlays or something. Do I have to create a 'dummy' camera just to get things to work? I know overlays are a special case but I assume they are still rendered to a viewport so again - is a camera required?
In my mind, a viewport with no camera would just not bother rendering anything 3D; maybe it gets cleared each frame and 2D stuff rendered, but I have no clue how Ogre internals work to know if that makes sense.
Looking to find experienced Ogre & shader developers/artists. PM me with a contact email address if interested.
-
bstone
- OGRE Expert User

- Posts: 1920
- Joined: Sun Feb 19, 2012 9:24 pm
- Location: Russia
- x 201
Re: Creating/setting a viewport with NULL camera?
Viewports only update if they have a camera assigned to them so you can have a viewport without a camera. You can also stop viewport from auto-updating each frame even if it has a camera, just in case.
-
saejox
- Goblin
- Posts: 260
- Joined: Tue Oct 25, 2011 1:07 am
- x 36
Re: Creating/setting a viewport with NULL camera?
Is it possible to have a viewport without a camera to just to display Overlays?
-
Kojack
- OGRE Moderator

- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 538
Re: Creating/setting a viewport with NULL camera?
To render an overlay, it needs to know the scene manager, to get the correct render queue to insert the overlay into. But viewports don't know which scene manager to use. That info is in the camera. The overlay system asks the camera attached to the viewport for the scene manager (you could have different scene managers on each viewport, so there's no one global scene manager to always use). Without a camera, the overlay system won't work.
-
saejox
- Goblin
- Posts: 260
- Joined: Tue Oct 25, 2011 1:07 am
- x 36
Re: Creating/setting a viewport with NULL camera?
@Kojack Thank you.