本文整理汇总了Java中android.opengl.GLES20.glUniform2f方法的典型用法代码示例。如果您正苦于以下问题:Java GLES20.glUniform2f方法的具体用法?Java GLES20.glUniform2f怎么用?Java GLES20.glUniform2f使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glUniform2f方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
public void draw() {
GLES20.glEnable(GLES20.GL_BLEND);
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
GLES20.glUseProgram(mProgram);
int mPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
GLES20.glEnableVertexAttribArray(mPositionHandle);
int vertexStride = COORDS_PER_VERTEX * 4;
GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride, mVertexBuffer);
GLES20.glUniform4fv(GLES20.glGetUniformLocation(mProgram, "aColor"), 1, mColor, 0);
GLES20.glUniform2f(GLES20.glGetUniformLocation(mProgram, "aCirclePosition"), mCenterX, mCenterY);
GLES20.glUniform1f(GLES20.glGetUniformLocation(mProgram, "aRadius"), mRadius);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, mDrawOrder.length, GLES20.GL_UNSIGNED_SHORT, mDrawListBuffer);
GLES20.glDisableVertexAttribArray(mPositionHandle);
}
示例3: drawBlurPass
import android.opengl.GLES20; //导入方法依赖的package包/类
private boolean drawBlurPass() {
if (showOriginal || blurType == 0) {
return false;
}
if (needUpdateBlurTexture) {
GLES20.glUseProgram(blurShaderProgram);
GLES20.glUniform1i(blurSourceImageHandle, 0);
GLES20.glEnableVertexAttribArray(blurInputTexCoordHandle);
GLES20.glVertexAttribPointer(blurInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
GLES20.glEnableVertexAttribArray(blurPositionHandle);
GLES20.glVertexAttribPointer(blurPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[0]);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[0], 0);
GLES20.glClear(0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
GLES20.glUniform1f(blurWidthHandle, 0.0f);
GLES20.glUniform1f(blurHeightHandle, 1.0f / renderBufferHeight);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[2]);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[2], 0);
GLES20.glClear(0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[0]);
GLES20.glUniform1f(blurWidthHandle, 1.0f / renderBufferWidth);
GLES20.glUniform1f(blurHeightHandle, 0.0f);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
needUpdateBlurTexture = false;
}
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[0]);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[0], 0);
GLES20.glClear(0);
if (blurType == 1) {
GLES20.glUseProgram(radialBlurShaderProgram);
GLES20.glUniform1i(radialBlurSourceImageHandle, 0);
GLES20.glUniform1i(radialBlurSourceImage2Handle, 1);
GLES20.glUniform1f(radialBlurExcludeSizeHandle, blurExcludeSize);
GLES20.glUniform1f(radialBlurExcludeBlurSizeHandle, blurExcludeBlurSize);
GLES20.glUniform2f(radialBlurExcludePointHandle, blurExcludePoint.x, blurExcludePoint.y);
GLES20.glUniform1f(radialBlurAspectRatioHandle, (float) renderBufferHeight / (float) renderBufferWidth);
GLES20.glEnableVertexAttribArray(radialBlurInputTexCoordHandle);
GLES20.glVertexAttribPointer(radialBlurInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
GLES20.glEnableVertexAttribArray(radialBlurPositionHandle);
GLES20.glVertexAttribPointer(radialBlurPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
} else if (blurType == 2) {
GLES20.glUseProgram(linearBlurShaderProgram);
GLES20.glUniform1i(linearBlurSourceImageHandle, 0);
GLES20.glUniform1i(linearBlurSourceImage2Handle, 1);
GLES20.glUniform1f(linearBlurExcludeSizeHandle, blurExcludeSize);
GLES20.glUniform1f(linearBlurExcludeBlurSizeHandle, blurExcludeBlurSize);
GLES20.glUniform1f(linearBlurAngleHandle, blurAngle);
GLES20.glUniform2f(linearBlurExcludePointHandle, blurExcludePoint.x, blurExcludePoint.y);
GLES20.glUniform1f(linearBlurAspectRatioHandle, (float) renderBufferHeight / (float) renderBufferWidth);
GLES20.glEnableVertexAttribArray(linearBlurInputTexCoordHandle);
GLES20.glVertexAttribPointer(linearBlurInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
GLES20.glEnableVertexAttribArray(linearBlurPositionHandle);
GLES20.glVertexAttribPointer(linearBlurPositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexInvertBuffer);
}
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]);
GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[2]);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
return true;
}
示例4: value2f
import android.opengl.GLES20; //导入方法依赖的package包/类
public void value2f(float v1, float v2) {
GLES20.glUniform2f(location, v1, v2);
}
示例5: drawFinalScene
import android.opengl.GLES20; //导入方法依赖的package包/类
private void drawFinalScene() {
GLES20.glUseProgram(mSceneGLProgram);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glUseProgram");
mTexHandle = GLES20.glGetUniformLocation(mSceneGLProgram, "s_texture");
mTexCoordHandle = GLES20.glGetAttribLocation(mSceneGLProgram, "a_texCoord");
mTriangleVerticesHandle = GLES20.glGetAttribLocation(mSceneGLProgram, "vPosition");
mProjectionHandle = GLES20.glGetUniformLocation(mSceneGLProgram, "u_projectionRatio");
GLES20.glDisable(GLES20.GL_BLEND);
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
GLES20.glViewport(0, 0, mViewWidth, mViewHeight);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glViewport");
GLES20.glUniform1i(mTexHandle, 2);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glUniform1i");
GLES20.glUniform2f(mProjectionHandle, DISTORTION_COEF, (DISTORTION_COEF * mViewHeight /(mViewWidth/2.0f)));
GLES20.glEnableVertexAttribArray(mTexCoordHandle);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glEnableVertexAttribArray");
GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT,
false, 0, mVideoTextureFinalScene);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glVertexAttribPointer");
GLES20.glEnableVertexAttribArray(mTriangleVerticesHandle);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glEnableVertexAttribArray");
GLES20.glVertexAttribPointer(mTriangleVerticesHandle, 3, GLES20.GL_FLOAT,
false, 0, mVerticesFinalScene);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glVertexAttribPointer");
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glDrawArrays");
GLES20.glDisableVertexAttribArray(mTexCoordHandle);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glDisableVertexAttribArray");
GLES20.glDisableVertexAttribArray(mTriangleVerticesHandle);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glDisableVertexAttribArray");
}
示例6: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
*
* This method takes in the current CameraView Matrix and the Camera's Projection Matrix, the
* current position and pose of the device, uses those to calculate the ModelViewMatrix and
* ModelViewProjectionMatrix. It binds the VBO, enables the custom attribute locations,
* binds and uploads the shader uniforms, calls our single DrawArray call, and finally disables
* and unbinds the shader attributes and VBO.
*
* @param cameraView
* @param cameraPerspective
* @param screenWidth
* @param screenHeight
* @param nearClip
* @param farClip
*/
public void draw(float[] cameraView, float[] cameraPerspective, float screenWidth, float screenHeight, float nearClip, float farClip) {
Matrix.multiplyMM(mModelViewMatrix, 0, cameraView, 0, mModelMatrix, 0);
Matrix.multiplyMM(mModelViewProjectionMatrix, 0, cameraPerspective, 0, mModelViewMatrix, 0);
ShaderUtil.checkGLError(TAG, "Before draw");
GLES20.glUseProgram(mProgramName);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);
GLES20.glVertexAttribPointer(
mPositionAttribute, FLOATS_PER_POINT, GLES20.GL_FLOAT, false, BYTES_PER_POINT, mPositionAddress);
GLES20.glVertexAttribPointer(
mPreviousAttribute, FLOATS_PER_POINT, GLES20.GL_FLOAT, false, BYTES_PER_POINT, mPreviousAddress);
GLES20.glVertexAttribPointer(
mNextAttribute, FLOATS_PER_POINT, GLES20.GL_FLOAT, false, BYTES_PER_POINT, mNextAddress);
GLES20.glVertexAttribPointer(
mSideAttribute, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mSideAddress);
GLES20.glVertexAttribPointer(
mWidthAttribte, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mWidthAddress);
GLES20.glVertexAttribPointer(
mCountersAttribute, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mCounterAddress);
GLES20.glUniformMatrix4fv(
mModelViewUniform, 1, false, mModelViewMatrix, 0);
GLES20.glUniformMatrix4fv(
mProjectionUniform, 1, false, cameraPerspective, 0);
GLES20.glUniform2f(mResolutionUniform, screenWidth, screenHeight);
GLES20.glUniform1f(mLineWidthUniform, 0.01f);
GLES20.glUniform3f(mColorUniform, mColor.x, mColor.y, mColor.z);
GLES20.glUniform1f(mOpacityUniform, 1.0f);
GLES20.glUniform1f(mNearUniform, nearClip);
GLES20.glUniform1f(mFarUniform, farClip);
GLES20.glUniform1f(mSizeAttenuationUniform, 1.0f);
GLES20.glUniform1f(mVisibility, 1.0f);
GLES20.glUniform1f(mAlphaTest, 1.0f);
GLES20.glUniform1f(mDrawModeUniform, mDrawMode?1.0f:0.0f);
GLES20.glUniform1f(mNearCutoffUniform, mDrawDistance - 0.0075f);
GLES20.glUniform1f(mFarCutoffUniform, mDrawDistance + 0.0075f);
GLES20.glUniform1f(mLineDepthScaleUniform, mLineDepthScale);
GLES20.glEnableVertexAttribArray(mPositionAttribute);
GLES20.glEnableVertexAttribArray(mPreviousAttribute);
GLES20.glEnableVertexAttribArray(mNextAttribute);
GLES20.glEnableVertexAttribArray(mSideAttribute);
GLES20.glEnableVertexAttribArray(mWidthAttribte);
GLES20.glEnableVertexAttribArray(mCountersAttribute);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, mNumBytes);
GLES20.glDisableVertexAttribArray(mCountersAttribute);
GLES20.glDisableVertexAttribArray(mWidthAttribte);
GLES20.glDisableVertexAttribArray(mSideAttribute);
GLES20.glDisableVertexAttribArray(mNextAttribute);
GLES20.glDisableVertexAttribArray(mPreviousAttribute);
GLES20.glDisableVertexAttribArray(mPositionAttribute);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
ShaderUtil.checkGLError(TAG, "Draw");
}