From 6a05079214aee5c3ae84de8838332ab781664b71 Mon Sep 17 00:00:00 2001 From: AndroidHot Date: Tue, 4 May 2021 17:16:29 +0800 Subject: [PATCH] EGLRender texture position use FboTexCoors --- app/src/main/cpp/render/EGLRender.cpp | 2 +- .../main/java/com/byteflow/app/egl/EGLActivity.java | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/src/main/cpp/render/EGLRender.cpp b/app/src/main/cpp/render/EGLRender.cpp index 60c4b24..ca7b624 100644 --- a/app/src/main/cpp/render/EGLRender.cpp +++ b/app/src/main/cpp/render/EGLRender.cpp @@ -384,7 +384,7 @@ void EGLRender::Init() glBufferData(GL_ARRAY_BUFFER, sizeof(vVertices), vVertices, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, m_VboIds[1]); - glBufferData(GL_ARRAY_BUFFER, sizeof(vFboTexCoors), vTexCoors, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(vFboTexCoors), vFboTexCoors, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_VboIds[2]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); diff --git a/app/src/main/java/com/byteflow/app/egl/EGLActivity.java b/app/src/main/java/com/byteflow/app/egl/EGLActivity.java index 8436ebe..78f5b1f 100644 --- a/app/src/main/java/com/byteflow/app/egl/EGLActivity.java +++ b/app/src/main/java/com/byteflow/app/egl/EGLActivity.java @@ -148,27 +148,24 @@ private void loadRGBAImage(int resId, NativeEglRender render) { private Bitmap createBitmapFromGLSurface(int x, int y, int w, int h) { int bitmapBuffer[] = new int[w * h]; - int bitmapSource[] = new int[w * h]; IntBuffer intBuffer = IntBuffer.wrap(bitmapBuffer); intBuffer.position(0); try { GLES20.glReadPixels(x, y, w, h, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, intBuffer); - int offset1, offset2; for (int i = 0; i < h; i++) { - offset1 = i * w; - offset2 = (h - i - 1) * w; for (int j = 0; j < w; j++) { - int texturePixel = bitmapBuffer[offset1 + j]; + int index = i * w + j; + int texturePixel = bitmapBuffer[index]; int blue = (texturePixel >> 16) & 0xff; int red = (texturePixel << 16) & 0x00ff0000; int pixel = (texturePixel & 0xff00ff00) | red | blue; - bitmapSource[offset2 + j] = pixel; + bitmapBuffer[index] = pixel; } } } catch (GLException e) { return null; } - return Bitmap.createBitmap(bitmapSource, w, h, Bitmap.Config.ARGB_8888); + return Bitmap.createBitmap(bitmapBuffer, w, h, Bitmap.Config.ARGB_8888); } }