An alternative approach to OpenGL View from above the camera

The traditional way to do a camera preview with OpenGL on the front panel is to take two SurfaceViews (one for the camera the other for OpenGL) and lay them on top of each other. The problem is that laying SurfaceViews is not recommended:

http://groups.google.com/group/android-developers/browse_thread/thread/4850fe5c314a3dc6

So what are the alternatives? I considered the following:

  • Subclass GlSurfaceView, and then call the Camera preview option on the holder of this subclass: Camera.setPreviewDisplay (mHolder);
  • Do not use GLSurfaceView, instead create your own subclass of SurfaceView, where you will show a preview of the camera on the holder, and also draw your openGL. This will require using OpenGL without GLSurfaceView, has anyone done this before?

I’m not sure if this is even possible or makes sense, since it involves displaying the camera’s preview on a surface mount and at the same time drawing OpenGL on the same surface. Is there any other reasonable alternative to solving the problem without using two SurfaceViews?

Thank!

+3
source share
3 answers

, , opengl. Google Maps, , API .

, , , , bindtexture 20-30 , , .

: GL GlSurfaceView, EGL .

0

: OpenGL. OpenGL , - .

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
draw_bottom_layer();

glClear(GL_DEPTH_BUFFER_BIT | stencil_used_as_mask ? GL_STENCIL_BUFFER_BIT : 0 );
draw_mid_layer();

glClear(GL_DEPTH_BUFFER_BIT | stencil_used_as_mask ? GL_STENCIL_BUFFER_BIT : 0 );
draw_top_layer();

"" OpenGL-, . , , , _ * _ layer().

0

I haven't used it yet, so I don't know much about it, but you may find SurfaceTexture useful.

0
source

Source: https://habr.com/ru/post/1783505/


All Articles