| | |
| | | import android.util.AttributeSet; |
| | | import android.util.Log; |
| | | |
| | | import com.orhanobut.logger.Logger; |
| | | |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | | import java.nio.FloatBuffer; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Logger.e("onDrawFrame"); |
| | | // Ignore the passed-in GL10 interface, and use the GLES20 |
| | | // class's static methods instead. |
| | | GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
| | |
| | | GLES20.glEnableVertexAttribArray(maTextureHandle); |
| | | checkGlError("glEnableVertexAttribArray maTextureHandle"); |
| | | |
| | | long now = SystemClock.elapsedRealtimeNanos(); |
| | | mRunTime += (now - mLastTime); |
| | | mLastTime = now; |
| | | double d = ((double)mRunTime) / 1000000000; |
| | | // long now = SystemClock.elapsedRealtimeNanos(); |
| | | // mRunTime += (now - mLastTime); |
| | | // mLastTime = now; |
| | | // double d = ((double)mRunTime) / 1000000000; |
| | | Matrix.setIdentityM(mMMatrix, 0); |
| | | Matrix.rotateM(mMMatrix, 0, 30, (float)Math.sin(d), (float)Math.cos(d), 0); |
| | | // Matrix.rotateM(mMMatrix, 0, 30, (float)Math.sin(d), (float)Math.cos(d), 0); //动态矩阵 |
| | | // Matrix.rotateM(mMMatrix, 0, 0, 0, 0, 0); |
| | | //Matrix.rotateM(mMMatrix, 0, 0, 0.5f, 0.5f,0); |
| | | Matrix.multiplyMM(mMVPMatrix, 0, mVMatrix, 0, mMMatrix, 0); |
| | | Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mMVPMatrix, 0); |
| | | |
| | |
| | | // class's static methods instead. |
| | | GLES20.glViewport(0, 0, width, height); |
| | | mRatio = (float) width / height; |
| | | Matrix.frustumM(mProjMatrix, 0, -mRatio, mRatio, -1, 1, 3, 7); |
| | | Matrix.frustumM(mProjMatrix, 0, -mRatio, mRatio, -1, 1, 2, 7); |
| | | } |
| | | |
| | | @Override |
| | |
| | | mSurface = new SurfaceTexture(mTextureID); |
| | | mSurface.setOnFrameAvailableListener(this); |
| | | |
| | | Matrix.setLookAtM(mVMatrix, 0, 0, 0, 4f, 0f, 0f, 0f, 0f, 1.0f, 0.0f); |
| | | Matrix.setLookAtM(mVMatrix, 0, |
| | | 0, 0, 2f, |
| | | 0f, 0f, 0f, |
| | | 0f, 1.0f, 0.0f); |
| | | |
| | | synchronized(this) { |
| | | updateSurface = false; |
| | |
| | | |
| | | private float[] mMVPMatrix = new float[16]; |
| | | private float[] mProjMatrix = new float[16]; |
| | | private float[] mMMatrix = new float[16]; |
| | | private float[] mMMatrix = new float[16];// 具体物体的3D变换矩阵,包括旋转、平移、缩放 |
| | | |
| | | private float[] mVMatrix = new float[16]; |
| | | private float[] mSTMatrix = new float[16]; |
| | | |