| | |
| | | package com.example.nativecodec; |
| | | |
| | | import android.graphics.SurfaceTexture; |
| | | import android.opengl.GLES10; |
| | | import android.opengl.GLES10Ext; |
| | | import android.opengl.GLES11Ext; |
| | | import android.opengl.GLES30; |
| | | import android.opengl.GLES31Ext; |
| | | import android.util.Log; |
| | | |
| | | import java.nio.Buffer; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | | import java.nio.FloatBuffer; |
| | |
| | | import android.os.SystemClock; |
| | | import android.util.AttributeSet; |
| | | |
| | | import static android.opengl.GLES20.glGetError; |
| | | //import static cn.com.basic.face.util.RtspFaceNative.dbgReadTexture; |
| | | |
| | | public class MyGLSurfaceView extends GLSurfaceView { |
| | | |
| | | MyRenderer mRenderer; |
| | | |
| | | public MyGLSurfaceView(Context context) { |
| | | |
| | | this(context, null); |
| | | } |
| | | |
| | |
| | | mLastTime = SystemClock.elapsedRealtimeNanos(); |
| | | } |
| | | |
| | | ByteBuffer buf = ByteBuffer.allocateDirect( 1920 * 1088 * 4); |
| | | |
| | | @Override |
| | | public void onDrawFrame(GL10 glUnused) { |
| | | synchronized(this) { |
| | |
| | | |
| | | GLES20.glActiveTexture(GLES20.GL_TEXTURE0); |
| | | GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureID); |
| | | checkGlError("glBindTexture"); |
| | | |
| | | //ByteBuffer buf = ByteBuffer.allocateDirect( 1920 * 1088 * 4); |
| | | //GLES11Ext.glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, buf); |
| | | //checkGlError("glEGLImageTargetTexture2DOES"); |
| | | |
| | | mVertices.position(VERTICES_DATA_POS_OFFSET); |
| | | GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false, |
| | |
| | | |
| | | GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); |
| | | checkGlError("glDrawArrays"); |
| | | |
| | | |
| | | //GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureID); |
| | | //checkGlError("glBindTexture"); |
| | | |
| | | //buf.rewind(); |
| | | //GLES11Ext.glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, buf); |
| | | //if (glGetError() == 0) |
| | | //{ |
| | | // byte[] newbuf = new byte[1920 * 1088 * 4]; |
| | | // buf.get(newbuf); |
| | | // int aa=123; |
| | | //} |
| | | // |
| | | |
| | | |
| | | //GLES20.glFinish(); |
| | | |
| | | //dbgReadTexture(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | private void checkGlError(String op) { |
| | | int error; |
| | | while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { |
| | | while ((error = glGetError()) != GLES20.GL_NO_ERROR) { |
| | | Log.e(TAG, op + ": glError " + error); |
| | | throw new RuntimeException(op + ": glError " + error); |
| | | //throw new RuntimeException(op + ": glError " + error); |
| | | } |
| | | } |
| | | |
| | |
| | | private long mLastTime = -1; |
| | | private long mRunTime = 0; |
| | | |
| | | private int mPBOID; |
| | | |
| | | |
| | | private static final String TAG = "MyRenderer"; |
| | | |
| | | // Magic key |