简体   繁体   中英

Android : Single SurfaceView vs multiple SurfaceView

I am trying to draw 3D object onto camera preview frames (Android). Should I use two surface views, one for camera preview and another GLSurfaceView for drawing. The views should be synchronized and frame rate of display should be good enough to provide a good user experience. So most of the tutorials talk about using multiple views. The alternate idea is to get texture from camera preview and merge it with the 3D object to be drawn so as to get the appropriate 2D raster image. Which method would be better for performance gains?

PS : I will be using the Java APIs for openGL es 2.0

Since two surface views increase the number of API calls per frame and require transparency, they will be slower.

You don't need two surface views for your purpose.

  1. Disable depth writes.
  2. Render the camera preview on a 2D quad filling the screen.
  3. Enable depth writes.
  4. Render 3D object.

This will make sure your 3D objects are rendered over the camera preview.

You can also achieve this with two surface views and transparency, but it will be slower.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM