本文整理汇总了Java中android.opengl.GLES20.glUseProgram方法的典型用法代码示例。如果您正苦于以下问题:Java GLES20.glUseProgram方法的具体用法?Java GLES20.glUseProgram怎么用?Java GLES20.glUseProgram使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glUseProgram方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDrawFrame
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 unused) {
angle = ((float) SystemClock.elapsedRealtime() - startTime) * 0.02f;
GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
if (scene != null) {
Matrix.setLookAtM(mViewMatrix, 0,
0, 0, -4,
0f, 0f, 0f,
0f, 1.0f, 0.0f);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
Matrix.rotateM(mMVPMatrix, 0, angle, 0.8f, 2.f, 1.f);
GLES20.glUseProgram(shaderProgram);
int mMVPMatrixHandle = GLES20.glGetUniformLocation(shaderProgram, "uMVPMatrix");
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
scene.render(shaderProgram, "vPosition", "aColor");
}
}
示例2: renderTexture
import android.opengl.GLES20; //导入方法依赖的package包/类
public void renderTexture(int texId) {
// Bind default FBO
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
// Use our shader program
GLES20.glUseProgram(mProgram);
GLToolbox.checkGlError("glUseProgram");
// Set viewport
GLES20.glViewport(0, 0, mViewWidth, mViewHeight);
GLToolbox.checkGlError("glViewport");
// Disable blending
GLES20.glDisable(GLES20.GL_BLEND);
// Set the vertex attributes
GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT, false,
0, mTexVertices);
GLES20.glEnableVertexAttribArray(mTexCoordHandle);
GLES20.glVertexAttribPointer(mPosCoordHandle, 2, GLES20.GL_FLOAT, false,
0, mPosVertices);
GLES20.glEnableVertexAttribArray(mPosCoordHandle);
GLToolbox.checkGlError("vertex attribute setup");
// Set the input texture
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLToolbox.checkGlError("glActiveTexture");
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texId);
GLToolbox.checkGlError("glBindTexture");
GLES20.glUniform1i(mTexSamplerHandle, 0);
// Draw
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
}
示例3: onDrawFrame
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public int onDrawFrame(int textureId, FloatBuffer vertexBuffer, FloatBuffer textureBuffer) {
GLES20.glUseProgram(mGLProgId);
if(!isInitialized()) {
return OpenGLUtils.NOT_INIT;
}
vertexBuffer.position(0);
GLES20.glVertexAttribPointer(mGLAttribPosition, 2, GLES20.GL_FLOAT, false, 0, vertexBuffer);
GLES20.glEnableVertexAttribArray(mGLAttribPosition);
textureBuffer.position(0);
GLES20.glVertexAttribPointer(mGLAttribTextureCoordinate, 2, GLES20.GL_FLOAT, false, 0, textureBuffer);
GLES20.glEnableVertexAttribArray(mGLAttribTextureCoordinate);
GLES20.glUniformMatrix4fv(mTextureTransformMatrixLocation, 1, false, mTextureTransformMatrix, 0);
if(textureId != OpenGLUtils.NO_TEXTURE){
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureId);
GLES20.glUniform1i(mGLUniformTexture, 0);
}
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
GLES20.glDisableVertexAttribArray(mGLAttribPosition);
GLES20.glDisableVertexAttribArray(mGLAttribTextureCoordinate);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);
return OpenGLUtils.ON_DRAWN;
}
示例4: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
final public void draw(int cameraTexId, int canvasWidth, int canvasHeight) {
// TODO move?
// Create camera render buffer
if (CAMERA_RENDER_BUF == null ||
CAMERA_RENDER_BUF.getWidth() != canvasWidth ||
CAMERA_RENDER_BUF.getHeight() != canvasHeight) {
CAMERA_RENDER_BUF = new RenderBuffer(canvasWidth, canvasHeight, BUF_ACTIVE_TEX_UNIT);
}
// Use shaders
GLES20.glUseProgram(PROGRAM);
int iChannel0Location = GLES20.glGetUniformLocation(PROGRAM, "iChannel0");
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, cameraTexId);
GLES20.glUniform1i(iChannel0Location, 0);
int vPositionLocation = GLES20.glGetAttribLocation(PROGRAM, "vPosition");
GLES20.glEnableVertexAttribArray(vPositionLocation);
GLES20.glVertexAttribPointer(vPositionLocation, 2, GLES20.GL_FLOAT, false, 4 * 2, VERTEX_BUF);
int vTexCoordLocation = GLES20.glGetAttribLocation(PROGRAM, "vTexCoord");
GLES20.glEnableVertexAttribArray(vTexCoordLocation);
GLES20.glVertexAttribPointer(vTexCoordLocation, 2, GLES20.GL_FLOAT, false, 4 * 2, ROATED_TEXTURE_COORD_BUF);
// Render to texture
CAMERA_RENDER_BUF.bind();
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
CAMERA_RENDER_BUF.unbind();
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
onDraw(CAMERA_RENDER_BUF.getTexId(), canvasWidth, canvasHeight);
iFrame++;
}
示例5: onSurfaceCreated
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
setUpBuffers();
setUpSprites();
GLES20.glClearColor(235f / 255.0f, 235f / 255.0f, 255f / 255.0f, 255f / 255.0f);
int vertexShader = SpriteKitGraphicTools.loadShader(GLES20.GL_VERTEX_SHADER,
SpriteKitGraphicTools.imageVertexShader);
int fragmentShader = SpriteKitGraphicTools.loadShader(GLES20.GL_FRAGMENT_SHADER,
SpriteKitGraphicTools.imageFragmentShader);
SpriteKitGraphicTools.imageShaderProgram = GLES20.glCreateProgram();
GLES20.glAttachShader(SpriteKitGraphicTools.imageShaderProgram, vertexShader);
GLES20.glAttachShader(SpriteKitGraphicTools.imageShaderProgram, fragmentShader);
GLES20.glLinkProgram(SpriteKitGraphicTools.imageShaderProgram);
GLES20.glUseProgram(SpriteKitGraphicTools.imageShaderProgram);
}
示例6: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Encapsulates the OpenGL ES instructions for drawing this shape.
*
* @param mvpMatrix - The Model View Project matrix in which to draw
* this shape.
*/
public void draw(float[] mvpMatrix) {
// Add program to OpenGL environment
GLES20.glUseProgram(mProgram);
// get handle to vertex shader's vPosition member
mPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");
// Enable a handle to the triangle vertices
GLES20.glEnableVertexAttribArray(mPositionHandle);
// Prepare the triangle coordinate data
GLES20.glVertexAttribPointer(
mPositionHandle, COORDS_PER_VERTEX,
GLES20.GL_FLOAT, false,
vertexStride, vertexBuffer);
// get handle to fragment shader's vColor member
mColorHandle = GLES20.glGetUniformLocation(mProgram, "vColor");
// Set color for drawing the triangle
GLES20.glUniform4fv(mColorHandle, 1, color, 0);
// get handle to shape's transformation matrix
mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
TextureRender.checkGlError("glGetUniformLocation");
// Apply the projection and view transformation
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);
TextureRender.checkGlError("glUniformMatrix4fv");
// Draw the triangle
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, vertexCount);
// Disable vertex array
GLES20.glDisableVertexAttribArray(mPositionHandle);
}
示例7: drawTex
import android.opengl.GLES20; //导入方法依赖的package包/类
private void drawTex(int tex, boolean isOES, int fbo)
{
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fbo);
if(fbo == 0)
GLES20.glViewport(0, 0, mView.getWidth(), mView.getHeight());
else
GLES20.glViewport(0, 0, mFBOWidth, mFBOHeight);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
if(isOES) {
GLES20.glUseProgram(progOES);
GLES20.glVertexAttribPointer(vPosOES, 2, GLES20.GL_FLOAT, false, 4*2, vert);
GLES20.glVertexAttribPointer(vTCOES, 2, GLES20.GL_FLOAT, false, 4*2, texOES);
} else {
GLES20.glUseProgram(prog2D);
GLES20.glVertexAttribPointer(vPos2D, 2, GLES20.GL_FLOAT, false, 4*2, vert);
GLES20.glVertexAttribPointer(vTC2D, 2, GLES20.GL_FLOAT, false, 4*2, tex2D);
}
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
if(isOES) {
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, tex);
GLES20.glUniform1i(GLES20.glGetUniformLocation(progOES, "sTexture"), 0);
} else {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex);
GLES20.glUniform1i(GLES20.glGetUniformLocation(prog2D, "sTexture"), 0);
}
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
GLES20.glFlush();
}
示例8: useProgram
import android.opengl.GLES20; //导入方法依赖的package包/类
public void useProgram() {
if (program == -1) {
throw new RuntimeException("The program has been released");
}
GLES20.glUseProgram(program);
GlUtil.checkNoGLES2Error("glUseProgram");
}
示例9: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
public void draw(final int textureId, final FloatBuffer cubeBuffer,
final FloatBuffer textureBuffer) {
GLES20.glUseProgram(mGLProgId);
runPendingOnDrawTasks();
if (!mIsInitialized) {
return;
}
cubeBuffer.position(0);
GLES20.glVertexAttribPointer(mGLAttribPosition, 3, GLES20.GL_FLOAT, false, 0, cubeBuffer);
GLES20.glEnableVertexAttribArray(mGLAttribPosition);
textureBuffer.position(0);
GLES20.glVertexAttribPointer(mGLAttribTextureCoordinate, 2, GLES20.GL_FLOAT, false, 0,
textureBuffer);
GLES20.glEnableVertexAttribArray(mGLAttribTextureCoordinate);
if (textureId != OpenGlUtils.NO_TEXTURE) {
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(mTextureTarget, textureId);
GLES20.glUniform1i(mGLUniformTexture, 0);
}
onDrawArraysPre();
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 6);
GLES20.glDisableVertexAttribArray(mGLAttribPosition);
GLES20.glDisableVertexAttribArray(mGLAttribTextureCoordinate);
GLES20.glBindTexture(mTextureTarget, 0);
Log.i(TAG,"java filter draw textureId = " + textureId);
if(mInputSurface != null){
mInputSurface.swapBuffers();
GLES20.glFlush();
}
}
示例10: onDrawFrame
import android.opengl.GLES20; //导入方法依赖的package包/类
public int onDrawFrame(final int textureId, final FloatBuffer cubeBuffer,
final FloatBuffer textureBuffer) {
GLES20.glUseProgram(mGLProgId);
runPendingOnDrawTasks();
if (!mIsInitialized) {
return OpenGLUtils.NOT_INIT;
}
cubeBuffer.position(0);
GLES20.glVertexAttribPointer(mGLAttribPosition, 2, GLES20.GL_FLOAT, false, 0, cubeBuffer);
GLES20.glEnableVertexAttribArray(mGLAttribPosition);
textureBuffer.position(0);
GLES20.glVertexAttribPointer(mGLAttribTextureCoordinate, 2, GLES20.GL_FLOAT, false, 0,
textureBuffer);
GLES20.glEnableVertexAttribArray(mGLAttribTextureCoordinate);
if (textureId != OpenGLUtils.NO_TEXTURE) {
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
GLES20.glUniform1i(mGLUniformTexture, 0);
}
onDrawArraysPre();
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
GLES20.glDisableVertexAttribArray(mGLAttribPosition);
GLES20.glDisableVertexAttribArray(mGLAttribTextureCoordinate);
onDrawArraysAfter();
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
return OpenGLUtils.ON_DRAWN;
}
示例11: drawFrame
import android.opengl.GLES20; //导入方法依赖的package包/类
public void drawFrame(SurfaceTexture st, boolean invert) {
checkGlError("onDrawFrame start");
st.getTransformMatrix(mSTMatrix);
if (invert) {
mSTMatrix[5] = -mSTMatrix[5];
mSTMatrix[13] = 1.0f - mSTMatrix[13];
}
GLES20.glUseProgram(mProgram);
checkGlError("glUseProgram");
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);
mTriangleVertices.position(TRIANGLE_VERTICES_DATA_POS_OFFSET);
GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false, TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
checkGlError("glVertexAttribPointer maPosition");
GLES20.glEnableVertexAttribArray(maPositionHandle);
checkGlError("glEnableVertexAttribArray maPositionHandle");
mTriangleVertices.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
GLES20.glVertexAttribPointer(maTextureHandle, 2, GLES20.GL_FLOAT, false, TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
checkGlError("glVertexAttribPointer maTextureHandle");
GLES20.glEnableVertexAttribArray(maTextureHandle);
checkGlError("glEnableVertexAttribArray maTextureHandle");
GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);
GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
checkGlError("glDrawArrays");
GLES20.glFinish();
}
示例12: onSurfaceCreated
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* 发生在应用程序第一次运行时
* 当设备被唤醒或者从其他activity切换回来时,这个方法也可能被调用
* @param gl
* @param config
*/
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
//设置清空屏幕用的颜色
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
//1.加载OpenGL程序及着色器代码
//读取glsl字符串
String vertexShaderStr = RawResourceReader.readTextFileFromRawResource(context, R.raw.simple_vertex_shader);
String fragmentShaderStr = RawResourceReader.readTextFileFromRawResource(context, R.raw.simple_fragment_shader);
//加载着色器代码
int vertexShader = GlUtil.loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderStr);
int fragmentShader = GlUtil.loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderStr);
//创建OpenGL程序对象,链接着色器代码
int program = GlUtil.linkProgram(vertexShader, fragmentShader);
GlUtil.validateProgram(program);
GlUtil.checkGlError("validateProgram");
//告诉openGL在绘制任何东西的时候要使用这里定义的程序
GLES20.glUseProgram(program);
GlUtil.checkGlError("glUseProgram");
//获取uniform的位置, 并把这个位置存入uColorLocation
aColorLocation = GLES20.glGetAttribLocation(program, A_COLOR);
GlUtil.checkGlError("glGetAttribLocation");
//获取属性的位置,有了这个位置,就能告诉OpenGL去哪里找到这个属性对应的数据
aPositionLocation = GLES20.glGetAttribLocation(program, A_POSITION);
GlUtil.checkGlError("glGetAttribLocation");
uMatrixLocation = GLES20.glGetUniformLocation(program, U_MATRIX);
GlUtil.checkGlError("uMatrixLocation");
//2.读取顶点数据
vertexData.position(0);//确保从缓冲区的开头读取数据。每个缓冲区都有一个内部指针可以通过调用position()来移动它
//告诉openGL可以在缓冲区vertexData找到属性a_Position对应的数据。
//参数:1.属性位置;2.表示vertexData中几个分量表示一个点;3.表数据类型;5.告诉opengl每个位置之间有多少个字节;6.表数据源
GLES20.glVertexAttribPointer(aPositionLocation, POSITION_COMPONENT_COUNT, GLES20.GL_FLOAT, false, STRIDE, vertexData);
GlUtil.checkGlError("glVertexAttribPointer");
//使能顶点数组
GLES20.glEnableVertexAttribArray(aPositionLocation);
GlUtil.checkGlError("glEnableVertexAttribArray");
vertexData.position(POSITION_COMPONENT_COUNT);
GLES20.glVertexAttribPointer(aColorLocation, COLOR_COMPONENT_COUNT, GLES20.GL_FLOAT, false, STRIDE, vertexData);
GlUtil.checkGlError("glVertexAttribPointer");
GLES20.glEnableVertexAttribArray(aColorLocation);
GlUtil.checkGlError("glEnableVertexAttribArray");
}
示例13: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
public void draw() {
if (mTexture == 0) {
mTexture = OpenGLUtils.loadTexture(mResource);
}
if (mProgram == null) {
mProgram = new ImageProgram();
}
setCube();
float translateX = (mPosition.x + mTranslationX) * 2.0f / mViewportSize.x;
float translateY = (-mPosition.y - mTranslationY) * 2.0f / mViewportSize.y;
float[] mvp = new float[16];
Matrix.setIdentityM(mvp, 0);
Matrix.translateM(mMVPMatrix, 0, mvp, 0, translateX, translateY, 0);
mMVPBuffer.position(0);
mMVPBuffer.put(mMVPMatrix).position(0);
GLES20.glUseProgram(mProgram.mProgram);
mCubeBuffer.position(0);
GLES20.glVertexAttribPointer(mProgram.mAPositionHandle, 2, GLES20.GL_FLOAT, false, 0, mCubeBuffer);
GLES20.glEnableVertexAttribArray(mProgram.mAPositionHandle);
mTextureBuffer.position(0);
GLES20.glVertexAttribPointer(mProgram.mATextureCoordinateHandle, 2, GLES20.GL_FLOAT, false, 0, mTextureBuffer);
GLES20.glEnableVertexAttribArray(mProgram.mATextureCoordinateHandle);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture);
GLES20.glUniform1i(mProgram.mUTextureHandle, 0);
mMVPBuffer.position(0);
GLES20.glUniformMatrix4fv(mProgram.mUMVPMatrixHandle, 1, false, mMVPBuffer);
GLES20.glUniform1f(mProgram.mUOpacityHandle, mOpacity);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
GLES20.glDisableVertexAttribArray(mProgram.mAPositionHandle);
GLES20.glDisableVertexAttribArray(mProgram.mATextureCoordinateHandle);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
}
示例14: render
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* draws Quad shape object.
* @param aMVPMatrix
* @param texture
*/
public void render(float[] aMVPMatrix, final int texture) {
// // Use culling to remove back faces.
GLES20.glDisable(GLES20.GL_CULL_FACE);
// Set our per-vertex lighting program.
GLES20.glUseProgram(aQuadProgramHandle);
// Set program handles for cube drawing.
aMVPMatrixHandle = GLES20.glGetUniformLocation(aQuadProgramHandle, "u_MVPMatrix");
aPositionHandle = GLES20.glGetAttribLocation(aQuadProgramHandle, "a_Position");
aColorHandle = GLES20.glGetAttribLocation(aQuadProgramHandle, "a_Color");
aTextureCoordinateHandle = GLES20.glGetAttribLocation(aQuadProgramHandle, "a_TexCoordinate");
aTextureUniformHandle = GLES20.glGetUniformLocation(aQuadProgramHandle, "u_Texture");
// Pass in the combined matrix.
GLES20.glUniformMatrix4fv(aMVPMatrixHandle, 1, false, aMVPMatrix, 0);
if (qvbo[0] > 0 && qibo[0] > 0) {
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, qvbo[0]);
// Bind Attributes
GLES20.glVertexAttribPointer(aPositionHandle, POSITION_DATA_SIZE, GLES20.GL_FLOAT, false,
STRIDE, 0);
GLES20.glEnableVertexAttribArray(aPositionHandle);
GLES20.glVertexAttribPointer(aColorHandle, COLOR_DATA_SIZE, GLES20.GL_FLOAT, false,
STRIDE, (POSITION_DATA_SIZE) * BYTES_PER_FLOAT);
GLES20.glEnableVertexAttribArray(aColorHandle);
GLES20.glVertexAttribPointer(aTextureCoordinateHandle, UV_DATA_SIZE, GLES20.GL_FLOAT, false,
STRIDE, (POSITION_DATA_SIZE + COLOR_DATA_SIZE) * BYTES_PER_FLOAT);
GLES20.glEnableVertexAttribArray(aTextureCoordinateHandle);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture);
GLES20.glUniform1f(aTextureUniformHandle, 0);
// Draw
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, qibo[0]);
GLES20.glDrawElements(GLES20.GL_TRIANGLE_STRIP, indexCount, GLES20.GL_UNSIGNED_SHORT, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
}
// // Use culling to remove back faces.
// GLES20.glEnable(GLES20.GL_CULL_FACE);
}
示例15: drawCustomParamsPass
import android.opengl.GLES20; //导入方法依赖的package包/类
private void drawCustomParamsPass() {
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[1]);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[1], 0);
GLES20.glClear(0);
GLES20.glUseProgram(toolsShaderProgram);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[0]);
GLES20.glUniform1i(sourceImageHandle, 0);
if (showOriginal) {
GLES20.glUniform1f(shadowsHandle, 1);
GLES20.glUniform1f(highlightsHandle, 1);
GLES20.glUniform1f(exposureHandle, 0);
GLES20.glUniform1f(contrastHandle, 1);
GLES20.glUniform1f(saturationHandle, 1);
GLES20.glUniform1f(warmthHandle, 0);
GLES20.glUniform1f(vignetteHandle, 0);
GLES20.glUniform1f(grainHandle, 0);
GLES20.glUniform1f(fadeAmountHandle, 0);
GLES20.glUniform3f(highlightsTintColorHandle, 0, 0, 0);
GLES20.glUniform1f(highlightsTintIntensityHandle, 0);
GLES20.glUniform3f(shadowsTintColorHandle, 0, 0, 0);
GLES20.glUniform1f(shadowsTintIntensityHandle, 0);
GLES20.glUniform1f(skipToneHandle, 1);
} else {
GLES20.glUniform1f(shadowsHandle, getShadowsValue());
GLES20.glUniform1f(highlightsHandle, getHighlightsValue());
GLES20.glUniform1f(exposureHandle, getExposureValue());
GLES20.glUniform1f(contrastHandle, getContrastValue());
GLES20.glUniform1f(saturationHandle, getSaturationValue());
GLES20.glUniform1f(warmthHandle, getWarmthValue());
GLES20.glUniform1f(vignetteHandle, getVignetteValue());
GLES20.glUniform1f(grainHandle, getGrainValue());
GLES20.glUniform1f(fadeAmountHandle, getFadeValue());
GLES20.glUniform3f(highlightsTintColorHandle, (tintHighlightsColor >> 16 & 0xff) / 255.0f, (tintHighlightsColor >> 8 & 0xff) / 255.0f, (tintHighlightsColor & 0xff) / 255.0f);
GLES20.glUniform1f(highlightsTintIntensityHandle, getTintHighlightsIntensityValue());
GLES20.glUniform3f(shadowsTintColorHandle, (tintShadowsColor >> 16 & 0xff) / 255.0f, (tintShadowsColor >> 8 & 0xff) / 255.0f, (tintShadowsColor & 0xff) / 255.0f);
GLES20.glUniform1f(shadowsTintIntensityHandle, getTintShadowsIntensityValue());
boolean skipTone = curvesToolValue.shouldBeSkipped();
GLES20.glUniform1f(skipToneHandle, skipTone ? 1.0f : 0.0f);
if (!skipTone) {
curvesToolValue.fillBuffer();
GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
GLES20.glBindTexture(GL10.GL_TEXTURE_2D, curveTextures[0]);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 200, 1, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, curvesToolValue.curveBuffer);
GLES20.glUniform1i(curvesImageHandle, 1);
}
}
GLES20.glUniform1f(widthHandle, renderBufferWidth);
GLES20.glUniform1f(heightHandle, renderBufferHeight);
GLES20.glEnableVertexAttribArray(inputTexCoordHandle);
GLES20.glVertexAttribPointer(inputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
GLES20.glEnableVertexAttribArray(positionHandle);
GLES20.glVertexAttribPointer(positionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
}