🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

What's the best way to show multiple camera views (like security cameras) with OpenGL

Started by
2 comments, last by EBZ 3 years, 9 months ago

I wanted to make a scene where you see 4 quads on screen (in a grid), each one with a different security camera shots showing completely different scenes.

I was thinking of recording those different shots/scenes using FBO's and then rendering the recorded scene using the fbo's resolved texture on to each quad. So in other words, an fbo for each security camera.


Would that be an optimal way of doing it or is there a better way? Thanks all!.

Advertisement

I'm assuming that you are not doing parallel rendering and that all you viewports are the same size and all use the same colour bit depth for render targets.

Under this assumption and in this case u could iterate through each of the 4 cams and render each scene in turn. Then after the last cam is rendered display the result to screen. This way u only need 1 FBO, 1 quad.

// pseudo

renderer.setrendertarget(fbo)
renderer.setvshader(...)
renderer.setpshader(...)
renderer.bindallsortofdata(...)
for (cam: cams)
{
  // a viewport defines an area that will be drawed on, anything outside of viewport area will not be rendered, so each cam show define its own viewport
  cam.setviewport(renderer)  
  
  // not a must, but you can also lookup scissors( ) as they define the drawing area that will be cut away, if a scissor is not defined that it matches the viewport size
  cam.setscissor(renderer) 
  
  cam.renderscene(renderer, and pass the appropriate scene) 
}
renderer.unbindallsortofdata()
renderer.unsetvshader()
renderer.unsetpshader()
renderer.unsetrendertarget(fbo)

renderer.renderquadwithtexturefromfbo()

renderer.show( )

Something like this should do the trick.

If you're doing parallel rendering, then use 4 fbos, etc…

That's it. All the best ?

Hey ddlox! I just tried you suggested (using the viewport) and this works perfectly! I was over complicated myself. Thanks for pointing me towards the right direction. Salute!

This topic is closed to new replies.

Advertisement