Displaying the camera stream on a GLSurfaceView via SurfaceTexture

后端 未结 2 1110
忘了有多久
忘了有多久 2021-02-06 04:34

I\'m trying to display the camera stream in a GLSurfaceView via a SurfaceTexture trasmitted to OpenGL ES 2.0 shaders.

I took inspiration from this post.

The imag

2条回答
  •  情书的邮戳
    2021-02-06 05:06

    I have used the SurfaceTexture succesfully to draw camera frames on a custom opengl texture without using the transformation matrix provided by android.

    Just try defining your indices vertices and textures the way you would do it for a normal texture draw. Like this for example.

    const GLfloat Vertices[] = {0.5, -0.5, 0,
                                0.5, 0.5, 0,
                               -0.5, 0.5, 0,
                               -0.5, -0.5, 0};
    
    const GLubyte Indices[] = { 0, 1, 2,
                                2, 3, 0 };
    
    const GLfloat Textures[] = { 1.,0.,
                                 0.,0.,
                                 0.,1.,
                                 1.,1. };
    

    You should be able to use the surfacetexture the way you use a normal texture.

    In case you want to perform some sort of 3D projection, this is a good post on how to generate a proper MVP matrix. Which you could use to multiply with the position in the vertex shader.

提交回复
热议问题