package com.jianji.delogo.Test.MediaCodec;
import android.content.Context;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
public class GLTestView extends GLSurfaceView implements GLSurfaceView.Renderer {
public GLTestView(Context context) {
this(context, null);
}
public GLTestView(Context context, AttributeSet attrs) {
super(context, attrs);
//设置OpenGL的版本
setEGLContextClientVersion(2);
setRenderer(this);
}
/**
* Called when the surface is created or recreated.
*/
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}
/**
* Called when the surface changed size.
*/
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
//设置大小位置
GLES20.glViewport(0, 0, width, height);
}
/**
* Called to draw the current frame.
*/
@Override
public void onDrawFrame(GL10 gl) {
//清屏,清理掉颜色的缓冲区
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
//设置清屏的颜色,这里是float颜色的取值范围的[0,1]
GLES20.glClearColor(1.0f,0f,0f,1.0f);
}
}