提交 f3969743 编写于 作者: G guoshuyu

init bitmap (2017-09-28)

上级 3f6046d7
......@@ -134,7 +134,7 @@ public class DetailFilterActivity extends GSYBaseActivityDetail {
});
//自定义render需要在播放器设置
//detailPlayer.setCustomGLRenderer(new GSYVideoGLViewCustomRender());
detailPlayer.setCustomGLRenderer(new GSYVideoGLViewCustomRender());
changeFilter.setOnClickListener(new View.OnClickListener() {
@Override
......
......@@ -5,6 +5,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import android.opengl.Matrix;
import com.shuyu.gsyvideoplayer.R;
import com.shuyu.gsyvideoplayer.render.GSYVideoGLViewSimpleRender;
......@@ -19,7 +20,7 @@ import javax.microedition.khronos.opengles.GL10;
@SuppressLint("ViewConstructor")
public class GSYVideoGLViewCustomRender extends GSYVideoGLViewSimpleRender {
private Bitmap mBitmap;
private Bitmap mBitmap, mBitmap2;
private int mTexturesBitmap[] = new int[1];
......@@ -44,10 +45,22 @@ public class GSYVideoGLViewCustomRender extends GSYVideoGLViewSimpleRender {
GLES20.glViewport(0, 0, width, height);
}
@Override
public void onDrawFrame(GL10 glUnused) {
super.onDrawFrame(glUnused);
float[] transform = new float[16];
Matrix.setRotateM(transform, 0, 360 * 60 / 100, 0.0f, 0.0f, 1.0f);
Matrix.scaleM(transform, 0, 50f / mSurfaceView.getWidth(), 50f / mSurfaceView.getWidth(), 1);
GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, transform, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
GLES20.glFinish();
}
@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
super.onSurfaceCreated(glUnused, config);
mBitmap = BitmapFactory.decodeResource(mSurfaceView.getResources(), R.drawable.unlock);
mBitmap2 = BitmapFactory.decodeResource(mSurfaceView.getResources(), R.drawable.video_enlarge);
GLES20.glGenTextures(1, mTexturesBitmap, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexturesBitmap[0]);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
......
......@@ -35,12 +35,17 @@ public class GSYVideoGLViewSimpleRender extends GSYVideoGLViewBaseRender {
private static final int TRIANGLE_VERTICES_DATA_UV_OFFSET = 3;
private static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65;
protected static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65;
private final float[] mTriangleVerticesData = {
// X, Y, Z, U, V
-1.0f, -1.0f, 0, 0.f, 0.f, 1.0f, -1.0f, 0, 1.f, 0.f, -1.0f,
1.0f, 0, 0.f, 1.f, 1.0f, 1.0f, 0, 1.f, 1.f,};
-1.0f, -1.0f, 0.0f,
0.0f, 0.0f, 1.0f,
-1.0f, 0.0f, 1.0f,
0.0f, -1.0f, 1.0f,
0.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f,
1.0f, 1.0f,};
private final String mVertexShader = "uniform mat4 uMVPMatrix;\n"
+ "uniform mat4 uSTMatrix;\n"
......@@ -52,15 +57,15 @@ public class GSYVideoGLViewSimpleRender extends GSYVideoGLViewBaseRender {
+ " vTextureCoord = (uSTMatrix * aTextureCoord).xy;\n"
+ "}\n";
private float[] mMVPMatrix = new float[16];
protected float[] mMVPMatrix = new float[16];
private float[] mSTMatrix = new float[16];
protected int mProgram;
private int mTextureID[] = new int[2];
protected int mTextureID[] = new int[2];
private int muMVPMatrixHandle;
protected int muMVPMatrixHandle;
private int muSTMatrixHandle;
......@@ -273,6 +278,7 @@ public class GSYVideoGLViewSimpleRender extends GSYVideoGLViewBaseRender {
/**
* 设置滤镜效果
*
* @param shaderEffect
*/
public void setEffect(GSYVideoGLView.ShaderInterface shaderEffect) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册