Java Code Examples for android.opengl.GLES20#glUniform1f()
The following examples show how to use
android.opengl.GLES20#glUniform1f() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextObjectFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 5 votes |
@Override protected void drawFilter() { super.drawFilter(); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, streamObjectTextureId[0]); //Set alpha. 0f if no image loaded. GLES20.glUniform1f(uAlphaHandle, streamObjectTextureId[0] == -1 ? 0f : alpha); }
Example 2
Source File: MediaEffectGLAlphaBlend.java From libcommon with Apache License 2.0 | 5 votes |
@Override protected void preDraw(@NonNull final int[] tex_ids, final float[] tex_matrix, final int offset) { super.preDraw(tex_ids, tex_matrix, offset); if (muMixRate >= 0) { synchronized (mSync) { GLES20.glUniform1f(muMixRate, mMixRate); } } }
Example 3
Source File: GlVignetteFilter.java From SimpleVideoEdit with Apache License 2.0 | 5 votes |
@Override public void onDraw() { GLES20.glUniform2f(getHandle("vignetteCenter"), vignetteCenterX, vignetteCenterY); GLES20.glUniform3fv(getHandle("vignetteColor"), 0, vignetteColor, 0); GLES20.glUniform1f(getHandle("vignetteStart"), vignetteStart); GLES20.glUniform1f(getHandle("vignetteEnd"), vignetteEnd); }
Example 4
Source File: ImageObjectFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 5 votes |
@Override protected void drawFilter() { super.drawFilter(); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, streamObjectTextureId[0]); //Set alpha. 0f if no image loaded. GLES20.glUniform1f(uAlphaHandle, streamObjectTextureId[0] == -1 ? 0f : alpha); }
Example 5
Source File: OffScreenBlurRenderer.java From HokoBlur with Apache License 2.0 | 5 votes |
private void drawOneDimenBlur(BlurContext blurContext, boolean isHorizontal) { try { GLES20.glUseProgram(mProgram.id()); int positionId = GLES20.glGetAttribLocation(mProgram.id(), "aPosition"); GLES20.glEnableVertexAttribArray(positionId); GLES20.glVertexAttribPointer(positionId, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, VERTEX_STRIDE, mVertexBuffer); int texCoordId = GLES20.glGetAttribLocation(mProgram.id(), "aTexCoord"); GLES20.glEnableVertexAttribArray(texCoordId); GLES20.glVertexAttribPointer(texCoordId, 2, GLES20.GL_FLOAT, false, 0, mTexCoordBuffer); if (isHorizontal) { blurContext.getBlurFrameBuffer().bindSelf(); } int textureUniformId = GLES20.glGetUniformLocation(mProgram.id(), "uTexture"); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, isHorizontal ? blurContext.getInputTexture().id() : blurContext.getHorizontalTexture().id()); GLES20.glUniform1i(textureUniformId, 0); int radiusId = GLES20.glGetUniformLocation(mProgram.id(), "uRadius"); int widthOffsetId = GLES20.glGetUniformLocation(mProgram.id(), "uWidthOffset"); int heightOffsetId = GLES20.glGetUniformLocation(mProgram.id(), "uHeightOffset"); GLES20.glUniform1i(radiusId, mRadius); GLES20.glUniform1f(widthOffsetId, isHorizontal ? 0 : 1f / blurContext.getBitmap().getWidth()); GLES20.glUniform1f(heightOffsetId, isHorizontal ? 1f / blurContext.getBitmap().getHeight() : 0); GLES20.glDrawElements(GLES20.GL_TRIANGLES, drawOrder.length, GLES20.GL_UNSIGNED_SHORT, mDrawListBuffer); if (!isHorizontal) { GLES20.glDisableVertexAttribArray(positionId); GLES20.glDisableVertexAttribArray(texCoordId); } } finally { resetAllBuffer(); } }
Example 6
Source File: GlRGBFilter.java From GPUVideo-android with MIT License | 4 votes |
@Override public void onDraw() { GLES20.glUniform1f(getHandle("red"), red); GLES20.glUniform1f(getHandle("green"), green); GLES20.glUniform1f(getHandle("blue"), blue); }
Example 7
Source File: ContrastBrightnessAdjustmentShaderProgram.java From Spectaculum with Apache License 2.0 | 4 votes |
public void setContrast(float contrast) { use(); GLES20.glUniform1f(mContrastHandle, contrast); }
Example 8
Source File: GlPixelationFilter.java From GPUVideo-android with MIT License | 4 votes |
@Override public void onDraw() { GLES20.glUniform1f(getHandle("pixel"), pixel); GLES20.glUniform1f(getHandle("imageWidthFactor"), imageWidthFactor); GLES20.glUniform1f(getHandle("imageHeightFactor"), imageHeightFactor); }
Example 9
Source File: AlphaFilter.java From PhotoMovie with Apache License 2.0 | 4 votes |
@Override public void drawFrame(float progress, int glTextureId, Rect textureRext, RectF srcRect, RectF dstRect) { GLES20.glUniform1f(mAlphaLocation, progress); super.drawFrame(progress, glTextureId, textureRext, srcRect, dstRect); }
Example 10
Source File: LineShaderRenderer.java From justaline-android with Apache License 2.0 | 4 votes |
/** * 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. */ 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.glDisable(GLES20.GL_DEPTH_TEST); // Blending setup GLES20.glEnable(GLES20.GL_BLEND); // GLES20.glBlendFuncSeparate( // GLES20.GL_SRC_ALPHA, GLES20.GL_DST_ALPHA, // RGB (src, dest) // GLES20.GL_ZERO, GLES20.GL_ONE); // ALPHA (src, dest) GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA); // Attach the texture. GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]); // GLES20.glActiveTexture(GLES20.GL_TEXTURE1); // GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[1]); // GLES20.glUniform1i(mTextureUniform, 0); GLES20.glUniform1i(mEndCapTextureUniform, 0); // 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( mWidthAttribute, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mWidthAddress); GLES20.glVertexAttribPointer( mLengthsAttribute, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mLengthAddress); GLES20.glVertexAttribPointer( mEndCapsAttribute, 1, GLES20.GL_FLOAT, false, BYTES_PER_FLOAT, mEndCapsAddress); // GLES20.glUniformMatrix4fv( mModelViewUniform, 1, false, mModelViewMatrix, 0); GLES20.glUniformMatrix4fv( mProjectionUniform, 1, false, cameraPerspective, 0); GLES20.glUniform2f(mResolutionUniform, screenWidth, screenHeight); GLES20.glUniform3f(mColorUniform, mColor.x, mColor.y, mColor.z); GLES20.glUniform1f(mNearUniform, nearClip); GLES20.glUniform1f(mFarUniform, farClip); GLES20.glUniform1f(mLineDepthScaleUniform, mLineDepthScale); GLES20.glUniform1f(mDrawingDistUniform, mDrawDistance); GLES20.glEnableVertexAttribArray(mPositionAttribute); GLES20.glEnableVertexAttribArray(mPreviousAttribute); GLES20.glEnableVertexAttribArray(mNextAttribute); GLES20.glEnableVertexAttribArray(mSideAttribute); GLES20.glEnableVertexAttribArray(mWidthAttribute); GLES20.glEnableVertexAttribArray(mLengthsAttribute); GLES20.glEnableVertexAttribArray(mEndCapsAttribute); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, mNumBytes); GLES20.glDisableVertexAttribArray(mEndCapsAttribute); GLES20.glDisableVertexAttribArray(mLengthsAttribute); GLES20.glDisableVertexAttribArray(mWidthAttribute); GLES20.glDisableVertexAttribArray(mSideAttribute); GLES20.glDisableVertexAttribArray(mNextAttribute); GLES20.glDisableVertexAttribArray(mPreviousAttribute); GLES20.glDisableVertexAttribArray(mPositionAttribute); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); // GLES20.glActiveTexture(GLES20.GL_TEXTURE1); // GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); // GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glDisable(GLES20.GL_BLEND); GLES20.glEnable(GLES20.GL_DEPTH_TEST); }
Example 11
Source File: LineIntegralConvolutionShaderProgram.java From Spectaculum with Apache License 2.0 | 4 votes |
public void setSigma(float sigma) { GLES20.glUniform1f(mSigmaHandle, sigma); }
Example 12
Source File: WaterColorFilter.java From AAVT with Apache License 2.0 | 4 votes |
@Override protected void onSetExpandData() { super.onSetExpandData(); GLES20.glUniform1f(mGLWidth,mWidth); GLES20.glUniform1f(mGLHeight,mHeight); }
Example 13
Source File: GlMonochromeFilter.java From SimpleVideoEdit with Apache License 2.0 | 4 votes |
@Override public void onDraw() { GLES20.glUniform1f(getHandle("intensity"), intensity); GLES20.glUniform3fv(getHandle("filterColor"), 0, filterColor, 0); }
Example 14
Source File: SharpenFilter.java From AndroidFastImageProcessing with MIT License | votes |
@Override protected void passShaderValues() { super.passShaderValues(); GLES20.glUniform1f(sharpenAmountHandle, sharpenAmount); }
Example 15
Source File: ChromaKeyFilter.java From AndroidFastImageProcessing with MIT License | votes |
@Override protected void passShaderValues() { super.passShaderValues(); GLES20.glUniform3f(colourHandle, colour[0], colour[1], colour[2]); GLES20.glUniform1f(thresholdHandle, threshold); GLES20.glUniform1f(smoothingHandle, smoothing); }
Example 16
Source File: SwirlFilter.java From AndroidFastImageProcessing with MIT License | votes |
@Override protected void passShaderValues() { super.passShaderValues(); GLES20.glUniform2f(centerHandle, center.x, center.y); GLES20.glUniform1f(radiusHandle, radius); GLES20.glUniform1f(angleHandle, angle); }
Example 17
Source File: LuminanceThresholdFilter.java From UltimateAndroid with Apache License 2.0 | votes |
@Override protected void passShaderValues() { super.passShaderValues(); GLES20.glUniform1f(thresholdHandle, threshold); }
Example 18
Source File: BilateralBlurFilter.java From AndroidFastImageProcessing with MIT License | votes |
@Override protected void passShaderValues() { super.passShaderValues(); GLES20.glUniform1f(distanceNormalizationHandle, distanceNormalization); }
Example 19
Source File: BulgeDistortionFilter.java From UltimateAndroid with Apache License 2.0 | votes |
@Override protected void passShaderValues() { super.passShaderValues(); GLES20.glUniform2f(centerHandle, center.x, center.y); GLES20.glUniform1f(radiusHandle, radius); GLES20.glUniform1f(distortionAmountHandle, distortionAmount); GLES20.glUniform1f(aspectRatioHandle, aspectRatio); }
Example 20
Source File: HazeFilter.java From UltimateAndroid with Apache License 2.0 | votes |
@Override protected void passShaderValues() { super.passShaderValues(); GLES20.glUniform1f(distanceHandle, distance); GLES20.glUniform1f(slopeHandle, slope); }