From 72505b6ff2ee0342a6950af306da0942718ca0b4 Mon Sep 17 00:00:00 2001 From: pans <pans@454eff88-639b-444f-9e54-f578c98de674> Date: 星期五, 18 八月 2017 15:54:36 +0800 Subject: [PATCH] capnp fix bug --- VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/MyGLSurfaceView.java | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 41 insertions(+), 2 deletions(-) diff --git a/VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/MyGLSurfaceView.java b/VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/MyGLSurfaceView.java index 60ac5e3..b273c29 100644 --- a/VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/MyGLSurfaceView.java +++ b/VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/MyGLSurfaceView.java @@ -17,8 +17,14 @@ 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; @@ -33,11 +39,15 @@ 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); } @@ -87,6 +97,8 @@ mLastTime = SystemClock.elapsedRealtimeNanos(); } + ByteBuffer buf = ByteBuffer.allocateDirect( 1920 * 1088 * 4); + @Override public void onDrawFrame(GL10 glUnused) { synchronized(this) { @@ -106,6 +118,11 @@ 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, @@ -135,6 +152,25 @@ 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 @@ -280,9 +316,9 @@ 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); } } @@ -339,6 +375,9 @@ private long mLastTime = -1; private long mRunTime = 0; + private int mPBOID; + + private static final String TAG = "MyRenderer"; // Magic key -- Gitblit v1.8.0