Converting from GLSurfaceView to TextureView (via GLTextureView)

前端 未结 4 1779
感情败类
感情败类 2020-11-30 21:49

When Android 4.0 (Ice Cream Sandwich) was released, a new view was introduced into the sdk. This View is the TextureView. In the documentation, it says that the TextureView

4条回答
  •  遥遥无期
    2020-11-30 22:36

    Brilliant!

    A minor addition to Mr. Goodale's brilliant answer:

    The 4.1.1 version of GLSurfaceView seems to have been modified to avoid rendering on a zero-width/height surface, I think. And there doesn't seem to be a gratuitous onSurfaceTextureChanged notification immediately following onSurfaceTextureAvailable.

    If you start with the 4.1.1 sources, onSurfaceTextureAvailable needs to read as follows:

    public void onSurfaceTextureAvailable(SurfaceTexture surface, int width,
            int height) 
    {
        this.surfaceCreated(surface);
        this.surfaceChanged(surface, 0,width,height);
    }
    

    Other than that, I was up and running in about five minutes flat! Thanks.

提交回复
热议问题