Java Code Examples for android.opengl.GLES20#glBlendColor()
The following examples show how to use
android.opengl.GLES20#glBlendColor() .
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: GLES20Canvas.java From PhotoMovie with Apache License 2.0 | 6 votes |
private void prepareDraw(int offset, int color, float lineWidth) { GLES20.glUseProgram(mDrawProgram); checkError(); if (lineWidth > 0) { GLES20.glLineWidth(lineWidth); checkError(); } float[] colorArray = getColor(color); boolean blendingEnabled = (colorArray[3] < 1f); enableBlending(blendingEnabled); if (blendingEnabled) { GLES20.glBlendColor(colorArray[0], colorArray[1], colorArray[2], colorArray[3]); checkError(); } GLES20.glUniform4fv(mDrawParameters[INDEX_COLOR].handle, 1, colorArray, 0); setPosition(mDrawParameters, offset); checkError(); }
Example 2
Source File: GLES20Canvas.java From android-openGL-canvas with Apache License 2.0 | 6 votes |
private void prepareDraw(int offset, int color, float lineWidth) { GLES20.glUseProgram(mDrawProgram); checkError(); if (lineWidth > 0) { GLES20.glLineWidth(lineWidth); checkError(); } float[] colorArray = getColor(color); enableBlending(true); GLES20.glBlendColor(colorArray[0], colorArray[1], colorArray[2], colorArray[3]); checkError(); GLES20.glUniform4fv(mDrawParameters[INDEX_COLOR].handle, 1, colorArray, 0); setPosition(mDrawParameters, offset); checkError(); }
Example 3
Source File: GLES20Canvas.java From Trebuchet with GNU General Public License v3.0 | 6 votes |
private void prepareDraw(int offset, int color, float lineWidth) { GLES20.glUseProgram(mDrawProgram); checkError(); if (lineWidth > 0) { GLES20.glLineWidth(lineWidth); checkError(); } float[] colorArray = getColor(color); boolean blendingEnabled = (colorArray[3] < 1f); enableBlending(blendingEnabled); if (blendingEnabled) { GLES20.glBlendColor(colorArray[0], colorArray[1], colorArray[2], colorArray[3]); checkError(); } GLES20.glUniform4fv(mDrawParameters[INDEX_COLOR].handle, 1, colorArray, 0); setPosition(mDrawParameters, offset); checkError(); }
Example 4
Source File: GLES20Canvas.java From TurboLauncher with Apache License 2.0 | 6 votes |
private void prepareDraw(int offset, int color, float lineWidth) { GLES20.glUseProgram(mDrawProgram); checkError(); if (lineWidth > 0) { GLES20.glLineWidth(lineWidth); checkError(); } float[] colorArray = getColor(color); boolean blendingEnabled = (colorArray[3] < 1f); enableBlending(blendingEnabled); if (blendingEnabled) { GLES20.glBlendColor(colorArray[0], colorArray[1], colorArray[2], colorArray[3]); checkError(); } GLES20.glUniform4fv(mDrawParameters[INDEX_COLOR].handle, 1, colorArray, 0); setPosition(mDrawParameters, offset); checkError(); }
Example 5
Source File: GLES20Canvas.java From LB-Launcher with Apache License 2.0 | 6 votes |
private void prepareDraw(int offset, int color, float lineWidth) { GLES20.glUseProgram(mDrawProgram); checkError(); if (lineWidth > 0) { GLES20.glLineWidth(lineWidth); checkError(); } float[] colorArray = getColor(color); boolean blendingEnabled = (colorArray[3] < 1f); enableBlending(blendingEnabled); if (blendingEnabled) { GLES20.glBlendColor(colorArray[0], colorArray[1], colorArray[2], colorArray[3]); checkError(); } GLES20.glUniform4fv(mDrawParameters[INDEX_COLOR].handle, 1, colorArray, 0); setPosition(mDrawParameters, offset); checkError(); }
Example 6
Source File: AnnotationRenderer.java From ARCore-Location with MIT License | 5 votes |
public void draw(float[] cameraView, float[] cameraPerspective) { ShaderUtil.checkGLError(TAG, "Before draw"); Matrix.multiplyMM(mModelViewMatrix, 0, cameraView, 0, mModelMatrix, 0); Matrix.multiplyMM(mModelViewProjectionMatrix, 0, cameraPerspective, 0, mModelViewMatrix, 0); GLES20.glUseProgram(mQuadProgram); // Attach the object texture. GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]); GLES20.glEnable(GLES20.GL_BLEND); GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA); GLES20.glBlendColor(0,0,0,0); GLES20.glUniform1i(mTextureUniform, 0); GLES20.glUniformMatrix4fv(mModelViewProjectionUniform, 1, false, mModelViewProjectionMatrix, 0); // Set the vertex positions. GLES20.glVertexAttribPointer( mQuadPositionParam, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, mQuadVertices); // Set the texture coordinates. GLES20.glVertexAttribPointer( mQuadTexCoordParam, TEXCOORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, mQuadTexCoord); // Enable vertex arrays GLES20.glEnableVertexAttribArray(mQuadPositionParam); GLES20.glEnableVertexAttribArray(mQuadTexCoordParam); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); // Disable vertex arrays GLES20.glDisableVertexAttribArray(mQuadPositionParam); GLES20.glDisableVertexAttribArray(mQuadTexCoordParam); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); ShaderUtil.checkGLError(TAG, "After draw"); }
Example 7
Source File: AnnotationRenderer.java From ARCore-Location with MIT License | 4 votes |
@Override public void createOnGlThread(Context context, int distance) { String text = annotationText; // Read the texture. Bitmap textureBitmap = null; try { textureBitmap = drawTextToAnnotation(context, text, metresReadable(distance)); textureBitmap.setHasAlpha(true); } catch (Exception e) { Log.e(TAG, "Exception reading texture", e); return; } GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glGenTextures(mTextures.length, mTextures, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); GLES20.glBlendColor(0,0,0,0); GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA); GLES20.glEnable(GLES20.GL_BLEND); GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, textureBitmap, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); textureBitmap.recycle(); ShaderUtil.checkGLError(TAG, "Texture loading"); // Build the geometry of a simple imageRenderer. int numVertices = 4; if (numVertices != QUAD_COORDS.length / COORDS_PER_VERTEX) { throw new RuntimeException("Unexpected number of vertices in BackgroundRenderer."); } ByteBuffer bbVertices = ByteBuffer.allocateDirect(QUAD_COORDS.length * Float.BYTES); bbVertices.order(ByteOrder.nativeOrder()); mQuadVertices = bbVertices.asFloatBuffer(); mQuadVertices.put(QUAD_COORDS); mQuadVertices.position(0); ByteBuffer bbTexCoords = ByteBuffer.allocateDirect(numVertices * TEXCOORDS_PER_VERTEX * Float.BYTES); bbTexCoords.order(ByteOrder.nativeOrder()); mQuadTexCoord = bbTexCoords.asFloatBuffer(); mQuadTexCoord.put(QUAD_TEXCOORDS); mQuadTexCoord.position(0); ByteBuffer bbTexCoordsTransformed = ByteBuffer.allocateDirect(numVertices * TEXCOORDS_PER_VERTEX * Float.BYTES); bbTexCoordsTransformed.order(ByteOrder.nativeOrder()); int vertexShader = loadGLShader(TAG, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER); int fragmentShader = loadGLShader(TAG, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER); mQuadProgram = GLES20.glCreateProgram(); GLES20.glAttachShader(mQuadProgram, vertexShader); GLES20.glAttachShader(mQuadProgram, fragmentShader); GLES20.glLinkProgram(mQuadProgram); GLES20.glUseProgram(mQuadProgram); ShaderUtil.checkGLError(TAG, "Program creation"); mQuadPositionParam = GLES20.glGetAttribLocation(mQuadProgram, "a_Position"); mQuadTexCoordParam = GLES20.glGetAttribLocation(mQuadProgram, "a_TexCoord"); mTextureUniform = GLES20.glGetUniformLocation(mQuadProgram, "u_Texture"); mModelViewProjectionUniform = GLES20.glGetUniformLocation(mQuadProgram, "u_ModelViewProjection"); ShaderUtil.checkGLError(TAG, "Program parameters"); Matrix.setIdentityM(mModelMatrix, 0); }
Example 8
Source File: AnnotationRenderer.java From ARCore-Location with MIT License | 4 votes |
@Override public void draw(float[] cameraView, float[] cameraPerspective, float lightIntensity) { ShaderUtil.checkGLError(TAG, "Before draw"); Matrix.multiplyMM(mModelViewMatrix, 0, cameraView, 0, mModelMatrix, 0); Matrix.multiplyMM(mModelViewProjectionMatrix, 0, cameraPerspective, 0, mModelViewMatrix, 0); GLES20.glUseProgram(mQuadProgram); // Attach the object texture. GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]); GLES20.glEnable(GLES20.GL_BLEND); GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA); GLES20.glBlendColor(0,0,0,0); GLES20.glUniform1i(mTextureUniform, 0); GLES20.glUniformMatrix4fv(mModelViewProjectionUniform, 1, false, mModelViewProjectionMatrix, 0); // Set the vertex positions. GLES20.glVertexAttribPointer( mQuadPositionParam, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, mQuadVertices); // Set the texture coordinates. GLES20.glVertexAttribPointer( mQuadTexCoordParam, TEXCOORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, mQuadTexCoord); // Enable vertex arrays GLES20.glEnableVertexAttribArray(mQuadPositionParam); GLES20.glEnableVertexAttribArray(mQuadTexCoordParam); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); // Disable vertex arrays GLES20.glDisableVertexAttribArray(mQuadPositionParam); GLES20.glDisableVertexAttribArray(mQuadTexCoordParam); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); ShaderUtil.checkGLError(TAG, "After draw"); }
Example 9
Source File: AnnotationRenderer.java From ARCore-Location with MIT License | 4 votes |
public void createOnGlThread(Context context, String text, int distance) { // Read the texture. Bitmap textureBitmap = null; try { textureBitmap = drawTextToAnnotation(context, text, metresReadable(distance)); textureBitmap.setHasAlpha(true); } catch (Exception e) { Log.e(TAG, "Exception reading texture", e); return; } GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glGenTextures(mTextures.length, mTextures, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); GLES20.glBlendColor(0,0,0,0); GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA); GLES20.glEnable(GLES20.GL_BLEND); GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, textureBitmap, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); textureBitmap.recycle(); ShaderUtil.checkGLError(TAG, "Texture loading"); // Build the geometry of a simple imageRenderer. int numVertices = 4; if (numVertices != QUAD_COORDS.length / COORDS_PER_VERTEX) { throw new RuntimeException("Unexpected number of vertices in BackgroundRenderer."); } ByteBuffer bbVertices = ByteBuffer.allocateDirect(QUAD_COORDS.length * Float.BYTES); bbVertices.order(ByteOrder.nativeOrder()); mQuadVertices = bbVertices.asFloatBuffer(); mQuadVertices.put(QUAD_COORDS); mQuadVertices.position(0); ByteBuffer bbTexCoords = ByteBuffer.allocateDirect(numVertices * TEXCOORDS_PER_VERTEX * Float.BYTES); bbTexCoords.order(ByteOrder.nativeOrder()); mQuadTexCoord = bbTexCoords.asFloatBuffer(); mQuadTexCoord.put(QUAD_TEXCOORDS); mQuadTexCoord.position(0); ByteBuffer bbTexCoordsTransformed = ByteBuffer.allocateDirect(numVertices * TEXCOORDS_PER_VERTEX * Float.BYTES); bbTexCoordsTransformed.order(ByteOrder.nativeOrder()); int vertexShader = loadGLShader(TAG, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER); int fragmentShader = loadGLShader(TAG, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER); mQuadProgram = GLES20.glCreateProgram(); GLES20.glAttachShader(mQuadProgram, vertexShader); GLES20.glAttachShader(mQuadProgram, fragmentShader); GLES20.glLinkProgram(mQuadProgram); GLES20.glUseProgram(mQuadProgram); ShaderUtil.checkGLError(TAG, "Program creation"); mQuadPositionParam = GLES20.glGetAttribLocation(mQuadProgram, "a_Position"); mQuadTexCoordParam = GLES20.glGetAttribLocation(mQuadProgram, "a_TexCoord"); mTextureUniform = GLES20.glGetUniformLocation(mQuadProgram, "u_Texture"); mModelViewProjectionUniform = GLES20.glGetUniformLocation(mQuadProgram, "u_ModelViewProjection"); ShaderUtil.checkGLError(TAG, "Program parameters"); Matrix.setIdentityM(mModelMatrix, 0); }
Example 10
Source File: AndroidGL.java From trekarta with GNU General Public License v3.0 | 4 votes |
@Override public void blendColor(float red, float green, float blue, float alpha) { GLES20.glBlendColor(red, green, blue, alpha); }