Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Answer:</strong></p> <p>1) Start with the source code of the GLSurfaceView, name the file GLTextureView.java</p> <p>2) Change the header to: <strong>GLTextureView extends TextureView implements SurfaceTextureListener</strong></p> <p>3) Rename constructors to GLTextureView. Remove code from init() method.</p> <p>4) Organize imports. Always choose the non-GLSurfaceView option.</p> <p>5) Find every instance of SurfaceHolder and change it to a SurfaceTexture</p> <p>6) Add Unimplemented methods for the SurfaceTextureListener, each method should be as follows:</p> <ul> <li>onSurfaceTextureAvailable - surfaceCreated(surface)</li> <li>onSurfaceTextureDestroyed - surfaceDestroyed(surface), (return true)</li> <li>onSurfaceTextureSizeChanged - surfaceChanged(surface, 0, width, height)</li> <li>onSurfaceTextureUpdated - requestRender()</li> </ul> <p>7) There should be one line where there is a call being made to getHolder(), change that to getSurfaceTexture()</p> <p>8) In the init() method, put the following line <code>setSurfaceTextureListener(this)</code></p> <p>Then add an <code>OnLayoutChangeListener</code> and have it call <code>surfaceChanged(getSurfaceTexture(), 0, right - left, bottom - top)</code>.</p> <p>With that you should be able to replace your GLSurfaceView code with <code>GLTextureView</code> and receive the benefits of <code>GLTextureView</code>. Also make sure your app supports Hardware Acceleration and that your Renderer extends <code>GLTextureView</code>.Renderer.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload