Java Code Examples for android.opengl.GLES20#glUniform1i()
The following examples show how to use
android.opengl.GLES20#glUniform1i() .
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: SaturationFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 6 votes |
@Override protected void drawFilter() { GLES20.glUseProgram(program); squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET); GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aPositionHandle); squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET); GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aTextureHandle); GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0); GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0); GLES20.glUniform1f(uShiftHandle, shift); GLES20.glUniform3f(uWeightsHandle, weights[0], weights[1], weights[2]); GLES20.glUniform3f(uExponentsHandle, exponents[0], exponents[1], exponents[2]); GLES20.glUniform1f(uSaturationHandle, saturation); GLES20.glUniform1i(uSamplerHandle, 4); GLES20.glActiveTexture(GLES20.GL_TEXTURE4); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId); }
Example 2
Source File: ColorFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 6 votes |
@Override protected void drawFilter() { GLES20.glUseProgram(program); squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET); GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aPositionHandle); squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET); GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aTextureHandle); GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0); GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0); GLES20.glUniform3f(uColorHandle, red, green, blue); GLES20.glUniform1i(uSamplerHandle, 4); GLES20.glActiveTexture(GLES20.GL_TEXTURE4); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId); }
Example 3
Source File: BrightnessFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 6 votes |
@Override protected void drawFilter() { GLES20.glUseProgram(program); squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET); GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aPositionHandle); squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET); GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aTextureHandle); GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0); GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0); GLES20.glUniform1f(uBrightnessHandle, brightness); GLES20.glUniform1i(uSamplerHandle, 4); GLES20.glActiveTexture(GLES20.GL_TEXTURE4); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId); }
Example 4
Source File: PolygonizationFilterRender.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 6 votes |
@Override protected void drawFilter() { GLES20.glUseProgram(program); squareVertex.position(SQUARE_VERTEX_DATA_POS_OFFSET); GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aPositionHandle); squareVertex.position(SQUARE_VERTEX_DATA_UV_OFFSET); GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false, SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex); GLES20.glEnableVertexAttribArray(aTextureHandle); GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0); GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0); GLES20.glUniform2f(uResolutionHandle, getWidth(), getHeight()); GLES20.glUniform1i(uSamplerHandle, 4); GLES20.glActiveTexture(GLES20.GL_TEXTURE4); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, previousTexId); }
Example 5
Source File: GPUImageFilter.java From SimpleVideoEditor with Apache License 2.0 | 6 votes |
public void onDraw(final int textureId, final FloatBuffer cubeBuffer, final FloatBuffer textureBuffer) { GLES20.glUseProgram(mGLProgId); runPendingOnDrawTasks(); if (!mIsInitialized) { return; } 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); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); }
Example 6
Source File: GlOverlayFilter.java From GPUVideo-android with MIT License | 6 votes |
@Override public void onDraw() { if (bitmap == null) { createBitmap(); } if (bitmap.getWidth() != inputResolution.getWidth() || bitmap.getHeight() != inputResolution.getHeight()) { createBitmap(); } bitmap.eraseColor(Color.argb(0, 0, 0, 0)); Canvas bitmapCanvas = new Canvas(bitmap); bitmapCanvas.scale(1, -1, bitmapCanvas.getWidth() / 2, bitmapCanvas.getHeight() / 2); drawCanvas(bitmapCanvas); int offsetDepthMapTextureUniform = getHandle("oTexture");// 3 GLES20.glActiveTexture(GLES20.GL_TEXTURE3); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]); if (bitmap != null && !bitmap.isRecycled()) { GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, bitmap, 0); } GLES20.glUniform1i(offsetDepthMapTextureUniform, 3); }
Example 7
Source File: FDOG1ShaderProgram.java From Spectaculum with Apache License 2.0 | 5 votes |
public void setTexture(Texture2D img, Texture2D tfm) { GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, img.getHandle()); GLES20.glUniform1i(mTextureHandle, 0); // bind texture unit 0 to the uniform GLES20.glActiveTexture(GLES20.GL_TEXTURE1); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tfm.getHandle()); GLES20.glUniform1i(mTextureHandle2, 1); // bind texture unit 0 to the uniform GLES20.glUniformMatrix4fv(mSTMatrixHandle, 1, false, img.getTransformMatrix(), 0); }
Example 8
Source File: CameraGLRendererBase.java From MOAAP with MIT License | 5 votes |
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(); }
Example 9
Source File: DrawerImpl.java From android-3D-model-viewer with GNU Lesser General Public License v3.0 | 5 votes |
private int setTexture(Object3DData obj, int textureId) { int mTextureUniformHandle = GLES20.glGetUniformLocation(mProgram, "u_Texture"); GLUtil.checkGlError("glGetUniformLocation"); // Set the active texture unit to texture unit 0. GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLUtil.checkGlError("glActiveTexture"); // Bind to the texture in OpenGL GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId); GLUtil.checkGlError("glBindTexture"); // Tell the texture uniform sampler to use this texture in the shader by binding to texture unit 0. GLES20.glUniform1i(mTextureUniformHandle, 0); GLUtil.checkGlError("glUniform1i"); int mTextureCoordinateHandle = GLES20.glGetAttribLocation(mProgram, "a_TexCoordinate"); GLUtil.checkGlError("glGetAttribLocation"); // Enable a handle to the triangle vertices GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle); GLUtil.checkGlError("glEnableVertexAttribArray"); // Prepare the triangle coordinate data obj.getTextureCoordsArrayBuffer().position(0); GLES20.glVertexAttribPointer(mTextureCoordinateHandle, 2, GLES20.GL_FLOAT, false, 0, obj.getTextureCoordsArrayBuffer()); GLUtil.checkGlError("glVertexAttribPointer"); return mTextureCoordinateHandle; }
Example 10
Source File: CameraGLRendererBase.java From MOAAP with MIT License | 5 votes |
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(); }
Example 11
Source File: TextureFlipShaderProgram.java From Spectaculum with Apache License 2.0 | 5 votes |
public void setMode(int mode) { if(mode < 0 || mode > 3) { throw new RuntimeException("mode must be in range [0, 3]"); } use(); GLES20.glUniform1i(mModeHandle, mode); }
Example 12
Source File: GLES20Canvas.java From PhotoMovie with Apache License 2.0 | 5 votes |
private void prepareTexture(BasicTexture texture, int program, ShaderParameter[] params) { GLES20.glUseProgram(program); checkError(); enableBlending(!texture.isOpaque() || getAlpha() < OPAQUE_ALPHA); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); checkError(); texture.onBind(this); GLES20.glBindTexture(texture.getTarget(), texture.getId()); checkError(); GLES20.glUniform1i(params[INDEX_TEXTURE_SAMPLER].handle, 0); checkError(); GLES20.glUniform1f(params[INDEX_ALPHA].handle, getAlpha()); checkError(); }
Example 13
Source File: PositionTextureCoordinatesTextureSelectShaderProgram.java From tilt-game-android with MIT License | 5 votes |
@Override public void bind(final GLState pGLState, final VertexBufferObjectAttributes pVertexBufferObjectAttributes) { GLES20.glDisableVertexAttribArray(ShaderProgramConstants.ATTRIBUTE_COLOR_LOCATION); super.bind(pGLState, pVertexBufferObjectAttributes); GLES20.glUniformMatrix4fv(PositionTextureCoordinatesTextureSelectShaderProgram.sUniformModelViewPositionMatrixLocation, 1, false, pGLState.getModelViewProjectionGLMatrix(), 0); GLES20.glUniform1i(PositionTextureCoordinatesTextureSelectShaderProgram.sUniformTexture0Location, 0); GLES20.glUniform1i(PositionTextureCoordinatesTextureSelectShaderProgram.sUniformTexture1Location, 1); }
Example 14
Source File: GSYVideoGLViewCustomRender3.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
@Override protected void bindDrawFrameTexture() { super.bindDrawFrameTexture(); //绑定注入bitmap int mFilterInputTextureUniform2 = GLES20.glGetUniformLocation(getProgram(), "sTexture2"); GLES20.glActiveTexture(GLES20.GL_TEXTURE3); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexturesBitmap[0]); GLES20.glUniform1i(mFilterInputTextureUniform2, mTexturesBitmap[0]); }
Example 15
Source File: DistortionRenderer.java From Cardboard with Apache License 2.0 | 5 votes |
private void renderDistortionMesh(DistortionMesh mesh) { GLES20.glBindBuffer(34962, mesh.mArrayBufferId); mesh.getClass(); mesh.getClass(); GLES20.glVertexAttribPointer(this.mProgramHolder.aPosition, 3, 5126, false, 20, 0 * 4); GLES20.glEnableVertexAttribArray(this.mProgramHolder.aPosition); mesh.getClass(); mesh.getClass(); GLES20.glVertexAttribPointer(this.mProgramHolder.aVignette, 1, 5126, false, 20, 2 * 4); GLES20.glEnableVertexAttribArray(this.mProgramHolder.aVignette); mesh.getClass(); mesh.getClass(); GLES20.glVertexAttribPointer(this.mProgramHolder.aTextureCoord, 2, 5126, false, 20, 3 * 4); GLES20.glEnableVertexAttribArray(this.mProgramHolder.aTextureCoord); GLES20.glActiveTexture(33984); GLES20.glBindTexture(3553, this.mTextureId); GLES20.glUniform1i(this.mProgramHolder.uTextureSampler, 0); GLES20.glUniform1f(this.mProgramHolder.uTextureCoordScale, this.mResolutionScale); GLES20.glBindBuffer(34963, mesh.mElementBufferId); GLES20.glDrawElements(5, mesh.nIndices, 5125, 0); }
Example 16
Source File: CameraGLRendererBase.java From Document-Scanner with GNU General Public License v3.0 | 5 votes |
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(); }
Example 17
Source File: GPUImageFilter.java From Fatigue-Detection with MIT License | 5 votes |
public void onDraw(int paramInt, FloatBuffer paramFloatBuffer1, FloatBuffer paramFloatBuffer2) { z(); GLES20.glUseProgram(this.aO); C(); if (!this.aU) { return; } paramFloatBuffer1.position(0); GLES20.glVertexAttribPointer(this.aP, 2, 5126, false, 0, paramFloatBuffer1); GLES20.glEnableVertexAttribArray(this.aP); paramFloatBuffer2.position(0); GLES20.glVertexAttribPointer(this.aR, 2, 5126, false, 0, paramFloatBuffer2); GLES20.glEnableVertexAttribArray(this.aR); if (paramInt != -1) { GLES20.glActiveTexture(33984); GLES20.glBindTexture(y(), paramInt); GLES20.glUniform1i(this.aQ, 0); } d(paramInt); GLES20.glDrawArrays(5, 0, 4); GLES20.glDisableVertexAttribArray(this.aP); GLES20.glDisableVertexAttribArray(this.aR); e(paramInt); GLES20.glBindTexture(y(), 0); }
Example 18
Source File: GSYVideoGLViewCustomRender.java From GSYVideoPlayer with Apache License 2.0 | 4 votes |
@Override public void onDrawFrame(GL10 glUnused) { super.onDrawFrame(glUnused); //curProgram = createProgram(getVertexShader(), mBitmapEffect.getShader(mSurfaceView)); GLES20.glUseProgram(curProgram); checkGlError("glUseProgram"); //绑定注入bitmap int mFilterInputTextureUniform2 = GLES20.glGetUniformLocation(curProgram, "sTexture2"); GLES20.glActiveTexture(GLES20.GL_TEXTURE3); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexturesBitmap[0]); GLES20.glUniform1i(mFilterInputTextureUniform2, mTexturesBitmap[0]); 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, 3, 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.glEnable(GLES20.GL_BLEND); GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); checkGlError("glDrawArrays"); GLES20.glFinish(); GLES20.glDisable(GLES20.GL_BLEND); }
Example 19
Source File: ShaderProgram.java From VideoRecorder with Apache License 2.0 | 4 votes |
public void setInteger(final int location, final int intValue) { GLES20.glUniform1i(location, intValue); }
Example 20
Source File: MosaicFilter.java From AndroidFastImageProcessing with MIT License | votes |
@Override protected void passShaderValues() { super.passShaderValues(); GLES20.glUniform2f(inputTileSizeHandle, inputTileSize.x, inputTileSize.y); GLES20.glUniform2f(displayTileSizeHandle, displayTileSize.x, displayTileSize.y); GLES20.glUniform1i(numOfTilesHandle, numOfTiles); if(color) { GLES20.glUniform1i(colorHandle, 1); } else { GLES20.glUniform1i(colorHandle, 0); } }