Game Development Reference
In-Depth Information
Listing 9-3 shows CameraSurface version 2 as a GL surface designed to use the preview
display of a Camera object as well as being capable of doing GLES drawing operations. The
caveat with this CameraSurface is that a GLES surface cannot set a Camera preview display
and vice versa; a push buffer ( Camera ) surface cannot do GLES system calls to draw virtual
objects on top. Take a look at Listing 9-3; when the camera surface constructor is called, the
surface type is set to GPU (hardware).
mHolder.setType(SurfaceHolder.SURFACE_TYPE_GPU)
Whenever this surface attempts to set itself as the preview display of the camera with
camera.setPreviewDisplay(holder);
an exception will be thrown with the error “Invalid Surface” and the app will crash. Therefore,
you cannot use this version of CameraSurface . To work around this caveat, AndAR uses two
surfaces: a push buffer surface for the video feed, and an OpenGL ES surface to perform GL
drawing calls, as seen in Figure 9-4 .
Figure 9-4. Merging GL and push buffer surfaces into the same view display
 
Search WWH ::




Custom Search