Java Code Examples for android.opengl.GLES20#glTexImage2D()
The following examples show how to use
android.opengl.GLES20#glTexImage2D() .
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: GLTexture.java From libcommon with Apache License 2.0 | 5 votes |
/** * コンストラクタ * @param texTarget GL_TEXTURE_EXTERNAL_OESはだめ * @param texUnit * @param width テクスチャサイズ * @param height テクスチャサイズ * @param filter_param テクスチャの補間方法を指定 GL_LINEARとかGL_NEAREST */ public GLTexture(final int texTarget, final int texUnit, final int width, final int height, final int filter_param) { // if (DEBUG) Log.v(TAG, String.format("コンストラクタ(%d,%d)", width, height)); mTextureTarget = texTarget; mTextureUnit = texUnit; // テクスチャに使うビットマップは縦横サイズが2の乗数でないとダメ。 // 更に、ミップマップするなら正方形でないとダメ // 指定したwidth/heightと同じか大きい2の乗数にする int w = 32; for (; w < width; w <<= 1); int h = 32; for (; h < height; h <<= 1); if (mTexWidth != w || mTexHeight != h) { mTexWidth = w; mTexHeight = h; } mImageWidth = mTexWidth; mImageHeight = mTexHeight; // if (DEBUG) Log.v(TAG, String.format("texSize(%d,%d)", mTexWidth, mTexHeight)); mTextureId = GLHelper.initTex(mTextureTarget, texUnit, filter_param); // テクスチャのメモリ領域を確保する GLES20.glTexImage2D(mTextureTarget, 0, // ミップマップレベル0(ミップマップしない) GLES20.GL_RGBA, // 内部フォーマット mTexWidth, mTexHeight, // サイズ 0, // 境界幅 GLES20.GL_RGBA, // 引き渡すデータのフォーマット GLES20.GL_UNSIGNED_BYTE, // データの型 null); // ピクセルデータ無し // テクスチャ変換行列を初期化 Matrix.setIdentityM(mTexMatrix, 0); mTexMatrix[0] = width / (float)mTexWidth; mTexMatrix[5] = height / (float)mTexHeight; setViewPort(0, 0, mImageWidth, mImageHeight); // if (DEBUG) Log.v(TAG, "GLTexture:id=" + mTextureId); }
Example 2
Source File: VideoEncodeRender.java From AudioVideoCodec with Apache License 2.0 | 5 votes |
/** * 创建水印纹理id */ private void createWaterTextureId() { int[] textureIds = new int[1]; //创建纹理 GLES20.glGenTextures(1, textureIds, 0); waterTextureId = textureIds[0]; //绑定纹理 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, waterTextureId); //环绕(超出纹理坐标范围) (s==x t==y GL_REPEAT 重复) GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT); //过滤(纹理像素映射到坐标点) (缩小、放大:GL_LINEAR线性) GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); ByteBuffer bitmapBuffer = ByteBuffer.allocate(bitmap.getHeight() * bitmap.getWidth() * 4);//RGBA bitmap.copyPixelsToBuffer(bitmapBuffer); //将bitmapBuffer位置移动到初始位置 bitmapBuffer.flip(); //设置内存大小绑定内存地址 GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, bitmap.getWidth(), bitmap.getHeight(), 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, bitmapBuffer); //解绑纹理 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); }
Example 3
Source File: CameraGLRendererBase.java From FtcSamples with MIT License | 5 votes |
private void initFBO(int width, int height) { Log.d(LOGTAG, "initFBO("+width+"x"+height+")"); deleteFBO(); GLES20.glGenTextures(1, texDraw, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texDraw[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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.glGenTextures(1, texFBO, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texFBO[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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); //int hFBO; GLES20.glGenFramebuffers(1, FBO, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, FBO[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texFBO[0], 0); Log.d(LOGTAG, "initFBO error status: " + GLES20.glGetError()); int FBOstatus = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); if (FBOstatus != GLES20.GL_FRAMEBUFFER_COMPLETE) Log.e(LOGTAG, "initFBO failed, status: " + FBOstatus); mFBOWidth = width; mFBOHeight = height; }
Example 4
Source File: CameraGLRendererBase.java From Image-Detection-Samples with Apache License 2.0 | 5 votes |
private void initFBO(int width, int height) { Log.d(LOGTAG, "initFBO("+width+"x"+height+")"); deleteFBO(); GLES20.glGenTextures(1, texDraw, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texDraw[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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.glGenTextures(1, texFBO, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texFBO[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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); //int hFBO; GLES20.glGenFramebuffers(1, FBO, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, FBO[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texFBO[0], 0); Log.d(LOGTAG, "initFBO error status: " + GLES20.glGetError()); int FBOstatus = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); if (FBOstatus != GLES20.GL_FRAMEBUFFER_COMPLETE) Log.e(LOGTAG, "initFBO failed, status: " + FBOstatus); mFBOWidth = width; mFBOHeight = height; }
Example 5
Source File: CameraGLRendererBase.java From sudokufx with Apache License 2.0 | 5 votes |
private void initFBO(int width, int height) { Log.d(LOGTAG, "initFBO("+width+"x"+height+")"); deleteFBO(); GLES20.glGenTextures(1, texDraw, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texDraw[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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.glGenTextures(1, texFBO, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texFBO[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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); //int hFBO; GLES20.glGenFramebuffers(1, FBO, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, FBO[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texFBO[0], 0); Log.d(LOGTAG, "initFBO error status: " + GLES20.glGetError()); int FBOstatus = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); if (FBOstatus != GLES20.GL_FRAMEBUFFER_COMPLETE) Log.e(LOGTAG, "initFBO failed, status: " + FBOstatus); mFBOWidth = width; mFBOHeight = height; }
Example 6
Source File: GlUtil.java From PLDroidShortVideo with Apache License 2.0 | 5 votes |
/** * Creates a texture from raw data. * * @param data Image data, in a "direct" ByteBuffer. * @param width Texture width, in pixels (not bytes). * @param height Texture height, in pixels. * @param format Image data format (use constant appropriate for glTexImage2D(), e.g. GL_RGBA). * @return Handle to texture. */ public static int createImageTexture(ByteBuffer data, int width, int height, int format) { int[] textureHandles = new int[1]; int textureHandle; GLES20.glGenTextures(1, textureHandles, 0); textureHandle = textureHandles[0]; GlUtil.checkGlError("glGenTextures"); // Bind the texture handle to the 2D texture target. GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle); // Configure min/mag filtering, i.e. what scaling method do we use if what we're rendering // is smaller or larger than the source image. GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); GlUtil.checkGlError("loadImageTexture"); // Load the data from the buffer into the texture handle. GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, /*level*/ 0, format, width, height, /*border*/ 0, format, GLES20.GL_UNSIGNED_BYTE, data); GlUtil.checkGlError("loadImageTexture"); return textureHandle; }
Example 7
Source File: CameraGLRendererBase.java From LPR with Apache License 2.0 | 5 votes |
private void initFBO(int width, int height) { Log.d(LOGTAG, "initFBO("+width+"x"+height+")"); deleteFBO(); GLES20.glGenTextures(1, texDraw, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texDraw[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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.glGenTextures(1, texFBO, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texFBO[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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); //int hFBO; GLES20.glGenFramebuffers(1, FBO, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, FBO[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texFBO[0], 0); Log.d(LOGTAG, "initFBO error status: " + GLES20.glGetError()); int FBOstatus = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); if (FBOstatus != GLES20.GL_FRAMEBUFFER_COMPLETE) Log.e(LOGTAG, "initFBO failed, status: " + FBOstatus); mFBOWidth = width; mFBOHeight = height; }
Example 8
Source File: CameraGLRendererBase.java From FaceT with Mozilla Public License 2.0 | 5 votes |
private void initFBO(int width, int height) { Log.d(LOGTAG, "initFBO("+width+"x"+height+")"); deleteFBO(); GLES20.glGenTextures(1, texDraw, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texDraw[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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.glGenTextures(1, texFBO, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texFBO[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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); //int hFBO; GLES20.glGenFramebuffers(1, FBO, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, FBO[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texFBO[0], 0); Log.d(LOGTAG, "initFBO error status: " + GLES20.glGetError()); int FBOstatus = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); if (FBOstatus != GLES20.GL_FRAMEBUFFER_COMPLETE) Log.e(LOGTAG, "initFBO failed, status: " + FBOstatus); mFBOWidth = width; mFBOHeight = height; }
Example 9
Source File: CameraGLRendererBase.java From ml-authentication with Apache License 2.0 | 5 votes |
private void initFBO(int width, int height) { Log.d(LOGTAG, "initFBO("+width+"x"+height+")"); deleteFBO(); GLES20.glGenTextures(1, texDraw, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texDraw[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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.glGenTextures(1, texFBO, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texFBO[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 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); //int hFBO; GLES20.glGenFramebuffers(1, FBO, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, FBO[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texFBO[0], 0); Log.d(LOGTAG, "initFBO error status: " + GLES20.glGetError()); int FBOstatus = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); if (FBOstatus != GLES20.GL_FRAMEBUFFER_COMPLETE) Log.e(LOGTAG, "initFBO failed, status: " + FBOstatus); mFBOWidth = width; mFBOHeight = height; }
Example 10
Source File: SmartPVRTexturePixelBufferStrategy.java From tilt-game-android with MIT License | 5 votes |
@Override public void loadPVRTextureData(final IPVRTexturePixelBufferStrategyBufferManager pPVRTexturePixelBufferStrategyManager, final int pWidth, final int pHeight, final int pBytesPerPixel, final PixelFormat pPixelFormat, final int pLevel, final int pCurrentPixelDataOffset, final int pCurrentPixelDataSize) throws IOException { final int glFormat = pPixelFormat.getGLFormat(); final int glType = pPixelFormat.getGLType(); /* Create the texture with the required parameters but without data. */ GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, pLevel, pPixelFormat.getGLInternalFormat(), pWidth, pHeight, 0, glFormat, glType, null); final int bytesPerRow = pWidth * pBytesPerPixel; final int stripeHeight = Math.max(1, this.mAllocationSizeMaximum / bytesPerRow); /* Load stripes. */ int currentStripePixelDataOffset = pCurrentPixelDataOffset; int currentStripeOffsetY = 0; while (currentStripeOffsetY < pHeight) { final int currentStripeHeight = Math.min(pHeight - currentStripeOffsetY, stripeHeight); final int currentStripePixelDataSize = currentStripeHeight * bytesPerRow; /* Adjust buffer. */ final Buffer pixelBuffer = pPVRTexturePixelBufferStrategyManager.getPixelBuffer(PVRTextureHeader.SIZE + currentStripePixelDataOffset, currentStripePixelDataSize); /* Send to hardware. */ GLES20.glTexSubImage2D(GLES20.GL_TEXTURE_2D, pLevel, 0, currentStripeOffsetY, pWidth, currentStripeHeight, glFormat, glType, pixelBuffer); currentStripePixelDataOffset += currentStripePixelDataSize; currentStripeOffsetY += currentStripeHeight; } }
Example 11
Source File: RendererCommon.java From VideoCRE with MIT License | 4 votes |
/** * Upload |planes| into OpenGL textures, taking stride into consideration. * * @return Array of three texture indices corresponding to Y-, U-, and V-plane respectively. */ public int[] uploadYuvData(int width, int height, int[] strides, ByteBuffer[] planes) { final int[] planeWidths = new int[] {width, width / 2, width / 2}; final int[] planeHeights = new int[] {height, height / 2, height / 2}; // Make a first pass to see if we need a temporary copy buffer. int copyCapacityNeeded = 0; for (int i = 0; i < 3; ++i) { if (strides[i] > planeWidths[i]) { copyCapacityNeeded = Math.max(copyCapacityNeeded, planeWidths[i] * planeHeights[i]); } } // Allocate copy buffer if necessary. if (copyCapacityNeeded > 0 && (copyBuffer == null || copyBuffer.capacity() < copyCapacityNeeded)) { copyBuffer = ByteBuffer.allocateDirect(copyCapacityNeeded); } // Make sure YUV textures are allocated. if (yuvTextures == null) { yuvTextures = new int[3]; for (int i = 0; i < 3; i++) { yuvTextures[i] = GlUtil.generateTexture(GLES20.GL_TEXTURE_2D); } } // Upload each plane. for (int i = 0; i < 3; ++i) { GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + i); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, yuvTextures[i]); // GLES only accepts packed data, i.e. stride == planeWidth. final ByteBuffer packedByteBuffer; if (strides[i] == planeWidths[i]) { // Input is packed already. packedByteBuffer = planes[i]; } else { VideoRenderer.nativeCopyPlane( planes[i], planeWidths[i], planeHeights[i], strides[i], copyBuffer, planeWidths[i]); packedByteBuffer = copyBuffer; } GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_LUMINANCE, planeWidths[i], planeHeights[i], 0, GLES20.GL_LUMINANCE, GLES20.GL_UNSIGNED_BYTE, packedByteBuffer); } return yuvTextures; }
Example 12
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(); }
Example 13
Source File: FilterShaders.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void drawEnhancePass() { boolean updateFrame; if (isVideo) { updateFrame = true; } else { updateFrame = !hsvGenerated; } if (updateFrame) { GLES20.glUseProgram(rgbToHsvShaderProgram); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); if (isVideo) { GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, videoTexture); GLES20.glUniformMatrix4fv(rgbToHsvMatrixHandle, 1, false, videoMatrix, 0); } else { GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[1]); } GLES20.glUniform1i(rgbToHsvSourceImageHandle, 0); GLES20.glEnableVertexAttribArray(rgbToHsvInputTexCoordHandle); GLES20.glVertexAttribPointer(rgbToHsvInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer); GLES20.glEnableVertexAttribArray(rgbToHsvPositionHandle); GLES20.glVertexAttribPointer(rgbToHsvPositionHandle, 2, GLES20.GL_FLOAT, false, 8, isVideo ? vertexInvertBuffer : vertexBuffer); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, enhanceFrameBuffer[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, enhanceTextures[0], 0); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); } if (!hsvGenerated) { int newCapacity = renderBufferWidth * renderBufferHeight * 4; if (hsvBuffer == null || newCapacity > hsvBuffer.capacity()) { hsvBuffer = ByteBuffer.allocateDirect(newCapacity); } if (cdtBuffer == null) { cdtBuffer = ByteBuffer.allocateDirect(PGPhotoEnhanceSegments * PGPhotoEnhanceSegments * PGPhotoEnhanceHistogramBins * 4); } if (calcBuffer == null) { calcBuffer = ByteBuffer.allocateDirect(PGPhotoEnhanceSegments * PGPhotoEnhanceSegments * 2 * 4 * (1 + PGPhotoEnhanceHistogramBins)); } GLES20.glReadPixels(0, 0, renderBufferWidth, renderBufferHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, hsvBuffer); Utilities.calcCDT(hsvBuffer, renderBufferWidth, renderBufferHeight, cdtBuffer, calcBuffer); GLES20.glBindTexture(GL10.GL_TEXTURE_2D, enhanceTextures[1]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, 256, 16, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, cdtBuffer); if (!isVideo) { hsvBuffer = null; cdtBuffer = null; calcBuffer = null; } hsvGenerated = true; } GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFrameBuffer[1]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture[1], 0); GLES20.glUseProgram(enhanceShaderProgram); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, enhanceTextures[0]); GLES20.glUniform1i(enhanceSourceImageHandle, 0); GLES20.glActiveTexture(GLES20.GL_TEXTURE1); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, enhanceTextures[1]); GLES20.glUniform1i(enhanceInputImageTexture2Handle, 1); if (delegate == null || delegate.shouldShowOriginal()) { GLES20.glUniform1f(enhanceIntensityHandle, 0); } else { GLES20.glUniform1f(enhanceIntensityHandle, delegate.getEnhanceValue()); } GLES20.glEnableVertexAttribArray(enhanceInputTexCoordHandle); GLES20.glVertexAttribPointer(enhanceInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer); GLES20.glEnableVertexAttribArray(enhancePositionHandle); GLES20.glVertexAttribPointer(enhancePositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); }
Example 14
Source File: VideoFrameDrawer.java From webrtc_android with MIT License | 4 votes |
/** * Upload |planes| into OpenGL textures, taking stride into consideration. * * @return Array of three texture indices corresponding to Y-, U-, and V-plane respectively. */ public int[] uploadYuvData(int width, int height, int[] strides, ByteBuffer[] planes) { final int[] planeWidths = new int[] {width, width / 2, width / 2}; final int[] planeHeights = new int[] {height, height / 2, height / 2}; // Make a first pass to see if we need a temporary copy buffer. int copyCapacityNeeded = 0; for (int i = 0; i < 3; ++i) { if (strides[i] > planeWidths[i]) { copyCapacityNeeded = Math.max(copyCapacityNeeded, planeWidths[i] * planeHeights[i]); } } // Allocate copy buffer if necessary. if (copyCapacityNeeded > 0 && (copyBuffer == null || copyBuffer.capacity() < copyCapacityNeeded)) { copyBuffer = ByteBuffer.allocateDirect(copyCapacityNeeded); } // Make sure YUV textures are allocated. if (yuvTextures == null) { yuvTextures = new int[3]; for (int i = 0; i < 3; i++) { yuvTextures[i] = GlUtil.generateTexture(GLES20.GL_TEXTURE_2D); } } // Upload each plane. for (int i = 0; i < 3; ++i) { GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + i); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, yuvTextures[i]); // GLES only accepts packed data, i.e. stride == planeWidth. final ByteBuffer packedByteBuffer; if (strides[i] == planeWidths[i]) { // Input is packed already. packedByteBuffer = planes[i]; } else { YuvHelper.copyPlane( planes[i], strides[i], copyBuffer, planeWidths[i], planeWidths[i], planeHeights[i]); packedByteBuffer = copyBuffer; } GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_LUMINANCE, planeWidths[i], planeHeights[i], 0, GLES20.GL_LUMINANCE, GLES20.GL_UNSIGNED_BYTE, packedByteBuffer); } return yuvTextures; }
Example 15
Source File: GlTextureFrameBuffer.java From webrtc_android with MIT License | 4 votes |
/** * (Re)allocate texture. Will do nothing if the requested size equals the current size. An * EGLContext must be bound on the current thread when calling this function. Must be called at * least once before using the framebuffer. May be called multiple times to change size. */ public void setSize(int width, int height) { if (width <= 0 || height <= 0) { throw new IllegalArgumentException("Invalid size: " + width + "x" + height); } if (width == this.width && height == this.height) { return; } this.width = width; this.height = height; // Lazy allocation the first time setSize() is called. if (textureId == 0) { textureId = GlUtil.generateTexture(GLES20.GL_TEXTURE_2D); } if (frameBufferId == 0) { final int frameBuffers[] = new int[1]; GLES20.glGenFramebuffers(1, frameBuffers, 0); frameBufferId = frameBuffers[0]; } // Allocate texture. GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, pixelFormat, width, height, 0, pixelFormat, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); GlUtil.checkNoGLES2Error("GlTextureFrameBuffer setSize"); // Attach the texture to the framebuffer as color attachment. GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBufferId); GLES20.glFramebufferTexture2D( GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, textureId, 0); // Check that the framebuffer is in a good state. final int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) { throw new IllegalStateException("Framebuffer not complete, status: " + status); } GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); }
Example 16
Source File: OpenGlUtils.java From TikTok with Apache License 2.0 | 4 votes |
public static Bitmap drawToBitmapByFilter(Bitmap bitmap, GPUImageFilter filter, int displayWidth, int displayHeight, boolean rotate){ if(filter == null) return null; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] mFrameBuffers = new int[1]; int[] mFrameBufferTextures = new int[1]; GLES20.glGenFramebuffers(1, mFrameBuffers, 0); GLES20.glGenTextures(1, mFrameBufferTextures, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mFrameBufferTextures[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBuffers[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mFrameBufferTextures[0], 0); GLES20.glViewport(0, 0, width, height); filter.onInputSizeChanged(width, height); filter.onDisplaySizeChanged(displayWidth, displayHeight); int textureId = OpenGlUtils.loadTexture(bitmap, OpenGlUtils.NO_TEXTURE, true); if(rotate){ FloatBuffer gLCubeBuffer = ByteBuffer .allocateDirect(TextureRotationUtil.CUBE_BAAB.length * 4) .order(ByteOrder.nativeOrder()) .asFloatBuffer(); gLCubeBuffer.put(TextureRotationUtil.CUBE_BAAB).position(0); FloatBuffer gLTextureBuffer = ByteBuffer .allocateDirect(TextureRotationUtil.TEXTURE_NO_ROTATION.length * 4) .order(ByteOrder.nativeOrder()) .asFloatBuffer(); gLTextureBuffer.put(TextureRotationUtil.getRotation(Rotation.ROTATION_90, true, false)).position(0); filter.onDrawFrame(textureId, gLCubeBuffer, gLTextureBuffer); }else { filter.onDrawFrame(textureId); } IntBuffer ib = IntBuffer.allocate(width * height); GLES20.glReadPixels(0, 0, width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, ib); Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); result.copyPixelsFromBuffer(IntBuffer.wrap(ib.array())); GLES20.glDeleteTextures(1, new int[]{textureId}, 0); GLES20.glDeleteFramebuffers(1, mFrameBuffers, 0); GLES20.glDeleteTextures(1, mFrameBufferTextures, 0); filter.onInputSizeChanged(displayWidth, displayHeight); return result; }
Example 17
Source File: GlFramebufferObject.java From GPUVideo-android with MIT License | 4 votes |
public void setup(final int width, final int height) { final int[] args = new int[1]; GLES20.glGetIntegerv(GL_MAX_TEXTURE_SIZE, args, 0); if (width > args[0] || height > args[0]) { throw new IllegalArgumentException("GL_MAX_TEXTURE_SIZE " + args[0]); } GLES20.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, args, 0); if (width > args[0] || height > args[0]) { throw new IllegalArgumentException("GL_MAX_RENDERBUFFER_SIZE " + args[0]); } GLES20.glGetIntegerv(GL_FRAMEBUFFER_BINDING, args, 0); final int saveFramebuffer = args[0]; GLES20.glGetIntegerv(GL_RENDERBUFFER_BINDING, args, 0); final int saveRenderbuffer = args[0]; GLES20.glGetIntegerv(GL_TEXTURE_BINDING_2D, args, 0); final int saveTexName = args[0]; release(); try { this.width = width; this.height = height; GLES20.glGenFramebuffers(args.length, args, 0); framebufferName = args[0]; GLES20.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName); GLES20.glGenRenderbuffers(args.length, args, 0); renderBufferName = args[0]; GLES20.glBindRenderbuffer(GL_RENDERBUFFER, renderBufferName); GLES20.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); GLES20.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderBufferName); GLES20.glGenTextures(args.length, args, 0); texName = args[0]; GLES20.glBindTexture(GL_TEXTURE_2D, texName); EglUtil.setupSampler(GL_TEXTURE_2D, GL_LINEAR, GL_NEAREST); GLES20.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); GLES20.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texName, 0); final int status = GLES20.glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { throw new RuntimeException("Failed to initialize framebuffer object " + status); } } catch (final RuntimeException e) { release(); throw e; } GLES20.glBindFramebuffer(GL_FRAMEBUFFER, saveFramebuffer); GLES20.glBindRenderbuffer(GL_RENDERBUFFER, saveRenderbuffer); GLES20.glBindTexture(GL_TEXTURE_2D, saveTexName); }
Example 18
Source File: GLFilterGroup.java From CameraCompat with MIT License | 4 votes |
@Override public void onOutputSizeChanged(final int width, final int height) { super.onOutputSizeChanged(width, height); if (mFrameBuffers != null) { destroyFrameBuffers(); } int size = mFilters.size(); for (int i = 0; i < size - 1; i++) { mFilters.get(i).onOutputSizeChanged(mImageHeight, mImageWidth); } mFilters.get(size - 1).onOutputSizeChanged(width, height); if (mMergedFilters.size() > 0) { size = mMergedFilters.size(); mFrameBuffers = new int[size - 1]; mFrameBufferTextures = new int[size - 1]; for (int i = 0; i < size - 1; i++) { GLES20.glGenFramebuffers(1, mFrameBuffers, i); GLES20.glGenTextures(1, mFrameBufferTextures, i); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mFrameBufferTextures[i]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, mImageHeight, mImageWidth, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBuffers[i]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mFrameBufferTextures[i], 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); } } }
Example 19
Source File: OpenGlUtils.java From Fatigue-Detection with MIT License | 4 votes |
public static void bindTextureToFrameBuffer(int paramInt1, int paramInt2, int paramInt3, int paramInt4) { GLES20.glBindTexture(3553, paramInt2); GLES20.glTexImage2D(3553, 0, 6408, paramInt3, paramInt4, 0, 6408, 5121, null); GLES20.glTexParameterf(3553, 10240, 9729.0F); GLES20.glTexParameterf(3553, 10241, 9729.0F); GLES20.glTexParameterf(3553, 10242, 33071.0F); GLES20.glTexParameterf(3553, 10243, 33071.0F); GLES20.glBindFramebuffer(36160, paramInt1); GLES20.glFramebufferTexture2D(36160, 36064, 3553, paramInt2, 0); GLES20.glBindTexture(3553, 0); GLES20.glBindFramebuffer(36160, 0); }
Example 20
Source File: GLState.java From 30-android-libraries-in-30-days with Apache License 2.0 | 2 votes |
/** * <b>Note:</b> does not pre-multiply the alpha channel!</br> * Except that difference, same as: {@link GLUtils#texSubImage2D(int, int, int, int, Bitmap, int, int)}</br> * </br> * See topic: '<a href="http://groups.google.com/group/android-developers/browse_thread/thread/baa6c33e63f82fca">PNG loading that doesn't premultiply alpha?</a>' * @param pBorder */ public void glTexImage2D(final int pTarget, final int pLevel, final Bitmap pBitmap, final int pBorder, final PixelFormat pPixelFormat) { final Buffer pixelBuffer = GLHelper.getPixels(pBitmap, pPixelFormat, ByteOrder.BIG_ENDIAN); GLES20.glTexImage2D(pTarget, pLevel, pPixelFormat.getGLInternalFormat(), pBitmap.getWidth(), pBitmap.getHeight(), pBorder, pPixelFormat.getGLFormat(), pPixelFormat.getGLType(), pixelBuffer); }