本文整理汇总了Java中android.opengl.GLES20类的典型用法代码示例。如果您正苦于以下问题:Java GLES20类的具体用法?Java GLES20怎么用?Java GLES20使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GLES20类属于android.opengl包,在下文中一共展示了GLES20类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawQuadSet
import android.opengl.GLES20; //导入依赖的package包/类
public void drawQuadSet( Vertexbuffer buffer, int length, int offset ){
if (length == 0) {
return;
}
buffer.updateGLData();
buffer.bind();
aXY.vertexBuffer( 2, 4, 0 );
aUV.vertexBuffer( 2, 4, 2 );
buffer.release();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * length, GLES20.GL_UNSIGNED_SHORT, Quad.SIZE * Short.SIZE/8 * offset );
} else {
FroyoGLES20Fix.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * length, GLES20.GL_UNSIGNED_SHORT, Quad.SIZE * Short.SIZE/8 * offset );
}
}
示例2: createShader
import android.opengl.GLES20; //导入依赖的package包/类
private int createShader(int shaderType, String shaderString) {
int shader = GLES20.glCreateShader(shaderType);
if (shader == 0) {
checkGLESError("create shader " + shaderType);
}
GLES20.glShaderSource(shader, shaderString);
GLES20.glCompileShader(shader);
int[] compiled = new int[1];
GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0);
if (compiled[0] == 0) {
GLES20.glDeleteShader(shader);
checkGLESError("compile shader " + shaderType);
}
return shader;
}
示例3: YuvConverter
import android.opengl.GLES20; //导入依赖的package包/类
/**
* This class should be constructed on a thread that has an active EGL context.
*/
public YuvConverter() {
threadChecker.checkIsOnValidThread();
textureFrameBuffer = new GlTextureFrameBuffer(GLES20.GL_RGBA);
shader = new GlShader(VERTEX_SHADER, FRAGMENT_SHADER);
shader.useProgram();
texMatrixLoc = shader.getUniformLocation("texMatrix");
xUnitLoc = shader.getUniformLocation("xUnit");
coeffsLoc = shader.getUniformLocation("coeffs");
GLES20.glUniform1i(shader.getUniformLocation("oesTex"), 0);
GlUtil.checkNoGLES2Error("Initialize fragment shader uniform values.");
// Initialize vertex shader attributes.
shader.setVertexAttribArray("in_pos", 2, DEVICE_RECTANGLE);
// If the width is not a multiple of 4 pixels, the texture
// will be scaled up slightly and clipped at the right border.
shader.setVertexAttribArray("in_tc", 2, TEXTURE_RECTANGLE);
}
示例4: drawLight
import android.opengl.GLES20; //导入依赖的package包/类
private void drawLight() {
final int pointMVPMatrixHandle = GLES20.glGetUniformLocation(mPointProgramHandle, "u_MVPMatrix");
final int pointPositionHandle = GLES20.glGetAttribLocation(mPointProgramHandle, "a_Position");
// Pass in the position.
GLES20.glVertexAttrib3f(pointPositionHandle, mLightPosInModelSpace[0], mLightPosInModelSpace[1], mLightPosInModelSpace[2]);
// Since we are not using a buffer object, disable vertex arrays for this attribute.
GLES20.glDisableVertexAttribArray(pointPositionHandle);
// Pass in the transformation matrix.
Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mLightModelMatrix, 0);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(pointMVPMatrixHandle, 1, false, mMVPMatrix, 0);
// Draw the point.
GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1);
}
示例5: compileShader
import android.opengl.GLES20; //导入依赖的package包/类
private static int compileShader(int shaderType, String source) {
final int shader = GLES20.glCreateShader(shaderType);
if (shader == 0) {
throw new RuntimeException("glCreateShader() failed. GLES20 error: " + GLES20.glGetError());
}
GLES20.glShaderSource(shader, source);
GLES20.glCompileShader(shader);
int[] compileStatus = new int[] {GLES20.GL_FALSE};
GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
if (compileStatus[0] != GLES20.GL_TRUE) {
Logging.e(
TAG, "Could not compile shader " + shaderType + ":" + GLES20.glGetShaderInfoLog(shader));
throw new RuntimeException(GLES20.glGetShaderInfoLog(shader));
}
GlUtil.checkNoGLES2Error("compileShader");
return shader;
}
示例6: updateFloatValue
import android.opengl.GLES20; //导入依赖的package包/类
private void updateFloatValue(float... value) {
switch (value.length) {
case 1:
GLES20.glUniform1f(handle(), value[0]);
break;
case 2:
GLES20.glUniform2f(handle(), value[0], value[1]);
break;
case 3:
GLES20.glUniform3f(handle(), value[0], value[1], value[2]);
break;
case 4:
GLES20.glUniform4f(handle(), value[0], value[1], value[2], value[3]);
break;
case 16:
GLES20.glUniformMatrix4fv(handle(), 1, false, value, 0);
default:
break;
}
}
示例7: initShader
import android.opengl.GLES20; //导入依赖的package包/类
/**
* 初始化着色器
* @param surfaceView
*/
private void initShader(HexagramSurfaceView surfaceView) {
//加载顶点着色器
mVertexShader = ShaderUtil.loadFromAeertsFile("vertex.sh" , surfaceView.getResources());
//加载片元着色器
mFragmentShader = ShaderUtil.loadFromAeertsFile("frag.sh" , surfaceView.getResources());
//创建程序
mProgram = ShaderUtil.createProgram(mVertexShader , mFragmentShader);
//顶点位置属性引用
maPositionHandle = GLES20.glGetAttribLocation(mProgram , "aPosition");
//顶点颜色属性引用
maColorHandle = GLES20.glGetAttribLocation(mProgram , "aColor");
//总变换矩阵引用
muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram , "uMVPMatrix");
}
示例8: setupPreScene
import android.opengl.GLES20; //导入依赖的package包/类
private void setupPreScene(int glProgram) {
GLES20.glUseProgram(glProgram);
mTexHandle = GLES20.glGetUniformLocation(glProgram, "s_texture");
mTexCoordHandle = GLES20.glGetAttribLocation(glProgram, "a_texCoord");
mTriangleVerticesHandle = GLES20.glGetAttribLocation(glProgram, "vPosition");
mTransformHandle = GLES20.glGetUniformLocation(glProgram, "u_xform");
mMVPTransformHandle = GLES20.glGetUniformLocation(glProgram, "u_mvp_xform");
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glUseProgram");
GLES20.glUniformMatrix4fv(mTransformHandle, 1, false, mVideoTransform, 0);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glUniformMatrix4fv");
GLES20.glEnable(GLES20.GL_DEPTH_TEST);
mColorFilterHandle = GLES20.glGetUniformLocation(glProgram, "u_filter");
mColorFilter = CLEAR_COLOR_FILTER;
}
示例9: onDrawFrame
import android.opengl.GLES20; //导入依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {
if (width == 0 || height == 0) {
return;
}
SystemTime.tick();
long rightNow = SystemClock.elapsedRealtime();
step = (now == 0 ? 0 : rightNow - now);
now = rightNow;
step();
NoosaScript.get().resetCamera();
NoosaScriptNoLighting.get().resetCamera();
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
draw();
}
示例10: drawLight
import android.opengl.GLES20; //导入依赖的package包/类
/**
* Draws a point representing the position of the light.
*/
private void drawLight()
{
final int pointMVPMatrixHandle = GLES20.glGetUniformLocation(mPointProgramHandle, "u_MVPMatrix");
final int pointPositionHandle = GLES20.glGetAttribLocation(mPointProgramHandle, "a_Position");
// Pass in the position.
GLES20.glVertexAttrib3f(pointPositionHandle, mLightPosInModelSpace[0], mLightPosInModelSpace[1], mLightPosInModelSpace[2]);
// Since we are not using a buffer object, disable vertex arrays for this attribute.
GLES20.glDisableVertexAttribArray(pointPositionHandle);
// Pass in the transformation matrix.
Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mLightModelMatrix, 0);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(pointMVPMatrixHandle, 1, false, mMVPMatrix, 0);
// Draw the point.
GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1);
}
示例11: onSetExpandData
import android.opengl.GLES20; //导入依赖的package包/类
@Override
protected void onSetExpandData() {
//todo 根据时间修改
if(isAdd){
mStep+=0.08f;
}else{
mStep-=0.08f;
}
if(mStep>=1.0f){
isAdd=false;
mStep=1.0f;
}else if(mStep<=0.0f){
isAdd=true;
mStep=0.0f;
}
super.onSetExpandData();
GLES20.glUniform4fv(mGLBorderColor,1,mBorderColor,0);
GLES20.glUniform1f(mGLStep,mStep);
}
示例12: loadShader
import android.opengl.GLES20; //导入依赖的package包/类
private int loadShader(int shaderType, String source) {
int shader = GLES20.glCreateShader(shaderType);
if (shader != 0) {
GLES20.glShaderSource(shader, source);
GLES20.glCompileShader(shader);
int[] compiled = new int[1];
GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0);
if (compiled[0] == 0) {
Log.e(TAG, "Could not compile shader " + shaderType + ":");
Log.e(TAG, GLES20.glGetShaderInfoLog(shader));
GLES20.glDeleteShader(shader);
shader = 0;
}
}
return shader;
}
示例13: prepareGl
import android.opengl.GLES20; //导入依赖的package包/类
/**
* Prepares window surface and GL state.
*/
private void prepareGl(Surface surface) {
Log.d(TAG, "prepareGl");
mWindowSurface = new WindowSurface(mEglCore, surface, false);
mWindowSurface.makeCurrent();
// Programs used for drawing onto the screen.
mFlatProgram = new FlatShadedProgram();
mTexProgram = new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_2D);
mCoarseTexture = GeneratedTexture.createTestTexture(GeneratedTexture.Image.COARSE);
mFineTexture = GeneratedTexture.createTestTexture(GeneratedTexture.Image.FINE);
// Set the background color.
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
// Disable depth testing -- we're 2D only.
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
// Don't need backface culling. (If you're feeling pedantic, you can turn it on to
// make sure we're defining our shapes correctly.)
GLES20.glDisable(GLES20.GL_CULL_FACE);
}
示例14: loadTexture
import android.opengl.GLES20; //导入依赖的package包/类
public static int loadTexture(final Buffer data, final int width,final int height, final int usedTexId,final int type) {
if(data == null)
return NO_TEXTURE;
int textures[] = new int[1];
if (usedTexId == NO_TEXTURE) {
GLES20.glGenTextures(1, textures, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height,
0, GLES20.GL_RGBA, type, data);
} else {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, usedTexId);
GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, width,
height, GLES20.GL_RGBA, type, data);
textures[0] = usedTexId;
}
return textures[0];
}
示例15: getTexture
import android.opengl.GLES20; //导入依赖的package包/类
public Bitmap getTexture() {
if (!initied) {
return null;
}
final Semaphore semaphore = new Semaphore(0);
final Bitmap object[] = new Bitmap[1];
try {
postRunnable(new Runnable() {
@Override
public void run() {
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[1]);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[blured ? 0 : 1], 0);
GLES20.glClear(0);
object[0] = getRenderBufferBitmap();
semaphore.release();
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
GLES20.glClear(0);
}
});
semaphore.acquire();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return object[0];
}