Java Code Examples for android.opengl.GLES20#GL_LUMINANCE
The following examples show how to use
android.opengl.GLES20#GL_LUMINANCE .
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: GlTextureFrameBuffer.java From sealrtc-android with MIT License | 6 votes |
/** * Generate texture and framebuffer resources. An EGLContext must be bound on the current thread * when calling this function. The framebuffer is not complete until setSize() is called. */ public GlTextureFrameBuffer(int pixelFormat) { switch (pixelFormat) { case GLES20.GL_LUMINANCE: case GLES20.GL_RGB: case GLES20.GL_RGBA: this.pixelFormat = pixelFormat; break; default: throw new IllegalArgumentException("Invalid pixel format: " + pixelFormat); } // Create texture. textureId = GlUtil.generateTexture(GLES20.GL_TEXTURE_2D); this.width = 0; this.height = 0; // Create framebuffer object. final int frameBuffers[] = new int[1]; GLES20.glGenFramebuffers(1, frameBuffers, 0); frameBufferId = frameBuffers[0]; }
Example 2
Source File: GlTextureFrameBuffer.java From VideoCRE with MIT License | 6 votes |
/** * Generate texture and framebuffer resources. An EGLContext must be bound on the current thread * when calling this function. The framebuffer is not complete until setSize() is called. */ public GlTextureFrameBuffer(int pixelFormat) { switch (pixelFormat) { case GLES20.GL_LUMINANCE: case GLES20.GL_RGB: case GLES20.GL_RGBA: this.pixelFormat = pixelFormat; break; default: throw new IllegalArgumentException("Invalid pixel format: " + pixelFormat); } // Create texture. textureId = GlUtil.generateTexture(GLES20.GL_TEXTURE_2D); this.width = 0; this.height = 0; // Create framebuffer object. final int frameBuffers[] = new int[1]; GLES20.glGenFramebuffers(1, frameBuffers, 0); frameBufferId = frameBuffers[0]; }
Example 3
Source File: GlTextureFrameBuffer.java From webrtc_android with MIT License | 5 votes |
/** * Generate texture and framebuffer resources. An EGLContext must be bound on the current thread * when calling this function. The framebuffer is not complete until setSize() is called. */ public GlTextureFrameBuffer(int pixelFormat) { switch (pixelFormat) { case GLES20.GL_LUMINANCE: case GLES20.GL_RGB: case GLES20.GL_RGBA: this.pixelFormat = pixelFormat; break; default: throw new IllegalArgumentException("Invalid pixel format: " + pixelFormat); } this.width = 0; this.height = 0; }
Example 4
Source File: FrameRenderer.java From DanDanPlayForAndroid with MIT License | 4 votes |
@Override public void onDrawFrame() { FrameBuffer pendingOutputBuffer = pendingOutputBufferReference.getAndSet(null); if (pendingOutputBuffer == null && renderedOutputBuffer == null) { // There is no output buffer to render at the moment. return; } if (pendingOutputBuffer != null) { if (renderedOutputBuffer != null) { renderedOutputBuffer.release(); } renderedOutputBuffer = pendingOutputBuffer; } FrameBuffer outputBuffer = renderedOutputBuffer; // Set color matrix. Assume BT709 if the color space is unknown. float[] colorConversion = kColorConversion709; /*switch (outputBuffer.pixelFormat) { case FrameBuffer.COLORSPACE_BT601: colorConversion = kColorConversion601; break; case FrameBuffer.COLORSPACE_BT2020: colorConversion = kColorConversion2020; break; case FrameBuffer.COLORSPACE_BT709: default: break; // Do nothing }*/ int bitDepth = outputBuffer.bitDepth; int format = bitDepth == 1 ? GLES20.GL_LUMINANCE : GLES20.GL_LUMINANCE_ALPHA; GLES20.glUniformMatrix3fv(colorMatrixLocation, 1, false, colorConversion, 0); GLES20.glUniform1f(bitDepthLocation, bitDepth); for (int i = 0; i < 3; i++) { GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + i); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, yuvTextures[i]); int width = outputBuffer.yuvStrides[i] / bitDepth; int height = (i == 0) ? outputBuffer.height : outputBuffer.height / 2; GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, format, width, height, 0, format, GLES20.GL_UNSIGNED_BYTE, outputBuffer.yuvPlanes[i]); } // Set cropping of stride if either width or stride has changed. if (previousWidth != outputBuffer.width || previousStride != outputBuffer.yuvStrides[0]) { float crop = (float) outputBuffer.width * bitDepth / outputBuffer.yuvStrides[0]; // This buffer is consumed during each call to glDrawArrays. It needs to be a member variable // rather than a local variable to ensure that it doesn't get garbage collected. textureCoords = nativeFloatBuffer( 0.0f, 0.0f, 0.0f, 1.0f, crop, 0.0f, crop, 1.0f); GLES20.glVertexAttribPointer( texLocation, 2, GLES20.GL_FLOAT, false, 0, textureCoords); previousWidth = outputBuffer.width; previousStride = outputBuffer.yuvStrides[0]; } GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); checkNoGLES2Error(); }