Second Viewport

Blitz3D Forums/Blitz3D Programming/Second Viewport

MajesticSpaceBen(Posted 2013) [#1]
Basically, I'm trying to display the view of a second camera in the upper right corner of the screen, on top of the existing viewport. I tried simply creating another viewport, but it did not seem to appear. The screen seemed to be unchanged.

Any tips on how to do this?


Yasha(Posted 2013) [#2]
I can't remember what actually happens when you have two cameras set to draw over the same area at once but it could be that the ordering isn't well-defined. In that case, you can split your rendering up into two passes:

- hide your main camera
- draw your small viewport (to anywhere) with RenderWorld
- copy your small view to a texture on a quad in the main scene, or just to a texture buffer, with CopyRect
- hide your small viewport camera
- show your main camera
- draw your main scene with RenderWorld
- if you put the copy on a quad, it will be drawn as part of the scene; if not, CopyRect it over the scene in a 2D drawing operation now

You usually end up doing some variation on this when multiple points of view are involved, as the complexity ratchets up quite quickly anyway and you usually want to start restricting things.


Rroff(Posted 2013) [#3]
If your rendering the smaller overlay viewpoint last after doing the main screen then it _should_ be ordered to display on top - it works correctly for other stuff where you render one scene first with certain settings then render again without clearing z-buffer or color buffer, etc. so aslong as your not sending them to be rendered in the wrong order should show up fine.


MajesticSpaceBen(Posted 2013) [#4]


Here's my code, does it seem right?


Floyd(Posted 2013) [#5]
Try creating the cameras in the opposite order. Or use EntityOrder to specify which camera renders last.

That's just a guess, but I know I did something like this.